@plexui/vue 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/es/components/Alert/Alert.js +6 -2
  2. package/dist/es/components/Alert/Alert.js.map +1 -1
  3. package/dist/es/components/Avatar/Avatar.js +3 -1
  4. package/dist/es/components/Avatar/Avatar.js.map +1 -1
  5. package/dist/es/components/ButtonGroup/ButtonGroup.js +7 -0
  6. package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
  7. package/dist/es/components/ButtonGroup/index.js.map +1 -1
  8. package/dist/es/components/Checkbox/Checkbox.js +5 -6
  9. package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
  10. package/dist/es/components/ColorPicker/ColorPicker.js +476 -0
  11. package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -0
  12. package/dist/es/components/ColorPicker/ColorWell.js +186 -0
  13. package/dist/es/components/ColorPicker/ColorWell.js.map +1 -0
  14. package/dist/es/components/ColorPicker/index.js +3 -0
  15. package/dist/es/components/ColorPicker/index.js.map +1 -0
  16. package/dist/es/components/ColorPicker/shared.js +132 -0
  17. package/dist/es/components/ColorPicker/shared.js.map +1 -0
  18. package/dist/es/components/ContextMenu/ContextMenu.js +223 -0
  19. package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -0
  20. package/dist/es/components/ContextMenu/index.js +2 -0
  21. package/dist/es/components/ContextMenu/index.js.map +1 -0
  22. package/dist/es/components/ContextMenu/shared.js +58 -0
  23. package/dist/es/components/ContextMenu/shared.js.map +1 -0
  24. package/dist/es/components/DatePicker/DatePicker.js +19 -3
  25. package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
  26. package/dist/es/components/DateRangePicker/DateRangePicker.js +1 -1
  27. package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
  28. package/dist/es/components/Dialog/Dialog.js +245 -25
  29. package/dist/es/components/Dialog/Dialog.js.map +1 -1
  30. package/dist/es/components/Dialog/dialogSteps.js +85 -0
  31. package/dist/es/components/Dialog/dialogSteps.js.map +1 -0
  32. package/dist/es/components/Dialog/dialogViewport.js +74 -0
  33. package/dist/es/components/Dialog/dialogViewport.js.map +1 -0
  34. package/dist/es/components/Dialog/index.js +1 -1
  35. package/dist/es/components/Dialog/index.js.map +1 -1
  36. package/dist/es/components/Dialog/sheetDrag.js +2 -1
  37. package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
  38. package/dist/es/components/Field/Field.js +11 -3
  39. package/dist/es/components/Field/Field.js.map +1 -1
  40. package/dist/es/components/FieldGroup/FieldGroup.js +12 -1
  41. package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
  42. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +2 -2
  43. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
  44. package/dist/es/components/Icon/index.js +1 -0
  45. package/dist/es/components/Icon/index.js.map +1 -1
  46. package/dist/es/components/Icon/svg/Eyedropper.js +10 -0
  47. package/dist/es/components/Icon/svg/Eyedropper.js.map +1 -0
  48. package/dist/es/components/IndexBar/IndexBar.js +215 -0
  49. package/dist/es/components/IndexBar/IndexBar.js.map +1 -0
  50. package/dist/es/components/IndexBar/index.js +2 -0
  51. package/dist/es/components/IndexBar/index.js.map +1 -0
  52. package/dist/es/components/Indicator/LoadingIndicator.js +1 -1
  53. package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
  54. package/dist/es/components/Input/Input.js +3 -2
  55. package/dist/es/components/Input/Input.js.map +1 -1
  56. package/dist/es/components/MarkdownEditor/MarkdownEditor.js +149 -1
  57. package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
  58. package/dist/es/components/Menu/Menu.js +206 -33
  59. package/dist/es/components/Menu/Menu.js.map +1 -1
  60. package/dist/es/components/Menu/index.js +1 -1
  61. package/dist/es/components/Menu/index.js.map +1 -1
  62. package/dist/es/components/Page/Page.js +43 -11
  63. package/dist/es/components/Page/Page.js.map +1 -1
  64. package/dist/es/components/PageControl/PageControl.js +210 -0
  65. package/dist/es/components/PageControl/PageControl.js.map +1 -0
  66. package/dist/es/components/PageControl/index.js +2 -0
  67. package/dist/es/components/PageControl/index.js.map +1 -0
  68. package/dist/es/components/PhoneLayout/PhoneLayout.js +50 -0
  69. package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -0
  70. package/dist/es/components/PhoneLayout/index.js +2 -0
  71. package/dist/es/components/PhoneLayout/index.js.map +1 -0
  72. package/dist/es/components/Popover/Popover.js +5 -1
  73. package/dist/es/components/Popover/Popover.js.map +1 -1
  74. package/dist/es/components/Popover/deferredPointerDownOutside.js +59 -4
  75. package/dist/es/components/Popover/deferredPointerDownOutside.js.map +1 -1
  76. package/dist/es/components/Select/Select.js +18 -11
  77. package/dist/es/components/Select/Select.js.map +1 -1
  78. package/dist/es/components/SelectControl/SelectControl.js +1 -0
  79. package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
  80. package/dist/es/components/Sidebar/Sidebar.js +21 -6
  81. package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
  82. package/dist/es/components/Slider/Slider.js +44 -9
  83. package/dist/es/components/Slider/Slider.js.map +1 -1
  84. package/dist/es/components/Stepper/Stepper.js +195 -0
  85. package/dist/es/components/Stepper/Stepper.js.map +1 -0
  86. package/dist/es/components/Stepper/index.js +2 -0
  87. package/dist/es/components/Stepper/index.js.map +1 -0
  88. package/dist/es/components/SwipeActions/SwipeActions.js +374 -0
  89. package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -0
  90. package/dist/es/components/SwipeActions/index.js +2 -0
  91. package/dist/es/components/SwipeActions/index.js.map +1 -0
  92. package/dist/es/components/Switch/Switch.js +3 -1
  93. package/dist/es/components/Switch/Switch.js.map +1 -1
  94. package/dist/es/components/TabBar/TabBar.js +205 -0
  95. package/dist/es/components/TabBar/TabBar.js.map +1 -0
  96. package/dist/es/components/TabBar/index.js +2 -0
  97. package/dist/es/components/TabBar/index.js.map +1 -0
  98. package/dist/es/components/Tabs/Tabs.js +10 -2
  99. package/dist/es/components/Tabs/Tabs.js.map +1 -1
  100. package/dist/es/components/TagInput/TagInput.js +3 -46
  101. package/dist/es/components/TagInput/TagInput.js.map +1 -1
  102. package/dist/es/components/Textarea/Textarea.js +2 -0
  103. package/dist/es/components/Textarea/Textarea.js.map +1 -1
  104. package/dist/es/components/Tip/Tip.js +276 -0
  105. package/dist/es/components/Tip/Tip.js.map +1 -0
  106. package/dist/es/components/Tip/index.js +2 -0
  107. package/dist/es/components/Tip/index.js.map +1 -0
  108. package/dist/es/components/Toast/ToastRenderer.js +30 -13
  109. package/dist/es/components/Toast/ToastRenderer.js.map +1 -1
  110. package/dist/es/components/Toast/Toaster.js +17 -6
  111. package/dist/es/components/Toast/Toaster.js.map +1 -1
  112. package/dist/es/components/Toast/toastLifecycle.js +113 -1
  113. package/dist/es/components/Toast/toastLifecycle.js.map +1 -1
  114. package/dist/es/components/Toolbar/Toolbar.js +37 -6
  115. package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
  116. package/dist/es/components/Toolbar/index.js.map +1 -1
  117. package/dist/es/components/Tooltip/slot.js +3 -3
  118. package/dist/es/components/Tooltip/slot.js.map +1 -1
  119. package/dist/es/composables/useEscCloseStack.js +8 -4
  120. package/dist/es/composables/useEscCloseStack.js.map +1 -1
  121. package/dist/es/lib/fieldRow.js +15 -2
  122. package/dist/es/lib/fieldRow.js.map +1 -1
  123. package/dist/es/lib/floatingBoundary.js +3 -1
  124. package/dist/es/lib/floatingBoundary.js.map +1 -1
  125. package/dist/es/lib/helpers.js +21 -0
  126. package/dist/es/lib/helpers.js.map +1 -1
  127. package/dist/es/lib/menuSubmenuPlacement.js +51 -6
  128. package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
  129. package/dist/es/lib/menuTriggerCover.js +70 -0
  130. package/dist/es/lib/menuTriggerCover.js.map +1 -0
  131. package/dist/es/lib/phoneLayout.js +16 -0
  132. package/dist/es/lib/phoneLayout.js.map +1 -0
  133. package/dist/es/lib/scrollEdges.js +34 -0
  134. package/dist/es/lib/scrollEdges.js.map +1 -0
  135. package/dist/es/lib/toastRegion.js +6 -0
  136. package/dist/es/lib/toastRegion.js.map +1 -0
  137. package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +13 -0
  138. package/dist/types/components/ButtonGroup/index.d.ts +1 -1
  139. package/dist/types/components/ColorPicker/ColorPicker.d.ts +244 -0
  140. package/dist/types/components/ColorPicker/ColorWell.d.ts +334 -0
  141. package/dist/types/components/ColorPicker/index.d.ts +3 -0
  142. package/dist/types/components/ColorPicker/shared.d.ts +69 -0
  143. package/dist/types/components/ContextMenu/ContextMenu.d.ts +128 -0
  144. package/dist/types/components/ContextMenu/index.d.ts +1 -0
  145. package/dist/types/components/ContextMenu/shared.d.ts +51 -0
  146. package/dist/types/components/DatePicker/DatePicker.d.ts +24 -4
  147. package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +4 -4
  148. package/dist/types/components/Dialog/Dialog.d.ts +100 -4
  149. package/dist/types/components/Dialog/dialogSteps.d.ts +10 -0
  150. package/dist/types/components/Dialog/dialogViewport.d.ts +1 -0
  151. package/dist/types/components/Dialog/index.d.ts +1 -1
  152. package/dist/types/components/Field/Field.d.ts +21 -2
  153. package/dist/types/components/FieldGroup/FieldGroup.d.ts +18 -1
  154. package/dist/types/components/Icon/index.d.ts +1 -0
  155. package/dist/types/components/Icon/svg/Eyedropper.d.ts +3 -0
  156. package/dist/types/components/IndexBar/IndexBar.d.ts +112 -0
  157. package/dist/types/components/IndexBar/index.d.ts +1 -0
  158. package/dist/types/components/Indicator/LoadingIndicator.d.ts +2 -2
  159. package/dist/types/components/Menu/Menu.d.ts +153 -40
  160. package/dist/types/components/Menu/index.d.ts +1 -1
  161. package/dist/types/components/Page/Page.d.ts +13 -5
  162. package/dist/types/components/PageControl/PageControl.d.ts +216 -0
  163. package/dist/types/components/PageControl/index.d.ts +1 -0
  164. package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +21 -0
  165. package/dist/types/components/PhoneLayout/index.d.ts +1 -0
  166. package/dist/types/components/Popover/deferredPointerDownOutside.d.ts +1 -1
  167. package/dist/types/components/Select/Select.d.ts +6 -6
  168. package/dist/types/components/Stepper/Stepper.d.ts +338 -0
  169. package/dist/types/components/Stepper/index.d.ts +1 -0
  170. package/dist/types/components/SwipeActions/SwipeActions.d.ts +135 -0
  171. package/dist/types/components/SwipeActions/index.d.ts +1 -0
  172. package/dist/types/components/TabBar/TabBar.d.ts +405 -0
  173. package/dist/types/components/TabBar/index.d.ts +1 -0
  174. package/dist/types/components/Tip/Tip.d.ts +146 -0
  175. package/dist/types/components/Tip/index.d.ts +1 -0
  176. package/dist/types/components/Toast/toastLifecycle.d.ts +34 -0
  177. package/dist/types/components/Toolbar/Toolbar.d.ts +26 -9
  178. package/dist/types/components/Toolbar/index.d.ts +1 -1
  179. package/dist/types/components/Tooltip/CopyTooltip.d.ts +1 -1
  180. package/dist/types/composables/useEscCloseStack.d.ts +2 -2
  181. package/dist/types/lib/fieldRow.d.ts +5 -0
  182. package/dist/types/lib/helpers.d.ts +6 -0
  183. package/dist/types/lib/menuSubmenuPlacement.d.ts +14 -1
  184. package/dist/types/lib/menuTriggerCover.d.ts +23 -0
  185. package/dist/types/lib/phoneLayout.d.ts +11 -0
  186. package/dist/types/lib/scrollEdges.d.ts +16 -0
  187. package/dist/types/lib/toastRegion.d.ts +5 -0
  188. package/package.json +2 -2
