@plexui/vue 0.1.3 → 0.1.5
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.
- package/dist/es/components/DateRangePicker/Calendar.js +19 -18
- package/dist/es/components/DateRangePicker/Calendar.js.map +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js +5 -0
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/DateRangePicker/context.js.map +1 -1
- package/dist/es/components/DateRangePicker/index.js.map +1 -1
- package/dist/es/components/DateRangePicker/types.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +46 -11
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Field/Field.js +6 -3
- package/dist/es/components/Field/Field.js.map +1 -1
- package/dist/es/components/InputGroup/InputGroup.js +0 -1
- package/dist/es/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +27 -5
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/Popover/Popover.js +24 -9
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/Select/Select.js +33 -15
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +7 -4
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/Transition/TransitionGroup.js +12 -1
- package/dist/es/components/Transition/TransitionGroup.js.map +1 -1
- package/dist/es/components/Transition/shared.js +30 -1
- package/dist/es/components/Transition/shared.js.map +1 -1
- package/dist/es/components/Transition/useTransitionChild.js +2 -2
- package/dist/es/components/Transition/useTransitionChild.js.map +1 -1
- package/dist/es/lib/dateUtils.js +5 -0
- package/dist/es/lib/dateUtils.js.map +1 -1
- package/dist/es/lib/helpers.js +30 -0
- package/dist/es/lib/helpers.js.map +1 -1
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +23 -1
- package/dist/types/components/DateRangePicker/context.d.ts +2 -1
- package/dist/types/components/DateRangePicker/index.d.ts +1 -1
- package/dist/types/components/DateRangePicker/types.d.ts +2 -0
- package/dist/types/components/Field/Field.d.ts +2 -2
- package/dist/types/components/Select/Select.d.ts +11 -0
- package/dist/types/components/SelectControl/SelectControl.d.ts +11 -0
- package/dist/types/components/Transition/TransitionGroup.d.ts +11 -0
- package/dist/types/components/Transition/shared.d.ts +23 -0
- package/dist/types/components/Transition/useTransitionChild.d.ts +1 -0
- package/dist/types/lib/dateUtils.d.ts +5 -0
- package/dist/types/lib/helpers.d.ts +13 -0
- package/package.json +1 -1
|
@@ -38,6 +38,8 @@ const SelectControlComponent = defineComponent({
|
|
|
38
38
|
onClearClick: Function,
|
|
39
39
|
/** Primary handler for when the control is selected with pointer or keyboard events (`@interact`). */
|
|
40
40
|
onInteract: Function,
|
|
41
|
+
/** Enter interacts too, as on a combobox button. Off by default, as Enter may be an attempt to submit a form. @default false */
|
|
42
|
+
interactOnEnter: { type: Boolean, default: false },
|
|
41
43
|
/** Size and spacing of the control: `3xs` 22px up to `3xl` 48px. @default "md" */
|
|
42
44
|
size: { type: String, default: "md" },
|
|
43
45
|
/** Displays a loading indicator in place of the dropdown icon and clear action. @default false */
|
|
@@ -57,10 +59,14 @@ const SelectControlComponent = defineComponent({
|
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
59
61
|
switch (evt.key) {
|
|
60
|
-
|
|
62
|
+
case "Enter":
|
|
61
63
|
case "ArrowDown":
|
|
62
64
|
case "ArrowUp":
|
|
63
65
|
case " ":
|
|
66
|
+
// NOTE: "Enter" may be an attempt to submit a form
|
|
67
|
+
if (evt.key === "Enter" && !props.interactOnEnter) {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
64
70
|
evt.stopPropagation();
|
|
65
71
|
evt.preventDefault();
|
|
66
72
|
if (props.onInteract) {
|
|
@@ -75,9 +81,6 @@ const SelectControlComponent = defineComponent({
|
|
|
75
81
|
}));
|
|
76
82
|
}
|
|
77
83
|
break;
|
|
78
|
-
case "Enter":
|
|
79
|
-
// NOTE: "Enter" does not open selects, as it may be an attempt to submit a form
|
|
80
|
-
break;
|
|
81
84
|
default:
|
|
82
85
|
// Allow all other key presses through
|
|
83
86
|
callListener(attrs.onKeydown, evt);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectControl.js","sourceRoot":"","sources":["../../../../src/components/SelectControl/SelectControl.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAmB,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,UAAU,EAAsD,MAAM,KAAK,CAAA;AAExG,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAsBhF,8EAA8E;AAC9E,MAAM,YAAY,GAAG,CAAC,QAAiB,EAAE,GAAG,IAAe,EAAE,EAAE;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,KAAK,MAAM,OAAO,IAAI,QAAQ;YAAE,YAAY,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAA;IAChE,CAAC;SAAM,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QAC1C,CAAC;QAAC,QAA8C,CAAC,GAAG,IAAI,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC,CAAA;AAED,MAAM,sBAAsB,GAAG,eAAe,CAAC;IAC7C,IAAI,EAAE,eAAe;IACrB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE;QACL,wDAAwD;QACxD,OAAO,EAAE,EAAE,IAAI,EAAE,MAA0D,EAAE,OAAO,EAAE,SAAS,EAAE;QAC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,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC1F;IACD,KAAK,CAAC,KAAK;QACT,OAAO,GAAG,EAAE,CACV,KAAK,CAAC,QAAQ,KAAK,aAAa;YAC9B,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACxE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAA;IAC9C,CAAC;CACF,CAAC,CAAA","sourcesContent":["import clsx, { type ClassValue } from \"clsx\"\nimport { defineComponent, h, shallowRef, type Component, type HTMLAttributes, type PropType } from \"vue\"\nimport type { ControlSize, Variants } from \"@plexui/styles/types\"\nimport { handlePressableMouseEnter } from \"../../lib/helpers.js\"\nimport { Button } from \"../Button/index.js\"\nimport { ChevronDown, Dropdown, X } from \"../Icon/index.js\"\nimport { LoadingIndicator } from \"../Indicator/index.js\"\nimport s from \"@plexui/styles/components/SelectControl/SelectControl.module.css\"\n\n// Vue port of packages/ui/src/components/SelectControl/SelectControl.tsx.\n// - The control is a <span role=\"button\"> that rebuilds <button> semantics,\n// as in React. Every attribute that is not a prop lands on it after the\n// control's own attributes (React spreads its rest props last), and an\n// `onClick` listener is dropped: the control opens on pointer down, like a\n// native select.\n// - `onClearClick` and `onInteract` are function props (`@clear-click`,\n// `@interact` in templates): the first one's presence adds the clear\n// button, the second one's changes what pointer down and the keyboard do.\n// - `@pointerdown`, `@keydown` and `@pointerenter` listeners are called the\n// way React calls `onPointerDown`, `onKeyDown` and `onPointerEnter`: only\n// while the control is interactive, `@keydown` only for keys the control\n// does not handle, and `@pointerdown` (plus `@click`) only without\n// `onInteract`. This is how a parent trigger (MenuTrigger, PopoverTrigger)\n// opens its content from the control.\n\nexport type DropdownIconType = \"chevronDown\" | \"dropdown\" | \"none\"\n\ntype Listener = ((...args: never[]) => unknown) | Listener[] | null | undefined\n\n/** Calls a listener attribute, which Vue may hold as an array of handlers. */\nconst callListener = (listener: unknown, ...args: unknown[]) => {\n if (Array.isArray(listener)) {\n for (const handler of listener) callListener(handler, ...args)\n } else if (typeof listener === \"function\") {\n ;(listener as (...params: unknown[]) => unknown)(...args)\n }\n}\n\nconst SelectControlComponent = defineComponent({\n name: \"SelectControl\",\n inheritAttrs: false,\n props: {\n /** Style variant for the control. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"soft\" | \"outline\" | \"ghost\">>, default: \"outline\" },\n /** Determines if the control should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Extends the control to 100% of available width. */\n block: { type: Boolean, default: undefined },\n /** Applies a negative margin using the current gutter to optically align the control with surrounding content. */\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n /** Disables the control visually and from interactions. @default false */\n disabled: { type: Boolean, default: undefined },\n /** Visually indicates that the control is in an invalid state. @default false */\n invalid: { type: Boolean, default: undefined },\n /** Indicates that the control is selected. An unselected state will display placeholder styles. @default false */\n selected: { type: Boolean, default: false },\n /** Displays a clear action that allows the select to be unset; called when it is pressed (`@clear-click`). */\n onClearClick: Function as PropType<() => void>,\n /** Primary handler for when the control is selected with pointer or keyboard events (`@interact`). */\n onInteract: Function as PropType<() => void>,\n /** Size and spacing of the control: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Displays a loading indicator in place of the dropdown icon and clear action. @default false */\n loading: { type: Boolean, default: undefined },\n /** Icon displayed in the far right of the control. @default \"dropdown\" */\n dropdownIconType: { type: String as PropType<DropdownIconType>, default: \"dropdown\" },\n /** Icon displayed at the start of the control */\n StartIcon: [Object, Function] as PropType<Component>,\n },\n setup(props, { slots, attrs }) {\n const controlRef = shallowRef<HTMLSpanElement | null>(null)\n\n // Act like a <button> and fire the click handler on keyboard actions\n const handleKeyDown = (evt: KeyboardEvent) => {\n // Enter and Space on a nested control (the clear button) activate that\n // control: neither this handler nor a wrapping trigger's may take them\n if (evt.target !== evt.currentTarget && (evt.key === \" \" || evt.key === \"Enter\")) {\n return\n }\n switch (evt.key) {\n // NOTE: \"Enter\" does not open selects, as it may be an attempt to submit a form\n case \"ArrowDown\":\n case \"ArrowUp\":\n case \" \":\n evt.stopPropagation()\n evt.preventDefault()\n\n if (props.onInteract) {\n props.onInteract()\n } else {\n // Otherwise, send a synthetic trigger event to the parent trigger\n controlRef.value?.dispatchEvent(\n new PointerEvent(\"pointerdown\", {\n bubbles: true,\n cancelable: true,\n pointerType: \"mouse\", // mimic mouse interaction\n }),\n )\n }\n break\n case \"Enter\":\n // NOTE: \"Enter\" does not open selects, as it may be an attempt to submit a form\n break\n default:\n // Allow all other key presses through\n callListener(attrs.onKeydown, evt)\n }\n }\n\n const handlePointerDown = (evt: PointerEvent) => {\n // Don't trigger on right clicks\n if (evt.button === 2) {\n return\n }\n\n // Prevent focus from entering the click target of the select\n // so that focus correctly moves into the menu.\n evt.stopPropagation()\n\n if (props.onInteract) {\n evt.preventDefault()\n props.onInteract()\n } else {\n // NOTE: cannot preventDefault() here, for the parent trigger\n callListener(attrs.onPointerdown, evt)\n // A parent trigger may also pass `onClick` (React's <Popover.Trigger> does).\n // This component opens on pointer down, so call it here, assuming that\n // `onPointerdown` is not going to be responsible for opening.\n callListener(attrs.onClick, evt)\n }\n }\n\n const handleClearClick = (evt: MouseEvent) => {\n evt.stopPropagation()\n evt.preventDefault()\n props.onClearClick?.()\n }\n\n return () => {\n const {\n class: className,\n onPointerdown: _onPointerdown,\n onKeydown: _onKeydown,\n onPointerenter,\n onClick: _onClick,\n ...restAttrs\n } = attrs as Record<string, unknown> & { onPointerenter?: Listener }\n const { disabled, loading, selected, pill, dropdownIconType, StartIcon } = props\n const clearable = !!props.onClearClick\n const showClearAction = clearable && selected && !loading && !disabled\n const hasDropdownIcon = dropdownIconType && dropdownIconType !== \"none\" && !loading\n const hasAnyTertiaryIndicator = showClearAction || loading || hasDropdownIcon\n const isInteractive = !loading && !disabled\n\n // Intentionally not using <button> and rebuilding the semantics\n return h(\n \"span\",\n {\n \"ref\": controlRef,\n \"class\": clsx(s.SelectControl, className as ClassValue),\n // Recreate <button> semantics\n \"role\": \"button\",\n \"tabindex\": disabled ? -1 : 0,\n \"onPointerenter\": (evt: PointerEvent) => {\n handlePressableMouseEnter(evt)\n callListener(onPointerenter, evt)\n },\n \"onPointerdown\": isInteractive ? handlePointerDown : undefined,\n \"onKeydown\": isInteractive ? handleKeyDown : undefined,\n \"data-variant\": props.variant,\n \"data-block\": props.block ? \"\" : undefined,\n \"data-pill\": pill ? \"\" : undefined,\n \"data-size\": props.size,\n \"data-optically-align\": props.opticallyAlign,\n \"aria-busy\": loading ? \"true\" : undefined,\n \"data-selected\": selected,\n \"data-loading\": loading ? \"\" : undefined,\n \"data-invalid\": props.invalid ? \"\" : undefined,\n \"data-disabled\": disabled ? \"\" : undefined,\n \"aria-disabled\": disabled,\n ...restAttrs,\n },\n [\n StartIcon ? h(StartIcon, { class: s.StartIcon }) : null,\n h(\"span\", { class: s.TriggerText }, slots.default?.()),\n hasAnyTertiaryIndicator\n ? h(\"div\", { class: s.IndicatorWrapper }, [\n showClearAction\n ? h(\n Button,\n {\n \"aria-label\": \"Clear current value\",\n \"class\": s.Clear,\n // Prevent pointerdown on the trigger from being captured\n \"onPointerdown\": (evt: PointerEvent) => evt.stopPropagation(),\n \"onClick\": handleClearClick,\n \"color\": \"secondary\",\n \"variant\": hasDropdownIcon ? \"ghost\" : \"solid\",\n // Mostly custom sizing through variables\n \"size\": \"3xs\",\n \"uniform\": true,\n \"pill\": pill,\n \"data-only-child\": !hasDropdownIcon ? \"\" : undefined,\n },\n { default: () => [h(X)] },\n )\n : null,\n loading ? h(LoadingIndicator, { class: s.LoadingIndicator }) : null,\n // Using raw SVG canvases (opposed to fixed icon canvases) led to less pixelation.\n hasDropdownIcon ? h(DropdownIcon, { iconType: dropdownIconType }) : null,\n ])\n : null,\n ],\n )\n }\n },\n})\n\ntype SelectControlOwnProps = InstanceType<typeof SelectControlComponent>[\"$props\"]\n\n/** SelectControl props plus the <span> attributes that fall through to it, as in React. */\nexport type SelectControlProps = SelectControlOwnProps & Omit<HTMLAttributes, keyof SelectControlOwnProps>\n\n/**\n * The trigger of a select: placeholder styles, start icon, clear action,\n * loading and dropdown indicators. Pair it with any floating UI (MenuTrigger,\n * PopoverTrigger); the default slot is the control's content.\n */\nexport const SelectControl = SelectControlComponent as typeof SelectControlComponent & {\n new (): { $props: SelectControlProps }\n}\n\nexport const DropdownIcon = defineComponent({\n name: \"DropdownIcon\",\n props: {\n iconType: { type: String as PropType<Exclude<DropdownIconType, \"none\">>, required: true },\n },\n setup(props) {\n return () =>\n props.iconType === \"chevronDown\"\n ? h(ChevronDown, { class: clsx(s.DropdownIcon, s.DropdownIconChevron) })\n : h(Dropdown, { class: s.DropdownIcon })\n },\n})\n"]}
|
|
1
|
+
{"version":3,"file":"SelectControl.js","sourceRoot":"","sources":["../../../../src/components/SelectControl/SelectControl.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,EAAE,EAAmB,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,UAAU,EAAsD,MAAM,KAAK,CAAA;AAExG,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,CAAC,MAAM,kEAAkE,CAAA;AAsBhF,8EAA8E;AAC9E,MAAM,YAAY,GAAG,CAAC,QAAiB,EAAE,GAAG,IAAe,EAAE,EAAE;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,KAAK,MAAM,OAAO,IAAI,Q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C,CAAC,IAAI;wBACR,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;wBACnE,kFAAkF;wBAClF,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;qBACzE,CAAC;oBACJ,CAAC,CAAC,IAAI;aACT,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,sBAE5B,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;IAC1C,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE;QACL,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAqD,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC1F;IACD,KAAK,CAAC,KAAK;QACT,OAAO,GAAG,EAAE,CACV,KAAK,CAAC,QAAQ,KAAK,aAAa;YAC9B,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACxE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,YAAY,EAAE,CAAC,CAAA;IAC9C,CAAC;CACF,CAAC,CAAA","sourcesContent":["import clsx, { type ClassValue } from \"clsx\"\nimport { defineComponent, h, shallowRef, type Component, type HTMLAttributes, type PropType } from \"vue\"\nimport type { ControlSize, Variants } from \"@plexui/styles/types\"\nimport { handlePressableMouseEnter } from \"../../lib/helpers.js\"\nimport { Button } from \"../Button/index.js\"\nimport { ChevronDown, Dropdown, X } from \"../Icon/index.js\"\nimport { LoadingIndicator } from \"../Indicator/index.js\"\nimport s from \"@plexui/styles/components/SelectControl/SelectControl.module.css\"\n\n// Vue port of packages/ui/src/components/SelectControl/SelectControl.tsx.\n// - The control is a <span role=\"button\"> that rebuilds <button> semantics,\n// as in React. Every attribute that is not a prop lands on it after the\n// control's own attributes (React spreads its rest props last), and an\n// `onClick` listener is dropped: the control opens on pointer down, like a\n// native select.\n// - `onClearClick` and `onInteract` are function props (`@clear-click`,\n// `@interact` in templates): the first one's presence adds the clear\n// button, the second one's changes what pointer down and the keyboard do.\n// - `@pointerdown`, `@keydown` and `@pointerenter` listeners are called the\n// way React calls `onPointerDown`, `onKeyDown` and `onPointerEnter`: only\n// while the control is interactive, `@keydown` only for keys the control\n// does not handle, and `@pointerdown` (plus `@click`) only without\n// `onInteract`. This is how a parent trigger (MenuTrigger, PopoverTrigger)\n// opens its content from the control.\n\nexport type DropdownIconType = \"chevronDown\" | \"dropdown\" | \"none\"\n\ntype Listener = ((...args: never[]) => unknown) | Listener[] | null | undefined\n\n/** Calls a listener attribute, which Vue may hold as an array of handlers. */\nconst callListener = (listener: unknown, ...args: unknown[]) => {\n if (Array.isArray(listener)) {\n for (const handler of listener) callListener(handler, ...args)\n } else if (typeof listener === \"function\") {\n ;(listener as (...params: unknown[]) => unknown)(...args)\n }\n}\n\nconst SelectControlComponent = defineComponent({\n name: \"SelectControl\",\n inheritAttrs: false,\n props: {\n /** Style variant for the control. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"soft\" | \"outline\" | \"ghost\">>, default: \"outline\" },\n /** Determines if the control should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Extends the control to 100% of available width. */\n block: { type: Boolean, default: undefined },\n /** Applies a negative margin using the current gutter to optically align the control with surrounding content. */\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n /** Disables the control visually and from interactions. @default false */\n disabled: { type: Boolean, default: undefined },\n /** Visually indicates that the control is in an invalid state. @default false */\n invalid: { type: Boolean, default: undefined },\n /** Indicates that the control is selected. An unselected state will display placeholder styles. @default false */\n selected: { type: Boolean, default: false },\n /** Displays a clear action that allows the select to be unset; called when it is pressed (`@clear-click`). */\n onClearClick: Function as PropType<() => void>,\n /** Primary handler for when the control is selected with pointer or keyboard events (`@interact`). */\n onInteract: Function as PropType<() => void>,\n /** Enter interacts too, as on a combobox button. Off by default, as Enter may be an attempt to submit a form. @default false */\n interactOnEnter: { type: Boolean, default: false },\n /** Size and spacing of the control: `3xs` 22px up to `3xl` 48px. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Displays a loading indicator in place of the dropdown icon and clear action. @default false */\n loading: { type: Boolean, default: undefined },\n /** Icon displayed in the far right of the control. @default \"dropdown\" */\n dropdownIconType: { type: String as PropType<DropdownIconType>, default: \"dropdown\" },\n /** Icon displayed at the start of the control */\n StartIcon: [Object, Function] as PropType<Component>,\n },\n setup(props, { slots, attrs }) {\n const controlRef = shallowRef<HTMLSpanElement | null>(null)\n\n // Act like a <button> and fire the click handler on keyboard actions\n const handleKeyDown = (evt: KeyboardEvent) => {\n // Enter and Space on a nested control (the clear button) activate that\n // control: neither this handler nor a wrapping trigger's may take them\n if (evt.target !== evt.currentTarget && (evt.key === \" \" || evt.key === \"Enter\")) {\n return\n }\n switch (evt.key) {\n case \"Enter\":\n case \"ArrowDown\":\n case \"ArrowUp\":\n case \" \":\n // NOTE: \"Enter\" may be an attempt to submit a form\n if (evt.key === \"Enter\" && !props.interactOnEnter) {\n break\n }\n\n evt.stopPropagation()\n evt.preventDefault()\n\n if (props.onInteract) {\n props.onInteract()\n } else {\n // Otherwise, send a synthetic trigger event to the parent trigger\n controlRef.value?.dispatchEvent(\n new PointerEvent(\"pointerdown\", {\n bubbles: true,\n cancelable: true,\n pointerType: \"mouse\", // mimic mouse interaction\n }),\n )\n }\n break\n default:\n // Allow all other key presses through\n callListener(attrs.onKeydown, evt)\n }\n }\n\n const handlePointerDown = (evt: PointerEvent) => {\n // Don't trigger on right clicks\n if (evt.button === 2) {\n return\n }\n\n // Prevent focus from entering the click target of the select\n // so that focus correctly moves into the menu.\n evt.stopPropagation()\n\n if (props.onInteract) {\n evt.preventDefault()\n props.onInteract()\n } else {\n // NOTE: cannot preventDefault() here, for the parent trigger\n callListener(attrs.onPointerdown, evt)\n // A parent trigger may also pass `onClick` (React's <Popover.Trigger> does).\n // This component opens on pointer down, so call it here, assuming that\n // `onPointerdown` is not going to be responsible for opening.\n callListener(attrs.onClick, evt)\n }\n }\n\n const handleClearClick = (evt: MouseEvent) => {\n evt.stopPropagation()\n evt.preventDefault()\n props.onClearClick?.()\n }\n\n return () => {\n const {\n class: className,\n onPointerdown: _onPointerdown,\n onKeydown: _onKeydown,\n onPointerenter,\n onClick: _onClick,\n ...restAttrs\n } = attrs as Record<string, unknown> & { onPointerenter?: Listener }\n const { disabled, loading, selected, pill, dropdownIconType, StartIcon } = props\n const clearable = !!props.onClearClick\n const showClearAction = clearable && selected && !loading && !disabled\n const hasDropdownIcon = dropdownIconType && dropdownIconType !== \"none\" && !loading\n const hasAnyTertiaryIndicator = showClearAction || loading || hasDropdownIcon\n const isInteractive = !loading && !disabled\n\n // Intentionally not using <button> and rebuilding the semantics\n return h(\n \"span\",\n {\n \"ref\": controlRef,\n \"class\": clsx(s.SelectControl, className as ClassValue),\n // Recreate <button> semantics\n \"role\": \"button\",\n \"tabindex\": disabled ? -1 : 0,\n \"onPointerenter\": (evt: PointerEvent) => {\n handlePressableMouseEnter(evt)\n callListener(onPointerenter, evt)\n },\n \"onPointerdown\": isInteractive ? handlePointerDown : undefined,\n \"onKeydown\": isInteractive ? handleKeyDown : undefined,\n \"data-variant\": props.variant,\n \"data-block\": props.block ? \"\" : undefined,\n \"data-pill\": pill ? \"\" : undefined,\n \"data-size\": props.size,\n \"data-optically-align\": props.opticallyAlign,\n \"aria-busy\": loading ? \"true\" : undefined,\n \"data-selected\": selected,\n \"data-loading\": loading ? \"\" : undefined,\n \"data-invalid\": props.invalid ? \"\" : undefined,\n \"data-disabled\": disabled ? \"\" : undefined,\n \"aria-disabled\": disabled,\n ...restAttrs,\n },\n [\n StartIcon ? h(StartIcon, { class: s.StartIcon }) : null,\n h(\"span\", { class: s.TriggerText }, slots.default?.()),\n hasAnyTertiaryIndicator\n ? h(\"div\", { class: s.IndicatorWrapper }, [\n showClearAction\n ? h(\n Button,\n {\n \"aria-label\": \"Clear current value\",\n \"class\": s.Clear,\n // Prevent pointerdown on the trigger from being captured\n \"onPointerdown\": (evt: PointerEvent) => evt.stopPropagation(),\n \"onClick\": handleClearClick,\n \"color\": \"secondary\",\n \"variant\": hasDropdownIcon ? \"ghost\" : \"solid\",\n // Mostly custom sizing through variables\n \"size\": \"3xs\",\n \"uniform\": true,\n \"pill\": pill,\n \"data-only-child\": !hasDropdownIcon ? \"\" : undefined,\n },\n { default: () => [h(X)] },\n )\n : null,\n loading ? h(LoadingIndicator, { class: s.LoadingIndicator }) : null,\n // Using raw SVG canvases (opposed to fixed icon canvases) led to less pixelation.\n hasDropdownIcon ? h(DropdownIcon, { iconType: dropdownIconType }) : null,\n ])\n : null,\n ],\n )\n }\n },\n})\n\ntype SelectControlOwnProps = InstanceType<typeof SelectControlComponent>[\"$props\"]\n\n/** SelectControl props plus the <span> attributes that fall through to it, as in React. */\nexport type SelectControlProps = SelectControlOwnProps & Omit<HTMLAttributes, keyof SelectControlOwnProps>\n\n/**\n * The trigger of a select: placeholder styles, start icon, clear action,\n * loading and dropdown indicators. Pair it with any floating UI (MenuTrigger,\n * PopoverTrigger); the default slot is the control's content.\n */\nexport const SelectControl = SelectControlComponent as typeof SelectControlComponent & {\n new (): { $props: SelectControlProps }\n}\n\nexport const DropdownIcon = defineComponent({\n name: \"DropdownIcon\",\n props: {\n iconType: { type: String as PropType<Exclude<DropdownIconType, \"none\">>, required: true },\n },\n setup(props) {\n return () =>\n props.iconType === \"chevronDown\"\n ? h(ChevronDown, { class: clsx(s.DropdownIcon, s.DropdownIconChevron) })\n : h(Dropdown, { class: s.DropdownIcon })\n },\n})\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
|
-
import { defineComponent, h, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
2
|
+
import { defineComponent, h, onBeforeUnmount, onErrorCaptured, onMounted, ref, watch, } from "vue";
|
|
3
3
|
import getDisableAnimations from "./getDisableAnimations.js";
|
|
4
4
|
import { flattenChildren, isPlaceholder, useChildList } from "./childList.js";
|
|
5
5
|
import { useTransitionChild } from "./useTransitionChild.js";
|
|
@@ -16,12 +16,16 @@ const TransitionGroupChildInner = defineComponent({
|
|
|
16
16
|
shouldRender: { type: Boolean, required: true },
|
|
17
17
|
enterDuration: { type: Number, required: true },
|
|
18
18
|
exitDuration: { type: Number, required: true },
|
|
19
|
+
overlay: Boolean,
|
|
19
20
|
removeChild: { type: Function, required: true },
|
|
20
21
|
callbacks: Object,
|
|
21
22
|
},
|
|
22
23
|
setup(props, { slots }) {
|
|
23
24
|
const element = ref(null);
|
|
24
25
|
const state = useTransitionChild(props, () => element.value);
|
|
26
|
+
// An exiting child stays mounted with live slots, where React renders its
|
|
27
|
+
// last element: state cleared along with the close must not throw here
|
|
28
|
+
onErrorCaptured(() => (props.shouldRender ? undefined : false));
|
|
25
29
|
return () => h(props.as, {
|
|
26
30
|
"ref": element,
|
|
27
31
|
"class": clsx(props.className, s.TransitionGroupChild),
|
|
@@ -32,6 +36,7 @@ const TransitionGroupChildInner = defineComponent({
|
|
|
32
36
|
"data-exiting": state.exit ? "" : undefined,
|
|
33
37
|
"data-exiting-active": state.exitActive ? "" : undefined,
|
|
34
38
|
"data-interrupted": state.interrupted ? "" : undefined,
|
|
39
|
+
"inert": props.overlay && state.exit ? "" : undefined,
|
|
35
40
|
}, slots.default?.());
|
|
36
41
|
},
|
|
37
42
|
});
|
|
@@ -110,6 +115,11 @@ export const TransitionGroup = defineComponent({
|
|
|
110
115
|
enterMountDelay: Number,
|
|
111
116
|
/** Render children changes immediately, bypassing transition timings */
|
|
112
117
|
disableAnimations: { type: Boolean, default: () => getDisableAnimations() },
|
|
118
|
+
/**
|
|
119
|
+
* For overlays: an exiting child is `inert`, out of the tab order and of hit
|
|
120
|
+
* testing, and with reduced motion it leaves without waiting for `exitDuration`.
|
|
121
|
+
*/
|
|
122
|
+
overlay: Boolean,
|
|
113
123
|
/** Determines how new children are added to the children array */
|
|
114
124
|
insertMethod: { type: String, default: "append" },
|
|
115
125
|
/** Called when an enter animation is staged (e.g., component mounted to the DOM) */
|
|
@@ -155,6 +165,7 @@ export const TransitionGroup = defineComponent({
|
|
|
155
165
|
shouldRender: child.shouldRender,
|
|
156
166
|
enterDuration: props.enterDuration,
|
|
157
167
|
exitDuration: props.exitDuration,
|
|
168
|
+
overlay: props.overlay,
|
|
158
169
|
removeChild: () => children.remove(child.key),
|
|
159
170
|
callbacks,
|
|
160
171
|
}, { default: () => [child.vnode] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransitionGroup.js","sourceRoot":"","sources":["../../../../src/components/Transition/TransitionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAA8C,MAAM,KAAK,CAAA;AAC5H,OAAO,oBAAoB,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAO/E,MAAM,YAAY,GAAG,QAAkD,CAAA;AAEvE,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAChD,IAAI,EAAE,2BAA2B;IACjC,KAAK,EAAE;QACL,EAAE,EAAE,EAAE,IAAI,EAAE,MAAuB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACrD,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,MA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AW,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;gBAC7C,SAAS;aACV,EACD,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CACjC,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport { defineComponent, h, onBeforeUnmount, onMounted, ref, watch, type PropType, type StyleValue, type VNode } from \"vue\"\nimport getDisableAnimations from \"./getDisableAnimations.js\"\nimport { flattenChildren, isPlaceholder, useChildList } from \"./childList.js\"\nimport type { InsertMethod, TransitionGroupChildCallback, TransitionGroupChildCallbacks } from \"./shared.js\"\nimport { useTransitionChild } from \"./useTransitionChild.js\"\nimport s from \"@plexui/styles/components/Transition/TransitionGroup.module.css\"\n\n// Port of packages/ui/src/components/Transition/TransitionGroup.tsx. Same\n// wrappers, data attributes and timings, so the shared CSS animates both.\n\ntype Tag = \"div\" | \"span\"\n\nconst callbackProp = Function as PropType<TransitionGroupChildCallback>\n\nconst TransitionGroupChildInner = defineComponent({\n name: \"TransitionGroupChildInner\",\n props: {\n as: { type: String as PropType<Tag>, required: true },\n className: String,\n transitionId: String,\n styleValue: [String, Object, Array] as PropType<StyleValue>,\n preventMountTransition: Boolean,\n shouldRender: { type: Boolean, required: true },\n enterDuration: { type: Number, required: true },\n exitDuration: { type: Number, required: true },\n removeChild: { type: Function as PropType<() => void>, required: true },\n callbacks: Object as PropType<TransitionGroupChildCallbacks>,\n },\n setup(props, { slots }) {\n const element = ref<HTMLElement | null>(null)\n const state = useTransitionChild(props, () => element.value)\n\n return () =>\n h(\n props.as,\n {\n \"ref\": element,\n \"class\": clsx(props.className, s.TransitionGroupChild),\n \"data-transition-id\": props.transitionId,\n \"style\": props.styleValue,\n \"data-entering\": state.enter ? \"\" : undefined,\n \"data-entering-active\": state.enterActive ? \"\" : undefined,\n \"data-exiting\": state.exit ? \"\" : undefined,\n \"data-exiting-active\": state.exitActive ? \"\" : undefined,\n \"data-interrupted\": state.interrupted ? \"\" : undefined,\n },\n slots.default?.(),\n )\n },\n})\n\n/**\n * Delays mounting a child by `enterMountDelay` ms, except on the initial\n * (prevented) mount. Like usehooks-ts' useTimeout, a changed delay restarts\n * the pending timer; removing the delay while pending leaves it unmounted.\n */\nexport const useMountDelay = (getProps: () => { preventMountTransition?: boolean; enterMountDelay?: number }) => {\n const delay = () => {\n const { preventMountTransition, enterMountDelay } = getProps()\n return !preventMountTransition && enterMountDelay != null ? enterMountDelay : null\n }\n const mounted = ref(delay() == null)\n let timeout: number | undefined\n\n onMounted(() => {\n watch(\n delay,\n (mountDelay) => {\n clearTimeout(timeout)\n if (!mounted.value && mountDelay != null) {\n timeout = window.setTimeout(() => (mounted.value = true), mountDelay)\n }\n },\n { immediate: true },\n )\n })\n onBeforeUnmount(() => clearTimeout(timeout))\n return mounted\n}\n\nconst TransitionGroupChild = defineComponent({\n name: \"TransitionGroupChild\",\n inheritAttrs: false,\n props: {\n preventMountTransition: Boolean,\n enterMountDelay: Number,\n },\n setup(props, { attrs, slots }) {\n const mounted = useMountDelay(() => props)\n return () =>\n mounted.value\n ? h(TransitionGroupChildInner, { ...attrs, preventMountTransition: props.preventMountTransition } as never, slots)\n : null\n },\n})\n\n// With `disableAnimations`, React wraps the children through `Children.map`,\n// which keys each wrapper by its child's key and a `false` child's wrapper by\n// its position. A reordered child moves with its wrapper (keeping its DOM and\n// state), and a `false` child turning into an element (or back) gets a new\n// wrapper. Placeholders take a symbol per position, which no child key can\n// equal.\nconst placeholderKeys: symbol[] = []\nconst wrapperKey = (vnode: VNode, index: number): PropertyKey => {\n if (!isPlaceholder(vnode)) return vnode.key!\n return (placeholderKeys[index] ??= Symbol(`placeholder-${index}`))\n}\n\n/**\n * Wraps each keyed child in a `<span>` (or `<div>`) that carries\n * `data-entering` / `data-exiting` state while it mounts and unmounts.\n *\n * A `false` slot child (a comment vnode) mirrors React's `Children.map`\n * over `false`: with `disableAnimations` it still renders an empty wrapper.\n * Leave the slot out entirely to render nothing.\n */\nexport const TransitionGroup = defineComponent({\n name: \"TransitionGroup\",\n inheritAttrs: false,\n props: {\n /** Determines the tag used by wrapping elements */\n as: { type: String as PropType<Tag>, default: \"span\" },\n /** Identifier passed to wrapping elements as `[data-transition-id]` */\n transitionId: String,\n /** Determines the amount of time that the enter state is applied during mounting */\n enterDuration: { type: Number, default: 0 },\n /** Determines the amount of time that the exit state is applied before unmounting */\n exitDuration: { type: Number, default: 0 },\n /** Determines if children should have an enter transition applied during mounting of the TransitionGroup. */\n preventInitialTransition: { type: Boolean, default: true },\n /** Delay in MS to wait before mounting a child. Unset for no delay (default). */\n enterMountDelay: Number,\n /** Render children changes immediately, bypassing transition timings */\n disableAnimations: { type: Boolean, default: () => getDisableAnimations() },\n /** Determines how new children are added to the children array */\n insertMethod: { type: String as PropType<InsertMethod>, default: \"append\" },\n /** Called when an enter animation is staged (e.g., component mounted to the DOM) */\n onEnter: callbackProp,\n /** Called when an enter animation starts */\n onEnterActive: callbackProp,\n /** Called when an enter animation completes */\n onEnterComplete: callbackProp,\n /** Called when an exit animation is staged */\n onExit: callbackProp,\n /** Called when an exit animation starts */\n onExitActive: callbackProp,\n /** Called when an exit animation completes (e.g., component unmounted from the DOM) */\n onExitComplete: callbackProp,\n },\n setup(props, { slots, attrs }) {\n const children = useChildList(\"TransitionGroup\")\n // Read at call time, so callers can swap handlers between renders\n const callbacks: TransitionGroupChildCallbacks = {\n onEnter: (el) => props.onEnter?.(el),\n onEnterActive: (el) => props.onEnterActive?.(el),\n onEnterComplete: (el) => props.onEnterComplete?.(el),\n onExit: (el) => props.onExit?.(el),\n onExitActive: (el) => props.onExitActive?.(el),\n onExitComplete: (el) => props.onExitComplete?.(el),\n }\n\n return () => {\n const slotChildren: VNode[] = flattenChildren(slots.default?.() ?? [])\n const className = attrs.class as string | undefined\n const style = attrs.style as StyleValue | undefined\n const renderChildren = children.next(\n children.keyedChildren(slotChildren),\n props.insertMethod,\n props.preventInitialTransition,\n )\n\n if (props.disableAnimations) {\n return slotChildren.map((vnode, index) =>\n h(\n props.as,\n { \"key\": wrapperKey(vnode, index), \"class\": className, style, \"data-transition-id\": props.transitionId },\n isPlaceholder(vnode) ? undefined : [vnode],\n ),\n )\n }\n\n return renderChildren.map((child) =>\n h(\n TransitionGroupChild,\n {\n key: child.key,\n preventMountTransition: child.preventMountTransition,\n enterMountDelay: props.enterMountDelay,\n as: props.as,\n className,\n transitionId: props.transitionId,\n styleValue: style,\n shouldRender: child.shouldRender,\n enterDuration: props.enterDuration,\n exitDuration: props.exitDuration,\n removeChild: () => children.remove(child.key),\n callbacks,\n },\n { default: () => [child.vnode] },\n ),\n )\n }\n },\n})\n\nexport type TransitionGroupProps = InstanceType<typeof TransitionGroup>[\"$props\"]\n"]}
|
|
1
|
+
{"version":3,"file":"TransitionGroup.js","sourceRoot":"","sources":["../../../../src/components/Transition/TransitionGroup.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,eAAe,EACf,CAAC,EACD,eAAe,EACf,eAAe,EACf,SAAS,EACT,GAAG,EACH,KAAK,GAIN,MAAM,KAAK,CAAA;AACZ,OAAO,oBAAoB,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,CAAC,MAAM,iEAAiE,CAAA;AAO/E,MAAM,YAAY,GAAG,QAAkD,CAAA;AAEvE,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAChD,IAAI,EAAE,2BAA2B;IACjC,KAAK,EAAE;QACL,EAAE,EAAE,EAAE,IAAI,EAAE,MAAuB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACrD,SAAS,EAAE,MAAM;QACjB,YAAY,EAAE,MAAM;QACpB,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GAAG;gBACd,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;gBACpD,eAAe,EAAE,KAAK,CAAC,eAAe;gBACtC,EAAE,EAAE,KAAK,CAAC,EAAE;gBACZ,SAAS;gBACT,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,UAAU,EAAE,KAAK;gBACjB,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,aAAa,EAAE,KAAK,CAAC,aAAa;gBAClC,YAAY,EAAE,KAAK,CAAC,YAAY;gBAChC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,WAAW,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;gBAC7C,SAAS;aACV,EACD,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CACjC,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onErrorCaptured,\n onMounted,\n ref,\n watch,\n type PropType,\n type StyleValue,\n type VNode,\n} from \"vue\"\nimport getDisableAnimations from \"./getDisableAnimations.js\"\nimport { flattenChildren, isPlaceholder, useChildList } from \"./childList.js\"\nimport type { InsertMethod, TransitionGroupChildCallback, TransitionGroupChildCallbacks } from \"./shared.js\"\nimport { useTransitionChild } from \"./useTransitionChild.js\"\nimport s from \"@plexui/styles/components/Transition/TransitionGroup.module.css\"\n\n// Port of packages/ui/src/components/Transition/TransitionGroup.tsx. Same\n// wrappers, data attributes and timings, so the shared CSS animates both.\n\ntype Tag = \"div\" | \"span\"\n\nconst callbackProp = Function as PropType<TransitionGroupChildCallback>\n\nconst TransitionGroupChildInner = defineComponent({\n name: \"TransitionGroupChildInner\",\n props: {\n as: { type: String as PropType<Tag>, required: true },\n className: String,\n transitionId: String,\n styleValue: [String, Object, Array] as PropType<StyleValue>,\n preventMountTransition: Boolean,\n shouldRender: { type: Boolean, required: true },\n enterDuration: { type: Number, required: true },\n exitDuration: { type: Number, required: true },\n overlay: Boolean,\n removeChild: { type: Function as PropType<() => void>, required: true },\n callbacks: Object as PropType<TransitionGroupChildCallbacks>,\n },\n setup(props, { slots }) {\n const element = ref<HTMLElement | null>(null)\n const state = useTransitionChild(props, () => element.value)\n\n // An exiting child stays mounted with live slots, where React renders its\n // last element: state cleared along with the close must not throw here\n onErrorCaptured(() => (props.shouldRender ? undefined : false))\n\n return () =>\n h(\n props.as,\n {\n \"ref\": element,\n \"class\": clsx(props.className, s.TransitionGroupChild),\n \"data-transition-id\": props.transitionId,\n \"style\": props.styleValue,\n \"data-entering\": state.enter ? \"\" : undefined,\n \"data-entering-active\": state.enterActive ? \"\" : undefined,\n \"data-exiting\": state.exit ? \"\" : undefined,\n \"data-exiting-active\": state.exitActive ? \"\" : undefined,\n \"data-interrupted\": state.interrupted ? \"\" : undefined,\n \"inert\": props.overlay && state.exit ? \"\" : undefined,\n },\n slots.default?.(),\n )\n },\n})\n\n/**\n * Delays mounting a child by `enterMountDelay` ms, except on the initial\n * (prevented) mount. Like usehooks-ts' useTimeout, a changed delay restarts\n * the pending timer; removing the delay while pending leaves it unmounted.\n */\nexport const useMountDelay = (getProps: () => { preventMountTransition?: boolean; enterMountDelay?: number }) => {\n const delay = () => {\n const { preventMountTransition, enterMountDelay } = getProps()\n return !preventMountTransition && enterMountDelay != null ? enterMountDelay : null\n }\n const mounted = ref(delay() == null)\n let timeout: number | undefined\n\n onMounted(() => {\n watch(\n delay,\n (mountDelay) => {\n clearTimeout(timeout)\n if (!mounted.value && mountDelay != null) {\n timeout = window.setTimeout(() => (mounted.value = true), mountDelay)\n }\n },\n { immediate: true },\n )\n })\n onBeforeUnmount(() => clearTimeout(timeout))\n return mounted\n}\n\nconst TransitionGroupChild = defineComponent({\n name: \"TransitionGroupChild\",\n inheritAttrs: false,\n props: {\n preventMountTransition: Boolean,\n enterMountDelay: Number,\n },\n setup(props, { attrs, slots }) {\n const mounted = useMountDelay(() => props)\n return () =>\n mounted.value\n ? h(TransitionGroupChildInner, { ...attrs, preventMountTransition: props.preventMountTransition } as never, slots)\n : null\n },\n})\n\n// With `disableAnimations`, React wraps the children through `Children.map`,\n// which keys each wrapper by its child's key and a `false` child's wrapper by\n// its position. A reordered child moves with its wrapper (keeping its DOM and\n// state), and a `false` child turning into an element (or back) gets a new\n// wrapper. Placeholders take a symbol per position, which no child key can\n// equal.\nconst placeholderKeys: symbol[] = []\nconst wrapperKey = (vnode: VNode, index: number): PropertyKey => {\n if (!isPlaceholder(vnode)) return vnode.key!\n return (placeholderKeys[index] ??= Symbol(`placeholder-${index}`))\n}\n\n/**\n * Wraps each keyed child in a `<span>` (or `<div>`) that carries\n * `data-entering` / `data-exiting` state while it mounts and unmounts.\n *\n * A `false` slot child (a comment vnode) mirrors React's `Children.map`\n * over `false`: with `disableAnimations` it still renders an empty wrapper.\n * Leave the slot out entirely to render nothing.\n */\nexport const TransitionGroup = defineComponent({\n name: \"TransitionGroup\",\n inheritAttrs: false,\n props: {\n /** Determines the tag used by wrapping elements */\n as: { type: String as PropType<Tag>, default: \"span\" },\n /** Identifier passed to wrapping elements as `[data-transition-id]` */\n transitionId: String,\n /** Determines the amount of time that the enter state is applied during mounting */\n enterDuration: { type: Number, default: 0 },\n /** Determines the amount of time that the exit state is applied before unmounting */\n exitDuration: { type: Number, default: 0 },\n /** Determines if children should have an enter transition applied during mounting of the TransitionGroup. */\n preventInitialTransition: { type: Boolean, default: true },\n /** Delay in MS to wait before mounting a child. Unset for no delay (default). */\n enterMountDelay: Number,\n /** Render children changes immediately, bypassing transition timings */\n disableAnimations: { type: Boolean, default: () => getDisableAnimations() },\n /**\n * For overlays: an exiting child is `inert`, out of the tab order and of hit\n * testing, and with reduced motion it leaves without waiting for `exitDuration`.\n */\n overlay: Boolean,\n /** Determines how new children are added to the children array */\n insertMethod: { type: String as PropType<InsertMethod>, default: \"append\" },\n /** Called when an enter animation is staged (e.g., component mounted to the DOM) */\n onEnter: callbackProp,\n /** Called when an enter animation starts */\n onEnterActive: callbackProp,\n /** Called when an enter animation completes */\n onEnterComplete: callbackProp,\n /** Called when an exit animation is staged */\n onExit: callbackProp,\n /** Called when an exit animation starts */\n onExitActive: callbackProp,\n /** Called when an exit animation completes (e.g., component unmounted from the DOM) */\n onExitComplete: callbackProp,\n },\n setup(props, { slots, attrs }) {\n const children = useChildList(\"TransitionGroup\")\n // Read at call time, so callers can swap handlers between renders\n const callbacks: TransitionGroupChildCallbacks = {\n onEnter: (el) => props.onEnter?.(el),\n onEnterActive: (el) => props.onEnterActive?.(el),\n onEnterComplete: (el) => props.onEnterComplete?.(el),\n onExit: (el) => props.onExit?.(el),\n onExitActive: (el) => props.onExitActive?.(el),\n onExitComplete: (el) => props.onExitComplete?.(el),\n }\n\n return () => {\n const slotChildren: VNode[] = flattenChildren(slots.default?.() ?? [])\n const className = attrs.class as string | undefined\n const style = attrs.style as StyleValue | undefined\n const renderChildren = children.next(\n children.keyedChildren(slotChildren),\n props.insertMethod,\n props.preventInitialTransition,\n )\n\n if (props.disableAnimations) {\n return slotChildren.map((vnode, index) =>\n h(\n props.as,\n { \"key\": wrapperKey(vnode, index), \"class\": className, style, \"data-transition-id\": props.transitionId },\n isPlaceholder(vnode) ? undefined : [vnode],\n ),\n )\n }\n\n return renderChildren.map((child) =>\n h(\n TransitionGroupChild,\n {\n key: child.key,\n preventMountTransition: child.preventMountTransition,\n enterMountDelay: props.enterMountDelay,\n as: props.as,\n className,\n transitionId: props.transitionId,\n styleValue: style,\n shouldRender: child.shouldRender,\n enterDuration: props.enterDuration,\n exitDuration: props.exitDuration,\n overlay: props.overlay,\n removeChild: () => children.remove(child.key),\n callbacks,\n },\n { default: () => [child.vnode] },\n ),\n )\n }\n },\n})\n\nexport type TransitionGroupProps = InstanceType<typeof TransitionGroup>[\"$props\"]\n"]}
|
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
// Types and helpers shared by the Vue transition components. Mirrors
|
|
2
2
|
// packages/ui/src/components/Transition/shared.ts.
|
|
3
|
-
|
|
3
|
+
// Overlay timers, in step with the `--motion-*` tokens
|
|
4
|
+
export const overlayTiming = { enterDuration: 250, exitDuration: 150 };
|
|
5
|
+
/** A panel that crosses the screen: a sheet or a side panel */
|
|
6
|
+
export const overlayTimingLarge = { enterDuration: 300, exitDuration: 200 };
|
|
7
|
+
/**
|
|
8
|
+
* An overlay stays a dismissable layer through its exit. A press on its trigger
|
|
9
|
+
* turns it around, and the layer must not count that press as outside and
|
|
10
|
+
* close it again: pass `transition` to the TransitionGroup and
|
|
11
|
+
* `onInteractOutside` to the layer.
|
|
12
|
+
*/
|
|
13
|
+
export const createExitGuard = () => {
|
|
14
|
+
let exiting = false;
|
|
15
|
+
return {
|
|
16
|
+
transition: {
|
|
17
|
+
onExit: () => {
|
|
18
|
+
exiting = true;
|
|
19
|
+
},
|
|
20
|
+
onEnterActive: () => {
|
|
21
|
+
exiting = false;
|
|
22
|
+
},
|
|
23
|
+
onExitComplete: () => {
|
|
24
|
+
exiting = false;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
onInteractOutside: (event) => {
|
|
28
|
+
if (exiting)
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
4
33
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/Transition/shared.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mDAAmD","sourcesContent":["// Types and helpers shared by the Vue transition components. Mirrors\n// packages/ui/src/components/Transition/shared.ts.\n\nexport type TransitionDefinition = {\n opacity?: number\n /** The horizontal translation value in pixels */\n x?: number\n /** The horizontal vertical value in pixels */\n y?: number\n /** The opacity value ranging from 0 to 1. */\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n blur?: number\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type InitialTransitionDefinition = Omit<\n TransitionDefinition,\n \"duration\" | \"delay\" | \"timingFunction\"\n>\n\nexport type LayoutTransitionDefinition = {\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type CallbackType =\n | \"enter\"\n | \"enter-active\"\n | \"enter-complete\"\n | \"exit\"\n | \"exit-active\"\n | \"exit-complete\"\n\n/** The element a transition callback receives (HTML or SVG) */\nexport type TransitionElement = HTMLElement | SVGElement\n\nexport type TransitionGroupChildCallback = (element: TransitionElement) => void\n\n/** Lifecycle hooks, called with the transitioning element (same moments as React's `onEnter`...). */\nexport type TransitionGroupChildCallbacks = {\n onEnter?: TransitionGroupChildCallback\n onEnterActive?: TransitionGroupChildCallback\n onEnterComplete?: TransitionGroupChildCallback\n onExit?: TransitionGroupChildCallback\n onExitActive?: TransitionGroupChildCallback\n onExitComplete?: TransitionGroupChildCallback\n}\n\nexport type InsertMethod = \"append\" | \"prepend\"\n"]}
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../src/components/Transition/shared.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,mDAAmD;AAuDnD,uDAAuD;AACvD,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AACtE,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,EAAE,GAAG,EAAE,CAAA;AAE3E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,OAAO;QACL,UAAU,EAAE;YACV,MAAM,EAAE,GAAG,EAAE;gBACX,OAAO,GAAG,IAAI,CAAA;YAChB,CAAC;YACD,aAAa,EAAE,GAAG,EAAE;gBAClB,OAAO,GAAG,KAAK,CAAA;YACjB,CAAC;YACD,cAAc,EAAE,GAAG,EAAE;gBACnB,OAAO,GAAG,KAAK,CAAA;YACjB,CAAC;SACF;QACD,iBAAiB,EAAE,CAAC,KAAY,EAAE,EAAE;YAClC,IAAI,OAAO;gBAAE,KAAK,CAAC,cAAc,EAAE,CAAA;QACrC,CAAC;KACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["// Types and helpers shared by the Vue transition components. Mirrors\n// packages/ui/src/components/Transition/shared.ts.\n\nexport type TransitionDefinition = {\n opacity?: number\n /** The horizontal translation value in pixels */\n x?: number\n /** The horizontal vertical value in pixels */\n y?: number\n /** The opacity value ranging from 0 to 1. */\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n blur?: number\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type InitialTransitionDefinition = Omit<\n TransitionDefinition,\n \"duration\" | \"delay\" | \"timingFunction\"\n>\n\nexport type LayoutTransitionDefinition = {\n duration?: number\n delay?: number\n timingFunction?: string\n}\n\nexport type CallbackType =\n | \"enter\"\n | \"enter-active\"\n | \"enter-complete\"\n | \"exit\"\n | \"exit-active\"\n | \"exit-complete\"\n\n/** The element a transition callback receives (HTML or SVG) */\nexport type TransitionElement = HTMLElement | SVGElement\n\nexport type TransitionGroupChildCallback = (element: TransitionElement) => void\n\n/** Lifecycle hooks, called with the transitioning element (same moments as React's `onEnter`...). */\nexport type TransitionGroupChildCallbacks = {\n onEnter?: TransitionGroupChildCallback\n onEnterActive?: TransitionGroupChildCallback\n onEnterComplete?: TransitionGroupChildCallback\n onExit?: TransitionGroupChildCallback\n onExitActive?: TransitionGroupChildCallback\n onExitComplete?: TransitionGroupChildCallback\n}\n\nexport type InsertMethod = \"append\" | \"prepend\"\n\n// Overlay timers, in step with the `--motion-*` tokens\nexport const overlayTiming = { enterDuration: 250, exitDuration: 150 }\n/** A panel that crosses the screen: a sheet or a side panel */\nexport const overlayTimingLarge = { enterDuration: 300, exitDuration: 200 }\n\n/**\n * An overlay stays a dismissable layer through its exit. A press on its trigger\n * turns it around, and the layer must not count that press as outside and\n * close it again: pass `transition` to the TransitionGroup and\n * `onInteractOutside` to the layer.\n */\nexport const createExitGuard = () => {\n let exiting = false\n return {\n transition: {\n onExit: () => {\n exiting = true\n },\n onEnterActive: () => {\n exiting = false\n },\n onExitComplete: () => {\n exiting = false\n },\n },\n onInteractOutside: (event: Event) => {\n if (exiting) event.preventDefault()\n },\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { onBeforeUnmount, onMounted, reactive, watch } from "vue";
|
|
2
|
-
import { waitForAnimationFrame } from "../../lib/helpers.js";
|
|
2
|
+
import { prefersReducedMotion, waitForAnimationFrame } from "../../lib/helpers.js";
|
|
3
3
|
import { getInitialTransitionState, transitionReducer } from "./transitionReducer.js";
|
|
4
4
|
const CALLBACKS = {
|
|
5
5
|
"enter": "onEnter",
|
|
@@ -46,7 +46,7 @@ export function useTransitionChild(props, getElement) {
|
|
|
46
46
|
exitTimeout = window.setTimeout(() => {
|
|
47
47
|
trigger("exit-complete");
|
|
48
48
|
props.removeChild();
|
|
49
|
-
}, props.exitDuration);
|
|
49
|
+
}, props.overlay && prefersReducedMotion() ? 0 : props.exitDuration);
|
|
50
50
|
});
|
|
51
51
|
cancel = () => {
|
|
52
52
|
cancelFrame();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransitionChild.js","sourceRoot":"","sources":["../../../../src/components/Transition/useTransitionChild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"useTransitionChild.js","sourceRoot":"","sources":["../../../../src/components/Transition/useTransitionChild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AACjE,OAAO,EAAE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AAC,CAAA;gBAC1B,OAAO,CAAC,gBAAgB,CAAC,CAAA;YAC3B,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAA;QACzB,CAAC,CAAC,CAAA;QACF,MAAM,GAAG,GAAG,EAAE;YACZ,WAAW,EAAE,CAAA;YACb,IAAI,YAAY,KAAK,SAAS;gBAAE,YAAY,CAAC,YAAY,CAAC,CAAA;QAC5D,CAAC,CAAA;IACH,CAAC,CAAA;IAED,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAA;IACxC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;IACvD,eAAe,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAEjC,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import { onBeforeUnmount, onMounted, reactive, watch } from \"vue\"\nimport { prefersReducedMotion, waitForAnimationFrame } from \"../../lib/helpers.js\"\nimport type { CallbackType, TransitionElement, TransitionGroupChildCallbacks } from \"./shared.js\"\nimport { getInitialTransitionState, transitionReducer, type TransitionStateAction } from \"./transitionReducer.js\"\n\nexport type TransitionChildProps = {\n shouldRender: boolean\n preventMountTransition?: boolean\n enterDuration: number\n exitDuration: number\n overlay?: boolean\n removeChild: () => void\n callbacks?: TransitionGroupChildCallbacks\n}\n\nconst CALLBACKS: Record<CallbackType, keyof TransitionGroupChildCallbacks> = {\n \"enter\": \"onEnter\",\n \"enter-active\": \"onEnterActive\",\n \"enter-complete\": \"onEnterComplete\",\n \"exit\": \"onExit\",\n \"exit-active\": \"onExitActive\",\n \"exit-complete\": \"onExitComplete\",\n}\n\n/**\n * The per-child enter/exit state machine of React's TransitionGroupChild\n * (same reducer, frames and timers), shared by TransitionGroup and\n * SlotTransitionGroup. Returns the reactive state that drives the\n * `data-entering*` / `data-exiting*` / `data-interrupted` attributes.\n */\nexport function useTransitionChild(props: TransitionChildProps, getElement: () => TransitionElement | null) {\n const state = reactive(getInitialTransitionState(!!props.preventMountTransition))\n const dispatch = (action: TransitionStateAction) => {\n Object.assign(state, transitionReducer(state, action))\n }\n\n let lastCallback: CallbackType | null = null\n const trigger = (type: CallbackType) => {\n const element = getElement()\n if (!element || type === lastCallback) return\n lastCallback = type\n props.callbacks?.[CALLBACKS[type]]?.(element)\n }\n\n // Allow a child to prevent mount transition, but still experience\n // future enter transition events, when applicable.\n let preventedMountTransition = false\n let cancel: (() => void) | undefined\n\n const run = (shouldRender: boolean) => {\n cancel?.()\n cancel = undefined\n\n // Exit transition\n if (!shouldRender) {\n let exitTimeout: number | undefined\n dispatch({ type: \"exit-before\" })\n trigger(\"exit\")\n const cancelFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"exit-active\" })\n trigger(\"exit-active\")\n exitTimeout = window.setTimeout(\n () => {\n trigger(\"exit-complete\")\n props.removeChild()\n },\n props.overlay && prefersReducedMotion() ? 0 : props.exitDuration,\n )\n })\n cancel = () => {\n cancelFrame()\n if (exitTimeout !== undefined) clearTimeout(exitTimeout)\n }\n return\n }\n\n // Enter transition: check if we need to prevent this specific entering cycle\n if (props.preventMountTransition && !preventedMountTransition) {\n preventedMountTransition = true\n return\n }\n\n let enterTimeout: number | undefined\n dispatch({ type: \"enter-before\" })\n trigger(\"enter\")\n const cancelFrame = waitForAnimationFrame(() => {\n dispatch({ type: \"enter-active\" })\n trigger(\"enter-active\")\n enterTimeout = window.setTimeout(() => {\n dispatch({ type: \"done\" })\n trigger(\"enter-complete\")\n }, props.enterDuration)\n })\n cancel = () => {\n cancelFrame()\n if (enterTimeout !== undefined) clearTimeout(enterTimeout)\n }\n }\n\n onMounted(() => run(props.shouldRender))\n watch(() => props.shouldRender, run, { flush: \"post\" })\n onBeforeUnmount(() => cancel?.())\n\n return state\n}\n"]}
|
package/dist/es/lib/dateUtils.js
CHANGED
|
@@ -28,6 +28,11 @@ export const isSameDay = (targetDate, compareDate) => targetDate.hasSame(compare
|
|
|
28
28
|
* Check if a date is today
|
|
29
29
|
*/
|
|
30
30
|
export const isToday = (dateTime) => isSameDay(dateTime, DateTime.local());
|
|
31
|
+
/**
|
|
32
|
+
* Where a date sits in a week row that starts on `weekStartsOn`, 0 (Sunday) to
|
|
33
|
+
* 6 (Saturday). Luxon's weekday runs from 1 (Monday) to 7 (Sunday).
|
|
34
|
+
*/
|
|
35
|
+
export const weekPosition = (date, weekStartsOn) => (date.weekday - weekStartsOn + 7) % 7;
|
|
31
36
|
/**
|
|
32
37
|
* Split an array of days into weeks (arrays of 7 days each)
|
|
33
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dateUtils.js","sourceRoot":"","sources":["../../../src/lib/dateUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAc,EAAc,EAAE;IAC3D,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC1C,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,IAAI,EAAE,CAAA,CAAC,mCAAmC;IACtF,MAAM,IAAI,GAAG,EAAE,CAAA;IAEf,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,WAAW,EAAE,GAAG,EAAE,EAAE,CAAC;QAC3C,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC/D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACpB,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,UAAoB,EAAE,WAAqB,EAAW,EAAE,CAC/E,UA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AAE,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY;QACpD,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU;KACjD,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { DateTime } from \"luxon\"\n\n/**\n * Get all days in a given month as DateTime objects\n */\nexport const getDaysOfMonth = (date: DateTime): DateTime[] => {\n const startOfMonth = date.startOf(\"month\")\n const daysInMonth = startOfMonth.daysInMonth ?? 31 // fallback to 31 days if undefined\n const days = []\n\n for (let day = 0; day < daysInMonth; day++) {\n const dayDate = startOfMonth.plus({ days: day }).startOf(\"day\")\n days.push(dayDate)\n }\n\n return days\n}\n\n/**\n * Check if the first date is before the second date\n */\nexport const isBefore = (targetDate: DateTime, compareDate: DateTime): boolean =>\n targetDate.toMillis() < compareDate?.toMillis()\n\n/**\n * Check if the first date is after the second date\n */\nexport const isAfter = (targetDate: DateTime, compareDate: DateTime): boolean =>\n targetDate.toMillis() > compareDate?.toMillis()\n\n/**\n * Check if two dates are the same day (ignoring time)\n */\nexport const isSameDay = (targetDate: DateTime, compareDate: DateTime): boolean =>\n targetDate.hasSame(compareDate, \"day\")\n\n/**\n * Check if a date is today\n */\nexport const isToday = (dateTime: DateTime): boolean => isSameDay(dateTime, DateTime.local())\n\n/**\n * Split an array of days into weeks (arrays of 7 days each)\n */\nexport const chunkIntoWeeks = (daysInMonth: DateTime[], size = 7): DateTime[][] => {\n const weeks = []\n for (let i = 0; i < daysInMonth.length; i += size) {\n weeks.push(daysInMonth.slice(i, i + size))\n }\n return weeks\n}\n\n/**\n * Get the start and end date of the month the provided date is in, with optional min and max limits.\n */\nexport const getMonthStartAndEnd = (\n date: DateTime,\n { min, max }: { min?: DateTime; max?: DateTime } = {},\n): [DateTime, DateTime] => {\n const startOfMonth = date.startOf(\"month\")\n const endOfMonth = date.endOf(\"month\")\n\n return [\n min ? DateTime.max(min, startOfMonth) : startOfMonth,\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month as DateTime objects\n */\nexport const getDaysOfMonth = (date: DateTime): DateTime[] => {\n const startOfMonth = date.startOf(\"month\")\n const daysInMonth = startOfMonth.daysInMonth ?? 31 // fallback to 31 days if undefined\n const days = []\n\n for (let day = 0; day < daysInMonth; day++) {\n const dayDate = startOfMonth.plus({ days: day }).startOf(\"day\")\n days.push(dayDate)\n }\n\n return days\n}\n\n/**\n * Check if the first date is before the second date\n */\nexport const isBefore = (targetDate: DateTime, compareDate: DateTime): boolean =>\n targetDate.toMillis() < compareDate?.toMillis()\n\n/**\n * Check if the first date is after the second date\n */\nexport const isAfter = (targetDate: DateTime, compareDate: DateTime): boolean =>\n targetDate.toMillis() > compareDate?.toMillis()\n\n/**\n * Check if two dates are the same day (ignoring time)\n */\nexport const isSameDay = (targetDate: DateTime, compareDate: DateTime): boolean =>\n targetDate.hasSame(compareDate, \"day\")\n\n/**\n * Check if a date is today\n */\nexport const isToday = (dateTime: DateTime): boolean => isSameDay(dateTime, DateTime.local())\n\n/**\n * Where a date sits in a week row that starts on `weekStartsOn`, 0 (Sunday) to\n * 6 (Saturday). Luxon's weekday runs from 1 (Monday) to 7 (Sunday).\n */\nexport const weekPosition = (date: DateTime, weekStartsOn: number): number =>\n (date.weekday - weekStartsOn + 7) % 7\n\n/**\n * Split an array of days into weeks (arrays of 7 days each)\n */\nexport const chunkIntoWeeks = (daysInMonth: DateTime[], size = 7): DateTime[][] => {\n const weeks = []\n for (let i = 0; i < daysInMonth.length; i += size) {\n weeks.push(daysInMonth.slice(i, i + size))\n }\n return weeks\n}\n\n/**\n * Get the start and end date of the month the provided date is in, with optional min and max limits.\n */\nexport const getMonthStartAndEnd = (\n date: DateTime,\n { min, max }: { min?: DateTime; max?: DateTime } = {},\n): [DateTime, DateTime] => {\n const startOfMonth = date.startOf(\"month\")\n const endOfMonth = date.endOf(\"month\")\n\n return [\n min ? DateTime.max(min, startOfMonth) : startOfMonth,\n max ? DateTime.min(max, endOfMonth) : endOfMonth,\n ]\n}\n"]}
|
package/dist/es/lib/helpers.js
CHANGED
|
@@ -95,9 +95,39 @@ export const toFilterProperty = ({ blur } = {}) => {
|
|
|
95
95
|
const filters = [blur == null ? null : `blur(${blur}px)`].filter(Boolean);
|
|
96
96
|
return filters.length ? filters.join(" ") : "none";
|
|
97
97
|
};
|
|
98
|
+
/** The `data-*` attributes among a component's props, to pass on to its element. */
|
|
99
|
+
export const dataAttributes = (props) => Object.fromEntries(Object.entries(props).filter(([key]) => key.startsWith("data-")));
|
|
98
100
|
export const preventDefaultHandler = (evt) => {
|
|
99
101
|
evt.preventDefault();
|
|
100
102
|
};
|
|
103
|
+
/**
|
|
104
|
+
* For an overlay's close auto focus: focus that moved on to something else
|
|
105
|
+
* while the overlay left stays there instead of going back to the trigger.
|
|
106
|
+
*/
|
|
107
|
+
export const keepMovedFocus = (evt) => {
|
|
108
|
+
const active = document.activeElement;
|
|
109
|
+
const movedOut = !!active && active !== document.body && !evt.target?.contains(active);
|
|
110
|
+
if (movedOut)
|
|
111
|
+
evt.preventDefault();
|
|
112
|
+
};
|
|
113
|
+
/*
|
|
114
|
+
* For a row that acts on pointerup, where a press can start on the trigger and
|
|
115
|
+
* end on the row. A touch acts on its click: the click comes last, and a row
|
|
116
|
+
* that closed its list at pointerup would send it to what lies behind the list.
|
|
117
|
+
*/
|
|
118
|
+
let touchPressed = false;
|
|
119
|
+
export const pressHandlers = (action) => ({
|
|
120
|
+
onPointerup: (evt) => {
|
|
121
|
+
touchPressed = evt.pointerType === "touch" || evt.pointerType === "pen";
|
|
122
|
+
if (!touchPressed)
|
|
123
|
+
action();
|
|
124
|
+
},
|
|
125
|
+
onClick: () => {
|
|
126
|
+
if (touchPressed)
|
|
127
|
+
action();
|
|
128
|
+
touchPressed = false;
|
|
129
|
+
},
|
|
130
|
+
});
|
|
101
131
|
/*
|
|
102
132
|
* Intentionally simple selector string. Purposeful exclusions: (for now)
|
|
103
133
|
* - select, because our selects are better recognized as button
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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,EAAiB,EAAE,CACjD,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAEnD;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,KAAU,EACV,GAAM,EACN,SAAoC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAQ;IAIrD,MAAM,MAAM,GAA+C,EAAE,CAAA;IAC7D,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAA,CAAC,4CAA4C;IAExF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAA;QAErC,wBAAwB;QACxB,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QACpC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACjC,SAAQ;QACV,CAAC;QAED,mBAAmB;QACnB,MAAM,KAAK,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAsC,CAAA;QACjF,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;QAClC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["// Port of packages/ui/src/lib/helpers.ts with Vue-facing types (events are\n// DOM events, style objects are plain records). Keep the logic identical: the\n// parity tests compare the DOM these produce with the React output.\n\nimport { canUseDOM, hasDocument, hasWindow } from \"./environment.js\"\nimport type { Pretty } from \"./utilityTypes.js\"\n\nexport const prefersReducedMotion = () => {\n if (!hasWindow || typeof window.matchMedia !== \"function\") {\n return false\n }\n\n return window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n}\n\nexport const handlePressableMouseEnter = (evt: Event) => {\n const target = evt.currentTarget\n\n // Safely coerce type to HTMLElement so TS is peaceful with `evt.target`\n if (!(target instanceof HTMLElement)) {\n return\n }\n\n const elementWidth = target.offsetWidth\n\n let scale = 0.985\n\n if (elementWidth <= 80) {\n scale = 0.96\n } else if (elementWidth <= 150) {\n scale = 0.97\n } else if (elementWidth <= 220) {\n scale = 0.98\n } else if (elementWidth > 600) {\n scale = 0.995\n }\n\n target.style.setProperty(\"--scale\", scale.toString())\n}\n\ninterface CancelAnimationFrame {\n (): void\n}\n\nexport const waitForAnimationFrame = (\n cb: () => void,\n options?: { frames: number },\n): CancelAnimationFrame => {\n const runAfterTick = () => {\n const id = setTimeout(cb)\n return () => {\n clearTimeout(id)\n }\n }\n\n if (!canUseDOM || typeof window.requestAnimationFrame !== \"function\") {\n return runAfterTick()\n }\n\n const visibilityHidden = hasDocument && document.visibilityState === \"hidden\"\n if (visibilityHidden) {\n return runAfterTick()\n }\n\n let frames = options?.frames ?? 2\n let animationFrame = window.requestAnimationFrame(function recurse() {\n frames -= 1\n if (frames === 0) {\n cb()\n } else {\n animationFrame = window.requestAnimationFrame(recurse)\n }\n })\n\n return () => {\n if (typeof window.cancelAnimationFrame === \"function\") {\n window.cancelAnimationFrame(animationFrame)\n }\n }\n}\n\nexport const toCssVariables = (\n variables: Record<string, string | number | undefined>,\n): Record<string, string> => {\n const formattedVariables = Object.keys(variables).reduce(\n (acc, variable) => {\n // Ensure value is truthy\n const value = variables[variable]\n // Accept 0 as a valid value\n if (value || value === 0) {\n // Add the prefix if it wasn't already provided\n const prefix = variable.startsWith(\"--\") ? \"\" : \"--\"\n const formattedValue = typeof value === \"number\" ? `${value}px` : value\n\n acc[`${prefix}${variable}`] = formattedValue\n }\n\n return acc\n },\n {} as Record<string, string>,\n )\n\n // Safe casting because we know we've formatted an object of CSS Variable strings\n return formattedVariables\n}\n\nexport const toAngle = (value: number | string): string =>\n typeof value === \"number\" ? `${value}deg` : value\n\nexport const toOpacityProperty = (opacity: number): string => String(opacity)\n\nexport const toMsDurationProperty = (duration: number): string => `${duration}ms`\n\nexport const toTransformProperty = ({\n x,\n y,\n scale,\n rotate,\n skewX,\n skewY,\n}: {\n x?: number\n y?: number\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n} = {}): string => {\n const transforms = [\n x == null ? null : `translateX(${x}px)`,\n y == null ? null : `translateY(${y}px)`,\n scale == null ? null : `scale(${scale})`,\n rotate == null ? null : `rotate(${toAngle(rotate)})`,\n skewX == null ? null : `skewX(${toAngle(skewX)})`,\n skewY == null ? null : `skewY(${toAngle(skewY)})`,\n ].filter(Boolean)\n\n return transforms.length ? transforms.join(\" \") : \"none\"\n}\n\nexport const toFilterProperty = ({ blur }: { blur?: number | undefined } = {}) => {\n // Maybe add more support in the future\n const filters = [blur == null ? null : `blur(${blur}px)`].filter(Boolean)\n\n return filters.length ? filters.join(\" \") : \"none\"\n}\n\nexport const preventDefaultHandler = (evt: Event) => {\n evt.preventDefault()\n}\n\n/*\n * Intentionally simple selector string. Purposeful exclusions: (for now)\n * - select, because our selects are better recognized as button\n * - unused selectors like iframe, object, .etc.\n * - states like [inert]\n */\nexport const focusableElements = (element: HTMLElement) =>\n element.querySelectorAll<HTMLElement>(\n 'a[href], input:not([disabled]):not([type=\"hidden\"]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex^=\"-\"]), [contenteditable]',\n )\n\nexport const sleep = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * Group an array of objects by a property, preserving the *first-seen* order\n * of each group.\n *\n * @example\n * groupByOrdered(people, \"team\")\n * // => [ { team: \"infra\", items:[...] }, { team:\"design\", items:[...] }, ... ]\n */\nexport function groupByProperty<T extends object, K extends keyof T, F = T[K]>(\n items: T[],\n key: K,\n format: (raw: T[K], item: T) => F = (raw) => raw as F,\n // Explicit: the inferred `Pretty<...>` is expanded in the published\n // declaration into a form consumers' type checks reject (TS2536)\n): ({ [P in K]: F } & { items: T[] })[] {\n const groups: Pretty<{ [P in K]: F } & { items: T[] }>[] = []\n const indexMap = new Map<unknown, number>() // maps group value -> index in groups array\n\n for (const item of items) {\n const value = format(item[key], item)\n\n // Add to existing group\n const existing = indexMap.get(value)\n if (existing !== undefined) {\n groups[existing].items.push(item)\n continue\n }\n\n // Create new group\n const group = { [key]: value, items: [item] } as { [P in K]: F } & { items: T[] }\n indexMap.set(value, groups.length)\n groups.push(group)\n }\n\n return groups\n}\n"]}
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/lib/helpers.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,8EAA8E;AAC9E,oEAAoE;AAEpE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,EAAE;IACvC,IAAI,CAAC,SAAS,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QAC1D,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,MAAM,CAAC,UAAU,CAAC,kCAAkC,CAAC,CAAC,OAAO,CAAA;AACtE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,GAAU,EAAE,EAAE;IACtD,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,CAAA;IAEhC,wEAAwE;IACxE,IAAI,CAAC,CAAC,MAAM,YAAY,WAAW,CAAC,EAAE,CAAC;QACrC,OAAM;IACR,CAAC;IAED,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAA;IAEvC,IAAI,KAAK,GAAG,KAAK,CAAA;IAEjB,IAAI,YAAY,IAAI,EAAE,EAAE,CAAC;QACvB,KAAK,GAAG,IAAI,CAAA;IACd,CAAC;SAAM,IAAI,YAAY,IAAI,GAAG,EA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Vue-facing types (events are\n// DOM events, style objects are plain records). Keep the logic identical: the\n// parity tests compare the DOM these produce with the React output.\n\nimport { canUseDOM, hasDocument, hasWindow } from \"./environment.js\"\nimport type { Pretty } from \"./utilityTypes.js\"\n\nexport const prefersReducedMotion = () => {\n if (!hasWindow || typeof window.matchMedia !== \"function\") {\n return false\n }\n\n return window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n}\n\nexport const handlePressableMouseEnter = (evt: Event) => {\n const target = evt.currentTarget\n\n // Safely coerce type to HTMLElement so TS is peaceful with `evt.target`\n if (!(target instanceof HTMLElement)) {\n return\n }\n\n const elementWidth = target.offsetWidth\n\n let scale = 0.985\n\n if (elementWidth <= 80) {\n scale = 0.96\n } else if (elementWidth <= 150) {\n scale = 0.97\n } else if (elementWidth <= 220) {\n scale = 0.98\n } else if (elementWidth > 600) {\n scale = 0.995\n }\n\n target.style.setProperty(\"--scale\", scale.toString())\n}\n\ninterface CancelAnimationFrame {\n (): void\n}\n\nexport const waitForAnimationFrame = (\n cb: () => void,\n options?: { frames: number },\n): CancelAnimationFrame => {\n const runAfterTick = () => {\n const id = setTimeout(cb)\n return () => {\n clearTimeout(id)\n }\n }\n\n if (!canUseDOM || typeof window.requestAnimationFrame !== \"function\") {\n return runAfterTick()\n }\n\n const visibilityHidden = hasDocument && document.visibilityState === \"hidden\"\n if (visibilityHidden) {\n return runAfterTick()\n }\n\n let frames = options?.frames ?? 2\n let animationFrame = window.requestAnimationFrame(function recurse() {\n frames -= 1\n if (frames === 0) {\n cb()\n } else {\n animationFrame = window.requestAnimationFrame(recurse)\n }\n })\n\n return () => {\n if (typeof window.cancelAnimationFrame === \"function\") {\n window.cancelAnimationFrame(animationFrame)\n }\n }\n}\n\nexport const toCssVariables = (\n variables: Record<string, string | number | undefined>,\n): Record<string, string> => {\n const formattedVariables = Object.keys(variables).reduce(\n (acc, variable) => {\n // Ensure value is truthy\n const value = variables[variable]\n // Accept 0 as a valid value\n if (value || value === 0) {\n // Add the prefix if it wasn't already provided\n const prefix = variable.startsWith(\"--\") ? \"\" : \"--\"\n const formattedValue = typeof value === \"number\" ? `${value}px` : value\n\n acc[`${prefix}${variable}`] = formattedValue\n }\n\n return acc\n },\n {} as Record<string, string>,\n )\n\n // Safe casting because we know we've formatted an object of CSS Variable strings\n return formattedVariables\n}\n\nexport const toAngle = (value: number | string): string =>\n typeof value === \"number\" ? `${value}deg` : value\n\nexport const toOpacityProperty = (opacity: number): string => String(opacity)\n\nexport const toMsDurationProperty = (duration: number): string => `${duration}ms`\n\nexport const toTransformProperty = ({\n x,\n y,\n scale,\n rotate,\n skewX,\n skewY,\n}: {\n x?: number\n y?: number\n scale?: number\n rotate?: number | string\n skewX?: number | string\n skewY?: number | string\n} = {}): string => {\n const transforms = [\n x == null ? null : `translateX(${x}px)`,\n y == null ? null : `translateY(${y}px)`,\n scale == null ? null : `scale(${scale})`,\n rotate == null ? null : `rotate(${toAngle(rotate)})`,\n skewX == null ? null : `skewX(${toAngle(skewX)})`,\n skewY == null ? null : `skewY(${toAngle(skewY)})`,\n ].filter(Boolean)\n\n return transforms.length ? transforms.join(\" \") : \"none\"\n}\n\nexport const toFilterProperty = ({ blur }: { blur?: number | undefined } = {}) => {\n // Maybe add more support in the future\n const filters = [blur == null ? null : `blur(${blur}px)`].filter(Boolean)\n\n return filters.length ? filters.join(\" \") : \"none\"\n}\n\n/** The `data-*` attributes among a component's props, to pass on to its element. */\nexport const dataAttributes = (props: Record<string, unknown>) =>\n Object.fromEntries(Object.entries(props).filter(([key]) => key.startsWith(\"data-\")))\n\nexport const preventDefaultHandler = (evt: Event) => {\n evt.preventDefault()\n}\n\n/**\n * For an overlay's close auto focus: focus that moved on to something else\n * while the overlay left stays there instead of going back to the trigger.\n */\nexport const keepMovedFocus = (evt: Event) => {\n const active = document.activeElement\n const movedOut = !!active && active !== document.body && !(evt.target as Node | null)?.contains(active)\n if (movedOut) evt.preventDefault()\n}\n\n/*\n * For a row that acts on pointerup, where a press can start on the trigger and\n * end on the row. A touch acts on its click: the click comes last, and a row\n * that closed its list at pointerup would send it to what lies behind the list.\n */\nlet touchPressed = false\n\nexport const pressHandlers = (action: () => void) => ({\n onPointerup: (evt: PointerEvent) => {\n touchPressed = evt.pointerType === \"touch\" || evt.pointerType === \"pen\"\n if (!touchPressed) action()\n },\n onClick: () => {\n if (touchPressed) action()\n touchPressed = false\n },\n})\n\n/*\n * Intentionally simple selector string. Purposeful exclusions: (for now)\n * - select, because our selects are better recognized as button\n * - unused selectors like iframe, object, .etc.\n * - states like [inert]\n */\nexport const focusableElements = (element: HTMLElement) =>\n element.querySelectorAll<HTMLElement>(\n 'a[href], input:not([disabled]):not([type=\"hidden\"]), textarea:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex^=\"-\"]), [contenteditable]',\n )\n\nexport const sleep = (ms: number): Promise<void> =>\n new Promise((resolve) => setTimeout(resolve, ms))\n\n/**\n * Group an array of objects by a property, preserving the *first-seen* order\n * of each group.\n *\n * @example\n * groupByOrdered(people, \"team\")\n * // => [ { team: \"infra\", items:[...] }, { team:\"design\", items:[...] }, ... ]\n */\nexport function groupByProperty<T extends object, K extends keyof T, F = T[K]>(\n items: T[],\n key: K,\n format: (raw: T[K], item: T) => F = (raw) => raw as F,\n // Explicit: the inferred `Pretty<...>` is expanded in the published\n // declaration into a form consumers' type checks reject (TS2536)\n): ({ [P in K]: F } & { items: T[] })[] {\n const groups: Pretty<{ [P in K]: F } & { items: T[] }>[] = []\n const indexMap = new Map<unknown, number>() // maps group value -> index in groups array\n\n for (const item of items) {\n const value = format(item[key], item)\n\n // Add to existing group\n const existing = indexMap.get(value)\n if (existing !== undefined) {\n groups[existing].items.push(item)\n continue\n }\n\n // Create new group\n const group = { [key]: value, items: [item] } as { [P in K]: F } & { items: T[] }\n indexMap.set(value, groups.length)\n groups.push(group)\n }\n\n return groups\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import { type PropType } from "vue";
|
|
|
3
3
|
import type { ControlSize } from "@plexui/styles/types";
|
|
4
4
|
import { type PopoverAlign, type PopoverSide } from "../Popover/index.js";
|
|
5
5
|
import type { DropdownIconType } from "../SelectControl/index.js";
|
|
6
|
-
import { type DateRange, type DateRangeShortcut } from "./types.js";
|
|
6
|
+
import { type DateRange, type DateRangeShortcut, type WeekStart } from "./types.js";
|
|
7
7
|
declare const DateRangePickerComponent: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
8
8
|
/** The selected date range value (`v-model:value`). */
|
|
9
9
|
value: {
|
|
@@ -16,6 +16,11 @@ declare const DateRangePickerComponent: import("vue").DefineComponent<import("vu
|
|
|
16
16
|
max: PropType<DateTime>;
|
|
17
17
|
/** Maximum length of the selectable range in days (inclusive). */
|
|
18
18
|
maxRangeDays: NumberConstructor;
|
|
19
|
+
/** The day each week starts on, from 0 (Sunday) to 6 (Saturday). @default 0 */
|
|
20
|
+
weekStartsOn: {
|
|
21
|
+
type: PropType<WeekStart>;
|
|
22
|
+
default: number;
|
|
23
|
+
};
|
|
19
24
|
/** Date range shortcuts for quick selection, shown to the left of the calendar. */
|
|
20
25
|
shortcuts: PropType<DateRangeShortcut[]>;
|
|
21
26
|
/** The preferred side of the trigger to render against when open. @default "bottom" */
|
|
@@ -103,6 +108,11 @@ declare const DateRangePickerComponent: import("vue").DefineComponent<import("vu
|
|
|
103
108
|
max: PropType<DateTime>;
|
|
104
109
|
/** Maximum length of the selectable range in days (inclusive). */
|
|
105
110
|
maxRangeDays: NumberConstructor;
|
|
111
|
+
/** The day each week starts on, from 0 (Sunday) to 6 (Saturday). @default 0 */
|
|
112
|
+
weekStartsOn: {
|
|
113
|
+
type: PropType<WeekStart>;
|
|
114
|
+
default: number;
|
|
115
|
+
};
|
|
106
116
|
/** Date range shortcuts for quick selection, shown to the left of the calendar. */
|
|
107
117
|
shortcuts: PropType<DateRangeShortcut[]>;
|
|
108
118
|
/** The preferred side of the trigger to render against when open. @default "bottom" */
|
|
@@ -190,6 +200,7 @@ declare const DateRangePickerComponent: import("vue").DefineComponent<import("vu
|
|
|
190
200
|
clearable: boolean;
|
|
191
201
|
triggerDateFormat: string;
|
|
192
202
|
triggerShowIcon: boolean;
|
|
203
|
+
weekStartsOn: WeekStart;
|
|
193
204
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
194
205
|
export type DateRangePickerProps = InstanceType<typeof DateRangePickerComponent>["$props"];
|
|
195
206
|
/**
|
|
@@ -209,6 +220,11 @@ export declare const DateRangePicker: import("vue").DefineComponent<import("vue"
|
|
|
209
220
|
max: PropType<DateTime>;
|
|
210
221
|
/** Maximum length of the selectable range in days (inclusive). */
|
|
211
222
|
maxRangeDays: NumberConstructor;
|
|
223
|
+
/** The day each week starts on, from 0 (Sunday) to 6 (Saturday). @default 0 */
|
|
224
|
+
weekStartsOn: {
|
|
225
|
+
type: PropType<WeekStart>;
|
|
226
|
+
default: number;
|
|
227
|
+
};
|
|
212
228
|
/** Date range shortcuts for quick selection, shown to the left of the calendar. */
|
|
213
229
|
shortcuts: PropType<DateRangeShortcut[]>;
|
|
214
230
|
/** The preferred side of the trigger to render against when open. @default "bottom" */
|
|
@@ -296,6 +312,11 @@ export declare const DateRangePicker: import("vue").DefineComponent<import("vue"
|
|
|
296
312
|
max: PropType<DateTime>;
|
|
297
313
|
/** Maximum length of the selectable range in days (inclusive). */
|
|
298
314
|
maxRangeDays: NumberConstructor;
|
|
315
|
+
/** The day each week starts on, from 0 (Sunday) to 6 (Saturday). @default 0 */
|
|
316
|
+
weekStartsOn: {
|
|
317
|
+
type: PropType<WeekStart>;
|
|
318
|
+
default: number;
|
|
319
|
+
};
|
|
299
320
|
/** Date range shortcuts for quick selection, shown to the left of the calendar. */
|
|
300
321
|
shortcuts: PropType<DateRangeShortcut[]>;
|
|
301
322
|
/** The preferred side of the trigger to render against when open. @default "bottom" */
|
|
@@ -383,5 +404,6 @@ export declare const DateRangePicker: import("vue").DefineComponent<import("vue"
|
|
|
383
404
|
clearable: boolean;
|
|
384
405
|
triggerDateFormat: string;
|
|
385
406
|
triggerShowIcon: boolean;
|
|
407
|
+
weekStartsOn: WeekStart;
|
|
386
408
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
387
409
|
export {};
|
|
@@ -2,12 +2,13 @@ import type { DateTime } from "luxon";
|
|
|
2
2
|
import { type InjectionKey } from "vue";
|
|
3
3
|
import type { ControlSize } from "@plexui/styles/types";
|
|
4
4
|
import type { DropdownIconType } from "../SelectControl/index.js";
|
|
5
|
-
import type { DateRange, DateRangeShortcut } from "./types.js";
|
|
5
|
+
import type { DateRange, DateRangeShortcut, WeekStart } from "./types.js";
|
|
6
6
|
export type DateRangeContextValue = {
|
|
7
7
|
readonly value: DateRange | null;
|
|
8
8
|
readonly min?: DateTime;
|
|
9
9
|
readonly max?: DateTime;
|
|
10
10
|
readonly maxRangeDays?: number;
|
|
11
|
+
readonly weekStartsOn: WeekStart;
|
|
11
12
|
readonly triggerStepperUnit?: "month";
|
|
12
13
|
readonly triggerClassName?: string;
|
|
13
14
|
readonly triggerShowIcon?: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { DateRangePicker, type DateRangePickerProps } from "./DateRangePicker.js";
|
|
2
|
-
export { type DateRange, type DateRangeShortcut } from "./types.js";
|
|
2
|
+
export { type DateRange, type DateRangeShortcut, type WeekStart } from "./types.js";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type DateTime } from "luxon";
|
|
2
2
|
export type DateRange = [DateTime, DateTime];
|
|
3
|
+
/** The day a week starts on: 0 is Sunday, 6 is Saturday. */
|
|
4
|
+
export type WeekStart = 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
3
5
|
export type DateRangeShortcut = {
|
|
4
6
|
label: string;
|
|
5
7
|
getDateRange: () => DateRange;
|