@plexui/vue 0.8.0 → 0.9.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.
- package/dist/es/components/Badge/Badge.js +1 -1
- package/dist/es/components/Badge/Badge.js.map +1 -1
- package/dist/es/components/Button/Button.js +13 -5
- package/dist/es/components/Button/Button.js.map +1 -1
- package/dist/es/components/Button/ButtonLink.js +7 -1
- package/dist/es/components/Button/ButtonLink.js.map +1 -1
- package/dist/es/components/Button/NavigationButton.js +27 -0
- package/dist/es/components/Button/NavigationButton.js.map +1 -0
- package/dist/es/components/Button/NavigationGlyph.js +27 -0
- package/dist/es/components/Button/NavigationGlyph.js.map +1 -0
- package/dist/es/components/Button/index.js +1 -0
- package/dist/es/components/Button/index.js.map +1 -1
- package/dist/es/components/Checkbox/Checkbox.js +14 -4
- package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/es/components/DateInput/DateInput.js +7 -3
- package/dist/es/components/DateInput/DateInput.js.map +1 -1
- package/dist/es/components/DatePicker/Calendar.js +130 -86
- package/dist/es/components/DatePicker/Calendar.js.map +1 -1
- package/dist/es/components/DatePicker/CalendarNavigationIcon.js +31 -0
- package/dist/es/components/DatePicker/CalendarNavigationIcon.js.map +1 -0
- package/dist/es/components/DatePicker/DatePicker.js +16 -4
- package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/es/components/DatePicker/context.js.map +1 -1
- package/dist/es/components/DatePicker/useCalendarGutter.js +14 -0
- package/dist/es/components/DatePicker/useCalendarGutter.js.map +1 -0
- package/dist/es/components/DateRangePicker/Calendar.js +92 -71
- package/dist/es/components/DateRangePicker/Calendar.js.map +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js +13 -4
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/DateRangePicker/Trigger.js +1 -0
- package/dist/es/components/DateRangePicker/Trigger.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +125 -52
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Dialog/index.js.map +1 -1
- package/dist/es/components/Dialog/sheetDrag.js +77 -24
- package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
- package/dist/es/components/Field/Field.js +58 -5
- package/dist/es/components/Field/Field.js.map +1 -1
- package/dist/es/components/FieldGroup/FieldGroup.js +3 -1
- package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
- package/dist/es/components/FileUpload/FileUpload.js +50 -11
- package/dist/es/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +24 -13
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
- package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.js +9 -3
- package/dist/es/components/FloatingLabelSelect/FloatingLabelSelect.js.map +1 -1
- package/dist/es/components/Icon/index.js +1 -0
- package/dist/es/components/Icon/index.js.map +1 -1
- package/dist/es/components/Icon/svg/Disclosure.js +10 -0
- package/dist/es/components/Icon/svg/Disclosure.js.map +1 -0
- package/dist/es/components/Indicator/LoadingIndicator.js +2 -2
- package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
- package/dist/es/components/Input/Input.js +15 -5
- package/dist/es/components/Input/Input.js.map +1 -1
- package/dist/es/components/InputGroup/InputGroup.js +3 -1
- package/dist/es/components/InputGroup/InputGroup.js.map +1 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js +126 -151
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +217 -35
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/Menu/internal.js +2 -1
- package/dist/es/components/Menu/internal.js.map +1 -1
- package/dist/es/components/OTPInput/OTPInput.js +7 -4
- package/dist/es/components/OTPInput/OTPInput.js.map +1 -1
- package/dist/es/components/Page/Page.js +93 -14
- package/dist/es/components/Page/Page.js.map +1 -1
- package/dist/es/components/Page/index.js +1 -1
- package/dist/es/components/Page/index.js.map +1 -1
- package/dist/es/components/Popover/Popover.js +16 -6
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/Popover/deferredPointerDownOutside.js +6 -0
- package/dist/es/components/Popover/deferredPointerDownOutside.js.map +1 -1
- package/dist/es/components/RadioGroup/RadioGroup.js +31 -13
- package/dist/es/components/RadioGroup/RadioGroup.js.map +1 -1
- package/dist/es/components/Select/Select.js +75 -25
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +58 -25
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/SelectControl/index.js +1 -1
- package/dist/es/components/SelectControl/index.js.map +1 -1
- package/dist/es/components/ShimmerText/ShimmerText.js +16 -3
- package/dist/es/components/ShimmerText/ShimmerText.js.map +1 -1
- package/dist/es/components/Slider/Slider.js +56 -16
- package/dist/es/components/Slider/Slider.js.map +1 -1
- package/dist/es/components/Sortable/Sortable.js +20 -13
- package/dist/es/components/Sortable/Sortable.js.map +1 -1
- package/dist/es/components/Switch/Switch.js +6 -3
- package/dist/es/components/Switch/Switch.js.map +1 -1
- package/dist/es/components/Tabs/Tabs.js +12 -11
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/TagInput/TagInput.js +46 -6
- package/dist/es/components/TagInput/TagInput.js.map +1 -1
- package/dist/es/components/Textarea/Textarea.js +13 -2
- package/dist/es/components/Textarea/Textarea.js.map +1 -1
- package/dist/es/components/Toast/ToastRenderer.js +144 -0
- package/dist/es/components/Toast/ToastRenderer.js.map +1 -0
- package/dist/es/components/Toast/Toaster.js +23 -1
- package/dist/es/components/Toast/Toaster.js.map +1 -1
- package/dist/es/components/Toast/toastLifecycle.js +283 -0
- package/dist/es/components/Toast/toastLifecycle.js.map +1 -0
- package/dist/es/components/Toolbar/Toolbar.js +107 -0
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -0
- package/dist/es/components/Toolbar/index.js +2 -0
- package/dist/es/components/Toolbar/index.js.map +1 -0
- package/dist/es/components/Tooltip/CopyTooltip.js +39 -13
- package/dist/es/components/Tooltip/CopyTooltip.js.map +1 -1
- package/dist/es/components/Tooltip/Tooltip.js +35 -14
- package/dist/es/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/es/composables/useFloatingBoundary.js +48 -0
- package/dist/es/composables/useFloatingBoundary.js.map +1 -0
- package/dist/es/composables/usePhoneSubmenu.js +19 -0
- package/dist/es/composables/usePhoneSubmenu.js.map +1 -0
- package/dist/es/lib/copyToClipboard.js +16 -7
- package/dist/es/lib/copyToClipboard.js.map +1 -1
- package/dist/es/lib/floatingBoundary.js +90 -0
- package/dist/es/lib/floatingBoundary.js.map +1 -0
- package/dist/es/lib/focusRestore.js +56 -0
- package/dist/es/lib/focusRestore.js.map +1 -0
- package/dist/es/lib/helpers.js +0 -18
- package/dist/es/lib/helpers.js.map +1 -1
- package/dist/es/lib/inputMode.js +9 -0
- package/dist/es/lib/inputMode.js.map +1 -0
- package/dist/es/lib/menuInitialFocus.js +100 -0
- package/dist/es/lib/menuInitialFocus.js.map +1 -0
- package/dist/es/lib/menuSubmenuPlacement.js +219 -0
- package/dist/es/lib/menuSubmenuPlacement.js.map +1 -0
- package/dist/es/lib/observeTextareaWidth.js +49 -0
- package/dist/es/lib/observeTextareaWidth.js.map +1 -0
- package/dist/es/lib/selectPress.js +34 -0
- package/dist/es/lib/selectPress.js.map +1 -0
- package/dist/es/lib/sortable.js +74 -20
- package/dist/es/lib/sortable.js.map +1 -1
- package/dist/types/components/Button/Button.d.ts +6 -2
- package/dist/types/components/Button/ButtonLink.d.ts +6 -2
- package/dist/types/components/Button/NavigationButton.d.ts +27 -0
- package/dist/types/components/Button/NavigationGlyph.d.ts +16 -0
- package/dist/types/components/Button/index.d.ts +1 -0
- package/dist/types/components/Checkbox/Checkbox.d.ts +12 -12
- package/dist/types/components/DateInput/DateInput.d.ts +4 -4
- package/dist/types/components/DatePicker/CalendarNavigationIcon.d.ts +6 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +13 -13
- package/dist/types/components/DatePicker/context.d.ts +1 -0
- package/dist/types/components/DatePicker/useCalendarGutter.d.ts +2 -0
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +13 -13
- package/dist/types/components/Dialog/Dialog.d.ts +46 -11
- package/dist/types/components/Dialog/index.d.ts +1 -1
- package/dist/types/components/Field/Field.d.ts +2 -2
- package/dist/types/components/FileUpload/FileUpload.d.ts +6 -6
- package/dist/types/components/FloatingLabelInput/FloatingLabelInput.d.ts +4 -4
- package/dist/types/components/Icon/index.d.ts +1 -0
- package/dist/types/components/Icon/svg/Disclosure.d.ts +3 -0
- package/dist/types/components/Indicator/LoadingIndicator.d.ts +2 -2
- package/dist/types/components/Input/Input.d.ts +2 -2
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts +8 -8
- package/dist/types/components/Menu/Menu.d.ts +18 -25
- package/dist/types/components/OTPInput/OTPInput.d.ts +6 -6
- package/dist/types/components/Page/Page.d.ts +48 -7
- package/dist/types/components/Page/index.d.ts +1 -1
- package/dist/types/components/Popover/Popover.d.ts +17 -6
- package/dist/types/components/RadioGroup/RadioGroup.d.ts +10 -10
- package/dist/types/components/SelectControl/index.d.ts +1 -1
- package/dist/types/components/Sortable/Sortable.d.ts +8 -8
- package/dist/types/components/Switch/Switch.d.ts +34 -12
- package/dist/types/components/Tabs/Tabs.d.ts +6 -6
- package/dist/types/components/TagInput/TagInput.d.ts +4 -4
- package/dist/types/components/Textarea/Textarea.d.ts +2 -2
- package/dist/types/components/Toast/ToastRenderer.d.ts +79 -0
- package/dist/types/components/Toast/Toaster.d.ts +6 -2
- package/dist/types/components/Toast/toastLifecycle.d.ts +90 -0
- package/dist/types/components/Toolbar/Toolbar.d.ts +149 -0
- package/dist/types/components/Toolbar/index.d.ts +1 -0
- package/dist/types/components/Tooltip/CopyTooltip.d.ts +2 -2
- package/dist/types/components/Tooltip/Tooltip.d.ts +6 -6
- package/dist/types/composables/useFloatingBoundary.d.ts +24 -0
- package/dist/types/composables/usePhoneSubmenu.d.ts +3 -0
- package/dist/types/lib/floatingBoundary.d.ts +9 -0
- package/dist/types/lib/focusRestore.d.ts +5 -0
- package/dist/types/lib/helpers.d.ts +0 -4
- package/dist/types/lib/inputMode.d.ts +7 -0
- package/dist/types/lib/menuInitialFocus.d.ts +9 -0
- package/dist/types/lib/menuSubmenuPlacement.d.ts +44 -0
- package/dist/types/lib/observeTextareaWidth.d.ts +2 -0
- package/dist/types/lib/selectPress.d.ts +23 -0
- package/dist/types/lib/sortable.d.ts +1 -1
- package/package.json +2 -2
|
@@ -23,7 +23,7 @@ const BadgeComponent = defineComponent({
|
|
|
23
23
|
setup(props, { slots }) {
|
|
24
24
|
const renderRemove = () => {
|
|
25
25
|
if (props.onRemove) {
|
|
26
|
-
return h("button", { "type": "button", "class": s.Remove, "aria-label": props.removeLabel, "onClick": props.onRemove }, [h(X)]);
|
|
26
|
+
return h("button", { "type": "button", "data-badge-remove": "", "class": s.Remove, "aria-label": props.removeLabel, "onClick": props.onRemove }, [h(X)]);
|
|
27
27
|
}
|
|
28
28
|
return props.removable ? h("span", { "class": s.Remove, "aria-hidden": "true" }, [h(X)]) : null;
|
|
29
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../../src/components/Badge/Badge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAsC,MAAM,KAAK,CAAA;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAA;AACpC,OAAO,CAAC,MAAM,kDAAkD,CAAA;AAUhE,MAAM,cAAc,GAAG,eAAe,CAAC;IACrC,IAAI,EAAE,OAAO;IACb,KAAK,EAAE;QACL,iDAAiD;QACjD,OAAO,EAAE,EAAE,IAAI,EAAE,MAA0D,EAAE,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AI,EAAE,CAAA;YACxC,MAAM,MAAM,GAAG,YAAY,EAAE,CAAA;YAE7B,OAAO,CAAC,CACN,KAAK,EACL;gBACE,OAAO,EAAE,CAAC,CAAC,KAAK;gBAChB,YAAY,EAAE,KAAK,CAAC,KAAK;gBACzB,WAAW,EAAE,KAAK,CAAC,IAAI;gBACvB,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;gBACxC,cAAc,EAAE,KAAK,CAAC,OAAO;aAC9B,EACD,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAChE,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,KAAK,GAAG,cAA4E,CAAA","sourcesContent":["import { defineComponent, h, type HTMLAttributes, type PropType } from \"vue\"\nimport type { SemanticColors, Sizes, Variants } from \"@plexui/styles/types\"\nimport { wrapTextNodeSiblings } from \"../../lib/renderHelpers.js\"\nimport { X } from \"../Icon/index.js\"\nimport s from \"@plexui/styles/components/Badge/Badge.module.css\"\n\n// Vue port of packages/ui/src/components/Badge/index.tsx. React spreads the\n// remaining props after its own attributes, so caller attributes win; Vue's\n// attribute fallthrough merges them onto the root the same way.\n\nexport type BadgeColor = SemanticColors<\n \"secondary\" | \"success\" | \"danger\" | \"warning\" | \"info\" | \"discovery\" | \"caution\"\n>\n\nconst BadgeComponent = defineComponent({\n name: \"Badge\",\n props: {\n /** Visual style of the badge. @default \"soft\" */\n variant: { type: String as PropType<Variants<\"solid\" | \"soft\" | \"outline\">>, default: \"soft\" },\n /** Size scale of the badge: `sm` 20px, `md` 22px, `lg` 24px, `xl` 32px. @default \"sm\" */\n size: { type: String as PropType<Sizes<\"sm\" | \"md\" | \"lg\" | \"xl\">>, default: \"sm\" },\n /** Determines if the badge should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Color of the badge, related to its meaning or intent. @default \"secondary\" */\n color: { type: String as PropType<BadgeColor>, default: \"secondary\" },\n /** Adds a cross at the end of the badge that calls this when pressed. */\n onRemove: Function as PropType<(event: MouseEvent) => void>,\n /** Accessible name of the cross. @default \"Remove\" */\n removeLabel: { type: String, default: \"Remove\" },\n /** Shows the cross as a mark, for a badge inside a control that takes the press. @default false */\n removable: { type: Boolean, default: false },\n },\n setup(props, { slots }) {\n const renderRemove = () => {\n if (props.onRemove) {\n return h(\n \"button\",\n { \"type\": \"button\", \"data-badge-remove\": \"\", \"class\": s.Remove, \"aria-label\": props.removeLabel, \"onClick\": props.onRemove },\n [h(X)],\n )\n }\n return props.removable ? h(\"span\", { \"class\": s.Remove, \"aria-hidden\": \"true\" }, [h(X)]) : null\n }\n\n return () => {\n const children = slots.default?.() ?? []\n const remove = renderRemove()\n\n return h(\n \"div\",\n {\n \"class\": s.Badge,\n \"data-color\": props.color,\n \"data-size\": props.size,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-variant\": props.variant,\n },\n wrapTextNodeSiblings(remove ? [...children, remove] : children),\n )\n }\n },\n})\n\ntype BadgeOwnProps = InstanceType<typeof BadgeComponent>[\"$props\"]\n\n/** Badge props plus the native <div> attributes that fall through to it, as in React. */\nexport type BadgeProps = BadgeOwnProps & Omit<HTMLAttributes, keyof BadgeOwnProps>\n\nexport const Badge = BadgeComponent as typeof BadgeComponent & { new (): { $props: BadgeProps } }\n"]}
|
|
@@ -15,6 +15,8 @@ const ButtonComponent = defineComponent({
|
|
|
15
15
|
variant: { type: String, default: "solid" },
|
|
16
16
|
/** Determines if the button should be a fully rounded pill shape. @default false */
|
|
17
17
|
pill: { type: Boolean, default: false },
|
|
18
|
+
/** Phone surface for neutral soft/ghost buttons; desktop retains the variant. */
|
|
19
|
+
mobileMaterial: String,
|
|
18
20
|
/** Determines if the button should have matching width and height, based on the `size`. @default false */
|
|
19
21
|
uniform: { type: Boolean, default: false },
|
|
20
22
|
/** Controls size of the button: height, plus defaults for `gutterSize`, `iconSize` and font size. @default "md" */
|
|
@@ -39,19 +41,24 @@ const ButtonComponent = defineComponent({
|
|
|
39
41
|
inert: { type: Boolean, default: undefined },
|
|
40
42
|
},
|
|
41
43
|
emits: {
|
|
42
|
-
click: (
|
|
44
|
+
click: (event) => {
|
|
45
|
+
void event;
|
|
46
|
+
return true;
|
|
47
|
+
},
|
|
43
48
|
},
|
|
44
49
|
setup(props, { slots, emit }) {
|
|
50
|
+
// Defaults to `loading` state
|
|
51
|
+
const isInertState = () => props.disabled || (props.inert === undefined ? props.loading : props.inert);
|
|
45
52
|
const handleClick = (event) => {
|
|
46
|
-
|
|
53
|
+
// React drops mouse events on a natively disabled button, including
|
|
54
|
+
// loading/inert; Vue delivers dispatched clicks, so guard the same state.
|
|
55
|
+
if (isInertState()) {
|
|
47
56
|
return;
|
|
48
57
|
}
|
|
49
58
|
emit("click", event);
|
|
50
59
|
};
|
|
51
60
|
return () => {
|
|
52
|
-
|
|
53
|
-
const inert = props.inert === undefined ? props.loading : props.inert;
|
|
54
|
-
const isInert = props.disabled || inert;
|
|
61
|
+
const isInert = isInertState();
|
|
55
62
|
const { loading } = props;
|
|
56
63
|
return h("button", {
|
|
57
64
|
"type": props.type,
|
|
@@ -59,6 +66,7 @@ const ButtonComponent = defineComponent({
|
|
|
59
66
|
"data-color": props.color,
|
|
60
67
|
"data-variant": props.variant,
|
|
61
68
|
"data-pill": props.pill ? "" : undefined,
|
|
69
|
+
"data-mobile-material": props.mobileMaterial,
|
|
62
70
|
"data-uniform": props.uniform ? "" : undefined,
|
|
63
71
|
"data-size": props.size,
|
|
64
72
|
"data-gutter-size": props.gutterSize,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../src/components/Button/Button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC,EAA4C,MAAM,KAAK,CAAA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,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,oBAAoB,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;aAC7E,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAOF,MAAM,CAAC,MAAM,MAAM,GAAG,eAA+E,CAAA","sourcesContent":["import { createCommentVNode, defineComponent, h, type ButtonHTMLAttributes, type PropType } from \"vue\"\nimport type { ControlSize, SemanticColors, Sizes, Variants } from \"@plexui/styles/types\"\nimport { handlePressableMouseEnter } from \"../../lib/helpers.js\"\nimport { wrapTextNodeSiblings } from \"../../lib/renderHelpers.js\"\nimport { LoadingIndicator } from \"../Indicator/index.js\"\nimport { TransitionGroup } from \"../Transition/index.js\"\nimport s from \"@plexui/styles/components/Button/Button.module.css\"\n\n// Vue port of packages/ui/src/components/Button/Button.tsx. Props, defaults\n// and rendered attributes match React 1:1 (checked by the parity tests).\n// Boolean props default to `undefined` where React distinguishes \"not set\"\n// from `false` (`inert` falls back to `loading`, `aria-disabled` renders \"false\").\n\nexport type ButtonColor = SemanticColors<\n \"primary\" | \"secondary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n>\n\nconst ButtonComponent = defineComponent({\n name: \"Button\",\n props: {\n /** @default \"button\" */\n type: { type: String as PropType<\"button\" | \"submit\" | \"reset\">, default: \"button\" },\n /** Color for the button. @default \"primary\" */\n color: { type: String as PropType<ButtonColor>, default: \"primary\" },\n /** Style variant for the Button. @default \"solid\" */\n variant: { type: String as PropType<Variants<\"solid\" | \"soft\" | \"outline\" | \"ghost\">>, default: \"solid\" },\n /** Determines if the button should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Determines if the button should have matching width and height, based on the `size`. @default false */\n uniform: { type: Boolean, default: false },\n /** Controls size of the button: height, plus defaults for `gutterSize`, `iconSize` and font size. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Controls the size of icons within the button, defaults to value from `size`. */\n iconSize: String as PropType<Sizes<\"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\">>,\n /** Controls gutter on the edges of the button, defaults to value from `size`. */\n gutterSize: String as PropType<Sizes<\"3xs\" | \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">>,\n /** Displays loading indicator on top of button contents. @default false */\n loading: { type: Boolean, default: undefined },\n /** Displays selected styles on the button, varying by `variant`. @default false */\n selected: { type: Boolean, default: undefined },\n /** Determines if the button should take up 100% of available width. @default false */\n block: { type: Boolean, default: undefined },\n /** Applies a negative margin using the current gutter to optically align the button with surrounding content. */\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n /** Disables the button visually and from interactions. @default false */\n disabled: { type: Boolean, default: undefined },\n /** Controls the visual tone when the button is disabled. \"relaxed\" will use a default cursor instead of not-allowed. */\n disabledTone: String as PropType<\"relaxed\">,\n /** Determines whether the button should be made inert, without introducing visual change. Defaults to `loading`. */\n inert: { type: Boolean, default: undefined },\n },\n emits: {\n click: (_event: MouseEvent) => true,\n },\n setup(props, { slots, emit }) {\n const handleClick = (event: MouseEvent) => {\n if (props.disabled) {\n return\n }\n emit(\"click\", event)\n }\n\n return () => {\n // Defaults to `loading` state\n const inert = props.inert === undefined ? props.loading : props.inert\n const isInert = props.disabled || inert\n const { loading } = props\n\n return h(\n \"button\",\n {\n \"type\": props.type,\n \"class\": s.Button,\n \"data-color\": props.color,\n \"data-variant\": props.variant,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-uniform\": props.uniform ? \"\" : undefined,\n \"data-size\": props.size,\n \"data-gutter-size\": props.gutterSize,\n \"data-icon-size\": props.iconSize,\n \"data-loading\": loading ? \"\" : undefined,\n \"data-selected\": props.selected ? \"\" : undefined,\n \"data-block\": props.block ? \"\" : undefined,\n \"data-optically-align\": props.opticallyAlign,\n \"onPointerenter\": handlePressableMouseEnter,\n // Non-visual, accessible disablement\n // NOTE: Do not use literal `inert` because that is incorrect semantically\n \"disabled\": isInert,\n \"aria-disabled\": isInert,\n \"tabindex\": isInert ? -1 : undefined,\n // Visual disablement\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-disabled-tone\": props.disabled ? props.disabledTone : undefined,\n \"onClick\": handleClick,\n },\n [\n // React renders `{loading && <LoadingIndicator />}`: nothing when\n // `loading` is unset, an empty slot when it is `false`.\n h(\n TransitionGroup,\n { class: s.ButtonLoader, enterDuration: 250, exitDuration: 150 },\n loading === undefined\n ? undefined\n : {\n default: () =>\n loading ? [h(LoadingIndicator, { key: \"loader\" })] : [createCommentVNode()],\n },\n ),\n h(\"span\", { class: s.ButtonInner }, wrapTextNodeSiblings(slots.default?.())),\n ],\n )\n }\n },\n})\n\ntype ButtonOwnProps = InstanceType<typeof ButtonComponent>[\"$props\"]\n\n/** Button props plus the native <button> attributes that fall through to it, as in React. */\nexport type ButtonProps = ButtonOwnProps & Omit<ButtonHTMLAttributes, keyof ButtonOwnProps>\n\nexport const Button = ButtonComponent as typeof ButtonComponent & { new (): { $props: ButtonProps } }\n"]}
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../../../src/components/Button/Button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC,EAA4C,MAAM,KAAK,CAAA;AAEtG,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAWlE,MAAM,eAAe,GAAG,eAAe,CAAC;IACtC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE;QACL,wBAAwB;QACxB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAiD,EAAE,OAAO,EAAE,QAAQ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","sourcesContent":["import { createCommentVNode, defineComponent, h, type ButtonHTMLAttributes, type PropType } from \"vue\"\nimport type { ControlSize, SemanticColors, Sizes, Variants } from \"@plexui/styles/types\"\nimport { handlePressableMouseEnter } from \"../../lib/helpers.js\"\nimport { wrapTextNodeSiblings } from \"../../lib/renderHelpers.js\"\nimport { LoadingIndicator } from \"../Indicator/index.js\"\nimport { TransitionGroup } from \"../Transition/index.js\"\nimport s from \"@plexui/styles/components/Button/Button.module.css\"\n\n// Vue port of packages/ui/src/components/Button/Button.tsx. Props, defaults\n// and rendered attributes match React 1:1 (checked by the parity tests).\n// Boolean props default to `undefined` where React distinguishes \"not set\"\n// from `false` (`inert` falls back to `loading`, `aria-disabled` renders \"false\").\n\nexport type ButtonColor = SemanticColors<\n \"primary\" | \"secondary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n>\n\nconst ButtonComponent = defineComponent({\n name: \"Button\",\n props: {\n /** @default \"button\" */\n type: { type: String as PropType<\"button\" | \"submit\" | \"reset\">, default: \"button\" },\n /** Color for the button. @default \"primary\" */\n color: { type: String as PropType<ButtonColor>, default: \"primary\" },\n /** Style variant for the Button. @default \"solid\" */\n variant: { type: String as PropType<Variants<\"solid\" | \"soft\" | \"outline\" | \"ghost\">>, default: \"solid\" },\n /** Determines if the button should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Phone surface for neutral soft/ghost buttons; desktop retains the variant. */\n mobileMaterial: String as PropType<\"glass\" | \"flat\">,\n /** Determines if the button should have matching width and height, based on the `size`. @default false */\n uniform: { type: Boolean, default: false },\n /** Controls size of the button: height, plus defaults for `gutterSize`, `iconSize` and font size. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Controls the size of icons within the button, defaults to value from `size`. */\n iconSize: String as PropType<Sizes<\"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\">>,\n /** Controls gutter on the edges of the button, defaults to value from `size`. */\n gutterSize: String as PropType<Sizes<\"3xs\" | \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">>,\n /** Displays loading indicator on top of button contents. @default false */\n loading: { type: Boolean, default: undefined },\n /** Displays selected styles on the button, varying by `variant`. @default false */\n selected: { type: Boolean, default: undefined },\n /** Determines if the button should take up 100% of available width. @default false */\n block: { type: Boolean, default: undefined },\n /** Applies a negative margin using the current gutter to optically align the button with surrounding content. */\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n /** Disables the button visually and from interactions. @default false */\n disabled: { type: Boolean, default: undefined },\n /** Controls the visual tone when the button is disabled. \"relaxed\" will use a default cursor instead of not-allowed. */\n disabledTone: String as PropType<\"relaxed\">,\n /** Determines whether the button should be made inert, without introducing visual change. Defaults to `loading`. */\n inert: { type: Boolean, default: undefined },\n },\n emits: {\n click: (event: MouseEvent) => {\n void event\n return true\n },\n },\n setup(props, { slots, emit }) {\n // Defaults to `loading` state\n const isInertState = () => props.disabled || (props.inert === undefined ? props.loading : props.inert)\n\n const handleClick = (event: MouseEvent) => {\n // React drops mouse events on a natively disabled button, including\n // loading/inert; Vue delivers dispatched clicks, so guard the same state.\n if (isInertState()) {\n return\n }\n emit(\"click\", event)\n }\n\n return () => {\n const isInert = isInertState()\n const { loading } = props\n\n return h(\n \"button\",\n {\n \"type\": props.type,\n \"class\": s.Button,\n \"data-color\": props.color,\n \"data-variant\": props.variant,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-mobile-material\": props.mobileMaterial,\n \"data-uniform\": props.uniform ? \"\" : undefined,\n \"data-size\": props.size,\n \"data-gutter-size\": props.gutterSize,\n \"data-icon-size\": props.iconSize,\n \"data-loading\": loading ? \"\" : undefined,\n \"data-selected\": props.selected ? \"\" : undefined,\n \"data-block\": props.block ? \"\" : undefined,\n \"data-optically-align\": props.opticallyAlign,\n \"onPointerenter\": handlePressableMouseEnter,\n // Non-visual, accessible disablement\n // NOTE: Do not use literal `inert` because that is incorrect semantically\n \"disabled\": isInert,\n \"aria-disabled\": isInert,\n \"tabindex\": isInert ? -1 : undefined,\n // Visual disablement\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-disabled-tone\": props.disabled ? props.disabledTone : undefined,\n \"onClick\": handleClick,\n },\n [\n // React renders `{loading && <LoadingIndicator />}`: nothing when\n // `loading` is unset, an empty slot when it is `false`.\n h(\n TransitionGroup,\n { class: s.ButtonLoader, enterDuration: 250, exitDuration: 150 },\n loading === undefined\n ? undefined\n : {\n default: () =>\n loading ? [h(LoadingIndicator, { key: \"loader\" })] : [createCommentVNode()],\n },\n ),\n h(\"span\", { class: s.ButtonInner }, wrapTextNodeSiblings(slots.default?.())),\n ],\n )\n }\n },\n})\n\ntype ButtonOwnProps = InstanceType<typeof ButtonComponent>[\"$props\"]\n\n/** Button props plus the native <button> attributes that fall through to it, as in React. */\nexport type ButtonProps = ButtonOwnProps & Omit<ButtonHTMLAttributes, keyof ButtonOwnProps>\n\nexport const Button = ButtonComponent as typeof ButtonComponent & { new (): { $props: ButtonProps } }\n"]}
|
|
@@ -15,6 +15,8 @@ export const ButtonLink = defineComponent({
|
|
|
15
15
|
variant: { type: String, default: "solid" },
|
|
16
16
|
/** Fully rounded pill shape. @default false */
|
|
17
17
|
pill: { type: Boolean, default: false },
|
|
18
|
+
/** Phone surface for neutral soft/ghost buttons; desktop retains the variant. */
|
|
19
|
+
mobileMaterial: String,
|
|
18
20
|
/** Control height and typography scale. @default "md" */
|
|
19
21
|
size: { type: String, default: "md" },
|
|
20
22
|
gutterSize: String,
|
|
@@ -31,7 +33,10 @@ export const ButtonLink = defineComponent({
|
|
|
31
33
|
to: [String, Object],
|
|
32
34
|
},
|
|
33
35
|
emits: {
|
|
34
|
-
click: (
|
|
36
|
+
click: (event) => {
|
|
37
|
+
void event;
|
|
38
|
+
return true;
|
|
39
|
+
},
|
|
35
40
|
},
|
|
36
41
|
setup(props, { slots, attrs, emit }) {
|
|
37
42
|
const DefaultComponent = useLinkComponent();
|
|
@@ -52,6 +57,7 @@ export const ButtonLink = defineComponent({
|
|
|
52
57
|
"data-color": props.color,
|
|
53
58
|
"data-variant": props.variant,
|
|
54
59
|
"data-pill": props.pill ? "" : undefined,
|
|
60
|
+
"data-mobile-material": props.mobileMaterial,
|
|
55
61
|
"data-block": props.block ? "" : undefined,
|
|
56
62
|
"data-optically-align": props.opticallyAlign,
|
|
57
63
|
"data-size": props.size,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonLink.js","sourceRoot":"","sources":["../../../../src/components/Button/ButtonLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,UAAU,EAAiB,MAAM,KAAK,CAAA;AAEnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAGhE,OAAO,CAAC,MAAM,oDAAoD,CAAA;AAIlE,MAAM,OAAO,GAAG,CAAC,KAA8B,EAAE,EAAE,CACjD,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAA;AAEtF,kFAAkF;AAClF,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;IACxC,IAAI,EAAE,YAAY;IAClB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE;QACL,6CAA6C;QAC7C,KAAK,EAAE,EAAE,IAAI,EAAE,MAA+B,EAAE,OAAO,EAAE,SAAS,EAAE;QACpE,sCAAsC;QACtC,OAAO,EAAE,EAAE,IAAI,EAAE,MAAoE,EAAE,OAAO,EAAE,OAAO,EAAE;QACzG,+CAA+C;QAC/C,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE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ACpE,CAAC,CAAC,sDAAsD;oBACtD,EAAE,KAAK,SAAS,IAAI,WAAW,CAAC,aAAa,CAAC;wBAC9C,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE;wBACd,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,EAClB,WAAW,EACX,SAAS,CACV,CACF,CAAA;YAED,OAAO,OAAO,aAAa,KAAK,QAAQ;gBACtC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;gBACxC,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAA;QAC/D,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import { defineComponent, h, mergeProps, type PropType } from \"vue\"\nimport type { ControlSize, Sizes, Variants } from \"@plexui/styles/types\"\nimport { handlePressableMouseEnter } from \"../../lib/helpers.js\"\nimport { takesToProp, wrapTextNodeSiblings } from \"../../lib/renderHelpers.js\"\nimport { useLinkComponent } from \"../PlexUIProvider/internal.js\"\nimport type { LinkComponent } from \"../PlexUIProvider/index.js\"\nimport type { ButtonColor } from \"./Button.js\"\nimport s from \"@plexui/styles/components/Button/Button.module.css\"\n\ntype RouteTarget = string | Record<string, unknown>\n\nconst defined = (props: Record<string, unknown>) =>\n Object.fromEntries(Object.entries(props).filter(([, value]) => value !== undefined))\n\n/** Vue port of `ButtonLink` from packages/ui/src/components/Button/Button.tsx. */\nexport const ButtonLink = defineComponent({\n name: \"ButtonLink\",\n inheritAttrs: false,\n props: {\n /** Color for the link. @default \"primary\" */\n color: { type: String as PropType<ButtonColor>, default: \"primary\" },\n /** Style variant. @default \"solid\" */\n variant: { type: String as PropType<Variants<\"solid\" | \"soft\" | \"outline\" | \"ghost\">>, default: \"solid\" },\n /** Fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Phone surface for neutral soft/ghost buttons; desktop retains the variant. */\n mobileMaterial: String as PropType<\"glass\" | \"flat\">,\n /** Control height and typography scale. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n gutterSize: String as PropType<Sizes<\"3xs\" | \"2xs\" | \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\">>,\n iconSize: String as PropType<Sizes<\"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\">>,\n /** Force external-link behavior. */\n external: { type: Boolean, default: undefined },\n block: { type: Boolean, default: undefined },\n opticallyAlign: String as PropType<\"start\" | \"end\">,\n disabled: { type: Boolean, default: undefined },\n disabledTone: String as PropType<\"relaxed\">,\n /** Link component override (e.g. a router link). */\n as: [String, Object, Function] as PropType<LinkComponent>,\n href: String,\n to: [String, Object] as PropType<RouteTarget>,\n },\n emits: {\n click: (event: MouseEvent) => {\n void event\n return true\n },\n },\n setup(props, { slots, attrs, emit }) {\n const DefaultComponent = useLinkComponent()\n\n return () => {\n const { href, to, disabled } = props\n const isExternal = props.external ?? /^https?:\\/\\//.test(href ?? (typeof to === \"string\" ? to : \"\") ?? \"\")\n const LinkComponent = props.as || (isExternal ? \"a\" : DefaultComponent.value)\n const { class: className, ...restAttrs } = attrs\n\n const sharedProps = {\n \"class\": [s.Button, className],\n // React renders boolean `disabled` on a link as an empty attribute\n \"disabled\": disabled ? \"\" : undefined,\n \"aria-disabled\": disabled,\n \"tabindex\": disabled ? -1 : undefined,\n // Visual disablement (inert not supported in links, always applied)\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-disabled-tone\": disabled ? props.disabledTone : undefined,\n \"data-color\": props.color,\n \"data-variant\": props.variant,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-mobile-material\": props.mobileMaterial,\n \"data-block\": props.block ? \"\" : undefined,\n \"data-optically-align\": props.opticallyAlign,\n \"data-size\": props.size,\n \"data-gutter-size\": props.gutterSize,\n \"data-icon-size\": props.iconSize,\n \"onClick\": disabled ? undefined : (event: MouseEvent) => emit(\"click\", event),\n \"onPointerenter\": handlePressableMouseEnter,\n }\n const inner = () => h(\"span\", { class: s.ButtonInner }, wrapTextNodeSiblings(slots.default?.()))\n\n if (disabled) {\n // Don't thread down stuff that isn't valid for a span - just keep the event handlers\n const eventProps = Object.fromEntries(\n Object.entries(restAttrs).filter(([key, value]) => key.startsWith(\"on\") && typeof value === \"function\"),\n )\n // mergeProps keeps both pointerenter handlers, as React composes them\n return h(\"span\", defined(mergeProps({ role: \"link\" }, sharedProps, eventProps)), [inner()])\n }\n\n const linkProps = defined(\n mergeProps(\n isExternal\n ? { target: \"_blank\", rel: \"noopener noreferrer\", href: href ?? to }\n : // A router link (`to` required) gets the href as `to`\n to === undefined && takesToProp(LinkComponent)\n ? { to: href }\n : { href, to },\n sharedProps,\n restAttrs,\n ),\n )\n\n return typeof LinkComponent === \"string\"\n ? h(LinkComponent, linkProps, [inner()])\n : h(LinkComponent, linkProps, { default: () => [inner()] })\n }\n },\n})\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
import { Button } from "./Button.js";
|
|
3
|
+
import { NavigationGlyph } from "./NavigationGlyph.js";
|
|
4
|
+
import s from "@plexui/styles/components/Button/NavigationButton.module.css";
|
|
5
|
+
const labels = { back: "Back", close: "Close", confirm: "Confirm" };
|
|
6
|
+
const NavigationButtonComponent = defineComponent({
|
|
7
|
+
name: "NavigationButton",
|
|
8
|
+
inheritAttrs: false,
|
|
9
|
+
props: { action: { type: String, required: true } },
|
|
10
|
+
setup(props, { attrs }) {
|
|
11
|
+
return () => h(Button, {
|
|
12
|
+
color: props.action === "confirm" ? "primary" : "secondary",
|
|
13
|
+
variant: props.action === "confirm" ? "solid" : "soft",
|
|
14
|
+
mobileMaterial: props.action === "confirm" ? undefined : "glass",
|
|
15
|
+
size: "lg",
|
|
16
|
+
...attrs,
|
|
17
|
+
"class": [s.NavigationButton, attrs.class],
|
|
18
|
+
uniform: true,
|
|
19
|
+
pill: true,
|
|
20
|
+
"aria-label": typeof attrs["aria-label"] === "string" ? attrs["aria-label"] : labels[props.action],
|
|
21
|
+
"data-navigation-action": props.action,
|
|
22
|
+
}, () => h(NavigationGlyph, { action: props.action }));
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
/** Every native/Button prop reaches the same button; refs retain the Button instance's $el. */
|
|
26
|
+
export const NavigationButton = NavigationButtonComponent;
|
|
27
|
+
//# sourceMappingURL=NavigationButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationButton.js","sourceRoot":"","sources":["../../../../src/components/Button/NavigationButton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAiB,MAAM,KAAK,CAAA;AACvD,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAa,CAAA;AACtD,OAAO,EAAE,eAAe,EAAyB,MAAM,sBAAsB,CAAA;AAC7E,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAE5E,MAAM,MAAM,GAAqC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;AAErG,MAAM,yBAAyB,GAAG,eAAe,CAAC;IAC9C,IAAI,EAAE,kBAAkB;IACxB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAoC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IACjF,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE;QAClB,OAAO,GAAG,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE;YACnB,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW;YAC3D,OAAO,EAAE,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;YACtD,cAAc,EAAE,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;YAChE,IAAI,EAAE,IAAI;YACV,GAAG,KAAK;YACR,OAAO,EAAE,CAAC,CAAC,CAAC,gBAAgB,EAAE,KAAK,CAAC,KAAK,CAAC;YAC1C,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,IAAI;YACV,YAAY,EAAE,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;YAClG,wBAAwB,EAAE,KAAK,CAAC,MAAM;SACzC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAC1D,CAAC;CACJ,CAAC,CAAA;AAOF,+FAA+F;AAC/F,MAAM,CAAC,MAAM,gBAAgB,GAAG,yBAE/B,CAAA","sourcesContent":["import { defineComponent, h, type PropType } from \"vue\"\nimport { Button, type ButtonProps } from \"./Button.js\"\nimport { NavigationGlyph, type NavigationAction } from \"./NavigationGlyph.js\"\nimport s from \"@plexui/styles/components/Button/NavigationButton.module.css\"\n\nconst labels: Record<NavigationAction, string> = { back: \"Back\", close: \"Close\", confirm: \"Confirm\" }\n\nconst NavigationButtonComponent = defineComponent({\n name: \"NavigationButton\",\n inheritAttrs: false,\n props: { action: { type: String as PropType<NavigationAction>, required: true } },\n setup(props, { attrs }) {\n return () => h(Button, {\n color: props.action === \"confirm\" ? \"primary\" : \"secondary\",\n variant: props.action === \"confirm\" ? \"solid\" : \"soft\",\n mobileMaterial: props.action === \"confirm\" ? undefined : \"glass\",\n size: \"lg\",\n ...attrs,\n \"class\": [s.NavigationButton, attrs.class],\n uniform: true,\n pill: true,\n \"aria-label\": typeof attrs[\"aria-label\"] === \"string\" ? attrs[\"aria-label\"] : labels[props.action],\n \"data-navigation-action\": props.action,\n }, () => h(NavigationGlyph, { action: props.action }))\n },\n})\n\nexport type NavigationButtonProps = Omit<ButtonProps, \"children\" | \"uniform\" | \"pill\" | \"iconSize\"> & {\n /** Visual role only; the caller owns navigation, dismissal and submission. */\n action: NavigationAction\n}\n\n/** Every native/Button prop reaches the same button; refs retain the Button instance's $el. */\nexport const NavigationButton = NavigationButtonComponent as typeof NavigationButtonComponent & {\n new (): { $props: NavigationButtonProps }\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
import ChevronLeft from "../Icon/svg/ChevronLeftMd.js";
|
|
3
|
+
import Check from "../Icon/svg/CheckMd.js";
|
|
4
|
+
import s from "@plexui/styles/components/Button/NavigationButton.module.css";
|
|
5
|
+
/** Mirrors React's NavigationGlyph, including the standard Dialog close path. */
|
|
6
|
+
export const NavigationGlyph = defineComponent({
|
|
7
|
+
name: "NavigationGlyph",
|
|
8
|
+
props: { action: { type: String, required: true } },
|
|
9
|
+
setup(props) {
|
|
10
|
+
return () => {
|
|
11
|
+
const attributes = {
|
|
12
|
+
"class": s.NavigationGlyph,
|
|
13
|
+
"aria-hidden": true,
|
|
14
|
+
"data-navigation-glyph": props.action,
|
|
15
|
+
"data-no-autosize": "",
|
|
16
|
+
};
|
|
17
|
+
if (props.action === "back")
|
|
18
|
+
return h(ChevronLeft, attributes);
|
|
19
|
+
if (props.action === "confirm")
|
|
20
|
+
return h(Check, attributes);
|
|
21
|
+
return h("svg", { ...attributes, viewBox: "0 0 20 20", width: "20", height: "20" }, [
|
|
22
|
+
h("path", { fill: "currentColor", d: "M5.16 5.16a.62.62 0 0 1 .88 0L10 9.12l3.96-3.96a.62.62 0 1 1 .88.88L10.88 10l3.96 3.96a.62.62 0 1 1-.88.88L10 10.88l-3.96 3.96a.62.62 0 1 1-.88-.88L9.12 10 5.16 6.04a.62.62 0 0 1 0-.88" }),
|
|
23
|
+
]);
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=NavigationGlyph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationGlyph.js","sourceRoot":"","sources":["../../../../src/components/Button/NavigationGlyph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAAiB,MAAM,KAAK,CAAA;AACvD,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,KAAK,MAAM,wBAAwB,CAAA;AAC1C,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAI5E,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;IAC3C,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAoC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IACjF,KAAK,CAAC,KAAK;QACP,OAAO,GAAG,EAAE;YACR,MAAM,UAAU,GAAG;gBACf,OAAO,EAAE,CAAC,CAAC,eAAe;gBAC1B,aAAa,EAAE,IAAI;gBACnB,uBAAuB,EAAE,KAAK,CAAC,MAAM;gBACrC,kBAAkB,EAAE,EAAE;aACzB,CAAA;YACD,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM;gBAAE,OAAO,CAAC,CAAC,WAAW,EAAE,UAAU,CAAC,CAAA;YAC9D,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS;gBAAE,OAAO,CAAC,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;YAC3D,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,GAAG,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;gBAChF,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,EAAE,0LAA0L,EAAE,CAAC;aACrO,CAAC,CAAA;QACN,CAAC,CAAA;IACL,CAAC;CACJ,CAAC,CAAA","sourcesContent":["import { defineComponent, h, type PropType } from \"vue\"\nimport ChevronLeft from \"../Icon/svg/ChevronLeftMd.js\"\nimport Check from \"../Icon/svg/CheckMd.js\"\nimport s from \"@plexui/styles/components/Button/NavigationButton.module.css\"\n\nexport type NavigationAction = \"back\" | \"close\" | \"confirm\"\n\n/** Mirrors React's NavigationGlyph, including the standard Dialog close path. */\nexport const NavigationGlyph = defineComponent({\n name: \"NavigationGlyph\",\n props: { action: { type: String as PropType<NavigationAction>, required: true } },\n setup(props) {\n return () => {\n const attributes = {\n \"class\": s.NavigationGlyph,\n \"aria-hidden\": true,\n \"data-navigation-glyph\": props.action,\n \"data-no-autosize\": \"\",\n }\n if (props.action === \"back\") return h(ChevronLeft, attributes)\n if (props.action === \"confirm\") return h(Check, attributes)\n return h(\"svg\", { ...attributes, viewBox: \"0 0 20 20\", width: \"20\", height: \"20\" }, [\n h(\"path\", { fill: \"currentColor\", d: \"M5.16 5.16a.62.62 0 0 1 .88 0L10 9.12l3.96-3.96a.62.62 0 1 1 .88.88L10.88 10l3.96 3.96a.62.62 0 1 1-.88.88L10 10.88l-3.96 3.96a.62.62 0 1 1-.88-.88L9.12 10 5.16 6.04a.62.62 0 0 1 0-.88\" }),\n ])\n }\n },\n})\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsC,MAAM,aAAa,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAwB,MAAM,iBAAiB,CAAA","sourcesContent":["export { Button, type ButtonColor, type ButtonProps } from \"./Button.js\"\nexport { ButtonLink } from \"./ButtonLink.js\"\nexport { CopyButton, type CopyButtonProps } from \"./CopyButton.js\"\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/Button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsC,MAAM,aAAa,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAwB,MAAM,iBAAiB,CAAA;AAClE,OAAO,EAAE,gBAAgB,EAA8B,MAAM,uBAAuB,CAAA","sourcesContent":["export { Button, type ButtonColor, type ButtonProps } from \"./Button.js\"\nexport { ButtonLink } from \"./ButtonLink.js\"\nexport { CopyButton, type CopyButtonProps } from \"./CopyButton.js\"\nexport { NavigationButton, type NavigationButtonProps } from \"./NavigationButton.js\"\n"]}
|
|
@@ -3,6 +3,7 @@ import { CheckboxIndicator as RekaCheckboxIndicator, CheckboxRoot as RekaCheckbo
|
|
|
3
3
|
import { bubbleInputStyle, useBubbleInputEffect, useCheckedTracker, useIsFormControl, useSize } from "./bubbleInput.js";
|
|
4
4
|
import { ControlButton, isListener } from "./ControlButton.js";
|
|
5
5
|
import s from "@plexui/styles/components/Checkbox/Checkbox.module.css";
|
|
6
|
+
import { Check, Minus } from "../Icon/index.js";
|
|
6
7
|
const CheckboxComponent = defineComponent({
|
|
7
8
|
name: "Checkbox",
|
|
8
9
|
inheritAttrs: false,
|
|
@@ -34,11 +35,11 @@ const CheckboxComponent = defineComponent({
|
|
|
34
35
|
},
|
|
35
36
|
emits: {
|
|
36
37
|
/** The state of the checkbox changed */
|
|
37
|
-
"update:checked": (
|
|
38
|
+
"update:checked": (checked) => typeof checked === "boolean" || checked === "indeterminate",
|
|
38
39
|
/** The checkbox gained focus */
|
|
39
|
-
focus: (
|
|
40
|
+
focus: (event) => { void event; return true; },
|
|
40
41
|
/** The checkbox lost focus */
|
|
41
|
-
blur: (
|
|
42
|
+
blur: (event) => { void event; return true; },
|
|
42
43
|
},
|
|
43
44
|
setup(props, { attrs, slots, emit }) {
|
|
44
45
|
const generatedId = useId();
|
|
@@ -144,7 +145,16 @@ const CheckboxComponent = defineComponent({
|
|
|
144
145
|
},
|
|
145
146
|
// Mounted for good: on every uncheck Presence reads computed style, and
|
|
146
147
|
// a long list of boxes cleared at once forces one style pass per box.
|
|
147
|
-
{
|
|
148
|
+
{
|
|
149
|
+
default: () => h("span", { class: s.IndicatorBox, "aria-hidden": "true" }, [
|
|
150
|
+
// A ghost marks the choice with the PlexUI icons of a list row, not with drawn arms.
|
|
151
|
+
props.variant === "ghost"
|
|
152
|
+
? h(RekaCheckboxIndicator, { class: s.GhostMark, forceMount: true }, {
|
|
153
|
+
default: () => [h(Check, { class: s.GhostCheck }), h(Minus, { class: s.GhostDash })],
|
|
154
|
+
})
|
|
155
|
+
: h(RekaCheckboxIndicator, { class: s.CheckMark, forceMount: true }),
|
|
156
|
+
]),
|
|
157
|
+
}),
|
|
148
158
|
}),
|
|
149
159
|
isFormControl.value
|
|
150
160
|
? h("input", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../../src/components/Checkbox/Checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,KAAK,CAAA;AAC/F,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAA;AACtG,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACvH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,oBAAoB,CAAA;AAC9E,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAYtE,MAAM,iBAAiB,GAAG,eAAe,CAAC;IACxC,IAAI,EAAE,UAAU;IAChB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE;QACL,gCAAgC;QAChC,EAAE,E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,MAAM,QAAQ,GAAG,iBAAiB,CAAA","sourcesContent":["import { computed, defineComponent, h, onMounted, ref, useId, watch, type PropType } from \"vue\"\nimport { CheckboxIndicator as RekaCheckboxIndicator, CheckboxRoot as RekaCheckboxRoot } from \"reka-ui\"\nimport { bubbleInputStyle, useBubbleInputEffect, useCheckedTracker, useIsFormControl, useSize } from \"./bubbleInput.js\"\nimport { ControlButton, isListener, type Listeners } from \"./ControlButton.js\"\nimport s from \"@plexui/styles/components/Checkbox/Checkbox.module.css\"\n\n// Vue port of packages/ui/src/components/Checkbox/Checkbox.tsx on Reka UI's\n// Checkbox (state, role, aria-checked, Enter handling, indicator presence).\n// Where Reka's DOM differs from Radix's, Radix's is rendered (see the parity\n// tests): the button carries `value`, no `aria-disabled` and no `aria-label`\n// copied from the label text; the hidden form input is Radix's BubbleInput;\n// the consumer's handlers run before the toggle and can cancel it; a form\n// reset restores the initial state.\n\nexport type CheckedState = boolean | \"indeterminate\"\n\nconst CheckboxComponent = defineComponent({\n name: \"Checkbox\",\n inheritAttrs: false,\n props: {\n /** The `id` of the checkbox. */\n id: String,\n /** The state of the checkbox when it is initially rendered. Use when you do not need to control its state. */\n defaultChecked: { type: [Boolean, String] as PropType<CheckedState>, default: undefined },\n /** The controlled state of the checkbox. Bind with `v-model:checked`. */\n checked: { type: [Boolean, String] as PropType<CheckedState>, default: undefined },\n /** Optional accessible label rendered to the right of the checkbox. The `label` slot takes rich content. */\n label: String,\n /** Optional second line below the label, linked via `aria-describedby`. The `description` slot takes rich content. */\n description: String,\n /** When `true`, prevents the user from interacting with the checkbox. */\n disabled: { type: Boolean, default: false },\n /** When `true`, indicates that the user must check the checkbox before the owning form can be submitted. */\n required: { type: Boolean, default: undefined },\n /** The name of the checkbox. Submitted with its owning form as part of a name/value pair. */\n name: String,\n /** The value given as data when submitted with a `name`. @default \"on\" */\n value: String,\n /** The orientation of the checkbox relative to the label. @default \"left\" */\n orientation: { type: String as PropType<\"left\" | \"right\">, default: \"left\" },\n /** Determines if the checkbox should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Visual style: `\"solid\"` fills the box when checked, `\"ghost\"` shows the checkmark only. @default \"solid\" */\n variant: { type: String as PropType<\"solid\" | \"ghost\">, default: \"solid\" },\n },\n emits: {\n /** The state of the checkbox changed */\n \"update:checked\": (_checked: CheckedState) => true,\n /** The checkbox gained focus */\n focus: (_event: FocusEvent) => true,\n /** The checkbox lost focus */\n blur: (_event: FocusEvent) => true,\n },\n setup(props, { attrs, slots, emit }) {\n const generatedId = useId()\n const container = ref<HTMLDivElement | null>(null)\n const control = ref<HTMLButtonElement | null>(null)\n const bubbleInput = ref<HTMLInputElement | null>(null)\n useCheckedTracker(bubbleInput)\n\n // Radix's useControllableState: controlled while `checked` is set, and\n // only actual changes are reported\n const internalChecked = ref<CheckedState>(props.defaultChecked ?? false)\n const checked = computed(() => props.checked ?? internalChecked.value)\n // The state a click asks for (Reka's toggle sets it), for the user click\n let requestedChecked = true\n const setChecked = (next: CheckedState) => {\n requestedChecked = next === true\n if (next === checked.value) return\n if (props.checked === undefined) internalChecked.value = next\n emit(\"update:checked\", next)\n }\n\n const initialChecked = checked.value\n const isFormControl = useIsFormControl(control, () => attrs.form)\n const controlSize = useSize(() => (isFormControl.value ? control.value : null))\n const onUserClick = useBubbleInputEffect(bubbleInput, () => checked.value, true)\n\n onMounted(() => {\n control.value = (container.value?.firstElementChild as HTMLButtonElement | null) ?? null\n })\n\n // Like a native checkbox, a form reset restores the initial state\n watch(control, (button, _, onCleanup) => {\n const form = button?.form\n if (!form) return\n const reset = () => setChecked(initialChecked)\n form.addEventListener(\"reset\", reset)\n onCleanup(() => form.removeEventListener(\"reset\", reset))\n })\n\n // In a form, the button's click stops here; the input's click bubbles instead\n const afterClick = (event: Event) => {\n const hasConsumerStoppedPropagation = event.cancelBubble\n onUserClick({ requestedChecked, hasConsumerStoppedPropagation })\n if (bubbleInput.value && isFormControl.value && !hasConsumerStoppedPropagation) event.stopPropagation()\n }\n\n // Prevents text selection when double-clicking the label\n const handleLabelMouseDown = (event: MouseEvent) => {\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault()\n }\n\n return () => {\n const { class: className, form, ...rest } = attrs\n const id = props.id ?? generatedId\n const hasLabel = Boolean(slots.label || props.label)\n // The description only renders next to a label; it comes before any ids\n // the caller (a Field, say) passes\n const descriptionId = hasLabel && (slots.description || props.description) ? `${id}-label-description` : undefined\n const indeterminateDefault = props.defaultChecked === \"indeterminate\" ? false : props.defaultChecked\n const inputDefaultChecked = indeterminateDefault ?? (initialChecked === \"indeterminate\" ? false : initialChecked)\n\n // The consumer's listeners compose with Reka's; other attributes land\n // on the button after the component's own, as `{...restProps}` does\n const listeners: Listeners = {\n onFocus: (event: FocusEvent) => emit(\"focus\", event),\n onBlur: (event: FocusEvent) => emit(\"blur\", event),\n }\n const buttonAttrs: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(rest)) {\n if (isListener(key)) listeners[key] = value\n else buttonAttrs[key] = value\n }\n const ariaDescribedBy =\n [descriptionId, buttonAttrs[\"aria-describedby\"] as string | undefined].filter(Boolean).join(\" \") || undefined\n const labelElement = hasLabel\n ? h(\"label\", { for: id, class: s.Label, onMousedown: handleLabelMouseDown }, slots.label ? slots.label() : props.label)\n : null\n\n return h(\n \"div\",\n {\n \"ref\": container,\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-has-label\": hasLabel ? \"\" : undefined,\n \"data-orientation\": props.orientation,\n \"class\": [className, s.Container],\n },\n [\n h(\n RekaCheckboxRoot as never,\n {\n \"asChild\": true,\n \"modelValue\": checked.value,\n \"onUpdate:modelValue\": setChecked,\n \"disabled\": props.disabled,\n // Passed even when unset, so Reka renders no aria-required=\"false\"\n \"required\": props.required,\n },\n {\n default: () =>\n h(\n ControlButton,\n {\n \"listeners\": listeners,\n \"after\": { onClick: afterClick },\n \"class\": s.Checkbox,\n \"id\": id,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-variant\": props.variant,\n \"value\": props.value ?? \"on\",\n // Reka marks a disabled checkbox aria-disabled; Radix does not\n \"aria-disabled\": undefined,\n ...buttonAttrs,\n \"aria-describedby\": ariaDescribedBy,\n },\n // Mounted for good: on every uncheck Presence reads computed style, and\n // a long list of boxes cleared at once forces one style pass per box.\n { default: () => h(RekaCheckboxIndicator, { class: s.CheckMark, forceMount: true }) },\n ),\n },\n ),\n isFormControl.value\n ? h(\"input\", {\n \"ref\": bubbleInput,\n \"type\": \"checkbox\",\n \"aria-hidden\": \"true\",\n \"^checked\": inputDefaultChecked ? \"\" : undefined,\n \"required\": props.required,\n \"disabled\": props.disabled,\n \"name\": props.name,\n \"^value\": props.value ?? \"on\",\n \"form\": form,\n \"tabindex\": -1,\n \"style\": bubbleInputStyle(controlSize.value, { transform: \"translateX(-100%)\" }),\n })\n : null,\n descriptionId\n ? h(\"div\", { class: s.LabelGroup }, [\n labelElement,\n h(\n \"span\",\n { id: descriptionId, class: s.Description },\n slots.description ? slots.description() : props.description,\n ),\n ])\n : labelElement,\n ],\n )\n }\n },\n})\n\ntype CheckboxOwnProps = InstanceType<typeof CheckboxComponent>[\"$props\"]\n\nexport type CheckboxProps = CheckboxOwnProps\n\nexport const Checkbox = CheckboxComponent\n"]}
|
|
1
|
+
{"version":3,"file":"Checkbox.js","sourceRoot":"","sources":["../../../../src/components/Checkbox/Checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,KAAK,CAAA;AAC/F,OAAO,EAAE,iBAAiB,IAAI,qBAAqB,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,SAAS,CAAA;AACtG,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACvH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,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U;wBAClB,aAAa,EAAE,MAAM;wBACrB,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;wBAChD,UAAU,EAAE,KAAK,CAAC,QAAQ;wBAC1B,UAAU,EAAE,KAAK,CAAC,QAAQ;wBAC1B,MAAM,EAAE,KAAK,CAAC,IAAI;wBAClB,QAAQ,EAAE,KAAK,CAAC,KAAK,IAAI,IAAI;wBAC7B,MAAM,EAAE,IAAI;wBACZ,UAAU,EAAE,CAAC,CAAC;wBACd,OAAO,EAAE,gBAAgB,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;qBACjF,CAAC;oBACJ,CAAC,CAAC,IAAI;gBACR,aAAa;oBACX,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,UAAU,EAAE,EAAE;wBAChC,YAAY;wBACZ,CAAC,CACC,MAAM,EACN,EAAE,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,WAAW,EAAE,EAC3C,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAC5D;qBACF,CAAC;oBACJ,CAAC,CAAC,YAAY;aACjB,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAMF,MAAM,CAAC,MAAM,QAAQ,GAAG,iBAAiB,CAAA","sourcesContent":["import { computed, defineComponent, h, onMounted, ref, useId, watch, type PropType } from \"vue\"\nimport { CheckboxIndicator as RekaCheckboxIndicator, CheckboxRoot as RekaCheckboxRoot } from \"reka-ui\"\nimport { bubbleInputStyle, useBubbleInputEffect, useCheckedTracker, useIsFormControl, useSize } from \"./bubbleInput.js\"\nimport { ControlButton, isListener, type Listeners } from \"./ControlButton.js\"\nimport s from \"@plexui/styles/components/Checkbox/Checkbox.module.css\"\nimport { Check, Minus } from \"../Icon/index.js\"\n\n// Vue port of packages/ui/src/components/Checkbox/Checkbox.tsx on Reka UI's\n// Checkbox (state, role, aria-checked, Enter handling, indicator presence).\n// Where Reka's DOM differs from Radix's, Radix's is rendered (see the parity\n// tests): the button carries `value`, no `aria-disabled` and no `aria-label`\n// copied from the label text; the hidden form input is Radix's BubbleInput;\n// the consumer's handlers run before the toggle and can cancel it; a form\n// reset restores the initial state.\n\nexport type CheckedState = boolean | \"indeterminate\"\n\nconst CheckboxComponent = defineComponent({\n name: \"Checkbox\",\n inheritAttrs: false,\n props: {\n /** The `id` of the checkbox. */\n id: String,\n /** The state of the checkbox when it is initially rendered. Use when you do not need to control its state. */\n defaultChecked: { type: [Boolean, String] as PropType<CheckedState>, default: undefined },\n /** The controlled state of the checkbox. Bind with `v-model:checked`. */\n checked: { type: [Boolean, String] as PropType<CheckedState>, default: undefined },\n /** Optional accessible label rendered to the right of the checkbox. The `label` slot takes rich content. */\n label: String,\n /** Optional second line below the label, linked via `aria-describedby`. The `description` slot takes rich content. */\n description: String,\n /** When `true`, prevents the user from interacting with the checkbox. */\n disabled: { type: Boolean, default: false },\n /** When `true`, indicates that the user must check the checkbox before the owning form can be submitted. */\n required: { type: Boolean, default: undefined },\n /** The name of the checkbox. Submitted with its owning form as part of a name/value pair. */\n name: String,\n /** The value given as data when submitted with a `name`. @default \"on\" */\n value: String,\n /** The orientation of the checkbox relative to the label. @default \"left\" */\n orientation: { type: String as PropType<\"left\" | \"right\">, default: \"left\" },\n /** Determines if the checkbox should be a fully rounded pill shape. @default false */\n pill: { type: Boolean, default: false },\n /** Visual style: `\"solid\"` fills the box when checked, `\"ghost\"` shows the checkmark only. @default \"solid\" */\n variant: { type: String as PropType<\"solid\" | \"ghost\">, default: \"solid\" },\n },\n emits: {\n /** The state of the checkbox changed */\n \"update:checked\": (checked: CheckedState) => typeof checked === \"boolean\" || checked === \"indeterminate\",\n /** The checkbox gained focus */\n focus: (event: FocusEvent) => { void event; return true },\n /** The checkbox lost focus */\n blur: (event: FocusEvent) => { void event; return true },\n },\n setup(props, { attrs, slots, emit }) {\n const generatedId = useId()\n const container = ref<HTMLDivElement | null>(null)\n const control = ref<HTMLButtonElement | null>(null)\n const bubbleInput = ref<HTMLInputElement | null>(null)\n useCheckedTracker(bubbleInput)\n\n // Radix's useControllableState: controlled while `checked` is set, and\n // only actual changes are reported\n const internalChecked = ref<CheckedState>(props.defaultChecked ?? false)\n const checked = computed(() => props.checked ?? internalChecked.value)\n // The state a click asks for (Reka's toggle sets it), for the user click\n let requestedChecked = true\n const setChecked = (next: CheckedState) => {\n requestedChecked = next === true\n if (next === checked.value) return\n if (props.checked === undefined) internalChecked.value = next\n emit(\"update:checked\", next)\n }\n\n const initialChecked = checked.value\n const isFormControl = useIsFormControl(control, () => attrs.form)\n const controlSize = useSize(() => (isFormControl.value ? control.value : null))\n const onUserClick = useBubbleInputEffect(bubbleInput, () => checked.value, true)\n\n onMounted(() => {\n control.value = (container.value?.firstElementChild as HTMLButtonElement | null) ?? null\n })\n\n // Like a native checkbox, a form reset restores the initial state\n watch(control, (button, _, onCleanup) => {\n const form = button?.form\n if (!form) return\n const reset = () => setChecked(initialChecked)\n form.addEventListener(\"reset\", reset)\n onCleanup(() => form.removeEventListener(\"reset\", reset))\n })\n\n // In a form, the button's click stops here; the input's click bubbles instead\n const afterClick = (event: Event) => {\n const hasConsumerStoppedPropagation = event.cancelBubble\n onUserClick({ requestedChecked, hasConsumerStoppedPropagation })\n if (bubbleInput.value && isFormControl.value && !hasConsumerStoppedPropagation) event.stopPropagation()\n }\n\n // Prevents text selection when double-clicking the label\n const handleLabelMouseDown = (event: MouseEvent) => {\n if (!event.defaultPrevented && event.detail > 1) event.preventDefault()\n }\n\n return () => {\n const { class: className, form, ...rest } = attrs\n const id = props.id ?? generatedId\n const hasLabel = Boolean(slots.label || props.label)\n // The description only renders next to a label; it comes before any ids\n // the caller (a Field, say) passes\n const descriptionId = hasLabel && (slots.description || props.description) ? `${id}-label-description` : undefined\n const indeterminateDefault = props.defaultChecked === \"indeterminate\" ? false : props.defaultChecked\n const inputDefaultChecked = indeterminateDefault ?? (initialChecked === \"indeterminate\" ? false : initialChecked)\n\n // The consumer's listeners compose with Reka's; other attributes land\n // on the button after the component's own, as `{...restProps}` does\n const listeners: Listeners = {\n onFocus: (event: FocusEvent) => emit(\"focus\", event),\n onBlur: (event: FocusEvent) => emit(\"blur\", event),\n }\n const buttonAttrs: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(rest)) {\n if (isListener(key)) listeners[key] = value\n else buttonAttrs[key] = value\n }\n const ariaDescribedBy =\n [descriptionId, buttonAttrs[\"aria-describedby\"] as string | undefined].filter(Boolean).join(\" \") || undefined\n const labelElement = hasLabel\n ? h(\"label\", { for: id, class: s.Label, onMousedown: handleLabelMouseDown }, slots.label ? slots.label() : props.label)\n : null\n\n return h(\n \"div\",\n {\n \"ref\": container,\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"data-has-label\": hasLabel ? \"\" : undefined,\n \"data-orientation\": props.orientation,\n \"class\": [className, s.Container],\n },\n [\n h(\n RekaCheckboxRoot as never,\n {\n \"asChild\": true,\n \"modelValue\": checked.value,\n \"onUpdate:modelValue\": setChecked,\n \"disabled\": props.disabled,\n // Passed even when unset, so Reka renders no aria-required=\"false\"\n \"required\": props.required,\n },\n {\n default: () =>\n h(\n ControlButton,\n {\n \"listeners\": listeners,\n \"after\": { onClick: afterClick },\n \"class\": s.Checkbox,\n \"id\": id,\n \"data-pill\": props.pill ? \"\" : undefined,\n \"data-variant\": props.variant,\n \"value\": props.value ?? \"on\",\n // Reka marks a disabled checkbox aria-disabled; Radix does not\n \"aria-disabled\": undefined,\n ...buttonAttrs,\n \"aria-describedby\": ariaDescribedBy,\n },\n // Mounted for good: on every uncheck Presence reads computed style, and\n // a long list of boxes cleared at once forces one style pass per box.\n {\n default: () => h(\"span\", { class: s.IndicatorBox, \"aria-hidden\": \"true\" }, [\n // A ghost marks the choice with the PlexUI icons of a list row, not with drawn arms.\n props.variant === \"ghost\"\n ? h(RekaCheckboxIndicator, { class: s.GhostMark, forceMount: true }, {\n default: () => [h(Check, { class: s.GhostCheck }), h(Minus, { class: s.GhostDash })],\n })\n : h(RekaCheckboxIndicator, { class: s.CheckMark, forceMount: true }),\n ]),\n },\n ),\n },\n ),\n isFormControl.value\n ? h(\"input\", {\n \"ref\": bubbleInput,\n \"type\": \"checkbox\",\n \"aria-hidden\": \"true\",\n \"^checked\": inputDefaultChecked ? \"\" : undefined,\n \"required\": props.required,\n \"disabled\": props.disabled,\n \"name\": props.name,\n \"^value\": props.value ?? \"on\",\n \"form\": form,\n \"tabindex\": -1,\n \"style\": bubbleInputStyle(controlSize.value, { transform: \"translateX(-100%)\" }),\n })\n : null,\n descriptionId\n ? h(\"div\", { class: s.LabelGroup }, [\n labelElement,\n h(\n \"span\",\n { id: descriptionId, class: s.Description },\n slots.description ? slots.description() : props.description,\n ),\n ])\n : labelElement,\n ],\n )\n }\n },\n})\n\ntype CheckboxOwnProps = InstanceType<typeof CheckboxComponent>[\"$props\"]\n\nexport type CheckboxProps = CheckboxOwnProps\n\nexport const Checkbox = CheckboxComponent\n"]}
|
|
@@ -48,8 +48,8 @@ const DateInputComponent = defineComponent({
|
|
|
48
48
|
placeholder: String,
|
|
49
49
|
},
|
|
50
50
|
emits: {
|
|
51
|
-
"update:value": (
|
|
52
|
-
"change": (
|
|
51
|
+
"update:value": (value) => value === null || DateTime.isDateTime(value),
|
|
52
|
+
"change": (value) => value === null || DateTime.isDateTime(value),
|
|
53
53
|
},
|
|
54
54
|
setup(props, { attrs, slots, emit, expose }) {
|
|
55
55
|
const hasTime = computed(() => !!props.timeMode);
|
|
@@ -145,10 +145,14 @@ const DateInputComponent = defineComponent({
|
|
|
145
145
|
input: computed(() => inputComponent.value?.input ?? null),
|
|
146
146
|
});
|
|
147
147
|
return () => {
|
|
148
|
-
const {
|
|
148
|
+
const { inputMode, inputmode, ...inputProps } = attrs;
|
|
149
|
+
delete inputProps.onInput;
|
|
150
|
+
delete inputProps.onClear;
|
|
149
151
|
return withDirectives(h(Input,
|
|
150
152
|
// mergeProps keeps the caller's `@blur` and runs it first, as React does
|
|
151
153
|
mergeProps(inputProps, {
|
|
154
|
+
// Accept both native and JSX spelling, without duplicate DOM attributes.
|
|
155
|
+
"inputmode": inputMode ?? inputmode ?? (props.timeMode?.includes("AA") ? "text" : "numeric"),
|
|
152
156
|
"ref": inputComponent,
|
|
153
157
|
"value": inputValue.value,
|
|
154
158
|
"onUpdate:value": (str) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../../../src/components/DateInput/DateInput.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GAKzB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EACL,QAAQ,EACR,eAAe,EACf,CAAC,EACD,UAAU,EACV,eAAe,EACf,SAAS,EACT,GAAG,EACH,KAAK,EACL,cAAc,GAEf,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,KAAK,EAAmB,MAAM,mBAAmB,CAAA;AAE1D,2EAA2E;AAC3E,oEAAoE;AACpE,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1E,+EAA+E;AAC/E,2EAA2E;AAC3E,oDAAoD;AACpD,+DAA+D;AAC/D,0EAA0E;AAC1E,2EAA2E;AAC3E,qCAAqC;AACrC,6EAA6E;AAC7E,gDAAgD;AAChD,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,yCAAyC;AAEzC,MAAM,kBAAkB,GAAG,eAAe,CAAC;IACzC,IAAI,EAAE,WAAW;IACjB,YAAY,EAAE,K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,KAAK;gBACzB,gBAAgB,EAAE,CAAC,GAAW,EAAE,EAAE;oBAChC,UAAU,CAAC,KAAK,GAAG,GAAG,CAAA;gBACxB,CAAC;gBACD,QAAQ,EAAE,UAAU;gBACpB,aAAa,EAAE,KAAK,CAAC,WAAW,IAAI,kBAAkB,CAAC,KAAK;gBAC5D,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;aACrD,CAAC,EACF;gBACE,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzE,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpE,CACF,EACD,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAChC,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAQF,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAwF,CAAA","sourcesContent":["import {\n maskitoDateOptionsGenerator,\n maskitoDateTimeOptionsGenerator,\n maskitoParseDate,\n maskitoParseDateTime,\n maskitoStringifyDate,\n maskitoStringifyDateTime,\n type MaskitoDateMode,\n type MaskitoDateParams,\n type MaskitoDateTimeParams,\n type MaskitoTimeMode,\n} from \"@maskito/kit\"\nimport { maskito as vMaskito } from \"@maskito/vue\"\nimport { DateTime } from \"luxon\"\nimport {\n computed,\n defineComponent,\n h,\n mergeProps,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n withDirectives,\n type PropType,\n} from \"vue\"\nimport { Input, type InputProps } from \"../Input/index.js\"\n\n// Vue port of packages/ui/src/components/DateInput/DateInput.tsx: an Input\n// with a Maskito date (or date + time) mask, same options as React.\n//\n// - `value` + `update:value` (`v-model:value`) and `change` mirror React's\n// `value` + `onChange`: both fire with a Luxon DateTime once a complete\n// valid date is typed, and with `null` when the field is emptied or cleared.\n// What is typed in between stays in the field without an event until the\n// field loses focus, which shows the value again.\n// - Every other attribute, listener and the `startAdornment` /\n// `endAdornment` slots go to Input, like React's `...inputProps`. React\n// sets `onInput` and `onClear` itself, so `@input` and `@clear` given to\n// DateInput are dropped, as there.\n// - The mask is `@maskito/vue`'s directive on Input's container; its default\n// element predicate picks the <input> inside.\n// - React reads the typed text in a listener React delegates to the root, so\n// it runs after Maskito's own `input` listeners on the <input>. The text is\n// read the same way here, from the event bubbling through Input's container.\n// Input's `update:value` only keeps its controlled value in step, so Input\n// does not put the previous text back.\n\nconst DateInputComponent = defineComponent({\n name: \"DateInput\",\n inheritAttrs: false,\n props: {\n /** Selected date (Luxon DateTime). Bind `v-model:value`. */\n value: { type: [Object, null] as PropType<DateTime | null>, required: true as const },\n /** Date format: `dd/mm/yyyy`, `mm/dd/yyyy`, `yyyy/mm/dd`, ... @default \"dd/mm/yyyy\" */\n mode: { type: String as PropType<MaskitoDateMode>, default: \"dd/mm/yyyy\" },\n /** Character between date parts. @default \".\" */\n separator: { type: String, default: \".\" },\n /** Enables time input: `HH:MM`, `HH:MM:SS`, ... */\n timeMode: String as PropType<MaskitoTimeMode>,\n /** Separator between the date and time parts. @default \", \" */\n dateTimeSeparator: { type: String, default: \", \" },\n /** Arrow-key increment step for time segments. @default 0 */\n timeStep: { type: Number, default: 0 },\n /** Earliest allowed date */\n min: Object as PropType<DateTime>,\n /** Latest allowed date */\n max: Object as PropType<DateTime>,\n /** Shows the clear button while the input has a value. @default false */\n clearable: { type: Boolean, default: false },\n /** Generated from the format when not set */\n placeholder: String,\n },\n emits: {\n \"update:value\": (_value: DateTime | null) => true,\n \"change\": (_value: DateTime | null) => true,\n },\n setup(props, { attrs, slots, emit, expose }) {\n const hasTime = computed(() => !!props.timeMode)\n // React memoizes on the dates' milliseconds, not on the DateTime objects\n const minMs = computed(() => props.min?.toMillis())\n const maxMs = computed(() => props.max?.toMillis())\n\n const dateParams = computed<MaskitoDateParams>(() => ({\n mode: props.mode,\n separator: props.separator,\n ...(minMs.value !== undefined ? { min: new Date(minMs.value) } : undefined),\n ...(maxMs.value !== undefined ? { max: new Date(maxMs.value) } : undefined),\n }))\n\n const dateTimeParams = computed<MaskitoDateTimeParams>(() => ({\n dateMode: props.mode,\n dateSeparator: props.separator,\n timeMode: props.timeMode ?? \"HH:MM\",\n dateTimeSeparator: props.dateTimeSeparator,\n ...(props.timeStep ? { timeStep: props.timeStep } : undefined),\n ...(minMs.value !== undefined ? { min: new Date(minMs.value) } : undefined),\n ...(maxMs.value !== undefined ? { max: new Date(maxMs.value) } : undefined),\n }))\n\n // Like React's memo, new options whenever either set of params changes\n const maskOptions = computed(() => {\n const date = dateParams.value\n const dateTime = dateTimeParams.value\n return hasTime.value ? maskitoDateTimeOptionsGenerator(dateTime) : maskitoDateOptionsGenerator(date)\n })\n\n const inputValue = ref(\"\")\n\n const format = (date: DateTime | null) => {\n if (!date) return \"\"\n return hasTime.value\n ? maskitoStringifyDateTime(date.toJSDate(), dateTimeParams.value)\n : maskitoStringifyDate(date.toJSDate(), dateParams.value)\n }\n\n const parse = (str: string) =>\n hasTime.value ? maskitoParseDateTime(str, dateTimeParams.value) : maskitoParseDate(str, dateParams.value)\n\n // React formats the value in an effect: the first render (and the server\n // markup) has an empty field, without the clear button\n const syncInputValue = () => {\n inputValue.value = format(props.value)\n }\n const valueMsKey = computed(() => props.value?.toMillis() ?? null)\n watch([valueMsKey, hasTime, dateParams, dateTimeParams], syncInputValue)\n onMounted(syncInputValue)\n\n const change = (value: DateTime | null) => {\n emit(\"update:value\", value)\n emit(\"change\", value)\n }\n\n const inputComponent = ref<{ $el: HTMLElement; input: HTMLInputElement | null; focus: () => void } | null>(null)\n\n const handleInput = (evt: Event) => {\n const input = inputComponent.value?.input\n if (!input || evt.target !== input) return\n const str = input.value\n inputValue.value = str\n\n if (!str) {\n change(null)\n return\n }\n\n const parsed = parse(str)\n\n if (parsed) {\n change(DateTime.fromJSDate(parsed))\n }\n }\n\n // Text that is not a complete date never reaches `change`, so leaving the\n // field shows the value again instead of a date the value does not hold\n const handleBlur = () => {\n if (inputValue.value && !parse(inputValue.value)) {\n inputValue.value = format(props.value)\n }\n }\n\n const handleClear = () => {\n inputValue.value = \"\"\n change(null)\n }\n\n let container: HTMLElement | null = null\n onMounted(() => {\n container = inputComponent.value?.$el ?? null\n container?.addEventListener(\"input\", handleInput)\n })\n onBeforeUnmount(() => {\n container?.removeEventListener(\"input\", handleInput)\n container = null\n })\n\n const defaultPlaceholder = computed(() => {\n const datePart = props.mode.replace(/\\//g, props.separator).toUpperCase()\n if (!hasTime.value) return datePart\n return `${datePart}${props.dateTimeSeparator}${props.timeMode}`\n })\n\n expose({\n focus: () => inputComponent.value?.focus(),\n input: computed(() => inputComponent.value?.input ?? null),\n })\n\n return () => {\n const { onInput: _onInput, onClear: _onClear, ...inputProps } = attrs\n return withDirectives(\n h(\n Input,\n // mergeProps keeps the caller's `@blur` and runs it first, as React does\n mergeProps(inputProps, {\n \"ref\": inputComponent,\n \"value\": inputValue.value,\n \"onUpdate:value\": (str: string) => {\n inputValue.value = str\n },\n \"onBlur\": handleBlur,\n \"placeholder\": props.placeholder ?? defaultPlaceholder.value,\n \"onClear\": props.clearable ? handleClear : undefined,\n }),\n {\n ...(slots.startAdornment ? { startAdornment: slots.startAdornment } : {}),\n ...(slots.endAdornment ? { endAdornment: slots.endAdornment } : {}),\n },\n ),\n [[vMaskito, maskOptions.value]],\n )\n }\n },\n})\n\ntype DateInputOwnProps = InstanceType<typeof DateInputComponent>[\"$props\"]\n\n/** DateInput props plus the Input props and attributes that fall through to it. */\nexport type DateInputProps = DateInputOwnProps &\n Omit<InputProps, keyof DateInputOwnProps | \"defaultValue\" | \"onUpdate:value\" | \"onInput\" | \"onClear\" | \"type\">\n\n/** Masked text input for typing dates (Luxon DateTime values). */\nexport const DateInput = DateInputComponent as typeof DateInputComponent & { new (): { $props: DateInputProps } }\n"]}
|
|
1
|
+
{"version":3,"file":"DateInput.js","sourceRoot":"","sources":["../../../../src/components/DateInput/DateInput.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,+BAA+B,EAC/B,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GAKzB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAChC,OAAO,EACL,QAAQ,EACR,eAAe,EACf,CAAC,EACD,UAAU,EACV,eAAe,EACf,SAAS,EACT,GAAG,EACH,KAAK,EACL,cAAc,GAEf,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,KAAK,EAAmB,MAAM,mBAAmB,CAAA;AAE1D,2EAA2E;AAC3E,oEAAoE;AACpE,EAAE;AACF,2EAA2E;AAC3E,0EAA0E;AAC1E,+EAA+E;AAC/E,2EAA2E;AAC3E,oDAAoD;AACpD,+DAA+D;AAC/D,0EAA0E;AAC1E,2EAA2E;AAC3E,qCAAqC;AACrC,6EAA6E;AAC7E,gDAAgD;AAChD,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,6EAA6E;AAC7E,yCAAyC;AAEzC,MAAM,kBAAkB,GAAG,eAAe,CAAC;IACzC,IAAI,EAAE,WAAW;IACjB,YAAY,EAAE,KAAK;IACnB,KAAK,EAAE;QACL,4DAA4D;QAC5D,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,CAA8B,EAAE,QAAQ,EAAE,IAAa,EAAE;QACrF,uFAAuF;QACvF,IAAI,EAAE,EAAE,IAAI,EAAE,MAAmC,EAAE,OAAO,EAAE,YAAY,EAAE;QAC1E,iDAAiD;QACjD,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAA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OAAO,EAAE,UAAU,CAAC,KAAK;gBACzB,gBAAgB,EAAE,CAAC,GAAW,EAAE,EAAE;oBAChC,UAAU,CAAC,KAAK,GAAG,GAAG,CAAA;gBACxB,CAAC;gBACD,QAAQ,EAAE,UAAU;gBACpB,aAAa,EAAE,KAAK,CAAC,WAAW,IAAI,kBAAkB,CAAC,KAAK;gBAC5D,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;aACrD,CAAC,EACF;gBACE,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzE,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpE,CACF,EACD,CAAC,CAAC,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAChC,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA;AAQF,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,kBAAwF,CAAA","sourcesContent":["import {\n maskitoDateOptionsGenerator,\n maskitoDateTimeOptionsGenerator,\n maskitoParseDate,\n maskitoParseDateTime,\n maskitoStringifyDate,\n maskitoStringifyDateTime,\n type MaskitoDateMode,\n type MaskitoDateParams,\n type MaskitoDateTimeParams,\n type MaskitoTimeMode,\n} from \"@maskito/kit\"\nimport { maskito as vMaskito } from \"@maskito/vue\"\nimport { DateTime } from \"luxon\"\nimport {\n computed,\n defineComponent,\n h,\n mergeProps,\n onBeforeUnmount,\n onMounted,\n ref,\n watch,\n withDirectives,\n type PropType,\n} from \"vue\"\nimport { Input, type InputProps } from \"../Input/index.js\"\n\n// Vue port of packages/ui/src/components/DateInput/DateInput.tsx: an Input\n// with a Maskito date (or date + time) mask, same options as React.\n//\n// - `value` + `update:value` (`v-model:value`) and `change` mirror React's\n// `value` + `onChange`: both fire with a Luxon DateTime once a complete\n// valid date is typed, and with `null` when the field is emptied or cleared.\n// What is typed in between stays in the field without an event until the\n// field loses focus, which shows the value again.\n// - Every other attribute, listener and the `startAdornment` /\n// `endAdornment` slots go to Input, like React's `...inputProps`. React\n// sets `onInput` and `onClear` itself, so `@input` and `@clear` given to\n// DateInput are dropped, as there.\n// - The mask is `@maskito/vue`'s directive on Input's container; its default\n// element predicate picks the <input> inside.\n// - React reads the typed text in a listener React delegates to the root, so\n// it runs after Maskito's own `input` listeners on the <input>. The text is\n// read the same way here, from the event bubbling through Input's container.\n// Input's `update:value` only keeps its controlled value in step, so Input\n// does not put the previous text back.\n\nconst DateInputComponent = defineComponent({\n name: \"DateInput\",\n inheritAttrs: false,\n props: {\n /** Selected date (Luxon DateTime). Bind `v-model:value`. */\n value: { type: [Object, null] as PropType<DateTime | null>, required: true as const },\n /** Date format: `dd/mm/yyyy`, `mm/dd/yyyy`, `yyyy/mm/dd`, ... @default \"dd/mm/yyyy\" */\n mode: { type: String as PropType<MaskitoDateMode>, default: \"dd/mm/yyyy\" },\n /** Character between date parts. @default \".\" */\n separator: { type: String, default: \".\" },\n /** Enables time input: `HH:MM`, `HH:MM:SS`, ... */\n timeMode: String as PropType<MaskitoTimeMode>,\n /** Separator between the date and time parts. @default \", \" */\n dateTimeSeparator: { type: String, default: \", \" },\n /** Arrow-key increment step for time segments. @default 0 */\n timeStep: { type: Number, default: 0 },\n /** Earliest allowed date */\n min: Object as PropType<DateTime>,\n /** Latest allowed date */\n max: Object as PropType<DateTime>,\n /** Shows the clear button while the input has a value. @default false */\n clearable: { type: Boolean, default: false },\n /** Generated from the format when not set */\n placeholder: String,\n },\n emits: {\n \"update:value\": (value: DateTime | null) => value === null || DateTime.isDateTime(value),\n \"change\": (value: DateTime | null) => value === null || DateTime.isDateTime(value),\n },\n setup(props, { attrs, slots, emit, expose }) {\n const hasTime = computed(() => !!props.timeMode)\n // React memoizes on the dates' milliseconds, not on the DateTime objects\n const minMs = computed(() => props.min?.toMillis())\n const maxMs = computed(() => props.max?.toMillis())\n\n const dateParams = computed<MaskitoDateParams>(() => ({\n mode: props.mode,\n separator: props.separator,\n ...(minMs.value !== undefined ? { min: new Date(minMs.value) } : undefined),\n ...(maxMs.value !== undefined ? { max: new Date(maxMs.value) } : undefined),\n }))\n\n const dateTimeParams = computed<MaskitoDateTimeParams>(() => ({\n dateMode: props.mode,\n dateSeparator: props.separator,\n timeMode: props.timeMode ?? \"HH:MM\",\n dateTimeSeparator: props.dateTimeSeparator,\n ...(props.timeStep ? { timeStep: props.timeStep } : undefined),\n ...(minMs.value !== undefined ? { min: new Date(minMs.value) } : undefined),\n ...(maxMs.value !== undefined ? { max: new Date(maxMs.value) } : undefined),\n }))\n\n // Like React's memo, new options whenever either set of params changes\n const maskOptions = computed(() => {\n const date = dateParams.value\n const dateTime = dateTimeParams.value\n return hasTime.value ? maskitoDateTimeOptionsGenerator(dateTime) : maskitoDateOptionsGenerator(date)\n })\n\n const inputValue = ref(\"\")\n\n const format = (date: DateTime | null) => {\n if (!date) return \"\"\n return hasTime.value\n ? maskitoStringifyDateTime(date.toJSDate(), dateTimeParams.value)\n : maskitoStringifyDate(date.toJSDate(), dateParams.value)\n }\n\n const parse = (str: string) =>\n hasTime.value ? maskitoParseDateTime(str, dateTimeParams.value) : maskitoParseDate(str, dateParams.value)\n\n // React formats the value in an effect: the first render (and the server\n // markup) has an empty field, without the clear button\n const syncInputValue = () => {\n inputValue.value = format(props.value)\n }\n const valueMsKey = computed(() => props.value?.toMillis() ?? null)\n watch([valueMsKey, hasTime, dateParams, dateTimeParams], syncInputValue)\n onMounted(syncInputValue)\n\n const change = (value: DateTime | null) => {\n emit(\"update:value\", value)\n emit(\"change\", value)\n }\n\n const inputComponent = ref<{ $el: HTMLElement; input: HTMLInputElement | null; focus: () => void } | null>(null)\n\n const handleInput = (evt: Event) => {\n const input = inputComponent.value?.input\n if (!input || evt.target !== input) return\n const str = input.value\n inputValue.value = str\n\n if (!str) {\n change(null)\n return\n }\n\n const parsed = parse(str)\n\n if (parsed) {\n change(DateTime.fromJSDate(parsed))\n }\n }\n\n // Text that is not a complete date never reaches `change`, so leaving the\n // field shows the value again instead of a date the value does not hold\n const handleBlur = () => {\n if (inputValue.value && !parse(inputValue.value)) {\n inputValue.value = format(props.value)\n }\n }\n\n const handleClear = () => {\n inputValue.value = \"\"\n change(null)\n }\n\n let container: HTMLElement | null = null\n onMounted(() => {\n container = inputComponent.value?.$el ?? null\n container?.addEventListener(\"input\", handleInput)\n })\n onBeforeUnmount(() => {\n container?.removeEventListener(\"input\", handleInput)\n container = null\n })\n\n const defaultPlaceholder = computed(() => {\n const datePart = props.mode.replace(/\\//g, props.separator).toUpperCase()\n if (!hasTime.value) return datePart\n return `${datePart}${props.dateTimeSeparator}${props.timeMode}`\n })\n\n expose({\n focus: () => inputComponent.value?.focus(),\n input: computed(() => inputComponent.value?.input ?? null),\n })\n\n return () => {\n const { inputMode, inputmode, ...inputProps } = attrs\n delete inputProps.onInput\n delete inputProps.onClear\n return withDirectives(\n h(\n Input,\n // mergeProps keeps the caller's `@blur` and runs it first, as React does\n mergeProps(inputProps, {\n // Accept both native and JSX spelling, without duplicate DOM attributes.\n \"inputmode\": inputMode ?? inputmode ?? (props.timeMode?.includes(\"AA\") ? \"text\" : \"numeric\"),\n \"ref\": inputComponent,\n \"value\": inputValue.value,\n \"onUpdate:value\": (str: string) => {\n inputValue.value = str\n },\n \"onBlur\": handleBlur,\n \"placeholder\": props.placeholder ?? defaultPlaceholder.value,\n \"onClear\": props.clearable ? handleClear : undefined,\n }),\n {\n ...(slots.startAdornment ? { startAdornment: slots.startAdornment } : {}),\n ...(slots.endAdornment ? { endAdornment: slots.endAdornment } : {}),\n },\n ),\n [[vMaskito, maskOptions.value]],\n )\n }\n },\n})\n\ntype DateInputOwnProps = InstanceType<typeof DateInputComponent>[\"$props\"]\n\n/** DateInput props plus the Input props and attributes that fall through to it. */\nexport type DateInputProps = DateInputOwnProps &\n Omit<InputProps, keyof DateInputOwnProps | \"defaultValue\" | \"onUpdate:value\" | \"onInput\" | \"onClear\" | \"type\">\n\n/** Masked text input for typing dates (Luxon DateTime values). */\nexport const DateInput = DateInputComponent as typeof DateInputComponent & { new (): { $props: DateInputProps } }\n"]}
|