From da81683750f52bab6ea1ea03da2bd4fd81ea0db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Schr=C3=B6ter?= Date: Fri, 28 Jul 2023 11:43:00 +0200 Subject: [PATCH] feat(date-picker): add positioner (#770) Co-authored-by: Segun Adebayo --- .changeset/breezy-peaches-jam.md | 5 + .xstate/date-picker.js | 2 +- examples/next-ts/pages/date-picker.tsx | 189 +++++++++--------- packages/machines/date-picker/package.json | 1 + .../date-picker/src/date-picker.anatomy.ts | 19 +- .../date-picker/src/date-picker.connect.ts | 13 ++ .../date-picker/src/date-picker.dom.ts | 3 + .../date-picker/src/date-picker.machine.ts | 22 +- .../date-picker/src/date-picker.types.ts | 13 ++ pnpm-lock.yaml | 103 ++++------ 10 files changed, 205 insertions(+), 165 deletions(-) create mode 100644 .changeset/breezy-peaches-jam.md diff --git a/.changeset/breezy-peaches-jam.md b/.changeset/breezy-peaches-jam.md new file mode 100644 index 0000000000..86afc572c4 --- /dev/null +++ b/.changeset/breezy-peaches-jam.md @@ -0,0 +1,5 @@ +--- +"@zag-js/date-picker": minor +--- + +Add positioner part to date picker machine to allow dynamic positioning. diff --git a/.xstate/date-picker.js b/.xstate/date-picker.js index fd02886e6e..86bd912e79 100644 --- a/.xstate/date-picker.js +++ b/.xstate/date-picker.js @@ -130,7 +130,7 @@ const fetchMachine = createMachine({ }, open: { tags: "open", - activities: ["trackDismissableElement"], + activities: ["trackDismissableElement", "trackPositioning"], entry: ctx.inline ? undefined : ["focusActiveCell"], exit: ["clearHoveredDate", "resetView"], on: { diff --git a/examples/next-ts/pages/date-picker.tsx b/examples/next-ts/pages/date-picker.tsx index 7f99e6896f..8d55e75647 100644 --- a/examples/next-ts/pages/date-picker.tsx +++ b/examples/next-ts/pages/date-picker.tsx @@ -40,63 +40,27 @@ export default function Page() { +
+
+
+ -
-
- - - -
- - + +
-
-