@@ -0,0 +1,223 @@
1
+ import { cloneVNode, defineComponent, h, inject, onBeforeUnmount, onMounted, provide, shallowRef, Teleport, } from "vue";
2
+ import s from "@plexui/styles/components/ContextMenu/ContextMenu.module.css";
3
+ import { firstElementChild, mergeSlotProps } from "../Tooltip/slot.js";
4
+ import { Menu, MenuContent, MenuTrigger, useMenuContext } from "../Menu/Menu.js";
5
+ import { useMenuRootInternals } from "../Menu/internal.js";
6
+ import { TransitionGroup } from "../Transition/index.js";
7
+ import { overlayTiming } from "../Transition/shared.js";
8
+ import { CONTEXT_MENU_LONG_PRESS, CONTEXT_MENU_LONG_PRESS_SLOP, contextMenuHoleMask, contextMenuPlacement, contextMenuPreview, } from "./shared.js";
9
+ const CONTEXT_MENU = Symbol("ContextMenu");
10
+ const useContextMenuContext = (part) => {
11
+ const context = inject(CONTEXT_MENU, null);
12
+ if (!context)
13
+ throw new Error(`${part} must be used within ContextMenu`);
14
+ return context;
15
+ };
16
+ const ContextMenuComponent = defineComponent({
17
+ name: "ContextMenu",
18
+ inheritAttrs: false,
19
+ emits: {
20
+ /** The menu opened */
21
+ open: () => true,
22
+ /** The menu closed */
23
+ close: () => true,
24
+ },
25
+ setup(_, { emit, slots }) {
26
+ provide(CONTEXT_MENU, { presentation: shallowRef(null), region: shallowRef(null) });
27
+ return () => h(Menu, { onOpen: () => emit("open"), onClose: () => emit("close") }, { default: () => slots.default?.() });
28
+ },
29
+ });
30
+ /**
31
+ * A menu of actions for an element, after the iOS 26 kit Context Menu (507:25994): a secondary click opens it at
32
+ * the pointer, a touch and hold opens it beside the element, which stays clear above a dimmed, blurred page, as
33
+ * iOS lifts the preview. The items are the ones of `Menu`.
34
+ */
35
+ export const ContextMenu = ContextMenuComponent;
36
+ /**
37
+ * Swallows the mouse events a browser sends after the touch and hold that opened the menu: the compatibility mousedown
38
+ * would focus the element under the finger, and focus leaving the menu closes it (inside a Dialog or a Sheet, whose
39
+ * content takes the press), and the click would activate the element.
40
+ */
41
+ const suppressNextClick = (doc) => {
42
+ const hold = (event) => {
43
+ event.preventDefault();
44
+ event.stopPropagation();
45
+ };
46
+ const swallow = (event) => {
47
+ hold(event);
48
+ stop();
49
+ };
50
+ const stop = () => {
51
+ doc.removeEventListener("mousedown", hold, true);
52
+ doc.removeEventListener("click", swallow, true);
53
+ doc.removeEventListener("pointerdown", stop, true);
54
+ window.clearTimeout(timer);
55
+ };
56
+ // A browser that sends no click after the hold must not swallow the next tap: a new press ends the wait too.
57
+ const timer = window.setTimeout(stop, 600);
58
+ doc.addEventListener("mousedown", hold, true);
59
+ doc.addEventListener("click", swallow, true);
60
+ doc.addEventListener("pointerdown", stop, true);
61
+ };
62
+ const ContextMenuTriggerComponent = defineComponent({
63
+ name: "ContextMenuTrigger",
64
+ inheritAttrs: false,
65
+ props: {
66
+ /** When `true`, the element keeps the browser's own context menu. */
67
+ disabled: { type: Boolean, default: false },
68
+ },
69
+ setup(props, { attrs, slots }) {
70
+ const menu = useMenuContext();
71
+ const internals = useMenuRootInternals();
72
+ const { presentation, region } = useContextMenuContext("ContextMenuTrigger");
73
+ let press = null;
74
+ const cancel = () => {
75
+ if (press)
76
+ window.clearTimeout(press.timer);
77
+ press = null;
78
+ };
79
+ onBeforeUnmount(cancel);
80
+ const open = (next) => {
81
+ presentation.value = next;
82
+ menu.setOpen(true);
83
+ };
84
+ const openPreview = (element, x) => {
85
+ region.value = element;
86
+ open(contextMenuPreview(element, x));
87
+ };
88
+ const handlers = {
89
+ onPointerdown: (event) => {
90
+ if (event.defaultPrevented || props.disabled || event.pointerType !== "touch" || !event.isPrimary)
91
+ return;
92
+ cancel();
93
+ const element = event.currentTarget;
94
+ const x = event.clientX;
95
+ const timer = window.setTimeout(() => {
96
+ if (!press || press.timer !== timer)
97
+ return;
98
+ press.opened = true;
99
+ openPreview(element, x);
100
+ }, CONTEXT_MENU_LONG_PRESS);
101
+ press = { id: event.pointerId, x, y: event.clientY, timer, opened: false };
102
+ },
103
+ onPointermove: (event) => {
104
+ if (!press || press.id !== event.pointerId || press.opened)
105
+ return;
106
+ if (Math.hypot(event.clientX - press.x, event.clientY - press.y) > CONTEXT_MENU_LONG_PRESS_SLOP)
107
+ cancel();
108
+ },
109
+ onPointerup: (event) => {
110
+ if (!press || press.id !== event.pointerId)
111
+ return;
112
+ if (press.opened)
113
+ suppressNextClick(event.currentTarget.ownerDocument);
114
+ cancel();
115
+ },
116
+ onPointercancel: (event) => {
117
+ if (press?.id === event.pointerId)
118
+ cancel();
119
+ },
120
+ onContextmenu: (event) => {
121
+ if (event.defaultPrevented || props.disabled)
122
+ return;
123
+ event.preventDefault();
124
+ const element = event.currentTarget;
125
+ region.value = element;
126
+ // A touch and hold that the browser reports as a context menu (Android) opens the preview once.
127
+ if (press) {
128
+ if (press.opened)
129
+ return;
130
+ window.clearTimeout(press.timer);
131
+ press.opened = true;
132
+ return openPreview(element, press.x);
133
+ }
134
+ if (internals.isUsingKeyboard.current)
135
+ return open({ kind: "keyboard", rect: element.getBoundingClientRect() });
136
+ open({ kind: "pointer", rect: { x: event.clientX, y: event.clientY, width: 0, height: 0 } });
137
+ },
138
+ };
139
+ return () => {
140
+ const child = firstElementChild(slots.default?.());
141
+ if (!child)
142
+ return null;
143
+ return cloneVNode(mergeSlotProps(child, { ...attrs, class: [s.Trigger, attrs.class], ...handlers }), undefined, true);
144
+ };
145
+ },
146
+ });
147
+ /** The element the menu is for (React `ContextMenu.Trigger`): it renders its child, which keeps its own role and focus. */
148
+ export const ContextMenuTrigger = ContextMenuTriggerComponent;
149
+ /**
150
+ * Reaches the body once mounted, as Reka's own Teleport does for the menu. Each one is its own component, so the
151
+ * anchor, the dimming and the menu of a context menu land in that order, as React's portals, also when a page has
152
+ * several context menus.
153
+ */
154
+ const BodyTeleport = defineComponent({
155
+ name: "ContextMenuTeleport",
156
+ setup(_, { slots }) {
157
+ const mounted = shallowRef(false);
158
+ onMounted(() => {
159
+ mounted.value = true;
160
+ });
161
+ return () => (mounted.value ? h(Teleport, { to: "body" }, slots.default?.() ?? []) : null);
162
+ },
163
+ });
164
+ const ContextMenuContentComponent = defineComponent({
165
+ name: "ContextMenuContent",
166
+ inheritAttrs: false,
167
+ props: {
168
+ /** Defines the `width` property of the content */
169
+ width: [Number, String],
170
+ /** Defines the `min-width` property of the content, in pixels. */
171
+ minWidth: [Number, String],
172
+ /** Defines the `max-height` property of the content, in pixels. */
173
+ maxHeight: Number,
174
+ /** Rounder list with fully rounded rows. */
175
+ pill: { type: Boolean, default: false },
176
+ },
177
+ setup(props, { slots }) {
178
+ const { open } = useMenuContext();
179
+ const { presentation, region } = useContextMenuContext("ContextMenuContent");
180
+ // Focus goes back to the element only when the keyboard opened the menu; a pointer leaves it where it was.
181
+ const onCloseAutoFocus = (event) => {
182
+ event.preventDefault();
183
+ if (presentation.value?.kind === "keyboard")
184
+ region.value?.focus({ preventScroll: true });
185
+ };
186
+ return () => {
187
+ const current = presentation.value;
188
+ const rect = current?.rect;
189
+ const preview = current?.kind === "preview" ? current : null;
190
+ const dimmed = open.value && preview !== null;
191
+ const contentProps = Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined));
192
+ return [
193
+ // The menu is placed against this invisible box: the pointer, or the element.
194
+ h(BodyTeleport, null, () => [
195
+ h(MenuTrigger, null, () => h("span", {
196
+ "aria-hidden": "true",
197
+ "tabindex": -1,
198
+ "class": s.Anchor,
199
+ "style": rect ? { left: `${rect.x}px`, top: `${rect.y}px`, width: `${rect.width}px`, height: `${rect.height}px` } : undefined,
200
+ })),
201
+ ]),
202
+ h(BodyTeleport, null, () => [
203
+ h(TransitionGroup, { class: s.Dimming, ...overlayTiming }, {
204
+ default: () => [
205
+ dimmed
206
+ ? h("div", { "key": "dimming", "data-context-menu-dimming": "", "class": s.Overlay, "style": contextMenuHoleMask(preview) }, [
207
+ h("div", {
208
+ class: s.Preview,
209
+ style: { left: `${preview.rect.x}px`, top: `${preview.rect.y}px`, width: `${preview.rect.width}px`, height: `${preview.rect.height}px`, borderRadius: `${preview.radius}px` },
210
+ }),
211
+ ])
212
+ : null,
213
+ ],
214
+ }),
215
+ ]),
216
+ h(MenuContent, { ...contentProps, ...contextMenuPlacement(current), onCloseAutoFocus }, { default: () => slots.default?.() }),
217
+ ];
218
+ };
219
+ },
220
+ });
221
+ /** The menu (React `ContextMenu.Content`); its items are `MenuItem`, `MenuSeparator` and the other Menu items. */
222
+ export const ContextMenuContent = ContextMenuContentComponent;
223
+ //# sourceMappingURL=ContextMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextMenu.js","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qBACF,CAAC;iBACH,CAAC;gBACF,CAAC,CAAC,WAAW,EAAE,EAAE,GAAG,YAAY,EAAE,GAAG,oBAAoB,CAAC,OAAO,CAAC,EAAE,gBAAgB,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC;aAC9H,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAKF,kHAAkH;AAClH,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAA2B,CAAA","sourcesContent":["import {\n cloneVNode,\n defineComponent,\n h,\n inject,\n onBeforeUnmount,\n onMounted,\n provide,\n shallowRef,\n Teleport,\n type InjectionKey,\n type ShallowRef,\n} from \"vue\"\nimport s from \"@plexui/styles/components/ContextMenu/ContextMenu.module.css\"\nimport { firstElementChild, mergeSlotProps } from \"../Tooltip/slot.js\"\nimport { Menu, MenuContent, MenuTrigger, useMenuContext } from \"../Menu/Menu.js\"\nimport { useMenuRootInternals } from \"../Menu/internal.js\"\nimport { TransitionGroup } from \"../Transition/index.js\"\nimport { overlayTiming } from \"../Transition/shared.js\"\nimport {\n CONTEXT_MENU_LONG_PRESS,\n CONTEXT_MENU_LONG_PRESS_SLOP,\n contextMenuHoleMask,\n contextMenuPlacement,\n contextMenuPreview,\n type ContextMenuPresentation,\n} from \"./shared.js\"\n\n// Vue port of packages/ui/src/components/ContextMenu/ContextMenu.tsx. Exports are flat (`ContextMenuTrigger` for\n// `ContextMenu.Trigger`); the items are the Menu ones (`MenuItem`, `MenuSeparator`, ...).\n\ntype ContextMenuContext = {\n presentation: ShallowRef<ContextMenuPresentation | null>\n region: ShallowRef<HTMLElement | null>\n}\n\nconst CONTEXT_MENU: InjectionKey<ContextMenuContext> = Symbol(\"ContextMenu\")\n\nconst useContextMenuContext = (part: string) => {\n const context = inject(CONTEXT_MENU, null)\n if (!context) throw new Error(`${part} must be used within ContextMenu`)\n return context\n}\n\nconst ContextMenuComponent = defineComponent({\n name: \"ContextMenu\",\n inheritAttrs: false,\n emits: {\n /** The menu opened */\n open: () => true,\n /** The menu closed */\n close: () => true,\n },\n setup(_, { emit, slots }) {\n provide(CONTEXT_MENU, { presentation: shallowRef(null), region: shallowRef(null) })\n return () => h(Menu, { onOpen: () => emit(\"open\"), onClose: () => emit(\"close\") }, { default: () => slots.default?.() })\n },\n})\n\n/** Props of `ContextMenu`. */\nexport type ContextMenuProps = InstanceType<typeof ContextMenuComponent>[\"$props\"]\n\n/**\n * A menu of actions for an element, after the iOS 26 kit Context Menu (507:25994): a secondary click opens it at\n * the pointer, a touch and hold opens it beside the element, which stays clear above a dimmed, blurred page, as\n * iOS lifts the preview. The items are the ones of `Menu`.\n */\nexport const ContextMenu = ContextMenuComponent\n\n/**\n * Swallows the mouse events a browser sends after the touch and hold that opened the menu: the compatibility mousedown\n * would focus the element under the finger, and focus leaving the menu closes it (inside a Dialog or a Sheet, whose\n * content takes the press), and the click would activate the element.\n */\nconst suppressNextClick = (doc: Document) => {\n const hold = (event: Event) => {\n event.preventDefault()\n event.stopPropagation()\n }\n const swallow = (event: Event) => {\n hold(event)\n stop()\n }\n const stop = () => {\n doc.removeEventListener(\"mousedown\", hold, true)\n doc.removeEventListener(\"click\", swallow, true)\n doc.removeEventListener(\"pointerdown\", stop, true)\n window.clearTimeout(timer)\n }\n // A browser that sends no click after the hold must not swallow the next tap: a new press ends the wait too.\n const timer = window.setTimeout(stop, 600)\n doc.addEventListener(\"mousedown\", hold, true)\n doc.addEventListener(\"click\", swallow, true)\n doc.addEventListener(\"pointerdown\", stop, true)\n}\n\ntype Press = { id: number; x: number; y: number; timer: number; opened: boolean }\n\nconst ContextMenuTriggerComponent = defineComponent({\n name: \"ContextMenuTrigger\",\n inheritAttrs: false,\n props: {\n /** When `true`, the element keeps the browser's own context menu. */\n disabled: { type: Boolean, default: false },\n },\n setup(props, { attrs, slots }) {\n const menu = useMenuContext()\n const internals = useMenuRootInternals()\n const { presentation, region } = useContextMenuContext(\"ContextMenuTrigger\")\n let press: Press | null = null\n\n const cancel = () => {\n if (press) window.clearTimeout(press.timer)\n press = null\n }\n onBeforeUnmount(cancel)\n\n const open = (next: ContextMenuPresentation) => {\n presentation.value = next\n menu.setOpen(true)\n }\n const openPreview = (element: HTMLElement, x: number) => {\n region.value = element\n open(contextMenuPreview(element, x))\n }\n\n const handlers = {\n onPointerdown: (event: PointerEvent) => {\n if (event.defaultPrevented || props.disabled || event.pointerType !== \"touch\" || !event.isPrimary) return\n cancel()\n const element = event.currentTarget as HTMLElement\n const x = event.clientX\n const timer = window.setTimeout(() => {\n if (!press || press.timer !== timer) return\n press.opened = true\n openPreview(element, x)\n }, CONTEXT_MENU_LONG_PRESS)\n press = { id: event.pointerId, x, y: event.clientY, timer, opened: false }\n },\n onPointermove: (event: PointerEvent) => {\n if (!press || press.id !== event.pointerId || press.opened) return\n if (Math.hypot(event.clientX - press.x, event.clientY - press.y) > CONTEXT_MENU_LONG_PRESS_SLOP) cancel()\n },\n onPointerup: (event: PointerEvent) => {\n if (!press || press.id !== event.pointerId) return\n if (press.opened) suppressNextClick((event.currentTarget as HTMLElement).ownerDocument)\n cancel()\n },\n onPointercancel: (event: PointerEvent) => {\n if (press?.id === event.pointerId) cancel()\n },\n onContextmenu: (event: MouseEvent) => {\n if (event.defaultPrevented || props.disabled) return\n event.preventDefault()\n const element = event.currentTarget as HTMLElement\n region.value = element\n // A touch and hold that the browser reports as a context menu (Android) opens the preview once.\n if (press) {\n if (press.opened) return\n window.clearTimeout(press.timer)\n press.opened = true\n return openPreview(element, press.x)\n }\n if (internals.isUsingKeyboard.current) return open({ kind: \"keyboard\", rect: element.getBoundingClientRect() })\n open({ kind: \"pointer\", rect: { x: event.clientX, y: event.clientY, width: 0, height: 0 } })\n },\n }\n\n return () => {\n const child = firstElementChild(slots.default?.())\n if (!child) return null\n return cloneVNode(mergeSlotProps(child, { ...attrs, class: [s.Trigger, attrs.class], ...handlers }), undefined, true)\n }\n },\n})\n\n/** Props of `ContextMenuTrigger`. */\nexport type ContextMenuTriggerProps = InstanceType<typeof ContextMenuTriggerComponent>[\"$props\"]\n\n/** The element the menu is for (React `ContextMenu.Trigger`): it renders its child, which keeps its own role and focus. */\nexport const ContextMenuTrigger = ContextMenuTriggerComponent\n\n/**\n * Reaches the body once mounted, as Reka's own Teleport does for the menu. Each one is its own component, so the\n * anchor, the dimming and the menu of a context menu land in that order, as React's portals, also when a page has\n * several context menus.\n */\nconst BodyTeleport = defineComponent({\n name: \"ContextMenuTeleport\",\n setup(_, { slots }) {\n const mounted = shallowRef(false)\n onMounted(() => {\n mounted.value = true\n })\n return () => (mounted.value ? h(Teleport, { to: \"body\" }, slots.default?.() ?? []) : null)\n },\n})\n\nconst ContextMenuContentComponent = defineComponent({\n name: \"ContextMenuContent\",\n inheritAttrs: false,\n props: {\n /** Defines the `width` property of the content */\n width: [Number, String],\n /** Defines the `min-width` property of the content, in pixels. */\n minWidth: [Number, String],\n /** Defines the `max-height` property of the content, in pixels. */\n maxHeight: Number,\n /** Rounder list with fully rounded rows. */\n pill: { type: Boolean, default: false },\n },\n setup(props, { slots }) {\n const { open } = useMenuContext()\n const { presentation, region } = useContextMenuContext(\"ContextMenuContent\")\n // Focus goes back to the element only when the keyboard opened the menu; a pointer leaves it where it was.\n const onCloseAutoFocus = (event: Event) => {\n event.preventDefault()\n if (presentation.value?.kind === \"keyboard\") region.value?.focus({ preventScroll: true })\n }\n\n return () => {\n const current = presentation.value\n const rect = current?.rect\n const preview = current?.kind === \"preview\" ? current : null\n const dimmed = open.value && preview !== null\n const contentProps = Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined))\n return [\n // The menu is placed against this invisible box: the pointer, or the element.\n h(BodyTeleport, null, () => [\n h(MenuTrigger, null, () => h(\"span\", {\n \"aria-hidden\": \"true\",\n \"tabindex\": -1,\n \"class\": s.Anchor,\n \"style\": rect ? { left: `${rect.x}px`, top: `${rect.y}px`, width: `${rect.width}px`, height: `${rect.height}px` } : undefined,\n })),\n ]),\n h(BodyTeleport, null, () => [\n h(TransitionGroup, { class: s.Dimming, ...overlayTiming }, {\n default: () => [\n dimmed\n ? h(\"div\", { \"key\": \"dimming\", \"data-context-menu-dimming\": \"\", \"class\": s.Overlay, \"style\": contextMenuHoleMask(preview) }, [\n h(\"div\", {\n class: s.Preview,\n style: { left: `${preview.rect.x}px`, top: `${preview.rect.y}px`, width: `${preview.rect.width}px`, height: `${preview.rect.height}px`, borderRadius: `${preview.radius}px` },\n }),\n ])\n : null,\n ],\n }),\n ]),\n h(MenuContent, { ...contentProps, ...contextMenuPlacement(current), onCloseAutoFocus }, { default: () => slots.default?.() }),\n ]\n }\n },\n})\n\n/** Props of `ContextMenuContent`. */\nexport type ContextMenuContentProps = InstanceType<typeof ContextMenuContentComponent>[\"$props\"]\n\n/** The menu (React `ContextMenu.Content`); its items are `MenuItem`, `MenuSeparator` and the other Menu items. */\nexport const ContextMenuContent = ContextMenuContentComponent\n"]}
@@ -0,0 +1,2 @@
1
+ export { ContextMenu, ContextMenuContent, ContextMenuTrigger } from "./ContextMenu.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ContextMenu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAqF,MAAM,kBAAkB,CAAA","sourcesContent":["export { ContextMenu, ContextMenuContent, ContextMenuTrigger, type ContextMenuContentProps, type ContextMenuProps, type ContextMenuTriggerProps } from \"./ContextMenu.js\"\n"]}
@@ -0,0 +1,58 @@
1
+ // Shared with packages/ui/src/components/ContextMenu/shared.ts: keep the two copies the same.
2
+ /** A touch held this long opens the menu, as a UIKit long press (0.5 s). */
3
+ export const CONTEXT_MENU_LONG_PRESS = 500;
4
+ /** A touch that moves farther than this before then scrolls or drags instead. */
5
+ export const CONTEXT_MENU_LONG_PRESS_SLOP = 10;
6
+ /** The kit's gap between the preview and the menu: iOS 27 Context Menu 125:58750, Alignment=Vertical, the menu at
7
+ * 176.5 under a content area that ends at 160.5 (the iOS 26 kit had 18). */
8
+ export const CONTEXT_MENU_PREVIEW_GAP = 16;
9
+ /** The kit's preview corner (Content Area, radius 30), for an element without corners of its own. */
10
+ const PREVIEW_RADIUS = 30;
11
+ const px = (value, base) => {
12
+ const number = Number.parseFloat(value);
13
+ if (!Number.isFinite(number))
14
+ return 0;
15
+ return value.trim().endsWith("%") ? (number / 100) * base : number;
16
+ };
17
+ /**
18
+ * The preview of a touch and hold: the element's box and corner (its own, or `--context-menu-preview-radius`), and
19
+ * the edge the menu keeps to, the one on the side of the touch, as the kit's Side=Leading and Side=Trailing.
20
+ */
21
+ export function contextMenuPreview(element, touchX) {
22
+ const box = element.getBoundingClientRect();
23
+ const rect = { x: box.left, y: box.top, width: box.width, height: box.height };
24
+ const style = getComputedStyle(element);
25
+ const short = Math.min(rect.width, rect.height);
26
+ const own = px(style.borderTopLeftRadius, short);
27
+ const fallback = px(style.getPropertyValue("--context-menu-preview-radius"), short) || PREVIEW_RADIUS;
28
+ const radius = Math.min(own > 0 ? own : fallback, short / 2);
29
+ const width = element.ownerDocument.defaultView?.innerWidth ?? rect.x + rect.width;
30
+ return { kind: "preview", rect, radius, align: touchX < width / 2 ? "start" : "end" };
31
+ }
32
+ /** The menu's side, alignment and offsets for a presentation. */
33
+ export function contextMenuPlacement(presentation) {
34
+ if (presentation?.kind === "preview")
35
+ return { side: "bottom", align: presentation.align, sideOffset: CONTEXT_MENU_PREVIEW_GAP, alignOffset: 0 };
36
+ if (presentation?.kind === "keyboard")
37
+ return { side: "bottom", align: "start", sideOffset: 5, alignOffset: 0 };
38
+ // As a desktop context menu, its corner at the pointer.
39
+ return { side: "bottom", align: "start", sideOffset: 2, alignOffset: 0 };
40
+ }
41
+ const round = (value) => Math.round(value * 100) / 100;
42
+ /**
43
+ * The dimming covers the page but the element: an SVG mask with the element's rounded box cut out, written to
44
+ * `--context-menu-hole`, so the element stays clear above the dimmed, blurred page.
45
+ */
46
+ export function contextMenuHoleMask(preview, viewport) {
47
+ const width = round(viewport?.width ?? window.innerWidth);
48
+ const height = round(viewport?.height ?? window.innerHeight);
49
+ const x = round(preview.rect.x);
50
+ const y = round(preview.rect.y);
51
+ const w = round(preview.rect.width);
52
+ const h = round(preview.rect.height);
53
+ const r = round(preview.radius);
54
+ const hole = `M${x + r} ${y}H${round(x + w - r)}A${r} ${r} 0 0 1 ${x + w} ${round(y + r)}V${round(y + h - r)}A${r} ${r} 0 0 1 ${round(x + w - r)} ${round(y + h)}H${round(x + r)}A${r} ${r} 0 0 1 ${x} ${round(y + h - r)}V${round(y + r)}A${r} ${r} 0 0 1 ${round(x + r)} ${y}Z`;
55
+ const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}' viewBox='0 0 ${width} ${height}'><path fill-rule='evenodd' d='M0 0H${width}V${height}H0Z${hole}'/></svg>`;
56
+ return { "--context-menu-hole": `url("data:image/svg+xml,${encodeURIComponent(svg)}")` };
57
+ }
58
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/ContextMenu/shared.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAC1C,iFAAiF;AACjF,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAA;AAC9C;4EAC4E;AAC5E,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAA;AAC1C,qGAAqG;AACrG,MAAM,cAAc,GAAG,EAAE,CAAA;AAUzB,MAAM,EAAE,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,EAAE;IACzC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACvC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC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AAC,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACpC,MAAM,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAA;IACjR,MAAM,GAAG,GAAG,kDAAkD,KAAK,aAAa,MAAM,kBAAkB,KAAK,IAAI,MAAM,uCAAuC,KAAK,IAAI,MAAM,MAAM,IAAI,WAAW,CAAA;IAClM,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,kBAAkB,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;AAC1F,CAAC","sourcesContent":["// Shared with packages/ui/src/components/ContextMenu/shared.ts: keep the two copies the same.\n/** A touch held this long opens the menu, as a UIKit long press (0.5 s). */\nexport const CONTEXT_MENU_LONG_PRESS = 500\n/** A touch that moves farther than this before then scrolls or drags instead. */\nexport const CONTEXT_MENU_LONG_PRESS_SLOP = 10\n/** The kit's gap between the preview and the menu: iOS 27 Context Menu 125:58750, Alignment=Vertical, the menu at\n * 176.5 under a content area that ends at 160.5 (the iOS 26 kit had 18). */\nexport const CONTEXT_MENU_PREVIEW_GAP = 16\n/** The kit's preview corner (Content Area, radius 30), for an element without corners of its own. */\nconst PREVIEW_RADIUS = 30\n\ntype Rect = { x: number; y: number; width: number; height: number }\n\n/** Where the menu opens: at the pointer, under the element for the keyboard, or beside a touch-and-hold preview. */\nexport type ContextMenuPresentation =\n | { kind: \"pointer\"; rect: Rect }\n | { kind: \"keyboard\"; rect: Rect }\n | { kind: \"preview\"; rect: Rect; radius: number; align: \"start\" | \"end\" }\n\nconst px = (value: string, base: number) => {\n const number = Number.parseFloat(value)\n if (!Number.isFinite(number)) return 0\n return value.trim().endsWith(\"%\") ? (number / 100) * base : number\n}\n\n/**\n * The preview of a touch and hold: the element's box and corner (its own, or `--context-menu-preview-radius`), and\n * the edge the menu keeps to, the one on the side of the touch, as the kit's Side=Leading and Side=Trailing.\n */\nexport function contextMenuPreview(element: HTMLElement, touchX: number): ContextMenuPresentation {\n const box = element.getBoundingClientRect()\n const rect = { x: box.left, y: box.top, width: box.width, height: box.height }\n const style = getComputedStyle(element)\n const short = Math.min(rect.width, rect.height)\n const own = px(style.borderTopLeftRadius, short)\n const fallback = px(style.getPropertyValue(\"--context-menu-preview-radius\"), short) || PREVIEW_RADIUS\n const radius = Math.min(own > 0 ? own : fallback, short / 2)\n const width = element.ownerDocument.defaultView?.innerWidth ?? rect.x + rect.width\n return { kind: \"preview\", rect, radius, align: touchX < width / 2 ? \"start\" : \"end\" }\n}\n\n/** The menu's side, alignment and offsets for a presentation. */\nexport function contextMenuPlacement(presentation: ContextMenuPresentation | null) {\n if (presentation?.kind === \"preview\")\n return { side: \"bottom\" as const, align: presentation.align, sideOffset: CONTEXT_MENU_PREVIEW_GAP, alignOffset: 0 }\n if (presentation?.kind === \"keyboard\") return { side: \"bottom\" as const, align: \"start\" as const, sideOffset: 5, alignOffset: 0 }\n // As a desktop context menu, its corner at the pointer.\n return { side: \"bottom\" as const, align: \"start\" as const, sideOffset: 2, alignOffset: 0 }\n}\n\nconst round = (value: number) => Math.round(value * 100) / 100\n\n/**\n * The dimming covers the page but the element: an SVG mask with the element's rounded box cut out, written to\n * `--context-menu-hole`, so the element stays clear above the dimmed, blurred page.\n */\nexport function contextMenuHoleMask(preview: Extract<ContextMenuPresentation, { kind: \"preview\" }>, viewport?: { width: number; height: number }) {\n const width = round(viewport?.width ?? window.innerWidth)\n const height = round(viewport?.height ?? window.innerHeight)\n const x = round(preview.rect.x)\n const y = round(preview.rect.y)\n const w = round(preview.rect.width)\n const h = round(preview.rect.height)\n const r = round(preview.radius)\n const hole = `M${x + r} ${y}H${round(x + w - r)}A${r} ${r} 0 0 1 ${x + w} ${round(y + r)}V${round(y + h - r)}A${r} ${r} 0 0 1 ${round(x + w - r)} ${round(y + h)}H${round(x + r)}A${r} ${r} 0 0 1 ${x} ${round(y + h - r)}V${round(y + r)}A${r} ${r} 0 0 1 ${round(x + r)} ${y}Z`\n const svg = `<svg xmlns='http://www.w3.org/2000/svg' width='${width}' height='${height}' viewBox='0 0 ${width} ${height}'><path fill-rule='evenodd' d='M0 0H${width}V${height}H0Z${hole}'/></svg>`\n return { \"--context-menu-hole\": `url(\"data:image/svg+xml,${encodeURIComponent(svg)}\")` }\n}\n"]}
@@ -61,8 +61,13 @@ const DatePickerComponent = defineComponent({
61
61
  triggerClassName: String,
62
62
  /** Display calendar icon at the start of the trigger. @default true */
63
63
  triggerShowIcon: { type: Boolean, default: true },
64
- /** Format of dates displayed in the trigger. @default "MM/dd/yy" ("MM/dd/yy HH:mm" with `showTime`) */
64
+ /** Format of dates displayed in the trigger. @default "MM/dd/yy" ("MM/dd/yy HH:mm" with `showTime` and no `triggerTimeFormat`) */
65
65
  triggerDateFormat: String,
66
+ /**
67
+ * With `showTime`, the format of the time shown after the date in the trigger. The date and the time are
68
+ * then two parts: in a row of a `FieldGroup` on a phone, the two capsules of iOS's compact date and time.
69
+ */
70
+ triggerTimeFormat: String,
66
71
  /** Display a clear action that allows the select to be unset. @default false */
67
72
  clearable: { type: Boolean, default: false },
68
73
  /** Extends select to 100% of available width. @default false */
@@ -125,8 +130,18 @@ const DatePickerComponent = defineComponent({
125
130
  throw new Error("DatePicker error: `min` date must not be after the `max` date");
126
131
  }
127
132
  const valueId = `${id ?? generatedId}-value`;
128
- const triggerDateFormat = props.triggerDateFormat ?? (props.showTime ? "MM/dd/yy HH:mm" : "MM/dd/yy");
129
- const text = value?.toFormat(triggerDateFormat) ?? placeholder;
133
+ const timeFormat = props.showTime ? props.triggerTimeFormat : undefined;
134
+ const triggerDateFormat = props.triggerDateFormat ?? (props.showTime && !timeFormat ? "MM/dd/yy HH:mm" : "MM/dd/yy");
135
+ // With a time format the date and the time are two parts, apart by a space; a phone row draws each as a capsule
136
+ const text = !value
137
+ ? placeholder
138
+ : timeFormat
139
+ ? h("span", { "data-date-parts": "" }, [
140
+ h("span", { "data-date-part": "date" }, value.toFormat(triggerDateFormat)),
141
+ " ",
142
+ h("span", { "data-date-part": "time" }, value.toFormat(timeFormat)),
143
+ ])
144
+ : value.toFormat(triggerDateFormat);
130
145
  return h(Popover, null, {
131
146
  default: () => [
132
147
  h(PopoverTrigger, null, {
@@ -138,6 +153,7 @@ const DatePickerComponent = defineComponent({
138
153
  "aria-describedby": props.ariaDescribedby,
139
154
  "aria-invalid": props.ariaInvalid,
140
155
  "class": props.triggerClassName,
156
+ "data-date-picker": "",
141
157
  "selected": !!value,
142
158
  "variant": props.variant,
143
159
  "pill": props.pill,
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../src/components/DatePicker/DatePicker.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0DAA0D,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,KAAK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K,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;qBAChE,EACD,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,EAAE,CACrC;iBACF;aACF,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAMF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAAA","sourcesContent":["import s from \"@plexui/styles/components/DatePicker/Calendar.module.css\"\nimport { DateTime } from \"luxon\"\nimport { defineComponent, h, provide, toRaw, useId, type PropType } from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { useBreakpoint } from \"../../composables/useBreakpoints.js\"\nimport { isAfter } from \"../../lib/dateUtils.js\"\nimport { Calendar } from \"../Icon/index.js\"\nimport { Popover, PopoverContent, PopoverTrigger, type PopoverAlign, type PopoverSide } from \"../Popover/index.js\"\nimport { SelectControl, type DropdownIconType } from \"../SelectControl/index.js\"\nimport { DateCalendar } from \"./Calendar.js\"\nimport { useCalendarGutter } from \"./useCalendarGutter.js\"\nimport { DateContextKey, type DateContextValue } from \"./context.js\"\n\n// Vue port of packages/ui/src/components/DatePicker/DatePicker.tsx.\n// - `value` + `update:value` (`v-model:value`), plus `change` with the same\n// value (React's `onChange`). Like React the picker is controlled: a\n// parent that does not update `value` keeps the shown date.\n// - `aria-label`, `aria-labelledby`, `aria-describedby` and `aria-invalid`\n// reach the trigger, as in React. Other attributes are not passed on\n// (React's DatePicker takes no other props).\n// - DateTime values are read unwrapped (`toRaw`), so a `ref()` holding one\n// (a deep reactive proxy) works like a plain value.\n\nconst DatePickerComponent = defineComponent({\n name: \"DatePicker\",\n inheritAttrs: false,\n props: {\n /** Allow targeting the input for forms and accessibility. */\n id: String,\n \"ariaLabel\": String,\n \"ariaLabelledby\": String,\n \"ariaDescribedby\": String,\n \"ariaInvalid\": {\n type: [Boolean, String] as PropType<boolean | \"true\" | \"false\" | \"grammar\" | \"spelling\">,\n default: undefined,\n },\n /** The selected date value (`v-model:value`). */\n value: { type: Object as PropType<DateTime | null>, default: null },\n /** Defines the earliest selectable date (inclusive). */\n min: Object as PropType<DateTime>,\n /** Defines the latest selectable date (inclusive). */\n max: Object as PropType<DateTime>,\n /** Preferred side; collisions can flip it. On phones, left and right prefer bottom so seven 44px day targets fit. @default \"bottom\" */\n side: { type: String as PropType<PopoverSide>, default: \"bottom\" },\n /** The distance in pixels from the trigger. @default 8 */\n sideOffset: { type: Number, default: 8 },\n /** The preferred alignment against the trigger. @default \"center\" */\n align: { type: String as PropType<PopoverAlign>, default: \"center\" },\n /** An offset in pixels from the \"start\" or \"end\" alignment options. @default 0 */\n alignOffset: Number,\n /** Disables the select visually and from interactions. @default false */\n disabled: { type: Boolean, default: false },\n /** Placeholder text for the select. @default \"Select date...\" */\n placeholder: { type: String, default: \"Select date...\" },\n /** Style variant for the select trigger. @default \"outline\" */\n variant: { type: String as PropType<\"soft\" | \"outline\" | \"ghost\">, default: \"outline\" },\n /** Determines if the select trigger should be a fully rounded pill shape. @default true */\n pill: { type: Boolean, default: true },\n /** Size of the control: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Icon displayed in the far right of the select trigger. @default \"dropdown\" */\n dropdownIconType: String as PropType<DropdownIconType>,\n /** Custom class applied to the select trigger */\n triggerClassName: String,\n /** Display calendar icon at the start of the trigger. @default true */\n triggerShowIcon: { type: Boolean, default: true },\n /** Format of dates displayed in the trigger. @default \"MM/dd/yy\" (\"MM/dd/yy HH:mm\" with `showTime`) */\n triggerDateFormat: String,\n /** Display a clear action that allows the select to be unset. @default false */\n clearable: { type: Boolean, default: false },\n /** Extends select to 100% of available width. @default false */\n block: { type: Boolean, default: false },\n /** Calendar header: arrow navigation (`\"buttons\"`) or month and year dropdowns. @default \"buttons\" */\n captionLayout: { type: String as PropType<\"buttons\" | \"dropdown\">, default: \"buttons\" },\n /** Show time input below the calendar for combined date and time selection. @default false */\n showTime: { type: Boolean, default: false },\n /** Range of selectable years when `captionLayout` is `\"dropdown\"`. @default [currentYear - 120, currentYear] */\n yearRange: Array as unknown as PropType<[number, number]>,\n },\n emits: {\n \"update:value\": (nextValue: DateTime | null) => nextValue === null || DateTime.isDateTime(nextValue),\n \"change\": (nextValue: DateTime | null) => nextValue === null || DateTime.isDateTime(nextValue),\n },\n setup(props, { emit }) {\n const wide = useBreakpoint(\"md\")\n const calendarGutter = useCalendarGutter()\n const unwrap = <T>(value: T): T => (value ? toRaw(value) : value)\n\n const onChange = (nextValue: DateTime | null) => {\n emit(\"update:value\", nextValue)\n emit(\"change\", nextValue)\n }\n\n const store: DateContextValue = {\n get value() {\n return unwrap(props.value) ?? null\n },\n get min() {\n return unwrap(props.min)\n },\n get max() {\n return unwrap(props.max)\n },\n get disabled() {\n return props.disabled\n },\n get captionLayout() {\n return props.captionLayout\n },\n get showTime() {\n return props.showTime\n },\n get yearRange() {\n return props.yearRange\n },\n onChange,\n }\n provide(DateContextKey, store)\n\n const handleClearClick = () => {\n onChange(null)\n }\n\n // The value text needs an id for aria-labelledby, also when `id` is not set\n const generatedId = useId()\n\n return () => {\n const { id, ariaLabelledby, align, placeholder } = props\n const value = store.value\n const { min, max } = store\n\n // min and max are inclusive, so equal bounds allow one date\n if (min && max && isAfter(min, max)) {\n throw new Error(\"DatePicker error: `min` date must not be after the `max` date\")\n }\n\n const valueId = `${id ?? generatedId}-value`\n\n const triggerDateFormat = props.triggerDateFormat ?? (props.showTime ? \"MM/dd/yy HH:mm\" : \"MM/dd/yy\")\n const text = value?.toFormat(triggerDateFormat) ?? placeholder\n\n return h(Popover, null, {\n default: () => [\n h(PopoverTrigger, null, {\n default: () => [\n h(\n SelectControl,\n {\n \"id\": id,\n \"aria-label\": props.ariaLabel,\n \"aria-labelledby\": ariaLabelledby ? `${ariaLabelledby} ${valueId}` : undefined,\n \"aria-describedby\": props.ariaDescribedby,\n \"aria-invalid\": props.ariaInvalid,\n \"class\": props.triggerClassName,\n \"selected\": !!value,\n \"variant\": props.variant,\n \"pill\": props.pill,\n \"block\": props.block,\n \"size\": props.size,\n \"disabled\": props.disabled,\n \"interactOnEnter\": true,\n \"StartIcon\": props.triggerShowIcon ? Calendar : undefined,\n \"dropdownIconType\": props.dropdownIconType,\n \"onClearClick\": props.clearable ? handleClearClick : undefined,\n },\n { default: () => [ariaLabelledby ? h(\"span\", { id: valueId }, text) : text] },\n ),\n ],\n }),\n h(\n PopoverContent,\n {\n class: s.Popover,\n minWidth: 230,\n collisionPadding: wide.value ? 20 : calendarGutter.value,\n side: wide.value || props.side === \"top\" ? props.side : \"bottom\",\n sideOffset: props.sideOffset,\n align,\n alignOffset: props.alignOffset ?? (align === \"center\" ? 0 : -5),\n },\n { default: () => [h(DateCalendar)] },\n ),\n ],\n })\n }\n },\n})\n\ntype DatePickerOwnProps = InstanceType<typeof DatePickerComponent>[\"$props\"]\n\nexport type DatePickerProps = DatePickerOwnProps\n\n/**\n * A date (and optionally time) picker: a SelectControl trigger opening a\n * calendar in a popover. Bind the date (a luxon `DateTime`) with\n * `v-model:value`.\n */\nexport const DatePicker = DatePickerComponent\n"]}
1
+ {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../src/components/DatePicker/DatePicker.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0DAA0D,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,KAAK,CAAA;AAE9E,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc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c,EACd;wBACE,KAAK,EAAE,CAAC,CAAC,OAAO;wBAChB,QAAQ,EAAE,GAAG;wBACb,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK;wBACxD,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ;wBAChE,UAAU,EAAE,KAAK,CAAC,UAAU;wBAC5B,KAAK;wBACL,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;qBAChE,EACD,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,EAAE,CACrC;iBACF;aACF,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAMF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,mBAAmB,CAAA","sourcesContent":["import s from \"@plexui/styles/components/DatePicker/Calendar.module.css\"\nimport { DateTime } from \"luxon\"\nimport { defineComponent, h, provide, toRaw, useId, type PropType } from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { useBreakpoint } from \"../../composables/useBreakpoints.js\"\nimport { isAfter } from \"../../lib/dateUtils.js\"\nimport { Calendar } from \"../Icon/index.js\"\nimport { Popover, PopoverContent, PopoverTrigger, type PopoverAlign, type PopoverSide } from \"../Popover/index.js\"\nimport { SelectControl, type DropdownIconType } from \"../SelectControl/index.js\"\nimport { DateCalendar } from \"./Calendar.js\"\nimport { useCalendarGutter } from \"./useCalendarGutter.js\"\nimport { DateContextKey, type DateContextValue } from \"./context.js\"\n\n// Vue port of packages/ui/src/components/DatePicker/DatePicker.tsx.\n// - `value` + `update:value` (`v-model:value`), plus `change` with the same\n// value (React's `onChange`). Like React the picker is controlled: a\n// parent that does not update `value` keeps the shown date.\n// - `aria-label`, `aria-labelledby`, `aria-describedby` and `aria-invalid`\n// reach the trigger, as in React. Other attributes are not passed on\n// (React's DatePicker takes no other props).\n// - DateTime values are read unwrapped (`toRaw`), so a `ref()` holding one\n// (a deep reactive proxy) works like a plain value.\n\nconst DatePickerComponent = defineComponent({\n name: \"DatePicker\",\n inheritAttrs: false,\n props: {\n /** Allow targeting the input for forms and accessibility. */\n id: String,\n \"ariaLabel\": String,\n \"ariaLabelledby\": String,\n \"ariaDescribedby\": String,\n \"ariaInvalid\": {\n type: [Boolean, String] as PropType<boolean | \"true\" | \"false\" | \"grammar\" | \"spelling\">,\n default: undefined,\n },\n /** The selected date value (`v-model:value`). */\n value: { type: Object as PropType<DateTime | null>, default: null },\n /** Defines the earliest selectable date (inclusive). */\n min: Object as PropType<DateTime>,\n /** Defines the latest selectable date (inclusive). */\n max: Object as PropType<DateTime>,\n /** Preferred side; collisions can flip it. On phones, left and right prefer bottom so seven 44px day targets fit. @default \"bottom\" */\n side: { type: String as PropType<PopoverSide>, default: \"bottom\" },\n /** The distance in pixels from the trigger. @default 8 */\n sideOffset: { type: Number, default: 8 },\n /** The preferred alignment against the trigger. @default \"center\" */\n align: { type: String as PropType<PopoverAlign>, default: \"center\" },\n /** An offset in pixels from the \"start\" or \"end\" alignment options. @default 0 */\n alignOffset: Number,\n /** Disables the select visually and from interactions. @default false */\n disabled: { type: Boolean, default: false },\n /** Placeholder text for the select. @default \"Select date...\" */\n placeholder: { type: String, default: \"Select date...\" },\n /** Style variant for the select trigger. @default \"outline\" */\n variant: { type: String as PropType<\"soft\" | \"outline\" | \"ghost\">, default: \"outline\" },\n /** Determines if the select trigger should be a fully rounded pill shape. @default true */\n pill: { type: Boolean, default: true },\n /** Size of the control: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Icon displayed in the far right of the select trigger. @default \"dropdown\" */\n dropdownIconType: String as PropType<DropdownIconType>,\n /** Custom class applied to the select trigger */\n triggerClassName: String,\n /** Display calendar icon at the start of the trigger. @default true */\n triggerShowIcon: { type: Boolean, default: true },\n /** Format of dates displayed in the trigger. @default \"MM/dd/yy\" (\"MM/dd/yy HH:mm\" with `showTime` and no `triggerTimeFormat`) */\n triggerDateFormat: String,\n /**\n * With `showTime`, the format of the time shown after the date in the trigger. The date and the time are\n * then two parts: in a row of a `FieldGroup` on a phone, the two capsules of iOS's compact date and time.\n */\n triggerTimeFormat: String,\n /** Display a clear action that allows the select to be unset. @default false */\n clearable: { type: Boolean, default: false },\n /** Extends select to 100% of available width. @default false */\n block: { type: Boolean, default: false },\n /** Calendar header: arrow navigation (`\"buttons\"`) or month and year dropdowns. @default \"buttons\" */\n captionLayout: { type: String as PropType<\"buttons\" | \"dropdown\">, default: \"buttons\" },\n /** Show time input below the calendar for combined date and time selection. @default false */\n showTime: { type: Boolean, default: false },\n /** Range of selectable years when `captionLayout` is `\"dropdown\"`. @default [currentYear - 120, currentYear] */\n yearRange: Array as unknown as PropType<[number, number]>,\n },\n emits: {\n \"update:value\": (nextValue: DateTime | null) => nextValue === null || DateTime.isDateTime(nextValue),\n \"change\": (nextValue: DateTime | null) => nextValue === null || DateTime.isDateTime(nextValue),\n },\n setup(props, { emit }) {\n const wide = useBreakpoint(\"md\")\n const calendarGutter = useCalendarGutter()\n const unwrap = <T>(value: T): T => (value ? toRaw(value) : value)\n\n const onChange = (nextValue: DateTime | null) => {\n emit(\"update:value\", nextValue)\n emit(\"change\", nextValue)\n }\n\n const store: DateContextValue = {\n get value() {\n return unwrap(props.value) ?? null\n },\n get min() {\n return unwrap(props.min)\n },\n get max() {\n return unwrap(props.max)\n },\n get disabled() {\n return props.disabled\n },\n get captionLayout() {\n return props.captionLayout\n },\n get showTime() {\n return props.showTime\n },\n get yearRange() {\n return props.yearRange\n },\n onChange,\n }\n provide(DateContextKey, store)\n\n const handleClearClick = () => {\n onChange(null)\n }\n\n // The value text needs an id for aria-labelledby, also when `id` is not set\n const generatedId = useId()\n\n return () => {\n const { id, ariaLabelledby, align, placeholder } = props\n const value = store.value\n const { min, max } = store\n\n // min and max are inclusive, so equal bounds allow one date\n if (min && max && isAfter(min, max)) {\n throw new Error(\"DatePicker error: `min` date must not be after the `max` date\")\n }\n\n const valueId = `${id ?? generatedId}-value`\n\n const timeFormat = props.showTime ? props.triggerTimeFormat : undefined\n const triggerDateFormat = props.triggerDateFormat ?? (props.showTime && !timeFormat ? \"MM/dd/yy HH:mm\" : \"MM/dd/yy\")\n // With a time format the date and the time are two parts, apart by a space; a phone row draws each as a capsule\n const text = !value\n ? placeholder\n : timeFormat\n ? h(\"span\", { \"data-date-parts\": \"\" }, [\n h(\"span\", { \"data-date-part\": \"date\" }, value.toFormat(triggerDateFormat)),\n \" \",\n h(\"span\", { \"data-date-part\": \"time\" }, value.toFormat(timeFormat)),\n ])\n : value.toFormat(triggerDateFormat)\n\n return h(Popover, null, {\n default: () => [\n h(PopoverTrigger, null, {\n default: () => [\n h(\n SelectControl,\n {\n \"id\": id,\n \"aria-label\": props.ariaLabel,\n \"aria-labelledby\": ariaLabelledby ? `${ariaLabelledby} ${valueId}` : undefined,\n \"aria-describedby\": props.ariaDescribedby,\n \"aria-invalid\": props.ariaInvalid,\n \"class\": props.triggerClassName,\n \"data-date-picker\": \"\",\n \"selected\": !!value,\n \"variant\": props.variant,\n \"pill\": props.pill,\n \"block\": props.block,\n \"size\": props.size,\n \"disabled\": props.disabled,\n \"interactOnEnter\": true,\n \"StartIcon\": props.triggerShowIcon ? Calendar : undefined,\n \"dropdownIconType\": props.dropdownIconType,\n \"onClearClick\": props.clearable ? handleClearClick : undefined,\n },\n { default: () => [ariaLabelledby ? h(\"span\", { id: valueId }, text) : text] },\n ),\n ],\n }),\n h(\n PopoverContent,\n {\n class: s.Popover,\n minWidth: 230,\n collisionPadding: wide.value ? 20 : calendarGutter.value,\n side: wide.value || props.side === \"top\" ? props.side : \"bottom\",\n sideOffset: props.sideOffset,\n align,\n alignOffset: props.alignOffset ?? (align === \"center\" ? 0 : -5),\n },\n { default: () => [h(DateCalendar)] },\n ),\n ],\n })\n }\n },\n})\n\ntype DatePickerOwnProps = InstanceType<typeof DatePickerComponent>[\"$props\"]\n\nexport type DatePickerProps = DatePickerOwnProps\n\n/**\n * A date (and optionally time) picker: a SelectControl trigger opening a\n * calendar in a popover. Bind the date (a luxon `DateTime`) with\n * `v-model:value`.\n */\nexport const DatePicker = DatePickerComponent\n"]}
@@ -30,7 +30,7 @@ const DateRangePickerComponent = defineComponent({
30
30
  maxRangeDays: Number,
31
31
  /** The day each week starts on, from 0 (Sunday) to 6 (Saturday). @default 0 */
32
32
  weekStartsOn: { type: Number, default: 0 },
33
- /** Date range shortcuts for quick selection, shown to the left of the calendar. */
33
+ /** Date range shortcuts for quick selection, shown to the left of the calendar. Not shown below the md breakpoint: on a phone, offer them in a row of their own (see the docs). */
34
34
  shortcuts: Array,
35
35
  /** Preferred side; collisions can flip it. On phones, left and right prefer bottom so seven 44px day targets fit. @default "bottom" */
36
36
  side: { type: String, default: "bottom" },
@@ -1 +1 @@
1
- {"version":3,"file":"DateRangePicker.js","sourceRoot":"","sources":["../../../../src/components/DateRangePicker/DateRangePicker.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,+DAA+D,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAiB,MAAM,KAAK,CAAA;AAEjF,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAA;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAuC,MAAM,qBAAqB,CAAA;AAClH,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAA;AA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AAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC;oBACjE,CAAC,CACC,cAAc,EACd;wBACE,KAAK,EAAE,CAAC,CAAC,OAAO;wBAChB,QAAQ,EAAE,GAAG;wBACb,gBAAgB,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK;wBACxD,IAAI,EAAE,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ;wBAChE,UAAU,EAAE,KAAK,CAAC,UAAU;wBAC5B,KAAK;wBACL,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;qBAChE,EACD;wBACE,OAAO,EAAE,GAAG,EAAE,CAAC;4BACb,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,kBAAkB,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;yBAC3G;qBACF,CACF;iBACF;aACF,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAIF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAA","sourcesContent":["import s from \"@plexui/styles/components/DateRangePicker/Calendar.module.css\"\nimport { DateTime } from \"luxon\"\nimport { computed, defineComponent, h, provide, toRaw, type PropType } from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { useBreakpoint } from \"../../composables/useBreakpoints.js\"\nimport { isAfter } from \"../../lib/dateUtils.js\"\nimport { Popover, PopoverContent, PopoverTrigger, type PopoverAlign, type PopoverSide } from \"../Popover/index.js\"\nimport { useCalendarGutter } from \"../DatePicker/useCalendarGutter.js\"\nimport type { DropdownIconType } from \"../SelectControl/index.js\"\nimport { DateRangeCalendar, DateRangeShortcuts } from \"./Calendar.js\"\nimport { DateRangeContextKey, type DateRangeContextValue } from \"./context.js\"\nimport { DateRangeTrigger } from \"./Trigger.js\"\nimport { type DateRange, type DateRangeShortcut, type WeekStart } from \"./types.js\"\n\n// Vue port of packages/ui/src/components/DateRangePicker/DateRangePicker.tsx.\n// - `value` + `update:value` (`v-model:value`), plus `change`, which also\n// carries the selected shortcut like React's `onChange(range, shortcut)`.\n// Like React the picker is controlled: a parent that does not update\n// `value` keeps the shown range.\n// - DateTime values are read unwrapped (`toRaw`), so a `ref()` holding a\n// range (a deep reactive proxy) works like a plain value.\n\nconst DateRangePickerComponent = defineComponent({\n name: \"DateRangePicker\",\n inheritAttrs: false,\n props: {\n /** The selected date range value (`v-model:value`). */\n value: { type: Array as unknown as PropType<DateRange | null>, default: null },\n /** Defines the earliest selectable date (inclusive). */\n min: Object as PropType<DateTime>,\n /** Defines the latest selectable date (inclusive). */\n max: Object as PropType<DateTime>,\n /** Maximum length of the selectable range in days (inclusive). */\n maxRangeDays: Number,\n /** The day each week starts on, from 0 (Sunday) to 6 (Saturday). @default 0 */\n weekStartsOn: { type: Number as PropType<WeekStart>, default: 0 },\n /** Date range shortcuts for quick selection, shown to the left of the calendar. */\n shortcuts: Array as PropType<DateRangeShortcut[]>,\n /** Preferred side; collisions can flip it. On phones, left and right prefer bottom so seven 44px day targets fit. @default \"bottom\" */\n side: { type: String as PropType<PopoverSide>, default: \"bottom\" },\n /** The distance in pixels from the trigger. @default 8 */\n sideOffset: { type: Number, default: 8 },\n /** The preferred alignment against the trigger. @default \"center\" */\n align: { type: String as PropType<PopoverAlign>, default: \"center\" },\n /** An offset in pixels from the \"start\" or \"end\" alignment options. @default 0 */\n alignOffset: Number,\n /** Disables the select visually and from interactions. @default false */\n disabled: { type: Boolean, default: false },\n /** Placeholder text for the select. @default \"Select date range...\" */\n placeholder: { type: String, default: \"Select date range...\" },\n /** Style variant for the select trigger. @default \"outline\" */\n variant: { type: String as PropType<\"soft\" | \"outline\" | \"ghost\">, default: \"outline\" },\n /** Determines if the select trigger should be a fully rounded pill shape. @default true */\n pill: { type: Boolean, default: true },\n /** Size of the control: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Icon displayed in the far right of the select trigger. @default \"dropdown\" */\n dropdownIconType: String as PropType<DropdownIconType>,\n /** Custom class applied to the select trigger */\n triggerClassName: String,\n /** Display calendar icon at the start of the trigger. @default true */\n triggerShowIcon: { type: Boolean, default: true },\n /** Shows a stepper in the trigger when the selected range matches the unit ('month'). */\n triggerStepperUnit: String as PropType<\"month\">,\n /** Format of dates displayed in the trigger. @default \"MM/dd/yy\" */\n triggerDateFormat: { type: String, default: \"MM/dd/yy\" },\n /** Display a clear action that allows the select to be unset. @default false */\n clearable: { type: Boolean, default: false },\n /** Extends select to 100% of available width. @default false */\n block: { type: Boolean, default: false },\n },\n emits: {\n \"update:value\": (nextValue: DateRange | null) => nextValue === null || nextValue.every(DateTime.isDateTime),\n \"change\": (nextValue: DateRange | null, shortcut?: DateRangeShortcut) =>\n (nextValue === null || nextValue.every(DateTime.isDateTime)) &&\n (shortcut === undefined || typeof shortcut.getDateRange === \"function\"),\n },\n setup(props, { emit }) {\n const wide = useBreakpoint(\"md\")\n const calendarGutter = useCalendarGutter()\n const unwrap = <T>(value: T): T => (value ? toRaw(value) : value)\n\n // A new range only when `value` or one of its endpoints changes, as the\n // identity React's effects see. The endpoints are read through the array\n // so that `range.value[0] = date` on a `ref()` range is tracked.\n const value = computed<DateRange | null>(() => {\n const range = props.value\n if (!range) return null\n return [toRaw(range[0]), toRaw(range[1])]\n })\n\n const store: DateRangeContextValue = {\n get value() {\n return value.value\n },\n get min() {\n return unwrap(props.min)\n },\n get max() {\n return unwrap(props.max)\n },\n get maxRangeDays() {\n return props.maxRangeDays\n },\n get weekStartsOn() {\n return props.weekStartsOn\n },\n get triggerStepperUnit() {\n return props.triggerStepperUnit\n },\n get triggerClassName() {\n return props.triggerClassName\n },\n get triggerShowIcon() {\n return props.triggerShowIcon\n },\n get triggerDateFormat() {\n return props.triggerDateFormat\n },\n get disabled() {\n return props.disabled\n },\n get variant() {\n return props.variant\n },\n get pill() {\n return props.pill\n },\n get block() {\n return props.block\n },\n get size() {\n return props.size\n },\n get dropdownIconType() {\n return props.dropdownIconType\n },\n get clearable() {\n return props.clearable\n },\n get placeholder() {\n return props.placeholder\n },\n get shortcuts() {\n return props.shortcuts\n },\n onChange: (nextValue, shortcut) => {\n emit(\"update:value\", nextValue)\n emit(\"change\", nextValue, shortcut)\n },\n }\n provide(DateRangeContextKey, store)\n\n return () => {\n const { min, max } = store\n const { align } = props\n\n // min and max are inclusive, so equal bounds allow one date\n if (min && max && isAfter(min, max)) {\n throw new Error(\"DateRangePicker error: `min` date must not be after the `max` date\")\n }\n\n return h(Popover, null, {\n default: () => [\n h(PopoverTrigger, null, { default: () => [h(DateRangeTrigger)] }),\n h(\n PopoverContent,\n {\n class: s.Popover,\n minWidth: 230,\n collisionPadding: wide.value ? 20 : calendarGutter.value,\n side: wide.value || props.side === \"top\" ? props.side : \"bottom\",\n sideOffset: props.sideOffset,\n align,\n alignOffset: props.alignOffset ?? (align === \"center\" ? 0 : -5),\n },\n {\n default: () => [\n h(\"div\", { class: \"flex\" }, [h(DateRangeShortcuts, { shortcuts: props.shortcuts }), h(DateRangeCalendar)]),\n ],\n },\n ),\n ],\n })\n }\n },\n})\n\nexport type DateRangePickerProps = InstanceType<typeof DateRangePickerComponent>[\"$props\"]\n\n/**\n * A date range picker: a SelectControl trigger (or a month stepper) opening\n * two calendars and optional shortcuts in a popover. Bind the range\n * (`[start, end]` luxon `DateTime`s) with `v-model:value`.\n */\nexport const DateRangePicker = DateRangePickerComponent\n"]}
1
+ {"version":3,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AkB,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;yBAC3G;qBACF,CACF;iBACF;aACF,CAAC,CAAA;QACJ,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAIF;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,wBAAwB,CAAA","sourcesContent":["import s from \"@plexui/styles/components/DateRangePicker/Calendar.module.css\"\nimport { DateTime } from \"luxon\"\nimport { computed, defineComponent, h, provide, toRaw, type PropType } from \"vue\"\nimport type { ControlSize } from \"@plexui/styles/types\"\nimport { useBreakpoint } from \"../../composables/useBreakpoints.js\"\nimport { isAfter } from \"../../lib/dateUtils.js\"\nimport { Popover, PopoverContent, PopoverTrigger, type PopoverAlign, type PopoverSide } from \"../Popover/index.js\"\nimport { useCalendarGutter } from \"../DatePicker/useCalendarGutter.js\"\nimport type { DropdownIconType } from \"../SelectControl/index.js\"\nimport { DateRangeCalendar, DateRangeShortcuts } from \"./Calendar.js\"\nimport { DateRangeContextKey, type DateRangeContextValue } from \"./context.js\"\nimport { DateRangeTrigger } from \"./Trigger.js\"\nimport { type DateRange, type DateRangeShortcut, type WeekStart } from \"./types.js\"\n\n// Vue port of packages/ui/src/components/DateRangePicker/DateRangePicker.tsx.\n// - `value` + `update:value` (`v-model:value`), plus `change`, which also\n// carries the selected shortcut like React's `onChange(range, shortcut)`.\n// Like React the picker is controlled: a parent that does not update\n// `value` keeps the shown range.\n// - DateTime values are read unwrapped (`toRaw`), so a `ref()` holding a\n// range (a deep reactive proxy) works like a plain value.\n\nconst DateRangePickerComponent = defineComponent({\n name: \"DateRangePicker\",\n inheritAttrs: false,\n props: {\n /** The selected date range value (`v-model:value`). */\n value: { type: Array as unknown as PropType<DateRange | null>, default: null },\n /** Defines the earliest selectable date (inclusive). */\n min: Object as PropType<DateTime>,\n /** Defines the latest selectable date (inclusive). */\n max: Object as PropType<DateTime>,\n /** Maximum length of the selectable range in days (inclusive). */\n maxRangeDays: Number,\n /** The day each week starts on, from 0 (Sunday) to 6 (Saturday). @default 0 */\n weekStartsOn: { type: Number as PropType<WeekStart>, default: 0 },\n /** Date range shortcuts for quick selection, shown to the left of the calendar. Not shown below the md breakpoint: on a phone, offer them in a row of their own (see the docs). */\n shortcuts: Array as PropType<DateRangeShortcut[]>,\n /** Preferred side; collisions can flip it. On phones, left and right prefer bottom so seven 44px day targets fit. @default \"bottom\" */\n side: { type: String as PropType<PopoverSide>, default: \"bottom\" },\n /** The distance in pixels from the trigger. @default 8 */\n sideOffset: { type: Number, default: 8 },\n /** The preferred alignment against the trigger. @default \"center\" */\n align: { type: String as PropType<PopoverAlign>, default: \"center\" },\n /** An offset in pixels from the \"start\" or \"end\" alignment options. @default 0 */\n alignOffset: Number,\n /** Disables the select visually and from interactions. @default false */\n disabled: { type: Boolean, default: false },\n /** Placeholder text for the select. @default \"Select date range...\" */\n placeholder: { type: String, default: \"Select date range...\" },\n /** Style variant for the select trigger. @default \"outline\" */\n variant: { type: String as PropType<\"soft\" | \"outline\" | \"ghost\">, default: \"outline\" },\n /** Determines if the select trigger should be a fully rounded pill shape. @default true */\n pill: { type: Boolean, default: true },\n /** Size of the control: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Icon displayed in the far right of the select trigger. @default \"dropdown\" */\n dropdownIconType: String as PropType<DropdownIconType>,\n /** Custom class applied to the select trigger */\n triggerClassName: String,\n /** Display calendar icon at the start of the trigger. @default true */\n triggerShowIcon: { type: Boolean, default: true },\n /** Shows a stepper in the trigger when the selected range matches the unit ('month'). */\n triggerStepperUnit: String as PropType<\"month\">,\n /** Format of dates displayed in the trigger. @default \"MM/dd/yy\" */\n triggerDateFormat: { type: String, default: \"MM/dd/yy\" },\n /** Display a clear action that allows the select to be unset. @default false */\n clearable: { type: Boolean, default: false },\n /** Extends select to 100% of available width. @default false */\n block: { type: Boolean, default: false },\n },\n emits: {\n \"update:value\": (nextValue: DateRange | null) => nextValue === null || nextValue.every(DateTime.isDateTime),\n \"change\": (nextValue: DateRange | null, shortcut?: DateRangeShortcut) =>\n (nextValue === null || nextValue.every(DateTime.isDateTime)) &&\n (shortcut === undefined || typeof shortcut.getDateRange === \"function\"),\n },\n setup(props, { emit }) {\n const wide = useBreakpoint(\"md\")\n const calendarGutter = useCalendarGutter()\n const unwrap = <T>(value: T): T => (value ? toRaw(value) : value)\n\n // A new range only when `value` or one of its endpoints changes, as the\n // identity React's effects see. The endpoints are read through the array\n // so that `range.value[0] = date` on a `ref()` range is tracked.\n const value = computed<DateRange | null>(() => {\n const range = props.value\n if (!range) return null\n return [toRaw(range[0]), toRaw(range[1])]\n })\n\n const store: DateRangeContextValue = {\n get value() {\n return value.value\n },\n get min() {\n return unwrap(props.min)\n },\n get max() {\n return unwrap(props.max)\n },\n get maxRangeDays() {\n return props.maxRangeDays\n },\n get weekStartsOn() {\n return props.weekStartsOn\n },\n get triggerStepperUnit() {\n return props.triggerStepperUnit\n },\n get triggerClassName() {\n return props.triggerClassName\n },\n get triggerShowIcon() {\n return props.triggerShowIcon\n },\n get triggerDateFormat() {\n return props.triggerDateFormat\n },\n get disabled() {\n return props.disabled\n },\n get variant() {\n return props.variant\n },\n get pill() {\n return props.pill\n },\n get block() {\n return props.block\n },\n get size() {\n return props.size\n },\n get dropdownIconType() {\n return props.dropdownIconType\n },\n get clearable() {\n return props.clearable\n },\n get placeholder() {\n return props.placeholder\n },\n get shortcuts() {\n return props.shortcuts\n },\n onChange: (nextValue, shortcut) => {\n emit(\"update:value\", nextValue)\n emit(\"change\", nextValue, shortcut)\n },\n }\n provide(DateRangeContextKey, store)\n\n return () => {\n const { min, max } = store\n const { align } = props\n\n // min and max are inclusive, so equal bounds allow one date\n if (min && max && isAfter(min, max)) {\n throw new Error(\"DateRangePicker error: `min` date must not be after the `max` date\")\n }\n\n return h(Popover, null, {\n default: () => [\n h(PopoverTrigger, null, { default: () => [h(DateRangeTrigger)] }),\n h(\n PopoverContent,\n {\n class: s.Popover,\n minWidth: 230,\n collisionPadding: wide.value ? 20 : calendarGutter.value,\n side: wide.value || props.side === \"top\" ? props.side : \"bottom\",\n sideOffset: props.sideOffset,\n align,\n alignOffset: props.alignOffset ?? (align === \"center\" ? 0 : -5),\n },\n {\n default: () => [\n h(\"div\", { class: \"flex\" }, [h(DateRangeShortcuts, { shortcuts: props.shortcuts }), h(DateRangeCalendar)]),\n ],\n },\n ),\n ],\n })\n }\n },\n})\n\nexport type DateRangePickerProps = InstanceType<typeof DateRangePickerComponent>[\"$props\"]\n\n/**\n * A date range picker: a SelectControl trigger (or a month stepper) opening\n * two calendars and optional shortcuts in a popover. Bind the range\n * (`[start, end]` luxon `DateTime`s) with `v-model:value`.\n */\nexport const DateRangePicker = DateRangePickerComponent\n"]}