frontile 0.18.0-beta.0 → 0.18.0-beta.2
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/declarations/-private/deprecated-args.d.ts +18 -0
- package/declarations/-private/notification.d.ts +4 -4
- package/declarations/-private/types.d.ts +10 -8
- package/declarations/components/buttons/button-group.d.ts +3 -1
- package/declarations/components/buttons/button.d.ts +12 -3
- package/declarations/components/buttons/chip.d.ts +15 -8
- package/declarations/components/buttons/close-button.d.ts +5 -2
- package/declarations/components/buttons/segmented-control/segmented-control.d.ts +9 -9
- package/declarations/components/buttons/toggle-button.d.ts +9 -1
- package/declarations/components/collections/calendar/calendar.d.ts +49 -49
- package/declarations/components/collections/calendar/utils.d.ts +1 -0
- package/declarations/components/collections/dropdown/dropdown.d.ts +13 -2
- package/declarations/components/collections/dropdown/menu-context.d.ts +3 -3
- package/declarations/components/collections/listbox/group.d.ts +7 -2
- package/declarations/components/collections/listbox/item.d.ts +27 -6
- package/declarations/components/collections/listbox/listbox.d.ts +31 -4
- package/declarations/components/collections/simple-table/body.d.ts +72 -72
- package/declarations/components/collections/simple-table/cell.d.ts +72 -72
- package/declarations/components/collections/simple-table/column.d.ts +72 -72
- package/declarations/components/collections/simple-table/footer.d.ts +72 -72
- package/declarations/components/collections/simple-table/header.d.ts +72 -72
- package/declarations/components/collections/simple-table/index.d.ts +84 -72
- package/declarations/components/collections/simple-table/row.d.ts +72 -72
- package/declarations/components/collections/table/column-visibility.d.ts +72 -72
- package/declarations/components/collections/table/sort-button.d.ts +72 -72
- package/declarations/components/collections/table/table.d.ts +73 -72
- package/declarations/components/disclosure/accordion/accordion.d.ts +23 -23
- package/declarations/components/forms/autocomplete.d.ts +24 -12
- package/declarations/components/forms/date-picker/date-picker.d.ts +268 -0
- package/declarations/components/forms/date-picker/end-content.d.ts +29 -0
- package/declarations/components/forms/date-picker/trigger.d.ts +40 -0
- package/declarations/components/forms/date-picker/types.d.ts +149 -0
- package/declarations/components/forms/date-picker/value.d.ts +43 -0
- package/declarations/components/forms/date-picker.d.ts +3 -0
- package/declarations/components/forms/field.d.ts +5 -0
- package/declarations/components/forms/form-control.d.ts +1 -1
- package/declarations/components/forms/form-feedback.d.ts +17 -2
- package/declarations/components/forms/icons.d.ts +4 -1
- package/declarations/components/forms/index.d.ts +2 -0
- package/declarations/components/forms/input.d.ts +10 -10
- package/declarations/components/forms/native-select.d.ts +7 -7
- package/declarations/components/forms/select/select.d.ts +30 -17
- package/declarations/components/forms/select/trigger.d.ts +5 -3
- package/declarations/components/forms/select/types.d.ts +42 -12
- package/declarations/components/forms/switch.d.ts +22 -18
- package/declarations/components/forms/textarea.d.ts +6 -6
- package/declarations/components/navigation/pagination/pagination.d.ts +21 -20
- package/declarations/components/navigation/tab-nav/tab-nav.d.ts +12 -12
- package/declarations/components/navigation/tabs/tabs.d.ts +12 -12
- package/declarations/components/notifications/index.d.ts +2 -2
- package/declarations/components/notifications/notification-card.d.ts +5 -5
- package/declarations/components/notifications/notifications-container.d.ts +2 -2
- package/declarations/components/overlays/drawer.d.ts +32 -32
- package/declarations/components/overlays/popover.d.ts +1 -1
- package/declarations/components/overlays/tooltip.d.ts +2 -2
- package/declarations/components/status/alert.d.ts +10 -10
- package/declarations/components/status/progress-bar.d.ts +5 -1
- package/declarations/components/utilities/kbd.d.ts +4 -4
- package/declarations/components/utilities/spinner.d.ts +14 -7
- package/declarations/index.d.ts +1 -1
- package/declarations/template-registry.d.ts +2 -1
- package/declarations/test-support.d.ts +22 -0
- package/declarations/utils/selection-indicator.d.ts +4 -0
- package/dist/components/buttons/button-group.js +26 -1
- package/dist/components/buttons/button-group.js.map +1 -1
- package/dist/components/buttons/button.js +23 -4
- package/dist/components/buttons/button.js.map +1 -1
- package/dist/components/buttons/chip.js +20 -3
- package/dist/components/buttons/chip.js.map +1 -1
- package/dist/components/buttons/close-button.js +18 -2
- package/dist/components/buttons/close-button.js.map +1 -1
- package/dist/components/buttons/segmented-control/item.js +1 -1
- package/dist/components/buttons/segmented-control/item.js.map +1 -1
- package/dist/components/buttons/segmented-control/segmented-control.js +2 -2
- package/dist/components/buttons/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/buttons/toggle-button.js +37 -3
- package/dist/components/buttons/toggle-button.js.map +1 -1
- package/dist/components/collections/calendar/calendar.js +43 -6
- package/dist/components/collections/calendar/calendar.js.map +1 -1
- package/dist/components/collections/calendar/day-cell.js +1 -1
- package/dist/components/collections/calendar/day-cell.js.map +1 -1
- package/dist/components/collections/calendar/header.js +1 -1
- package/dist/components/collections/calendar/header.js.map +1 -1
- package/dist/components/collections/calendar/month-grid.js +1 -1
- package/dist/components/collections/calendar/month-grid.js.map +1 -1
- package/dist/components/collections/calendar/utils.js +1 -1
- package/dist/components/collections/calendar/utils.js.map +1 -1
- package/dist/components/collections/calendar/year-grid.js +15 -3
- package/dist/components/collections/calendar/year-grid.js.map +1 -1
- package/dist/components/collections/command/command.js +1 -1
- package/dist/components/collections/command/command.js.map +1 -1
- package/dist/components/collections/command/dialog.js +1 -1
- package/dist/components/collections/command/dialog.js.map +1 -1
- package/dist/components/collections/command/footer.js +3 -3
- package/dist/components/collections/command/footer.js.map +1 -1
- package/dist/components/collections/command/input.js +1 -1
- package/dist/components/collections/command/input.js.map +1 -1
- package/dist/components/collections/command/list.js +1 -1
- package/dist/components/collections/command/list.js.map +1 -1
- package/dist/components/collections/dropdown/dropdown.js +45 -7
- package/dist/components/collections/dropdown/dropdown.js.map +1 -1
- package/dist/components/collections/dropdown/menu-context.js.map +1 -1
- package/dist/components/collections/listbox/group.js +1 -1
- package/dist/components/collections/listbox/group.js.map +1 -1
- package/dist/components/collections/listbox/item.js +47 -8
- package/dist/components/collections/listbox/item.js.map +1 -1
- package/dist/components/collections/listbox/listbox.js +53 -2
- package/dist/components/collections/listbox/listbox.js.map +1 -1
- package/dist/components/collections/simple-table/body.js +1 -1
- package/dist/components/collections/simple-table/body.js.map +1 -1
- package/dist/components/collections/simple-table/cell.js +1 -1
- package/dist/components/collections/simple-table/cell.js.map +1 -1
- package/dist/components/collections/simple-table/column.js +1 -1
- package/dist/components/collections/simple-table/column.js.map +1 -1
- package/dist/components/collections/simple-table/footer.js +1 -1
- package/dist/components/collections/simple-table/footer.js.map +1 -1
- package/dist/components/collections/simple-table/header.js +1 -1
- package/dist/components/collections/simple-table/header.js.map +1 -1
- package/dist/components/collections/simple-table/index.js +5 -3
- package/dist/components/collections/simple-table/index.js.map +1 -1
- package/dist/components/collections/simple-table/row.js +1 -1
- package/dist/components/collections/simple-table/row.js.map +1 -1
- package/dist/components/collections/table/checkbox.js +1 -1
- package/dist/components/collections/table/checkbox.js.map +1 -1
- package/dist/components/collections/table/column-visibility.js +1 -1
- package/dist/components/collections/table/column-visibility.js.map +1 -1
- package/dist/components/collections/table/sort-button.js +1 -1
- package/dist/components/collections/table/sort-button.js.map +1 -1
- package/dist/components/collections/table/table.js +7 -3
- package/dist/components/collections/table/table.js.map +1 -1
- package/dist/components/disclosure/accordion/accordion.js +3 -2
- package/dist/components/disclosure/accordion/accordion.js.map +1 -1
- package/dist/components/disclosure/accordion/item.js +1 -1
- package/dist/components/disclosure/accordion/item.js.map +1 -1
- package/dist/components/forms/autocomplete.js +47 -2
- package/dist/components/forms/autocomplete.js.map +1 -1
- package/dist/components/forms/checkbox-group.js +1 -1
- package/dist/components/forms/checkbox-group.js.map +1 -1
- package/dist/components/forms/checkbox.js +1 -1
- package/dist/components/forms/checkbox.js.map +1 -1
- package/dist/components/forms/date-picker/date-picker.js +301 -0
- package/dist/components/forms/date-picker/date-picker.js.map +1 -0
- package/dist/components/forms/date-picker/end-content.js +21 -0
- package/dist/components/forms/date-picker/end-content.js.map +1 -0
- package/dist/components/forms/date-picker/trigger.js +14 -0
- package/dist/components/forms/date-picker/trigger.js.map +1 -0
- package/dist/components/forms/date-picker/types.js +2 -0
- package/dist/components/forms/date-picker/types.js.map +1 -0
- package/dist/components/forms/date-picker/value.js +97 -0
- package/dist/components/forms/date-picker/value.js.map +1 -0
- package/dist/components/forms/date-picker.js +2 -0
- package/dist/components/forms/date-picker.js.map +1 -0
- package/dist/components/forms/field.js +3 -1
- package/dist/components/forms/field.js.map +1 -1
- package/dist/components/forms/form-control.js +1 -1
- package/dist/components/forms/form-control.js.map +1 -1
- package/dist/components/forms/form-description.js +1 -1
- package/dist/components/forms/form-description.js.map +1 -1
- package/dist/components/forms/form-feedback.js +26 -3
- package/dist/components/forms/form-feedback.js.map +1 -1
- package/dist/components/forms/icons.js +4 -1
- package/dist/components/forms/icons.js.map +1 -1
- package/dist/components/forms/index.js +2 -0
- package/dist/components/forms/index.js.map +1 -1
- package/dist/components/forms/input-otp.js +1 -1
- package/dist/components/forms/input-otp.js.map +1 -1
- package/dist/components/forms/input.js +1 -1
- package/dist/components/forms/input.js.map +1 -1
- package/dist/components/forms/label.js +1 -1
- package/dist/components/forms/label.js.map +1 -1
- package/dist/components/forms/native-select.js +2 -2
- package/dist/components/forms/native-select.js.map +1 -1
- package/dist/components/forms/radio-group.js +1 -1
- package/dist/components/forms/radio-group.js.map +1 -1
- package/dist/components/forms/radio.js +1 -1
- package/dist/components/forms/radio.js.map +1 -1
- package/dist/components/forms/select/end-content.js +1 -1
- package/dist/components/forms/select/end-content.js.map +1 -1
- package/dist/components/forms/select/select.js +61 -7
- package/dist/components/forms/select/select.js.map +1 -1
- package/dist/components/forms/select/selected-items.js +1 -1
- package/dist/components/forms/select/selected-items.js.map +1 -1
- package/dist/components/forms/select/trigger.js +6 -4
- package/dist/components/forms/select/trigger.js.map +1 -1
- package/dist/components/forms/switch.js +10 -2
- package/dist/components/forms/switch.js.map +1 -1
- package/dist/components/forms/textarea.js +1 -1
- package/dist/components/forms/textarea.js.map +1 -1
- package/dist/components/navigation/external-link.js +2 -2
- package/dist/components/navigation/external-link.js.map +1 -1
- package/dist/components/navigation/pagination/pagination.js +2 -2
- package/dist/components/navigation/pagination/pagination.js.map +1 -1
- package/dist/components/navigation/tab-nav/item.js +1 -1
- package/dist/components/navigation/tab-nav/item.js.map +1 -1
- package/dist/components/navigation/tab-nav/tab-nav.js +2 -2
- package/dist/components/navigation/tab-nav/tab-nav.js.map +1 -1
- package/dist/components/navigation/tabs/panel.js +1 -1
- package/dist/components/navigation/tabs/panel.js.map +1 -1
- package/dist/components/navigation/tabs/tab.js +1 -1
- package/dist/components/navigation/tabs/tab.js.map +1 -1
- package/dist/components/navigation/tabs/tabs.js +3 -3
- package/dist/components/navigation/tabs/tabs.js.map +1 -1
- package/dist/components/notifications/index.js +2 -2
- package/dist/components/notifications/notification-card.js +1 -1
- package/dist/components/notifications/notifications-container.js +2 -2
- package/dist/components/notifications/notifications-container.js.map +1 -1
- package/dist/components/overlays/drawer/body.js +1 -1
- package/dist/components/overlays/drawer/body.js.map +1 -1
- package/dist/components/overlays/drawer/drag-handle.js +1 -1
- package/dist/components/overlays/drawer/drag-handle.js.map +1 -1
- package/dist/components/overlays/drawer/footer.js +1 -1
- package/dist/components/overlays/drawer/footer.js.map +1 -1
- package/dist/components/overlays/drawer/header.js +4 -4
- package/dist/components/overlays/drawer/header.js.map +1 -1
- package/dist/components/overlays/drawer.js +4 -4
- package/dist/components/overlays/drawer.js.map +1 -1
- package/dist/components/overlays/modal/body.js +1 -1
- package/dist/components/overlays/modal/body.js.map +1 -1
- package/dist/components/overlays/modal/footer.js +1 -1
- package/dist/components/overlays/modal/footer.js.map +1 -1
- package/dist/components/overlays/modal/header.js +1 -1
- package/dist/components/overlays/modal/header.js.map +1 -1
- package/dist/components/overlays/modal.js +1 -1
- package/dist/components/overlays/modal.js.map +1 -1
- package/dist/components/overlays/overlay.js +1 -1
- package/dist/components/overlays/overlay.js.map +1 -1
- package/dist/components/overlays/popover.js.map +1 -1
- package/dist/components/overlays/tooltip.js +14 -2
- package/dist/components/overlays/tooltip.js.map +1 -1
- package/dist/components/status/alert.js +19 -15
- package/dist/components/status/alert.js.map +1 -1
- package/dist/components/status/progress-bar.js +10 -2
- package/dist/components/status/progress-bar.js.map +1 -1
- package/dist/components/utilities/avatar.js +1 -1
- package/dist/components/utilities/avatar.js.map +1 -1
- package/dist/components/utilities/divider.js +1 -1
- package/dist/components/utilities/divider.js.map +1 -1
- package/dist/components/utilities/kbd.js +3 -3
- package/dist/components/utilities/kbd.js.map +1 -1
- package/dist/components/utilities/skeleton.js +1 -1
- package/dist/components/utilities/skeleton.js.map +1 -1
- package/dist/components/utilities/spinner.js +26 -7
- package/dist/components/utilities/spinner.js.map +1 -1
- package/dist/deprecated-args-BIUjLA8y.js +32 -0
- package/dist/deprecated-args-BIUjLA8y.js.map +1 -0
- package/dist/forms.js +2 -0
- package/dist/forms.js.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/{manager-CDIZzrQ9.js → manager-B-PnYqDs.js} +28 -22
- package/dist/manager-B-PnYqDs.js.map +1 -0
- package/dist/{notification-card-D5fd-Sxa.js → notification-card-CYmWQ35W.js} +25 -22
- package/dist/notification-card-CYmWQ35W.js.map +1 -0
- package/dist/notifications.js +2 -2
- package/dist/services/notifications.js +1 -1
- package/dist/test-support.js +40 -2
- package/dist/test-support.js.map +1 -1
- package/dist/utils/selection-indicator.js +30 -2
- package/dist/utils/selection-indicator.js.map +1 -1
- package/package.json +3 -3
- package/dist/manager-CDIZzrQ9.js.map +0 -1
- package/dist/notification-card-D5fd-Sxa.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","sources":["../../../src/components/buttons/button.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { modifier } from 'ember-modifier';\nimport type { TOC } from '@ember/component/template-only';\nimport { useStyles } from '@frontile/theme';\nimport { press, type PressEvent } from '../../modifiers/press';\nimport { Spinner } from '../utilities/spinner';\n\n/**\n * Sets `disabled` on the element while `loading` is true, restoring whatever\n * the consumer had before. This is a modifier rather than a plain attribute\n * because splattributes are applied last: `disabled={{@isLoading}}` written\n * before `...attributes` is clobbered by a consumer's own `disabled`, and\n * written after it a consumer's `disabled={{false}}` would erase ours.\n * Modifiers run after attributes, so neither ordering problem applies.\n *\n * Known limitation: this re-runs only when `loading` changes, so `previous`\n * is a snapshot taken once at install time — it goes stale if the consumer's\n * own `disabled` binding changes while loading is already in flight, in\n * either direction:\n *\n * - true → false: Glimmer rewrites the attribute to `false`, we do not\n * re-run, so the button stays disabled (from our own `el.disabled = true`)\n * until loading ends and teardown restores the stale `previous` (`false`),\n * which happens to match — net: the button goes live at the same moment,\n * with the disabling outliving the intent for no visible reason.\n * - false → true: Glimmer rewrites the attribute to `true`, we do not\n * re-run, so `previous` is left holding the stale `false`. When loading\n * ends, teardown restores `previous` and sets `disabled = false` — the\n * button ends up enabled even though the consumer's binding says\n * `disabled={{true}}`. This is a fail-open: the consumer's disable is\n * silently and indefinitely lost. See the\n * `'known limitation: a consumer disable applied mid-load is lost when\n * loading ends'` test in buttons-test.gts, which pins this exact case.\n *\n * Closing this would need a MutationObserver watching `disabled` for a case\n * nobody has hit; the project has decided not to add one.\n */\nconst disableWhile = modifier((el: HTMLButtonElement, [loading]: [boolean]) => {\n if (!loading) {\n return;\n }\n\n const previous = el.disabled;\n el.disabled = true;\n\n return () => {\n el.disabled = previous;\n };\n});\n\n/**\n * The spinner stands in for the icon while loading, on whichever side\n * `@iconPlacement` puts it. Extracted so the spinner-or-icon choice is written\n * once; the caller passes the icon through as this component's default block.\n *\n * The invocation below is still written twice, once per side, and that is\n * deliberate: the block contains `{{yield to=\"icon\"}}`, and Glimmer has no way\n * to hoist a block-yielding invocation into a `{{#let}}` or a helper. Only the\n * choice was deduplicated, not the two call sites.\n */\nconst SpinnerOrIcon: TOC<{\n Args: {\n isLoading: boolean;\n spinnerClass: string;\n };\n Blocks: {\n default: [];\n };\n}> = <template>\n {{#if @isLoading}}\n <Spinner @class={{@spinnerClass}} data-test-id=\"loading-spinner\" />\n {{else}}\n {{yield}}\n {{/if}}\n</template>;\n\nexport interface ButtonArgs {\n /**\n * The HTML type of the button\n *\n * @defaultValue 'button'\n */\n type?: 'button' | 'submit' | 'reset';\n\n /**\n * The button appearance\n *\n * @defaultValue 'default'\n */\n appearance?: 'default' | 'soft' | 'outlined' | 'minimal' | 'tonal' | 'custom';\n\n /**\n * The intent of the button\n */\n intent?:\n | 'default'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n /**\n * The size of the button\n */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n\n /**\n * Disable rendering the button element. It yields an object with classNames instead.\n */\n isRenderless?: boolean;\n\n /**\n * Custom class name, it will override the default ones using Tailwind Merge library.\n */\n class?: string;\n\n /**\n * If button is part of a group. Most of the time, this is automatically set\n * when using the ButtonGroup component.\n */\n isInGroup?: boolean;\n\n /**\n * Renders a spinner in place of the icon and disables the button.\n *\n * @defaultValue false\n */\n isLoading?: boolean;\n\n /**\n * Which side the `icon` block — and the loading spinner that replaces it —\n * sits on.\n *\n * @defaultValue 'start'\n */\n iconPlacement?: 'start' | 'end';\n\n /**\n * Callback for when the button is pressed.\n */\n onPress?: (event: PressEvent) => void;\n}\n\ninterface ButtonSignature {\n Args: ButtonArgs;\n Blocks: {\n default: [{ classNames: string; isLoading: boolean }];\n icon?: [];\n loading?: [];\n };\n Element: HTMLButtonElement;\n}\n\nclass Button extends Component<ButtonSignature> {\n @tracked isPressed = false;\n\n get type(): string {\n if (this.args.type) {\n return this.args.type;\n }\n return 'button';\n }\n\n get isLoading(): boolean {\n return this.args.isLoading === true;\n }\n\n get isIconAtEnd(): boolean {\n return this.args.iconPlacement === 'end';\n }\n\n get isIconAtStart(): boolean {\n return !this.isIconAtEnd;\n }\n\n @cached\n get classNames(): string {\n const { button } = useStyles();\n\n return button({\n intent: this.args.intent || 'default',\n size: this.args.size,\n appearance: this.args.appearance || 'default',\n isInGroup: this.args.isInGroup,\n isLoading: this.isLoading,\n class: this.args.class\n });\n }\n\n @cached\n get spinnerClassNames(): string {\n const { buttonSpinner } = useStyles();\n\n return buttonSpinner();\n }\n\n /**\n * The object yielded to the default block (and, when `@isRenderless`, in\n * place of rendering). Hoisted so the shape is written once — it's part of\n * this component's public contract, asserted on directly by tests.\n */\n @cached\n get yieldedHash(): { classNames: string; isLoading: boolean } {\n return { classNames: this.classNames, isLoading: this.isLoading };\n }\n\n handlePressChange = (isPressed: boolean): void => {\n this.isPressed = isPressed;\n };\n\n onPress = (event: PressEvent) => {\n if (typeof this.args.onPress === 'function') {\n this.args.onPress(event);\n }\n };\n\n <template>\n {{#if @isRenderless}}\n {{yield this.yieldedHash}}\n {{else}}\n <button\n type={{this.type}}\n class={{this.classNames}}\n aria-busy={{if this.isLoading \"true\"}}\n data-loading={{if this.isLoading \"true\"}}\n data-pressed={{if this.isPressed \"true\"}}\n {{press this.onPress onPressChange=this.handlePressChange}}\n ...attributes\n {{disableWhile this.isLoading}}\n >\n {{#if this.isIconAtStart}}\n <SpinnerOrIcon\n @isLoading={{this.isLoading}}\n @spinnerClass={{this.spinnerClassNames}}\n >\n {{yield to=\"icon\"}}\n </SpinnerOrIcon>\n {{/if}}\n\n {{#if this.isLoading}}\n {{#if (has-block \"loading\")}}\n {{yield to=\"loading\"}}\n {{else}}\n {{yield this.yieldedHash}}\n {{/if}}\n {{else}}\n {{yield this.yieldedHash}}\n {{/if}}\n\n {{#if this.isIconAtEnd}}\n <SpinnerOrIcon\n @isLoading={{this.isLoading}}\n @spinnerClass={{this.spinnerClassNames}}\n >\n {{yield to=\"icon\"}}\n </SpinnerOrIcon>\n {{/if}}\n </button>\n {{/if}}\n </template>\n}\n\nexport { Button, type ButtonSignature };\nexport default Button;\n"],"names":["disableWhile","modifier","el","loading","previous","disabled","SpinnerOrIcon","setComponentTemplate","precompileTemplate","strictMode","scope","Spinner","templateOnly","Button","Component","g","prototype","tracked","i","type","args","isLoading","isIconAtEnd","iconPlacement","isIconAtStart","classNames","button","useStyles","intent","size","appearance","isInGroup","class","n","cached","spinnerClassNames","buttonSpinner","yieldedHash","hand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AI,OAAO,IAAI,CAACrB,IAAI,CAACoB,OAAO,KAAK,UAAA,EAAY;AAC3C,MAAA,IAAI,CAACpB,IAAI,CAACoB,OAAO,CAACC,KAAA,CAAA;AACpB,IAAA;EACF,CAAA;AAEA,EAAA;IAAAlC,oBAAA,CAAAC,kBAAA,CAAA,o+BAAA,EA2CA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAgC,KAAA;QAAA1C,YAAA;AAAAM,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
1
|
+
{"version":3,"file":"button.js","sources":["../../../src/components/buttons/button.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { modifier } from 'ember-modifier';\nimport type { TOC } from '@ember/component/template-only';\nimport { useStyles } from '@frontile/theme';\nimport { press, type PressEvent } from '../../modifiers/press';\nimport { Spinner } from '../utilities/spinner';\nimport { renamedArgValue } from '../../-private/deprecated-args';\n\n/**\n * Sets `disabled` on the element while `loading` is true, restoring whatever\n * the consumer had before. This is a modifier rather than a plain attribute\n * because splattributes are applied last: `disabled={{@isLoading}}` written\n * before `...attributes` is clobbered by a consumer's own `disabled`, and\n * written after it a consumer's `disabled={{false}}` would erase ours.\n * Modifiers run after attributes, so neither ordering problem applies.\n *\n * Known limitation: this re-runs only when `loading` changes, so `previous`\n * is a snapshot taken once at install time — it goes stale if the consumer's\n * own `disabled` binding changes while loading is already in flight, in\n * either direction:\n *\n * - true → false: Glimmer rewrites the attribute to `false`, we do not\n * re-run, so the button stays disabled (from our own `el.disabled = true`)\n * until loading ends and teardown restores the stale `previous` (`false`),\n * which happens to match — net: the button goes live at the same moment,\n * with the disabling outliving the intent for no visible reason.\n * - false → true: Glimmer rewrites the attribute to `true`, we do not\n * re-run, so `previous` is left holding the stale `false`. When loading\n * ends, teardown restores `previous` and sets `disabled = false` — the\n * button ends up enabled even though the consumer's binding says\n * `disabled={{true}}`. This is a fail-open: the consumer's disable is\n * silently and indefinitely lost. See the\n * `'known limitation: a consumer disable applied mid-load is lost when\n * loading ends'` test in buttons-test.gts, which pins this exact case.\n *\n * Closing this would need a MutationObserver watching `disabled` for a case\n * nobody has hit; the project has decided not to add one.\n */\nconst disableWhile = modifier((el: HTMLButtonElement, [loading]: [boolean]) => {\n if (!loading) {\n return;\n }\n\n const previous = el.disabled;\n el.disabled = true;\n\n return () => {\n el.disabled = previous;\n };\n});\n\n/**\n * The spinner stands in for the icon while loading, on whichever side\n * `@iconPlacement` puts it. Extracted so the spinner-or-icon choice is written\n * once; the caller passes the icon through as this component's default block.\n *\n * The invocation below is still written twice, once per side, and that is\n * deliberate: the block contains `{{yield to=\"icon\"}}`, and Glimmer has no way\n * to hoist a block-yielding invocation into a `{{#let}}` or a helper. Only the\n * choice was deduplicated, not the two call sites.\n */\nconst SpinnerOrIcon: TOC<{\n Args: {\n isLoading: boolean;\n spinnerClass: string;\n };\n Blocks: {\n default: [];\n };\n}> = <template>\n {{#if @isLoading}}\n <Spinner @class={{@spinnerClass}} />\n {{else}}\n {{yield}}\n {{/if}}\n</template>;\n\nexport interface ButtonArgs {\n /**\n * The HTML type of the button\n *\n * @defaultValue 'button'\n */\n type?: 'button' | 'submit' | 'reset';\n\n /**\n * The button variant.\n *\n * @defaultValue 'solid'\n */\n variant?:\n 'solid' | 'soft' | 'subtle' | 'outline' | 'ghost' | 'plain' | 'custom';\n\n /**\n * @deprecated Use `variant`. `default` is now `solid`, `outlined` is\n * `outline`, and `minimal` is `plain`.\n */\n appearance?: 'default' | 'soft' | 'outlined' | 'minimal' | 'tonal' | 'custom';\n\n /**\n * The color of the button\n */\n color?:\n | 'neutral'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n /**\n * @deprecated Use `color`. `default` is now `neutral`.\n */\n intent?:\n | 'default'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n /**\n * The size of the button\n */\n size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';\n\n /**\n * Disable rendering the button element. It yields an object with classNames instead.\n */\n isRenderless?: boolean;\n\n /**\n * Custom class name, it will override the default ones using Tailwind Merge library.\n */\n class?: string;\n\n /**\n * If button is part of a group. Most of the time, this is automatically set\n * when using the ButtonGroup component.\n */\n isInGroup?: boolean;\n\n /**\n * Renders a spinner in place of the icon and disables the button.\n *\n * @defaultValue false\n */\n isLoading?: boolean;\n\n /**\n * Which side the `icon` block — and the loading spinner that replaces it —\n * sits on.\n *\n * @defaultValue 'start'\n */\n iconPlacement?: 'start' | 'end';\n\n /**\n * Callback for when the button is pressed.\n */\n onPress?: (event: PressEvent) => void;\n}\n\ninterface ButtonSignature {\n Args: ButtonArgs;\n Blocks: {\n default: [{ classNames: string; isLoading: boolean }];\n icon?: [];\n loading?: [];\n };\n Element: HTMLButtonElement;\n}\n\nclass Button extends Component<ButtonSignature> {\n @tracked isPressed = false;\n\n get type(): string {\n if (this.args.type) {\n return this.args.type;\n }\n return 'button';\n }\n\n get isLoading(): boolean {\n return this.args.isLoading === true;\n }\n\n get isIconAtEnd(): boolean {\n return this.args.iconPlacement === 'end';\n }\n\n get isIconAtStart(): boolean {\n return !this.isIconAtEnd;\n }\n\n @cached\n get classNames(): string {\n const { button } = useStyles();\n\n return button({\n color:\n renamedArgValue(\n this.args.color,\n this.args.intent,\n { default: 'neutral' } as const,\n {\n component: 'Button',\n from: 'intent',\n to: 'color',\n id: 'frontile.button.intent'\n }\n ) || 'neutral',\n size: this.args.size,\n variant:\n renamedArgValue(\n this.args.variant,\n this.args.appearance,\n {\n default: 'solid',\n outlined: 'outline',\n minimal: 'plain',\n soft: 'subtle',\n tonal: 'soft'\n } as const,\n {\n component: 'Button',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.button.appearance'\n }\n ) || 'solid',\n isInGroup: this.args.isInGroup,\n isLoading: this.isLoading,\n class: this.args.class\n });\n }\n\n @cached\n get spinnerClassNames(): string {\n const { buttonSpinner } = useStyles();\n\n return buttonSpinner();\n }\n\n /**\n * The object yielded to the default block (and, when `@isRenderless`, in\n * place of rendering). Hoisted so the shape is written once — it's part of\n * this component's public contract, asserted on directly by tests.\n */\n @cached\n get yieldedHash(): { classNames: string; isLoading: boolean } {\n return { classNames: this.classNames, isLoading: this.isLoading };\n }\n\n handlePressChange = (isPressed: boolean): void => {\n this.isPressed = isPressed;\n };\n\n onPress = (event: PressEvent) => {\n if (typeof this.args.onPress === 'function') {\n this.args.onPress(event);\n }\n };\n\n <template>\n {{#if @isRenderless}}\n {{yield this.yieldedHash}}\n {{else}}\n <button\n type={{this.type}}\n class={{this.classNames}}\n aria-busy={{if this.isLoading \"true\"}}\n data-loading={{if this.isLoading \"true\"}}\n data-pressed={{if this.isPressed \"true\"}}\n data-component=\"button\"\n data-part=\"base\"\n {{press this.onPress onPressChange=this.handlePressChange}}\n ...attributes\n {{disableWhile this.isLoading}}\n >\n {{#if this.isIconAtStart}}\n <SpinnerOrIcon\n @isLoading={{this.isLoading}}\n @spinnerClass={{this.spinnerClassNames}}\n >\n {{yield to=\"icon\"}}\n </SpinnerOrIcon>\n {{/if}}\n\n {{#if this.isLoading}}\n {{#if (has-block \"loading\")}}\n {{yield to=\"loading\"}}\n {{else}}\n {{yield this.yieldedHash}}\n {{/if}}\n {{else}}\n {{yield this.yieldedHash}}\n {{/if}}\n\n {{#if this.isIconAtEnd}}\n <SpinnerOrIcon\n @isLoading={{this.isLoading}}\n @spinnerClass={{this.spinnerClassNames}}\n >\n {{yield to=\"icon\"}}\n </SpinnerOrIcon>\n {{/if}}\n </button>\n {{/if}}\n </template>\n}\n\nexport { Button, type ButtonSignature };\nexport default Button;\n"],"names":["disableWhile","modifier","el","loading","previous","disabled","SpinnerOrIcon","setComponentTemplate","precompileTemplate","strictMode","scope","Spinner","templateOnly","Button","Component","g","prototype","tracked","i","type","args","isLoading","isIconAtEnd","iconPlacement","isIconAtStart","classNames","button","useStyles","color","renamedArgValue","intent","default","component","from","to","id","size","variant","appearance","outlined","minimal","soft","tonal","isInGroup","class","n","cached","spinnerClassNames","buttonSpinner","yieldedHash","handlePressChange","isPressed","onPress","event","press"],"mappings":";;;;;;;;;;;;AAuCA,MAAMA,eAAeC,QAAA,CAAS,CAACC,EAAI,EAAmB,CAACC,OAAA,CAAmB,KAAA;EACxE,IAAI,CAACA,OAAA,EAAS;AACZ,IAAA;AACF,EAAA;AAEA,EAAA,MAAMC,QAAA,GAAWF,GAAGG,QAAQ;EAC5BH,EAAA,CAAGG,QAAQ,GAAG,IAAA;AAEd,EAAA,OAAO,MAAA;IACLH,EAAA,CAAGG,QAAQ,GAAGD,QAAA;EAChB,CAAA;AACF,CAAA,CAAA;AAEA;;;;;;;;;AASC;AACD,MAAME,aAQD,GAAAC,oBAAA,CAAAC,kBAAA,CAAA,4FAAA,EAML;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA,CAAA;AAoGV,MAAMC,eAAeC,SAAA,CAAU;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,WAAA,EAAA,CAC5BC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAoB,KAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,UAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,WAAA,CAAA,EAAA,MAAA;EAErB,IAAIC,IAAAA,GAAe;AACjB,IAAA,IAAI,IAAI,CAACC,IAAI,CAACD,IAAI,EAAE;AAClB,MAAA,OAAO,IAAI,CAACC,IAAI,CAACD,IAAI;AACvB,IAAA;AACA,IAAA,OAAO,QAAA;AACT,EAAA;EAEA,IAAIE,SAAAA,GAAqB;AACvB,IAAA,OAAO,IAAI,CAACD,IAAI,CAACC,SAAS,KAAK,IAAA;AACjC,EAAA;EAEA,I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AA;AAAA,EAAA;IAAAC,gBAAA,CAAA,IAAA,CAAA7B,SAAA,EAAA,YAAA,EAAA,CAxCC8B,MAAA,CAAA,CAAA;AAAA;EA0CD,IACIC,iBAAAA,GAA4B;IAC9B,MAAM;AAAEC,MAAAA;KAAe,GAAGrB,SAAA,EAAA;IAE1B,OAAOqB,aAAA,EAAA;AACT,EAAA;AAEA;;;;AAIC;AAJD,EAAA;IAAAH,gBAAA,CAAA,IAAA,CAAA7B,SAAA,EAAA,mBAAA,EAAA,CAPC8B,MAAA,CAAA,CAAA;AAAA;EAYD,IACIG,WAAAA,GAA0D;IAC5D,OAAO;MAAExB,UAAA,EAAY,IAAI,CAACA,UAAU;MAAEJ,SAAA,EAAW,IAAI,CAACA;KAAU;AAClE,EAAA;AAAA,EAAA;IAAAwB,gBAAA,CAAA,IAAA,CAAA7B,SAAA,EAAA,aAAA,EAAA,CAHC8B,MAAA,CAAA,CAAA;AAAA;EAKDI,iBAAA,GAAqBC,SAAkB,IAAO;IAC5C,IAAI,CAACA,SAAS,GAAGA,SAAA;EACnB,CAAA;EAEAC,OAAA,GAAWC,KAAO,IAAA;IAChB,IAAI,OAAO,IAAI,CAACjC,IAAI,CAACgC,OAAO,KAAK,UAAA,EAAY;AAC3C,MAAA,IAAI,CAAChC,IAAI,CAACgC,OAAO,CAACC,KAAA,CAAA;AACpB,IAAA;EACF,CAAA;AAEA,EAAA;IAAA9C,oBAAA,CAAAC,kBAAA,CAAA,ihCAAA,EA6CA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAA4C,KAAA;QAAAtD,YAAA;AAAAM,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { useStyles } from '@frontile/theme';
|
|
3
3
|
import { CloseButton } from './close-button.js';
|
|
4
|
+
import { r as renamedArgValue } from '../../deprecated-args-BIUjLA8y.js';
|
|
4
5
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
5
6
|
import { setComponentTemplate } from '@ember/component';
|
|
6
7
|
|
|
@@ -15,9 +16,25 @@ class Chip extends Component {
|
|
|
15
16
|
dot,
|
|
16
17
|
closeButton
|
|
17
18
|
} = chip({
|
|
18
|
-
|
|
19
|
+
color: renamedArgValue(this.args.color, this.args.intent, {
|
|
20
|
+
default: 'neutral'
|
|
21
|
+
}, {
|
|
22
|
+
component: 'Chip',
|
|
23
|
+
from: 'intent',
|
|
24
|
+
to: 'color',
|
|
25
|
+
id: 'frontile.chip.intent'
|
|
26
|
+
}) || 'neutral',
|
|
19
27
|
size: this.args.size,
|
|
20
|
-
|
|
28
|
+
variant: renamedArgValue(this.args.variant, this.args.appearance, {
|
|
29
|
+
default: 'solid',
|
|
30
|
+
outlined: 'outline',
|
|
31
|
+
faded: 'soft'
|
|
32
|
+
}, {
|
|
33
|
+
component: 'Chip',
|
|
34
|
+
from: 'appearance',
|
|
35
|
+
to: 'variant',
|
|
36
|
+
id: 'frontile.chip.appearance'
|
|
37
|
+
}) || 'solid',
|
|
21
38
|
radius: this.args.radius,
|
|
22
39
|
isDisabled: this.args.isDisabled
|
|
23
40
|
});
|
|
@@ -31,7 +48,7 @@ class Chip extends Component {
|
|
|
31
48
|
};
|
|
32
49
|
}
|
|
33
50
|
static {
|
|
34
|
-
setComponentTemplate(precompileTemplate("<div class={{this.classNames.base}} ...attributes>\n {{#if @withDot}}\n <span class={{this.classNames.dot}}></span>\n {{/if}}\n <span class={{this.classNames.content}}>\n {{yield}}\n </span>\n {{#if @onClose}}\n <CloseButton @class={{this.classNames.closeButton}} @title={{@closeButtonTitle}} @onPress={{@onClose}} tabindex={{@closeButtonTabIndex}} disabled={{@isDisabled}} />\n {{/if}}\n</div>", {
|
|
51
|
+
setComponentTemplate(precompileTemplate("<div class={{this.classNames.base}} data-component=\"chip\" data-part=\"base\" ...attributes>\n {{#if @withDot}}\n <span class={{this.classNames.dot}} data-part=\"dot\"></span>\n {{/if}}\n <span class={{this.classNames.content}} data-part=\"content\">\n {{yield}}\n </span>\n {{#if @onClose}}\n <CloseButton @class={{this.classNames.closeButton}} @title={{@closeButtonTitle}} @onPress={{@onClose}} tabindex={{@closeButtonTabIndex}} disabled={{@isDisabled}} data-part=\"close-button\" />\n {{/if}}\n</div>", {
|
|
35
52
|
strictMode: true,
|
|
36
53
|
scope: () => ({
|
|
37
54
|
CloseButton
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.js","sources":["../../../src/components/buttons/chip.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles } from '@frontile/theme';\nimport { CloseButton } from './close-button';\n\ninterface ChipSignature {\n Args: {\n /**\n * The chip
|
|
1
|
+
{"version":3,"file":"chip.js","sources":["../../../src/components/buttons/chip.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles } from '@frontile/theme';\nimport { CloseButton } from './close-button';\nimport { renamedArgValue } from '../../-private/deprecated-args';\n\ninterface ChipSignature {\n Args: {\n /**\n * The chip variant.\n *\n * @defaultValue 'solid'\n */\n variant?: 'solid' | 'outline' | 'soft';\n\n /**\n * @deprecated Use `variant`. `default` is now `solid`, `outlined` is\n * `outline`, and `faded` is `soft`.\n */\n appearance?: 'default' | 'outlined' | 'faded';\n\n /**\n * The color of the chip.\n */\n color?:\n | 'neutral'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n /**\n * @deprecated Use `color`. `default` is now `neutral`.\n */\n intent?:\n | 'default'\n | 'primary'\n | 'secondary'\n | 'tertiary'\n | 'success'\n | 'warning'\n | 'danger';\n\n /**\n * The size of the chip\n *\n * @defaultValue 'md'\n */\n size?: 'sm' | 'md' | 'lg';\n\n /**\n * The border radius of the chip\n *\n * @defaultValue 'full'\n */\n radius?: 'none' | 'sm' | 'lg' | 'full';\n\n /**\n * Adds a dot before the content, colored by `@color`. On the `solid`\n * variant the dot takes the chip's text color, since the chip's\n * background is already the chip's color.\n *\n * @defaultValue false\n */\n withDot?: boolean;\n\n /**\n * Function to be called when clicking on the close button.\n * If you pass this argument, the close button will be visible.\n */\n onClose?: () => void;\n\n /**\n * The accessible name of the close button. Every close button would\n * otherwise be announced as just \"Close\", which does not say *what* is\n * being removed — worth setting when several chips sit together.\n *\n * @defaultValue 'Close'\n */\n closeButtonTitle?: string;\n\n /**\n * `tabindex` for the close button.\n *\n * Set to `-1` when chips sit inside another control (a multi-select field,\n * say) and the close button should stay a pointer affordance: every chip\n * would otherwise cost a Tab stop before the control itself is reached.\n * Whoever does this owes keyboard users another way to remove a chip.\n *\n * @defaultValue undefined (the close button is a normal tab stop)\n */\n closeButtonTabIndex?: number | string;\n\n /**\n * Dims the chip and disables its close button, if any.\n *\n * @defaultValue false\n */\n isDisabled?: boolean;\n\n /**\n * Custom class name, it will override the default ones using Tailwind Merge library.\n */\n class?: string;\n };\n Blocks: {\n default: [];\n };\n Element: HTMLDivElement;\n}\n\nclass Chip extends Component<ChipSignature> {\n get classNames() {\n const { chip } = useStyles();\n\n const { base, content, dot, closeButton } = chip({\n color:\n renamedArgValue(\n this.args.color,\n this.args.intent,\n { default: 'neutral' } as const,\n {\n component: 'Chip',\n from: 'intent',\n to: 'color',\n id: 'frontile.chip.intent'\n }\n ) || 'neutral',\n size: this.args.size,\n variant:\n renamedArgValue(\n this.args.variant,\n this.args.appearance,\n { default: 'solid', outlined: 'outline', faded: 'soft' } as const,\n {\n component: 'Chip',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.chip.appearance'\n }\n ) || 'solid',\n radius: this.args.radius,\n isDisabled: this.args.isDisabled\n });\n\n return {\n base: base({ class: this.args.class }),\n content: content(),\n dot: dot(),\n closeButton: closeButton()\n };\n }\n\n <template>\n <div\n class={{this.classNames.base}}\n data-component=\"chip\"\n data-part=\"base\"\n ...attributes\n >\n {{#if @withDot}}\n <span class={{this.classNames.dot}} data-part=\"dot\"></span>\n {{/if}}\n <span class={{this.classNames.content}} data-part=\"content\">\n {{yield}}\n </span>\n {{#if @onClose}}\n <CloseButton\n @class={{this.classNames.closeButton}}\n @title={{@closeButtonTitle}}\n @onPress={{@onClose}}\n tabindex={{@closeButtonTabIndex}}\n disabled={{@isDisabled}}\n data-part=\"close-button\"\n />\n {{/if}}\n </div>\n </template>\n}\n\nexport { Chip, type ChipSignature };\nexport default Chip;\n"],"names":["Chip","Component","classNames","chip","useStyles","base","content","dot","closeButton","color","renamedArgValue","args","intent","default","component","from","to","id","size","variant","appearance","outlined","faded","radius","isDisabled","class","setComponentTemplate","precompileTemplate","strictMode","scope","CloseButton"],"mappings":";;;;;;;AAgHA,MAAMA,aAAaC,SAAA,CAAU;EAC3B,IAAIC,UAAAA,GAAa;IACf,MAAM;AAAEC,MAAAA;KAAM,GAAGC,SAAA,EAAA;IAEjB,MAAM;MAAEC,IAAI;MAAEC,OAAO;MAAEC,GAAG;AAAEC,MAAAA;KAAa,GAAGL,IAAA,CAAK;AAC/CM,MAAAA,KAAA,EACEC,eAAA,CACE,IAAI,CAACC,IAAI,CAACF,KAAK,EACf,IAAI,CAACE,IAAI,CAACC,MAAM,EAChB;AAAEC,QAAAA,OAAA,EAAS;AAAU,OAAA,EACrB;AACEC,QAAAA,SAAA,EAAW,MAAA;AACXC,QAAAA,IAAA,EAAM,QAAA;AACNC,QAAAA,EAAA,EAAI,OAAA;AACJC,QAAAA,EAAA,EAAI;OACN,CAAA,IACG,SAAA;AACPC,MAAAA,IAAA,EAAM,IAAI,CAACP,IAAI,CAACO,IAAI;AACpBC,MAAAA,OAAA,EACET,eAAA,CACE,IAAI,CAACC,IAAI,CAACQ,OAAO,EACjB,IAAI,CAACR,IAAI,CAACS,UAAU,EACpB;AAAEP,QAAAA,OAAA,EAAS,OAAA;AAASQ,QAAAA,QAAA,EAAU,SAAA;AAAWC,QAAAA,KAAA,EAAO;AAAO,OAAA,EACvD;AACER,QAAAA,SAAA,EAAW,MAAA;AACXC,QAAAA,IAAA,EAAM,YAAA;AACNC,QAAAA,EAAA,EAAI,SAAA;AACJC,QAAAA,EAAA,EAAI;OACN,CAAA,IACG,OAAA;AACPM,MAAAA,MAAA,EAAQ,IAAI,CAACZ,IAAI,CAACY,MAAM;AACxBC,MAAAA,UAAA,EAAY,IAAI,CAACb,IAAI,CAACa;AACxB,KAAA,CAAA;IAEA,OAAO;MACLnB,IAAA,EAAMA,IAAA,CAAK;AAAEoB,QAAAA,KAAA,EAAO,IAAI,CAACd,IAAI,CAACc;AAAM,OAAA,CAAA;MACpCnB,OAAA,EAASA,OAAA,EAAA;MACTC,GAAA,EAAKA,GAAA,EAAA;MACLC,WAAA,EAAaA,WAAA;KACf;AACF,EAAA;AAEA,EAAA;IAAAkB,oBAAA,CAAAC,kBAAA,CAAA,ygBAAA,EAwBA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -31,6 +31,22 @@ class CloseButton extends Component {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
get variant() {
|
|
35
|
+
const legacy = this.args.variant;
|
|
36
|
+
if (legacy === 'transparent' || legacy === 'subtle') {
|
|
37
|
+
deprecate(`CloseButton: \`@variant="${legacy}"\` is deprecated. Use \`@variant="${legacy === 'transparent' ? 'ghost' : 'soft'}"\`.`, false, {
|
|
38
|
+
id: 'frontile.close-button.variant-values',
|
|
39
|
+
until: '0.19.0',
|
|
40
|
+
for: 'frontile',
|
|
41
|
+
since: {
|
|
42
|
+
available: '0.18.0',
|
|
43
|
+
enabled: '0.18.0'
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return legacy === 'transparent' ? 'ghost' : 'soft';
|
|
47
|
+
}
|
|
48
|
+
return legacy ?? 'ghost';
|
|
49
|
+
}
|
|
34
50
|
get classes() {
|
|
35
51
|
const {
|
|
36
52
|
closeButton
|
|
@@ -40,7 +56,7 @@ class CloseButton extends Component {
|
|
|
40
56
|
icon
|
|
41
57
|
} = closeButton({
|
|
42
58
|
size: this.args.size || 'md',
|
|
43
|
-
variant: this.
|
|
59
|
+
variant: this.variant
|
|
44
60
|
});
|
|
45
61
|
return {
|
|
46
62
|
base: base({
|
|
@@ -69,7 +85,7 @@ class CloseButton extends Component {
|
|
|
69
85
|
decorateMethodV2(this.prototype, "handleClick", [action]);
|
|
70
86
|
}
|
|
71
87
|
static {
|
|
72
|
-
setComponentTemplate(precompileTemplate("<button type=\"button\" class={{this.classes.base}} data-pressed={{if this.isPressed \"true\"}} ...attributes {{press this.handlePress onPressChange=this.handlePressChange}} {{on \"click\" this.handleClick}}>\n\n {{#if (has-block)}}\n {{yield this.classes.icon}}\n {{else}}\n <svg class={{this.classes.icon}} aria-hidden=\"true\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"></path>\n </svg>\n {{/if}}\n\n <VisuallyHidden>\n {{if @title @title \"Close\"}}\n </VisuallyHidden>\n</button>", {
|
|
88
|
+
setComponentTemplate(precompileTemplate("<button type=\"button\" class={{this.classes.base}} data-pressed={{if this.isPressed \"true\"}} data-component=\"close-button\" data-part=\"base\" ...attributes {{press this.handlePress onPressChange=this.handlePressChange}} {{on \"click\" this.handleClick}}>\n\n {{#if (has-block)}}\n {{yield this.classes.icon}}\n {{else}}\n <svg class={{this.classes.icon}} data-part=\"icon\" aria-hidden=\"true\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"></path>\n </svg>\n {{/if}}\n\n <VisuallyHidden>\n {{if @title @title \"Close\"}}\n </VisuallyHidden>\n</button>", {
|
|
73
89
|
strictMode: true,
|
|
74
90
|
scope: () => ({
|
|
75
91
|
press,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"close-button.js","sources":["../../../src/components/buttons/close-button.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\nimport { on } from '@ember/modifier';\nimport { deprecate } from '@ember/debug';\nimport { VisuallyHidden } from '../utilities/visually-hidden';\nimport { press, type PressEvent } from '../../modifiers/press';\nimport { useStyles, type CloseButtonVariants } from '@frontile/theme';\nimport type Owner from '@ember/owner';\n\ninterface CloseButtonSignature {\n Args: {\n /**\n * The title of the close button\n *\n * @defaultValue 'Close'\n */\n title?: string;\n\n /**\n * The icon size\n *\n * @defaultValue 'lg'\n */\n size?: CloseButtonVariants['size'];\n\n /**\n * @defaultValue '
|
|
1
|
+
{"version":3,"file":"close-button.js","sources":["../../../src/components/buttons/close-button.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { action } from '@ember/object';\nimport { tracked } from '@glimmer/tracking';\nimport { on } from '@ember/modifier';\nimport { deprecate } from '@ember/debug';\nimport { VisuallyHidden } from '../utilities/visually-hidden';\nimport { press, type PressEvent } from '../../modifiers/press';\nimport { useStyles, type CloseButtonVariants } from '@frontile/theme';\nimport type Owner from '@ember/owner';\n\ninterface CloseButtonSignature {\n Args: {\n /**\n * The title of the close button\n *\n * @defaultValue 'Close'\n */\n title?: string;\n\n /**\n * The icon size\n *\n * @defaultValue 'lg'\n */\n size?: CloseButtonVariants['size'];\n\n /**\n * @defaultValue 'ghost'\n *\n * `transparent` and `subtle` are @deprecated — use `ghost` and `soft` instead.\n */\n variant?: 'ghost' | 'soft' | 'transparent' | 'subtle';\n\n /**\n * The function to call when button is pressed\n */\n onPress?: (event: PressEvent) => void;\n\n /**\n * Deprecated: The function to call when button is clicked\n *\n * @deprecated Use onPress instead for better cross-platform support\n */\n onClick?: (event: Event) => void;\n\n /**\n * Additional class for close button element\n */\n class?: string;\n };\n Blocks: {\n default: [string | null];\n };\n Element: HTMLButtonElement;\n}\n\nclass CloseButton extends Component<CloseButtonSignature> {\n @tracked isPressed = false;\n\n constructor(owner: Owner, args: CloseButtonSignature['Args']) {\n super(owner, args);\n\n if (args.onClick) {\n deprecate(\n 'CloseButton: onClick is deprecated. Use onPress instead for better cross-platform support including touch, keyboard, and screen reader interactions.',\n false,\n {\n id: 'frontile.close-button.onClick',\n until: '0.18.0',\n for: 'frontile',\n since: { available: '0.17.0', enabled: '0.17.0' }\n }\n );\n }\n }\n\n get variant(): 'ghost' | 'soft' {\n const legacy = this.args.variant;\n\n if (legacy === 'transparent' || legacy === 'subtle') {\n deprecate(\n `CloseButton: \\`@variant=\"${legacy}\"\\` is deprecated. Use \\`@variant=\"${legacy === 'transparent' ? 'ghost' : 'soft'}\"\\`.`,\n false,\n {\n id: 'frontile.close-button.variant-values',\n until: '0.19.0',\n for: 'frontile',\n since: { available: '0.18.0', enabled: '0.18.0' }\n }\n );\n\n return legacy === 'transparent' ? 'ghost' : 'soft';\n }\n\n return legacy ?? 'ghost';\n }\n\n get classes() {\n const { closeButton } = useStyles();\n\n let { base, icon } = closeButton({\n size: this.args.size || 'md',\n variant: this.variant\n });\n\n return {\n base: base({ class: this.args.class }),\n icon: icon()\n };\n }\n\n handlePressChange = (isPressed: boolean): void => {\n this.isPressed = isPressed;\n };\n\n @action handlePress(event: PressEvent): void {\n if (typeof this.args.onPress === 'function') {\n this.args.onPress(event);\n }\n }\n\n @action handleClick(event: Event): void {\n if (typeof this.args.onClick === 'function') {\n this.args.onClick(event);\n }\n }\n\n <template>\n <button\n type=\"button\"\n class={{this.classes.base}}\n data-pressed={{if this.isPressed \"true\"}}\n data-component=\"close-button\"\n data-part=\"base\"\n ...attributes\n {{press this.handlePress onPressChange=this.handlePressChange}}\n {{on \"click\" this.handleClick}}\n >\n\n {{#if (has-block)}}\n {{yield this.classes.icon}}\n {{else}}\n <svg\n class={{this.classes.icon}}\n data-part=\"icon\"\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"2\"\n d=\"M6 18L18 6M6 6l12 12\"\n ></path>\n </svg>\n {{/if}}\n\n <VisuallyHidden>\n {{if @title @title \"Close\"}}\n </VisuallyHidden>\n </button>\n </template>\n}\n\nexport { CloseButton, type CloseButtonSignature };\nexport default CloseButton;\n"],"names":["CloseButton","Component","g","prototype","tracked","i","constructor","owner","args","onClick","deprecate","id","until","for","since","available","enabled","variant","legacy","classes","closeButton","useStyles","base","icon","size","class","handlePressChange","isPressed","handlePress","event","onPress","n","action","handleClick","setComponentTemplate","precompileTemplate","strictMode","scope","press","on","VisuallyHidden"],"mappings":";;;;;;;;;;;;AAwDA,MAAMA,oBAAoBC,SAAA,CAAU;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,WAAA,EAAA,CACjCC,OAAA,CAAA,EAAA,YAAA;AAAA,MAAA,OAAoB,KAAA;AAAA,IAAA,CAAA,CAAA;AAAA;EAAA,UAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,WAAA,CAAA,EAAA,MAAA;AAErBC,EAAAA,WAAAA,CAAYC,KAAY,EAAEC,IAAkC,EAAE;AAC5D,IAAA,KAAK,CAACD,KAAA,EAAOC,IAAA,CAAA;IAEb,IAAIA,IAAA,CAAKC,OAAO,EAAE;AAChBC,MAAAA,SAAA,CACE,wJACA,KAAA,EACA;AACEC,QAAAA,EAAA,EAAI,+BAAA;AACJC,QAAAA,KAAA,EAAO,QAAA;AACPC,QAAAA,GAAA,EAAK,UAAA;AACLC,QAAAA,KAAA,EAAO;AAAEC,UAAAA,SAAA,EAAW,QAAA;AAAUC,UAAAA,OAAA,EAAS;AAAS;AAClD,OAAA,CAAA;AAEJ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I,CAACsB,OAAO,KAAK,UAAA,EAAY;AAC3C,MAAA,IAAI,CAACtB,IAAI,CAACsB,OAAO,CAACD,KAAA,CAAA;AACpB,IAAA;AACF,EAAA;AAAA,EAAA;IAAAE,gBAAA,CAAA,IAAA,CAAA5B,SAAA,EAAA,aAAA,EAAA,CAJC6B,MAAA,CAAA,CAAA;AAAA;EAMOC,WAAAA,CAAYJ,KAAY,EAAQ;IACtC,IAAI,OAAO,IAAI,CAACrB,IAAI,CAACC,OAAO,KAAK,UAAA,EAAY;AAC3C,MAAA,IAAI,CAACD,IAAI,CAACC,OAAO,CAACoB,KAAA,CAAA;AACpB,IAAA;AACF,EAAA;AAAA,EAAA;IAAAE,gBAAA,CAAA,IAAA,CAAA5B,SAAA,EAAA,aAAA,EAAA,CAJC6B,MAAA,CAAA,CAAA;AAAA;AAMD,EAAA;IAAAE,oBAAA,CAAAC,kBAAA,CAAA,kuBAAA,EAqCA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,KAAA;QAAAC,EAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -40,7 +40,7 @@ class SegmentedControlItem extends Component {
|
|
|
40
40
|
this.args.context.requestFormSync();
|
|
41
41
|
};
|
|
42
42
|
static {
|
|
43
|
-
setComponentTemplate(precompileTemplate("{{#if @context.name}}\n {{!-- Form mode. Native radios bring their own arrow-key and focus\n behaviour for a same-named group, so RovingFocus deliberately stands\n down here rather than fighting the browser for control. --}}\n <label class=\"{{@context.itemClass}} {{@class}}\" data-selected=\"{{this.isSelected}}\" data-disabled=\"{{this.isDisabled}}\" {{@context.indicator.setupTarget this.isSelected}} ...attributes>\n <input type=\"radio\" name={{@context.name}} value={{this.stringValue}} checked={{this.isSelected}} disabled={{this.isDisabled}} class=\"sr-only\" {{this.registerValue @value}} {{on \"change\" this.handleChange}} />\n {{yield (hash isSelected=this.isSelected)}}\n </label>\n{{else}}\n <button type=\"button\" role=\"radio\" aria-checked=\"{{this.isSelected}}\" disabled={{this.isDisabled}} class=\"{{@context.itemClass}} {{@class}}\" data-selected=\"{{this.isSelected}}\" data-disabled=\"{{this.isDisabled}}\" {{this.registerValue @value}} {{@context.indicator.setupTarget this.isSelected}} {{@context.roving.setupItem}} {{press this.handleClick}} ...attributes>\n {{yield (hash isSelected=this.isSelected)}}\n </button>\n{{/if}}", {
|
|
43
|
+
setComponentTemplate(precompileTemplate("{{#if @context.name}}\n {{!-- Form mode. Native radios bring their own arrow-key and focus\n behaviour for a same-named group, so RovingFocus deliberately stands\n down here rather than fighting the browser for control. --}}\n <label data-part=\"item\" class=\"{{@context.itemClass}} {{@class}}\" data-selected=\"{{this.isSelected}}\" data-disabled=\"{{this.isDisabled}}\" {{@context.indicator.setupTarget this.isSelected}} ...attributes>\n <input type=\"radio\" name={{@context.name}} value={{this.stringValue}} checked={{this.isSelected}} disabled={{this.isDisabled}} class=\"sr-only\" {{this.registerValue @value}} {{on \"change\" this.handleChange}} />\n {{yield (hash isSelected=this.isSelected)}}\n </label>\n{{else}}\n <button type=\"button\" role=\"radio\" data-part=\"item\" aria-checked=\"{{this.isSelected}}\" disabled={{this.isDisabled}} class=\"{{@context.itemClass}} {{@class}}\" data-selected=\"{{this.isSelected}}\" data-disabled=\"{{this.isDisabled}}\" {{this.registerValue @value}} {{@context.indicator.setupTarget this.isSelected}} {{@context.roving.setupItem}} {{press this.handleClick}} ...attributes>\n {{yield (hash isSelected=this.isSelected)}}\n </button>\n{{/if}}", {
|
|
44
44
|
strictMode: true,
|
|
45
45
|
scope: () => ({
|
|
46
46
|
on,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sources":["../../../../src/components/buttons/segmented-control/item.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { press } from '../../../modifiers/press';\nimport { modifier } from 'ember-modifier';\nimport type { SegmentedControlContext } from './segmented-control';\n\ninterface SegmentedControlItemArgs<T> {\n /**\n * The value this item represents. Selecting it calls the control's\n * `@onChange` with exactly this value.\n */\n value: T;\n\n /**\n * Disables this item alone: it cannot be clicked and keyboard navigation\n * skips over it. The whole control can be disabled with the control's own\n * `@isDisabled`.\n *\n * @defaultValue false\n */\n isDisabled?: boolean;\n\n /** Class names appended to this item's theme classes. */\n class?: string;\n\n /**\n * Supplied by SegmentedControl. Not part of the public API.\n *\n * @internal\n */\n context: SegmentedControlContext<T>;\n}\n\ninterface SegmentedControlItemSignature<T> {\n Args: SegmentedControlItemArgs<T>;\n Blocks: {\n default: [{ isSelected: boolean }];\n };\n Element: HTMLButtonElement | HTMLLabelElement;\n}\n\nclass SegmentedControlItem<T> extends Component<\n SegmentedControlItemSignature<T>\n> {\n get isSelected(): boolean {\n return this.args.context.isSelected(this.args.value);\n }\n\n get isDisabled(): boolean {\n return this.args.isDisabled || this.args.context.isGroupDisabled;\n }\n\n registerValue = modifier((element: HTMLElement, [value]: [T]) => {\n this.args.context.registerValue(element, value);\n\n return (): void => {\n this.args.context.unregisterValue(element);\n };\n });\n\n handleClick = (): void => {\n if (this.isDisabled) {\n return;\n }\n this.args.context.select(this.args.value);\n };\n\n get stringValue(): string {\n return String(this.args.value);\n }\n\n handleChange = (): void => {\n if (this.isDisabled) {\n return;\n }\n this.args.context.select(this.args.value);\n\n // The browser has already moved checkedness in the DOM. Ask the control to\n // re-assert the whole group from `@value` once the consumer has had its\n // chance to respond, so a declined (or absent) `@onChange` cannot leave the\n // native state disagreeing with the rendered selection.\n this.args.context.requestFormSync();\n };\n\n <template>\n {{#if @context.name}}\n {{! Form mode. Native radios bring their own arrow-key and focus\n behaviour for a same-named group, so RovingFocus deliberately stands\n down here rather than fighting the browser for control. }}\n <label\n class=\"{{@context.itemClass}} {{@class}}\"\n data-selected=\"{{this.isSelected}}\"\n data-disabled=\"{{this.isDisabled}}\"\n {{@context.indicator.setupTarget this.isSelected}}\n ...attributes\n >\n <input\n type=\"radio\"\n name={{@context.name}}\n value={{this.stringValue}}\n checked={{this.isSelected}}\n disabled={{this.isDisabled}}\n class=\"sr-only\"\n {{this.registerValue @value}}\n {{on \"change\" this.handleChange}}\n />\n {{yield (hash isSelected=this.isSelected)}}\n </label>\n {{else}}\n <button\n type=\"button\"\n role=\"radio\"\n aria-checked=\"{{this.isSelected}}\"\n disabled={{this.isDisabled}}\n class=\"{{@context.itemClass}} {{@class}}\"\n data-selected=\"{{this.isSelected}}\"\n data-disabled=\"{{this.isDisabled}}\"\n {{this.registerValue @value}}\n {{@context.indicator.setupTarget this.isSelected}}\n {{@context.roving.setupItem}}\n {{press this.handleClick}}\n ...attributes\n >\n {{yield (hash isSelected=this.isSelected)}}\n </button>\n {{/if}}\n </template>\n}\n\nexport {\n SegmentedControlItem,\n type SegmentedControlItemSignature,\n type SegmentedControlItemArgs\n};\nexport default SegmentedControlItem;\n"],"names":["SegmentedControlItem","Component","isSelected","args","context","value","isDisabled","isGroupDisabled","registerValue","modifier","element","unregisterValue","handleClick","select","stringValue","String","handleChange","requestFormSync","setComponentTemplate","precompileTemplate","strictMode","scope","on","hash","press"],"mappings":";;;;;;;;AA0CA,MAAMA,oBAAA,SAAgCC,SAAA,CACN;EAE9B,IAAIC,UAAAA,GAAsB;AACxB,IAAA,OAAO,IAAI,CAACC,IAAI,CAACC,OAAO,CAACF,UAAU,CAAC,IAAI,CAACC,IAAI,CAACE,KAAK,CAAA;AACrD,EAAA;EAEA,IAAIC,UAAAA,GAAsB;AACxB,IAAA,OAAO,IAAI,CAACH,IAAI,CAACG,UAAU,IAAI,IAAI,CAACH,IAAI,CAACC,OAAO,CAACG,eAAe;AAClE,EAAA;EAEAC,aAAA,GAAgBC,SAAS,CAACC,OAAS,EAAa,CAACL,MAAW,KAAA;IAC1D,IAAI,CAACF,IAAI,CAACC,OAAO,CAACI,aAAa,CAACE,OAAA,EAASL,KAAA,CAAA;AAEzC,IAAA,OAAO,MAAQ;MACb,IAAI,CAACF,IAAI,CAACC,OAAO,CAACO,eAAe,CAACD,OAAA,CAAA;IACpC,CAAA;AACF,EAAA,CAAA,CAAA;EAEAE,WAAA,GAAcA,MAAQ;IACpB,IAAI,IAAI,CAACN,UAAU,EAAE;AACnB,MAAA;AACF,IAAA;AACA,IAAA,IAAI,CAACH,IAAI,CAACC,OAAO,CAACS,MAAM,CAAC,IAAI,CAACV,IAAI,CAACE,KAAK,CAAA;EAC1C,CAAA;EAEA,IAAIS,WAAAA,GAAsB;AACxB,IAAA,OAAOC,MAAA,CAAO,IAAI,CAACZ,IAAI,CAACE,KAAK,CAAA;AAC/B,EAAA;EAEAW,YAAA,GAAeA,MAAQ;IACrB,IAAI,IAAI,CAACV,UAAU,EAAE;AACnB,MAAA;AACF,IAAA;AACA,IAAA,IAAI,CAACH,IAAI,CAACC,OAAO,CAACS,MAAM,CAAC,IAAI,CAACV,IAAI,CAACE,KAAK,CAAA;AAExC;AACA;AACA;AACA;AACA,IAAA,IAAI,CAACF,IAAI,CAACC,OAAO,CAACa,eAAe,EAAA;EACnC,CAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"item.js","sources":["../../../../src/components/buttons/segmented-control/item.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { on } from '@ember/modifier';\nimport { press } from '../../../modifiers/press';\nimport { modifier } from 'ember-modifier';\nimport type { SegmentedControlContext } from './segmented-control';\n\ninterface SegmentedControlItemArgs<T> {\n /**\n * The value this item represents. Selecting it calls the control's\n * `@onChange` with exactly this value.\n */\n value: T;\n\n /**\n * Disables this item alone: it cannot be clicked and keyboard navigation\n * skips over it. The whole control can be disabled with the control's own\n * `@isDisabled`.\n *\n * @defaultValue false\n */\n isDisabled?: boolean;\n\n /** Class names appended to this item's theme classes. */\n class?: string;\n\n /**\n * Supplied by SegmentedControl. Not part of the public API.\n *\n * @internal\n */\n context: SegmentedControlContext<T>;\n}\n\ninterface SegmentedControlItemSignature<T> {\n Args: SegmentedControlItemArgs<T>;\n Blocks: {\n default: [{ isSelected: boolean }];\n };\n Element: HTMLButtonElement | HTMLLabelElement;\n}\n\nclass SegmentedControlItem<T> extends Component<\n SegmentedControlItemSignature<T>\n> {\n get isSelected(): boolean {\n return this.args.context.isSelected(this.args.value);\n }\n\n get isDisabled(): boolean {\n return this.args.isDisabled || this.args.context.isGroupDisabled;\n }\n\n registerValue = modifier((element: HTMLElement, [value]: [T]) => {\n this.args.context.registerValue(element, value);\n\n return (): void => {\n this.args.context.unregisterValue(element);\n };\n });\n\n handleClick = (): void => {\n if (this.isDisabled) {\n return;\n }\n this.args.context.select(this.args.value);\n };\n\n get stringValue(): string {\n return String(this.args.value);\n }\n\n handleChange = (): void => {\n if (this.isDisabled) {\n return;\n }\n this.args.context.select(this.args.value);\n\n // The browser has already moved checkedness in the DOM. Ask the control to\n // re-assert the whole group from `@value` once the consumer has had its\n // chance to respond, so a declined (or absent) `@onChange` cannot leave the\n // native state disagreeing with the rendered selection.\n this.args.context.requestFormSync();\n };\n\n <template>\n {{#if @context.name}}\n {{! Form mode. Native radios bring their own arrow-key and focus\n behaviour for a same-named group, so RovingFocus deliberately stands\n down here rather than fighting the browser for control. }}\n <label\n data-part=\"item\"\n class=\"{{@context.itemClass}} {{@class}}\"\n data-selected=\"{{this.isSelected}}\"\n data-disabled=\"{{this.isDisabled}}\"\n {{@context.indicator.setupTarget this.isSelected}}\n ...attributes\n >\n <input\n type=\"radio\"\n name={{@context.name}}\n value={{this.stringValue}}\n checked={{this.isSelected}}\n disabled={{this.isDisabled}}\n class=\"sr-only\"\n {{this.registerValue @value}}\n {{on \"change\" this.handleChange}}\n />\n {{yield (hash isSelected=this.isSelected)}}\n </label>\n {{else}}\n <button\n type=\"button\"\n role=\"radio\"\n data-part=\"item\"\n aria-checked=\"{{this.isSelected}}\"\n disabled={{this.isDisabled}}\n class=\"{{@context.itemClass}} {{@class}}\"\n data-selected=\"{{this.isSelected}}\"\n data-disabled=\"{{this.isDisabled}}\"\n {{this.registerValue @value}}\n {{@context.indicator.setupTarget this.isSelected}}\n {{@context.roving.setupItem}}\n {{press this.handleClick}}\n ...attributes\n >\n {{yield (hash isSelected=this.isSelected)}}\n </button>\n {{/if}}\n </template>\n}\n\nexport {\n SegmentedControlItem,\n type SegmentedControlItemSignature,\n type SegmentedControlItemArgs\n};\nexport default SegmentedControlItem;\n"],"names":["SegmentedControlItem","Component","isSelected","args","context","value","isDisabled","isGroupDisabled","registerValue","modifier","element","unregisterValue","handleClick","select","stringValue","String","handleChange","requestFormSync","setComponentTemplate","precompileTemplate","strictMode","scope","on","hash","press"],"mappings":";;;;;;;;AA0CA,MAAMA,oBAAA,SAAgCC,SAAA,CACN;EAE9B,IAAIC,UAAAA,GAAsB;AACxB,IAAA,OAAO,IAAI,CAACC,IAAI,CAACC,OAAO,CAACF,UAAU,CAAC,IAAI,CAACC,IAAI,CAACE,KAAK,CAAA;AACrD,EAAA;EAEA,IAAIC,UAAAA,GAAsB;AACxB,IAAA,OAAO,IAAI,CAACH,IAAI,CAACG,UAAU,IAAI,IAAI,CAACH,IAAI,CAACC,OAAO,CAACG,eAAe;AAClE,EAAA;EAEAC,aAAA,GAAgBC,SAAS,CAACC,OAAS,EAAa,CAACL,MAAW,KAAA;IAC1D,IAAI,CAACF,IAAI,CAACC,OAAO,CAACI,aAAa,CAACE,OAAA,EAASL,KAAA,CAAA;AAEzC,IAAA,OAAO,MAAQ;MACb,IAAI,CAACF,IAAI,CAACC,OAAO,CAACO,eAAe,CAACD,OAAA,CAAA;IACpC,CAAA;AACF,EAAA,CAAA,CAAA;EAEAE,WAAA,GAAcA,MAAQ;IACpB,IAAI,IAAI,CAACN,UAAU,EAAE;AACnB,MAAA;AACF,IAAA;AACA,IAAA,IAAI,CAACH,IAAI,CAACC,OAAO,CAACS,MAAM,CAAC,IAAI,CAACV,IAAI,CAACE,KAAK,CAAA;EAC1C,CAAA;EAEA,IAAIS,WAAAA,GAAsB;AACxB,IAAA,OAAOC,MAAA,CAAO,IAAI,CAACZ,IAAI,CAACE,KAAK,CAAA;AAC/B,EAAA;EAEAW,YAAA,GAAeA,MAAQ;IACrB,IAAI,IAAI,CAACV,UAAU,EAAE;AACnB,MAAA;AACF,IAAA;AACA,IAAA,IAAI,CAACH,IAAI,CAACC,OAAO,CAACS,MAAM,CAAC,IAAI,CAACV,IAAI,CAACE,KAAK,CAAA;AAExC;AACA;AACA;AACA;AACA,IAAA,IAAI,CAACF,IAAI,CAACC,OAAO,CAACa,eAAe,EAAA;EACnC,CAAA;AAEA,EAAA;IAAAC,oBAAA,CAAAC,kBAAA,CAAA,+rCAAA,EA4CA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,EAAA;QAAAC,IAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -48,7 +48,7 @@ class SegmentedControl extends Component {
|
|
|
48
48
|
segmentedControl
|
|
49
49
|
} = useStyles();
|
|
50
50
|
return segmentedControl({
|
|
51
|
-
|
|
51
|
+
color: this.args.color,
|
|
52
52
|
variant: this.args.variant,
|
|
53
53
|
size: this.args.size,
|
|
54
54
|
orientation: this.args.orientation,
|
|
@@ -161,7 +161,7 @@ class SegmentedControl extends Component {
|
|
|
161
161
|
decorateMethodV2(this.prototype, "context", [cached]);
|
|
162
162
|
}
|
|
163
163
|
static {
|
|
164
|
-
setComponentTemplate(precompileTemplate("<div role=\"radiogroup\" aria-orientation={{this.orientation}} aria-disabled={{if @isDisabled \"true\"}} class=\"group/segmented {{this.styles.base class=@classes.base}}\" {{this.indicator.setupContainer}} ...attributes>\n <span aria-hidden=\"true\" class={{this.styles.indicator class=@classes.indicator}}></span>\n\n {{!--\n Glint cannot compose WithBoundArgs with a generic component, so the\n curried Item does not type-check against the block signature even\n though that signature is correct. The let exists only to isolate the\n failure onto the yield, keeping the ignore below scoped to a single\n line; a nocheck directive would silence this whole template instead.\n --}}\n {{#let (component SegmentedControlItem context=this.context) as |Item|}}\n {{!-- @glint-ignore: WithBoundArgs vs. a generic component --}}\n {{yield (hash Item=Item)}}\n {{/let}}\n</div>", {
|
|
164
|
+
setComponentTemplate(precompileTemplate("<div data-component=\"segmented-control\" data-part=\"base\" role=\"radiogroup\" aria-orientation={{this.orientation}} aria-disabled={{if @isDisabled \"true\"}} class=\"group/segmented {{this.styles.base class=@classes.base}}\" {{this.indicator.setupContainer}} ...attributes>\n <span data-part=\"indicator\" aria-hidden=\"true\" class={{this.styles.indicator class=@classes.indicator}}></span>\n\n {{!--\n Glint cannot compose WithBoundArgs with a generic component, so the\n curried Item does not type-check against the block signature even\n though that signature is correct. The let exists only to isolate the\n failure onto the yield, keeping the ignore below scoped to a single\n line; a nocheck directive would silence this whole template instead.\n --}}\n {{#let (component SegmentedControlItem context=this.context) as |Item|}}\n {{!-- @glint-ignore: WithBoundArgs vs. a generic component --}}\n {{yield (hash Item=Item)}}\n {{/let}}\n</div>", {
|
|
165
165
|
strictMode: true,
|
|
166
166
|
scope: () => ({
|
|
167
167
|
SegmentedControlItem,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segmented-control.js","sources":["../../../../src/components/buttons/segmented-control/segmented-control.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { hash } from '@ember/helper';\nimport { registerDestructor } from '@ember/destroyable';\nimport type Owner from '@ember/owner';\nimport { useStyles, type SlotsToClasses } from '@frontile/theme';\nimport {\n selectionIndicator,\n type SelectionIndicator\n} from '../../../utils/selection-indicator';\nimport { rovingFocus, type RovingFocus } from '../../../utils/roving-focus';\nimport { deferredWork } from '../../../utils/deferred-work';\nimport SegmentedControlItem from './item';\nimport type {\n SegmentedControlSlots,\n SegmentedControlVariants\n} from '@frontile/theme';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface SegmentedControlArgs<T> {\n /**\n * The currently selected value. Compared against each item's `@value` with\n * `===`, so object values must be referentially stable.\n *\n * *Passing* this argument at all puts the component in controlled mode --\n * passing it as `undefined` included, which is how a controlled control says\n * \"nothing is selected\". The selection then only ever reflects what you\n * pass, so pair it with `@onChange` and update your own state; setting it\n * back to `undefined` clears the selection. Omit the argument entirely to\n * let the control track the selection itself, seeded by `@defaultValue`.\n */\n value?: T;\n\n /**\n * Sets the initially selected value when the control is used uncontrolled\n * (that is, when `@value` is not provided). Ignored in controlled mode.\n *\n * @defaultValue undefined\n */\n defaultValue?: T;\n\n /** Called with the newly selected value when an item is chosen. */\n onChange?: (value: T) => void;\n\n /**\n * When set, items render as `<label>` wrapping a native radio input under\n * this name, so the control submits with its form. Without it the control\n * renders buttons and reports only through `onChange`.\n */\n name?: string;\n\n /**\n * The colour intent applied to the selected item's indicator and label.\n *\n * @defaultValue 'default'\n */\n intent?: SegmentedControlVariants['intent'];\n\n /**\n * The visual style of the control's track and indicator.\n *\n * @defaultValue 'solid'\n */\n variant?: SegmentedControlVariants['variant'];\n\n /**\n * The size of the control, driving item padding and text size.\n *\n * @defaultValue 'md'\n */\n size?: SegmentedControlVariants['size'];\n\n /**\n * Lays the items out in a row or a column, and switches the arrow keys that\n * move between them to match.\n *\n * @defaultValue 'horizontal'\n */\n orientation?: SegmentedControlVariants['orientation'];\n\n /**\n * Stretches the control to its container and gives every item equal width.\n *\n * @defaultValue false\n */\n isFullWidth?: boolean;\n\n /**\n * Draws a hairline between neighbouring items, hidden around the selected\n * one so the indicator never crosses a visible line.\n *\n * @defaultValue false\n */\n hasSeparators?: boolean;\n\n /**\n * Disables every item. Individual items can be disabled with the item's own\n * `@isDisabled`.\n *\n * @defaultValue false\n */\n isDisabled?: boolean;\n\n /** Class names for each slot of the component, merged with the theme's. */\n classes?: SlotsToClasses<SegmentedControlSlots>;\n}\n\ninterface SegmentedControlContext<T> {\n indicator: SelectionIndicator;\n roving: RovingFocus;\n isSelected: (value: T) => boolean;\n select: (value: T) => void;\n registerValue: (element: HTMLElement, value: T) => void;\n unregisterValue: (element: HTMLElement) => void;\n isGroupDisabled: boolean;\n name?: string;\n itemClass: string;\n requestFormSync: () => void;\n}\n\ninterface SegmentedControlSignature<T> {\n Args: SegmentedControlArgs<T>;\n Blocks: {\n default: [\n {\n Item: WithBoundArgs<typeof SegmentedControlItem<T>, 'context'>;\n }\n ];\n };\n Element: HTMLDivElement;\n}\n\nclass SegmentedControl<T> extends Component<SegmentedControlSignature<T>> {\n indicator = selectionIndicator();\n\n // Uncontrolled mode's own selection, seeded from `@defaultValue`. Written on\n // every `select` regardless of mode -- see `select` -- so the two modes stay\n // on one code path, exactly as `Switch` does it.\n @tracked _value: T | undefined;\n\n // Values are held against their elements rather than serialised into a\n // `data-` attribute, so a non-string `@value` survives the round trip from\n // keyboard activation back to `onChange`. A `Map` rather than a `WeakMap`\n // because form mode has to walk every registered element to re-assert\n // checkedness; entries are removed by the registering modifier's teardown,\n // so nothing outlives the elements themselves.\n #values = new Map<HTMLElement, T>();\n\n #formSync = deferredWork('@frontile/buttons:segmented-control-form-sync');\n\n roving = rovingFocus(() => ({\n orientation: this.args.orientation ?? 'horizontal',\n activationMode: 'automatic' as const,\n onActivate: this.activateElement\n }));\n\n constructor(owner: Owner, args: SegmentedControlSignature<T>['Args']) {\n super(owner, args);\n this._value = this.args.defaultValue;\n // The indicator and the roving-focus manager clean themselves up through\n // their own modifiers' destructors. This frame is the component's own, so\n // it is the only thing here that needs registering.\n registerDestructor(this, () => {\n this.#formSync.cancel();\n });\n }\n\n @cached\n get styles() {\n const { segmentedControl } = useStyles();\n\n return segmentedControl({\n intent: this.args.intent,\n variant: this.args.variant,\n size: this.args.size,\n orientation: this.args.orientation,\n isFullWidth: this.args.isFullWidth,\n isDisabled: this.args.isDisabled,\n hasSeparators: this.args.hasSeparators\n });\n }\n\n get orientation(): 'horizontal' | 'vertical' {\n return this.args.orientation ?? 'horizontal';\n }\n\n /**\n * Whether `@value` was *passed* decides the mode -- not whether it holds a\n * value. `@value` is generic, so `undefined` is a legitimate selection\n * meaning \"nothing is selected\"; testing `!== undefined` (as `Switch` can,\n * because its `@isSelected` is a boolean and `undefined` there really does\n * mean \"not passed\") would run a controlled control uncontrolled until its\n * first pick, and would make clearing the selection impossible.\n *\n * Glimmer's named-args object carries a key for every argument written in\n * the invoking template, so `in` distinguishes `@value={{undefined}}` from\n * an omitted `@value` -- which `undefined` alone cannot.\n */\n get isControlled(): boolean {\n return 'value' in this.args;\n }\n\n /**\n * The selection everything else reads: the argument when controlled, the\n * internal field otherwise. `requestFormSync` re-asserts the native radios\n * from this (via `isSelected`) rather than from `@value`, so an uncontrolled\n * form-mode control does not snap the user's click back.\n */\n get selectedValue(): T | undefined {\n return this.isControlled ? this.args.value : this._value;\n }\n\n isSelected = (value: T): boolean => {\n return this.selectedValue === value;\n };\n\n select = (value: T): void => {\n if (this.args.isDisabled) {\n return;\n }\n // Written unconditionally, as in `Switch`: in controlled mode the getter\n // above ignores it, so one assignment serves both modes.\n this._value = value;\n this.args.onChange?.(value);\n };\n\n activateElement = (element: HTMLElement): void => {\n // `has`, not a `!== undefined` check on the result: `T` may itself be\n // `undefined`, so only membership distinguishes \"this element is not\n // registered\" from \"it is registered against an undefined value\".\n if (!this.#values.has(element)) {\n return;\n }\n this.select(this.#values.get(element) as T);\n };\n\n registerValue = (element: HTMLElement, value: T): void => {\n this.#values.set(element, value);\n };\n\n unregisterValue = (element: HTMLElement): void => {\n this.#values.delete(element);\n };\n\n /**\n * Form mode only. A native radio flips its own `checked` the moment it is\n * clicked and Glimmer will not undo that, so the DOM can drift from `@value`\n * when a consumer declines the change.\n *\n * It waits a frame rather than correcting synchronously: reading `@value`\n * inside the change handler would see the stale value and stomp a legitimate\n * update.\n */\n requestFormSync = (): void => {\n this.#formSync.schedule(() => {\n if (this.isDestroying || this.isDestroyed) {\n return;\n }\n\n // The whole group is walked: unchecking the clicked radio does not\n // restore its previously-checked sibling.\n for (const [element, value] of this.#values) {\n if (!(element instanceof HTMLInputElement)) {\n continue;\n }\n const shouldBeChecked = this.isSelected(value);\n if (element.checked !== shouldBeChecked) {\n element.checked = shouldBeChecked;\n }\n }\n });\n };\n\n @cached\n get context(): SegmentedControlContext<T> {\n return {\n indicator: this.indicator,\n roving: this.roving,\n isSelected: this.isSelected,\n select: this.select,\n registerValue: this.registerValue,\n unregisterValue: this.unregisterValue,\n isGroupDisabled: this.args.isDisabled ?? false,\n name: this.args.name,\n requestFormSync: this.requestFormSync,\n itemClass: this.styles.item({ class: this.args.classes?.item })\n };\n }\n\n <template>\n <div\n role=\"radiogroup\"\n aria-orientation={{this.orientation}}\n aria-disabled={{if @isDisabled \"true\"}}\n class=\"group/segmented {{this.styles.base class=@classes.base}}\"\n {{this.indicator.setupContainer}}\n ...attributes\n >\n <span\n aria-hidden=\"true\"\n class={{this.styles.indicator class=@classes.indicator}}\n ></span>\n\n {{!\n Glint cannot compose WithBoundArgs with a generic component, so the\n curried Item does not type-check against the block signature even\n though that signature is correct. The let exists only to isolate the\n failure onto the yield, keeping the ignore below scoped to a single\n line; a nocheck directive would silence this whole template instead.\n }}\n {{#let (component SegmentedControlItem context=this.context) as |Item|}}\n {{! @glint-ignore: WithBoundArgs vs. a generic component }}\n {{yield (hash Item=Item)}}\n {{/let}}\n </div>\n </template>\n}\n\nexport {\n SegmentedControl,\n type SegmentedControlSignature,\n type SegmentedControlArgs,\n type SegmentedControlContext\n};\nexport default SegmentedControl;\n"],"names":["SegmentedControl","Component","indicator","selectionIndicator","g","prototype","tracked","i","Map","deferredWork","roving","rovingFocus","orientation","args","activationMode","onActivate","activateElement","constructor","owner","_value","defaultValue","registerDestructor","cancel","styles","segmentedControl","useStyles","intent","variant","size","isFullWidth","isDisabled","hasSeparators","n","cached","isControlled","selectedValue","value","isSelected","select","onChange","element","has","get","registerValue","set","unregisterValue","delete","requestFormSync","schedule","isDestroying","isDestroyed","HTMLInputElement","shouldBeChecked","checked","context","isGroupDisabled","name","itemClass","item","class","classes","setCompon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1C,IAAI,CAACiB,UAAU,IAAI,KAAA;AACzC0B,MAAAA,IAAA,EAAM,IAAI,CAAC3C,IAAI,CAAC2C,IAAI;MACpBT,eAAA,EAAiB,IAAI,CAACA,eAAe;AACrCU,MAAAA,SAAA,EAAW,IAAI,CAAClC,MAAM,CAACmC,IAAI,CAAC;AAAEC,QAAAA,KAAA,EAAO,IAAI,CAAC9C,IAAI,CAAC+C,OAAO,EAAEF;OAAK;KAC/D;AACF,EAAA;AAAA,EAAA;IAAA1B,gBAAA,CAAA,IAAA,CAAA3B,SAAA,EAAA,SAAA,EAAA,CAdC4B,MAAA,CAAA,CAAA;AAAA;AAgBD,EAAA;IAAA4B,oBAAA,CAAAC,kBAAA,CAAA,k4BAAA,EA0BA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,oBAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
1
|
+
{"version":3,"file":"segmented-control.js","sources":["../../../../src/components/buttons/segmented-control/segmented-control.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { cached, tracked } from '@glimmer/tracking';\nimport { hash } from '@ember/helper';\nimport { registerDestructor } from '@ember/destroyable';\nimport type Owner from '@ember/owner';\nimport { useStyles, type SlotsToClasses } from '@frontile/theme';\nimport {\n selectionIndicator,\n type SelectionIndicator\n} from '../../../utils/selection-indicator';\nimport { rovingFocus, type RovingFocus } from '../../../utils/roving-focus';\nimport { deferredWork } from '../../../utils/deferred-work';\nimport SegmentedControlItem from './item';\nimport type {\n SegmentedControlSlots,\n SegmentedControlVariants\n} from '@frontile/theme';\nimport type { WithBoundArgs } from '@glint/template';\n\ninterface SegmentedControlArgs<T> {\n /**\n * The currently selected value. Compared against each item's `@value` with\n * `===`, so object values must be referentially stable.\n *\n * *Passing* this argument at all puts the component in controlled mode --\n * passing it as `undefined` included, which is how a controlled control says\n * \"nothing is selected\". The selection then only ever reflects what you\n * pass, so pair it with `@onChange` and update your own state; setting it\n * back to `undefined` clears the selection. Omit the argument entirely to\n * let the control track the selection itself, seeded by `@defaultValue`.\n */\n value?: T;\n\n /**\n * Sets the initially selected value when the control is used uncontrolled\n * (that is, when `@value` is not provided). Ignored in controlled mode.\n *\n * @defaultValue undefined\n */\n defaultValue?: T;\n\n /** Called with the newly selected value when an item is chosen. */\n onChange?: (value: T) => void;\n\n /**\n * When set, items render as `<label>` wrapping a native radio input under\n * this name, so the control submits with its form. Without it the control\n * renders buttons and reports only through `onChange`.\n */\n name?: string;\n\n /**\n * The colour applied to the selected item's indicator and label.\n *\n * @defaultValue 'neutral'\n */\n color?: SegmentedControlVariants['color'];\n\n /**\n * The visual style of the control's track and indicator.\n *\n * @defaultValue 'solid'\n */\n variant?: SegmentedControlVariants['variant'];\n\n /**\n * The size of the control, driving item padding and text size.\n *\n * @defaultValue 'md'\n */\n size?: SegmentedControlVariants['size'];\n\n /**\n * Lays the items out in a row or a column, and switches the arrow keys that\n * move between them to match.\n *\n * @defaultValue 'horizontal'\n */\n orientation?: SegmentedControlVariants['orientation'];\n\n /**\n * Stretches the control to its container and gives every item equal width.\n *\n * @defaultValue false\n */\n isFullWidth?: boolean;\n\n /**\n * Draws a hairline between neighbouring items, hidden around the selected\n * one so the indicator never crosses a visible line.\n *\n * @defaultValue false\n */\n hasSeparators?: boolean;\n\n /**\n * Disables every item. Individual items can be disabled with the item's own\n * `@isDisabled`.\n *\n * @defaultValue false\n */\n isDisabled?: boolean;\n\n /** Class names for each slot of the component, merged with the theme's. */\n classes?: SlotsToClasses<SegmentedControlSlots>;\n}\n\ninterface SegmentedControlContext<T> {\n indicator: SelectionIndicator;\n roving: RovingFocus;\n isSelected: (value: T) => boolean;\n select: (value: T) => void;\n registerValue: (element: HTMLElement, value: T) => void;\n unregisterValue: (element: HTMLElement) => void;\n isGroupDisabled: boolean;\n name?: string;\n itemClass: string;\n requestFormSync: () => void;\n}\n\ninterface SegmentedControlSignature<T> {\n Args: SegmentedControlArgs<T>;\n Blocks: {\n default: [\n {\n Item: WithBoundArgs<typeof SegmentedControlItem<T>, 'context'>;\n }\n ];\n };\n Element: HTMLDivElement;\n}\n\nclass SegmentedControl<T> extends Component<SegmentedControlSignature<T>> {\n indicator = selectionIndicator();\n\n // Uncontrolled mode's own selection, seeded from `@defaultValue`. Written on\n // every `select` regardless of mode -- see `select` -- so the two modes stay\n // on one code path, exactly as `Switch` does it.\n @tracked _value: T | undefined;\n\n // Values are held against their elements rather than serialised into a\n // `data-` attribute, so a non-string `@value` survives the round trip from\n // keyboard activation back to `onChange`. A `Map` rather than a `WeakMap`\n // because form mode has to walk every registered element to re-assert\n // checkedness; entries are removed by the registering modifier's teardown,\n // so nothing outlives the elements themselves.\n #values = new Map<HTMLElement, T>();\n\n #formSync = deferredWork('@frontile/buttons:segmented-control-form-sync');\n\n roving = rovingFocus(() => ({\n orientation: this.args.orientation ?? 'horizontal',\n activationMode: 'automatic' as const,\n onActivate: this.activateElement\n }));\n\n constructor(owner: Owner, args: SegmentedControlSignature<T>['Args']) {\n super(owner, args);\n this._value = this.args.defaultValue;\n // The indicator and the roving-focus manager clean themselves up through\n // their own modifiers' destructors. This frame is the component's own, so\n // it is the only thing here that needs registering.\n registerDestructor(this, () => {\n this.#formSync.cancel();\n });\n }\n\n @cached\n get styles() {\n const { segmentedControl } = useStyles();\n\n return segmentedControl({\n color: this.args.color,\n variant: this.args.variant,\n size: this.args.size,\n orientation: this.args.orientation,\n isFullWidth: this.args.isFullWidth,\n isDisabled: this.args.isDisabled,\n hasSeparators: this.args.hasSeparators\n });\n }\n\n get orientation(): 'horizontal' | 'vertical' {\n return this.args.orientation ?? 'horizontal';\n }\n\n /**\n * Whether `@value` was *passed* decides the mode -- not whether it holds a\n * value. `@value` is generic, so `undefined` is a legitimate selection\n * meaning \"nothing is selected\"; testing `!== undefined` (as `Switch` can,\n * because its `@isSelected` is a boolean and `undefined` there really does\n * mean \"not passed\") would run a controlled control uncontrolled until its\n * first pick, and would make clearing the selection impossible.\n *\n * Glimmer's named-args object carries a key for every argument written in\n * the invoking template, so `in` distinguishes `@value={{undefined}}` from\n * an omitted `@value` -- which `undefined` alone cannot.\n */\n get isControlled(): boolean {\n return 'value' in this.args;\n }\n\n /**\n * The selection everything else reads: the argument when controlled, the\n * internal field otherwise. `requestFormSync` re-asserts the native radios\n * from this (via `isSelected`) rather than from `@value`, so an uncontrolled\n * form-mode control does not snap the user's click back.\n */\n get selectedValue(): T | undefined {\n return this.isControlled ? this.args.value : this._value;\n }\n\n isSelected = (value: T): boolean => {\n return this.selectedValue === value;\n };\n\n select = (value: T): void => {\n if (this.args.isDisabled) {\n return;\n }\n // Written unconditionally, as in `Switch`: in controlled mode the getter\n // above ignores it, so one assignment serves both modes.\n this._value = value;\n this.args.onChange?.(value);\n };\n\n activateElement = (element: HTMLElement): void => {\n // `has`, not a `!== undefined` check on the result: `T` may itself be\n // `undefined`, so only membership distinguishes \"this element is not\n // registered\" from \"it is registered against an undefined value\".\n if (!this.#values.has(element)) {\n return;\n }\n this.select(this.#values.get(element) as T);\n };\n\n registerValue = (element: HTMLElement, value: T): void => {\n this.#values.set(element, value);\n };\n\n unregisterValue = (element: HTMLElement): void => {\n this.#values.delete(element);\n };\n\n /**\n * Form mode only. A native radio flips its own `checked` the moment it is\n * clicked and Glimmer will not undo that, so the DOM can drift from `@value`\n * when a consumer declines the change.\n *\n * It waits a frame rather than correcting synchronously: reading `@value`\n * inside the change handler would see the stale value and stomp a legitimate\n * update.\n */\n requestFormSync = (): void => {\n this.#formSync.schedule(() => {\n if (this.isDestroying || this.isDestroyed) {\n return;\n }\n\n // The whole group is walked: unchecking the clicked radio does not\n // restore its previously-checked sibling.\n for (const [element, value] of this.#values) {\n if (!(element instanceof HTMLInputElement)) {\n continue;\n }\n const shouldBeChecked = this.isSelected(value);\n if (element.checked !== shouldBeChecked) {\n element.checked = shouldBeChecked;\n }\n }\n });\n };\n\n @cached\n get context(): SegmentedControlContext<T> {\n return {\n indicator: this.indicator,\n roving: this.roving,\n isSelected: this.isSelected,\n select: this.select,\n registerValue: this.registerValue,\n unregisterValue: this.unregisterValue,\n isGroupDisabled: this.args.isDisabled ?? false,\n name: this.args.name,\n requestFormSync: this.requestFormSync,\n itemClass: this.styles.item({ class: this.args.classes?.item })\n };\n }\n\n <template>\n <div\n data-component=\"segmented-control\"\n data-part=\"base\"\n role=\"radiogroup\"\n aria-orientation={{this.orientation}}\n aria-disabled={{if @isDisabled \"true\"}}\n class=\"group/segmented {{this.styles.base class=@classes.base}}\"\n {{this.indicator.setupContainer}}\n ...attributes\n >\n <span\n data-part=\"indicator\"\n aria-hidden=\"true\"\n class={{this.styles.indicator class=@classes.indicator}}\n ></span>\n\n {{!\n Glint cannot compose WithBoundArgs with a generic component, so the\n curried Item does not type-check against the block signature even\n though that signature is correct. The let exists only to isolate the\n failure onto the yield, keeping the ignore below scoped to a single\n line; a nocheck directive would silence this whole template instead.\n }}\n {{#let (component SegmentedControlItem context=this.context) as |Item|}}\n {{! @glint-ignore: WithBoundArgs vs. a generic component }}\n {{yield (hash Item=Item)}}\n {{/let}}\n </div>\n </template>\n}\n\nexport {\n SegmentedControl,\n type SegmentedControlSignature,\n type SegmentedControlArgs,\n type SegmentedControlContext\n};\nexport default SegmentedControl;\n"],"names":["SegmentedControl","Component","indicator","selectionIndicator","g","prototype","tracked","i","Map","deferredWork","roving","rovingFocus","orientation","args","activationMode","onActivate","activateElement","constructor","owner","_value","defaultValue","registerDestructor","cancel","styles","segmentedControl","useStyles","color","variant","size","isFullWidth","isDisabled","hasSeparators","n","cached","isControlled","selectedValue","value","isSelected","select","onChange","element","has","get","registerValue","set","unregisterValue","delete","requestFormSync","schedule","isDestroying","isDestroyed","HTMLInputElement","shouldBeChecked","checked","context","isGroupDisabled","name","itemClass","item","class","classes","setComponentTemplate","precompileTemplate","strictMode","scope","SegmentedControlItem","hash"],"mappings":";;;;;;;;;;;;;AAoIA,MAAMA,gBAAA,SAA4BC,SA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ACpBT,eAAA,EAAiB,IAAI,CAACA,eAAe;AACrCU,MAAAA,SAAA,EAAW,IAAI,CAAClC,MAAM,CAACmC,IAAI,CAAC;AAAEC,QAAAA,KAAA,EAAO,IAAI,CAAC9C,IAAI,CAAC+C,OAAO,EAAEF;OAAK;KAC/D;AACF,EAAA;AAAA,EAAA;IAAA1B,gBAAA,CAAA,IAAA,CAAA3B,SAAA,EAAA,SAAA,EAAA,CAdC4B,MAAA,CAAA,CAAA;AAAA;AAgBD,EAAA;IAAA4B,oBAAA,CAAAC,kBAAA,CAAA,k9BAAA,EA6BA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,oBAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -1,18 +1,52 @@
|
|
|
1
1
|
import Component from '@glimmer/component';
|
|
2
2
|
import { useStyles } from '@frontile/theme';
|
|
3
3
|
import press from '../../modifiers/press.js';
|
|
4
|
+
import { r as renamedArgValue } from '../../deprecated-args-BIUjLA8y.js';
|
|
4
5
|
import { precompileTemplate } from '@ember/template-compilation';
|
|
5
6
|
import { setComponentTemplate } from '@ember/component';
|
|
6
7
|
|
|
7
8
|
class ToggleButton extends Component {
|
|
9
|
+
/**
|
|
10
|
+
* ToggleButton's theme only ever renders the `outline` variant — reading
|
|
11
|
+
* this getter resolves (and, when needed, deprecates) `@appearance` /
|
|
12
|
+
* `@variant` so a consumer still migrating gets the warning, even though
|
|
13
|
+
* the resolved value itself has nowhere else to go.
|
|
14
|
+
*/
|
|
15
|
+
get variant() {
|
|
16
|
+
return renamedArgValue(this.args.variant, this.args.appearance, {
|
|
17
|
+
default: 'solid',
|
|
18
|
+
outlined: 'outline',
|
|
19
|
+
minimal: 'plain',
|
|
20
|
+
soft: 'subtle',
|
|
21
|
+
tonal: 'soft'
|
|
22
|
+
}, {
|
|
23
|
+
component: 'ToggleButton',
|
|
24
|
+
from: 'appearance',
|
|
25
|
+
to: 'variant',
|
|
26
|
+
id: 'frontile.toggle-button.appearance'
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
get color() {
|
|
30
|
+
return renamedArgValue(this.args.color, this.args.intent, {
|
|
31
|
+
default: 'neutral'
|
|
32
|
+
}, {
|
|
33
|
+
component: 'ToggleButton',
|
|
34
|
+
from: 'intent',
|
|
35
|
+
to: 'color',
|
|
36
|
+
id: 'frontile.toggle-button.intent'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
8
39
|
get classNames() {
|
|
9
40
|
const {
|
|
10
41
|
toggleButton
|
|
11
42
|
} = useStyles();
|
|
43
|
+
// Resolve (and deprecate) `@appearance`/`@variant` for their side effect;
|
|
44
|
+
// the theme itself only defines the `outline` variant for ToggleButton.
|
|
45
|
+
void this.variant;
|
|
12
46
|
return toggleButton({
|
|
13
|
-
|
|
47
|
+
color: this.color || 'neutral',
|
|
14
48
|
size: this.args.size,
|
|
15
|
-
|
|
49
|
+
variant: 'outline',
|
|
16
50
|
isSelected: this.isSelected,
|
|
17
51
|
isInGroup: this.args.isInGroup,
|
|
18
52
|
class: this.args.class
|
|
@@ -27,7 +61,7 @@ class ToggleButton extends Component {
|
|
|
27
61
|
}
|
|
28
62
|
};
|
|
29
63
|
static {
|
|
30
|
-
setComponentTemplate(precompileTemplate("<button type=\"button\" {{press this.onChange}} class={{this.classNames}} aria-pressed=\"{{this.isSelected}}\" ...attributes>\n {{yield}}\n</button>", {
|
|
64
|
+
setComponentTemplate(precompileTemplate("<button type=\"button\" {{press this.onChange}} class={{this.classNames}} aria-pressed=\"{{this.isSelected}}\" data-component=\"toggle-button\" data-part=\"base\" ...attributes>\n {{yield}}\n</button>", {
|
|
31
65
|
strictMode: true,
|
|
32
66
|
scope: () => ({
|
|
33
67
|
press
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toggle-button.js","sources":["../../../src/components/buttons/toggle-button.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles } from '@frontile/theme';\nimport { press } from '../../modifiers/press';\nimport type { ButtonArgs } from './button';\n\ninterface ToggleButtonArgs extends Pick<\n ButtonArgs,\n 'intent' | 'size' | 'class' | 'isInGroup'\n> {\n /**\n * If the button is currently selected\n *\n * @defaultValue false\n */\n isSelected?: boolean;\n\n /**\n * Callback when the buttle is toggled\n */\n onChange?: (isSelected: boolean) => void;\n}\n\ninterface ToggleButtonSignature {\n Args: ToggleButtonArgs;\n Blocks: {\n default: [];\n };\n Element: HTMLButtonElement;\n}\n\nclass ToggleButton extends Component<ToggleButtonSignature> {\n get classNames(): string {\n const { toggleButton } = useStyles();\n\n return toggleButton({\n
|
|
1
|
+
{"version":3,"file":"toggle-button.js","sources":["../../../src/components/buttons/toggle-button.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { useStyles } from '@frontile/theme';\nimport { press } from '../../modifiers/press';\nimport type { ButtonArgs } from './button';\nimport { renamedArgValue } from '../../-private/deprecated-args';\n\ninterface ToggleButtonArgs extends Pick<\n ButtonArgs,\n 'variant' | 'appearance' | 'color' | 'intent' | 'size' | 'class' | 'isInGroup'\n> {\n /**\n * If the button is currently selected\n *\n * @defaultValue false\n */\n isSelected?: boolean;\n\n /**\n * Callback when the buttle is toggled\n */\n onChange?: (isSelected: boolean) => void;\n}\n\ninterface ToggleButtonSignature {\n Args: ToggleButtonArgs;\n Blocks: {\n default: [];\n };\n Element: HTMLButtonElement;\n}\n\nclass ToggleButton extends Component<ToggleButtonSignature> {\n /**\n * ToggleButton's theme only ever renders the `outline` variant — reading\n * this getter resolves (and, when needed, deprecates) `@appearance` /\n * `@variant` so a consumer still migrating gets the warning, even though\n * the resolved value itself has nowhere else to go.\n */\n get variant() {\n return renamedArgValue(\n this.args.variant,\n this.args.appearance,\n {\n default: 'solid',\n outlined: 'outline',\n minimal: 'plain',\n soft: 'subtle',\n tonal: 'soft'\n } as const,\n {\n component: 'ToggleButton',\n from: 'appearance',\n to: 'variant',\n id: 'frontile.toggle-button.appearance'\n }\n );\n }\n\n get color() {\n return renamedArgValue(\n this.args.color,\n this.args.intent,\n { default: 'neutral' } as const,\n {\n component: 'ToggleButton',\n from: 'intent',\n to: 'color',\n id: 'frontile.toggle-button.intent'\n }\n );\n }\n\n get classNames(): string {\n const { toggleButton } = useStyles();\n // Resolve (and deprecate) `@appearance`/`@variant` for their side effect;\n // the theme itself only defines the `outline` variant for ToggleButton.\n void this.variant;\n\n return toggleButton({\n color: this.color || 'neutral',\n size: this.args.size,\n variant: 'outline',\n isSelected: this.isSelected,\n isInGroup: this.args.isInGroup,\n class: this.args.class\n });\n }\n\n get isSelected() {\n return !!this.args.isSelected;\n }\n\n onChange = () => {\n if (typeof this.args.onChange === 'function') {\n this.args.onChange(!this.isSelected);\n }\n };\n\n <template>\n <button\n type=\"button\"\n {{press this.onChange}}\n class={{this.classNames}}\n aria-pressed=\"{{this.isSelected}}\"\n data-component=\"toggle-button\"\n data-part=\"base\"\n ...attributes\n >\n {{yield}}\n </button>\n </template>\n}\n\nexport { ToggleButton, type ToggleButtonSignature };\nexport default ToggleButton;\n"],"names":["ToggleButton","Component","variant","renamedArgValue","args","appearance","default","outlined","minimal","soft","tonal","component","from","to","id","color","intent","classNames","toggleButton","useStyles","size","isSelected","isInGroup","class","onChange","setComponentTemplate","precompileTemplate","strictMode","scope","press"],"mappings":";;;;;;;AA+BA,MAAMA,qBAAqBC,SAAA,CAAU;AACnC;;;;;AAKC;EACD,IAAIC,OAAAA,GAAU;AACZ,IAAA,OAAOC,eAAA,CACL,IAAI,CAACC,IAAI,CAACF,OAAO,EACjB,IAAI,CAACE,IAAI,CAACC,UAAU,EACpB;AACEC,MAAAA,OAAA,EAAS,OAAA;AACTC,MAAAA,QAAA,EAAU,SAAA;AACVC,MAAAA,OAAA,EAAS,OAAA;AACTC,MAAAA,IAAA,EAAM,QAAA;AACNC,MAAAA,KAAA,EAAO;AACT,KAAA,EACA;AACEC,MAAAA,SAAA,EAAW,cAAA;AACXC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I,oBAAA,CAAAC,kBAAA,CAAA,2MAAA,EAYA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;;;"}
|
|
@@ -2,6 +2,7 @@ import Component from '@glimmer/component';
|
|
|
2
2
|
import { tracked, cached } from '@glimmer/tracking';
|
|
3
3
|
import { on } from '@ember/modifier';
|
|
4
4
|
import { modifier } from 'ember-modifier';
|
|
5
|
+
import { deferredWork } from '../../../utils/deferred-work.js';
|
|
5
6
|
import { startOfMonth, startOfDay, isBefore, isAfter, isSameDay, isSameMonth, addYears, addMonths, endOfWeek, startOfWeek, addWeeks, addDays, endOfMonth } from 'date-fns';
|
|
6
7
|
import { useStyles } from '@frontile/theme';
|
|
7
8
|
import { MonthGrid } from './month-grid.js';
|
|
@@ -34,6 +35,10 @@ class Calendar extends Component {
|
|
|
34
35
|
get captionLayout() {
|
|
35
36
|
return this.args.captionLayout ?? 'label';
|
|
36
37
|
}
|
|
38
|
+
// The autofocus below is deferred a frame; `deferredWork` holds the
|
|
39
|
+
// test-waiter token so `settled()` does not race it, and cancels cleanly on
|
|
40
|
+
// teardown.
|
|
41
|
+
#autofocusWork = deferredWork('@frontile/collections:calendar-autofocus');
|
|
37
42
|
static {
|
|
38
43
|
decorateFieldV2(this.prototype, "isYearGridOpen", [tracked], function () {
|
|
39
44
|
return false;
|
|
@@ -44,9 +49,14 @@ class Calendar extends Component {
|
|
|
44
49
|
this.isYearGridOpen = !this.isYearGridOpen;
|
|
45
50
|
};
|
|
46
51
|
returnFocusToYearTrigger(element) {
|
|
47
|
-
const trigger = element?.querySelector('[data-
|
|
52
|
+
const trigger = element?.querySelector('[data-part="year-trigger"]');
|
|
48
53
|
if (trigger) {
|
|
49
|
-
|
|
54
|
+
// Same reasoning as the day-cell focus below: inside a popover this
|
|
55
|
+
// element may not be positioned yet, and scrolling to it would move the
|
|
56
|
+
// page out from under the user.
|
|
57
|
+
trigger.focus({
|
|
58
|
+
preventScroll: true
|
|
59
|
+
});
|
|
50
60
|
return;
|
|
51
61
|
}
|
|
52
62
|
// A `<:header>` block replaces the default header entirely, so there is
|
|
@@ -451,7 +461,7 @@ class Calendar extends Component {
|
|
|
451
461
|
* hijacked by the day-grid's roving-focus handling.
|
|
452
462
|
*/
|
|
453
463
|
focusOrigin(event) {
|
|
454
|
-
const key = event.target?.closest('[data-
|
|
464
|
+
const key = event.target?.closest('[data-part="day"]')?.dataset['key'];
|
|
455
465
|
return key ? fromDayKey(key) : null;
|
|
456
466
|
}
|
|
457
467
|
handleKeydown = event => {
|
|
@@ -545,7 +555,34 @@ class Calendar extends Component {
|
|
|
545
555
|
return;
|
|
546
556
|
}
|
|
547
557
|
this.#shouldFocus = false;
|
|
548
|
-
|
|
558
|
+
// No nested component renders a `day` part, so unlike the general
|
|
559
|
+
// `closest('[data-component]') === root` guard used elsewhere, this
|
|
560
|
+
// query cannot pick up a descendant component's own day-shaped cell --
|
|
561
|
+
// there is nothing else in the tree it could collide with.
|
|
562
|
+
// Deferred by a frame rather than focused here, because focusing during
|
|
563
|
+
// insert costs the container its enter animation: a calendar in a
|
|
564
|
+
// popover is inserted already carrying the transition's enter classes,
|
|
565
|
+
// and taking focus synchronously flushes style before that start state
|
|
566
|
+
// is ever painted, so the browser finds nothing to animate from and
|
|
567
|
+
// skips the transition entirely. (It only ever skipped the *enter* half
|
|
568
|
+
// -- closing was unaffected, which is what made it look like an
|
|
569
|
+
// animation bug rather than a focus one.) One frame is enough; by then
|
|
570
|
+
// the transition is running and focus no longer disturbs it.
|
|
571
|
+
//
|
|
572
|
+
// `preventScroll` is a separate matter: the portaled content is focused
|
|
573
|
+
// before floating-ui has positioned it, so an ordinary focus scrolls the
|
|
574
|
+
// page to wherever the unpositioned element currently sits -- in
|
|
575
|
+
// practice the end of the document, yanking the page to the bottom.
|
|
576
|
+
// Nothing is lost in the standalone case either: the day being focused
|
|
577
|
+
// is one the user just navigated to in a calendar already on screen.
|
|
578
|
+
// Looked up when the frame fires rather than now, so a focus request
|
|
579
|
+
// superseded within the same frame still lands on the current day.
|
|
580
|
+
this.#autofocusWork.schedule(() => {
|
|
581
|
+
element.querySelector('[data-part="day"][tabindex="0"]')?.focus({
|
|
582
|
+
preventScroll: true
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
return () => this.#autofocusWork.cancel();
|
|
549
586
|
});
|
|
550
587
|
/** How many months to render, starting at `visibleMonth`. */
|
|
551
588
|
get visibleMonths() {
|
|
@@ -672,7 +709,7 @@ class Calendar extends Component {
|
|
|
672
709
|
calendar
|
|
673
710
|
} = useStyles();
|
|
674
711
|
return calendar({
|
|
675
|
-
|
|
712
|
+
color: this.args.color,
|
|
676
713
|
size: this.args.size,
|
|
677
714
|
isDisabled: this.args.isDisabled
|
|
678
715
|
});
|
|
@@ -791,7 +828,7 @@ class Calendar extends Component {
|
|
|
791
828
|
};
|
|
792
829
|
};
|
|
793
830
|
static {
|
|
794
|
-
setComponentTemplate(precompileTemplate("{{!-- template-lint-disable no-invalid-interactive --}}\n{{!-- The keydown listener implements the roving-tabindex grid pattern for\n the day buttons nested inside; the root itself stays a plain,\n non-focusable container. --}}\n<div data-
|
|
831
|
+
setComponentTemplate(precompileTemplate("{{!-- template-lint-disable no-invalid-interactive --}}\n{{!-- The keydown listener implements the roving-tabindex grid pattern for\n the day buttons nested inside; the root itself stays a plain,\n non-focusable container. --}}\n<div data-component=\"calendar\" data-part=\"base\" class={{this.styles.base class=@classes.base}} {{on \"keydown\" this.handleKeydown}} {{this.applyFocus this.focusedDate this.isYearGridOpen}} {{this.rootRef.setup}} ...attributes>\n {{!-- Header, year panel and grids share one column sized to the grids,\n so a wide footer block cannot stretch the header and pull the paging\n arrows away from the days they page. --}}\n <div data-part=\"body\" class={{this.styles.body class=@classes.body}}>\n {{#if (has-block \"header\")}}\n {{yield this.headerContext to=\"header\"}}\n {{else}}\n <CalendarHeader @context={{this.headerContext}} @captionLayout={{this.captionLayout}} @months={{this.monthOptions}} @isYearGridOpen={{this.isYearGridOpen}} @onToggleYearGrid={{this.toggleYearGrid}} @classes={{this.headerClasses}} />\n {{/if}}\n\n <VisuallyHidden>\n <div data-fr-calendar-live aria-live=\"polite\">{{this.caption}}</div>\n </VisuallyHidden>\n\n {{!-- The year panel stands in for the grids rather than stacking\n above them; otherwise picking a year pushes the days off screen. --}}\n {{#if this.isYearGridOpen}}\n <YearGrid @years={{this.yearOptions}} @currentYear={{this.visibleYear}} @onSelect={{this.pickYear}} @onDismiss={{this.dismissYearGrid}} @classes={{this.yearGridClasses}} />\n {{else}}\n <div data-part=\"months-wrapper\" class={{this.styles.monthsWrapper class=@classes.monthsWrapper}}>\n {{#each this.months key=\"key\" as |monthData|}}\n <MonthGrid @month={{monthData}} @weekdays={{this.weekdays}} @caption={{this.captionFor monthData.month}} @stateFor={{this.stateFor}} @isReadOnly={{this.isReadOnly}} @labelledBy={{@labelledBy}} @onSelect={{this.selectDay}} @onHover={{this.hoverDay}} @hasDayContent={{has-block \"day\"}} @hasWeekdayContent={{has-block \"weekday\"}} @classes={{this.gridClasses}}>\n <:day as |day|>{{yield day to=\"day\"}}</:day>\n <:weekday as |wd|>{{yield wd to=\"weekday\"}}</:weekday>\n </MonthGrid>\n {{/each}}\n </div>\n {{/if}}\n </div>\n\n {{#if (has-block \"footer\")}}\n <div data-part=\"footer\" class={{this.styles.footer class=@classes.footer}}>{{yield to=\"footer\"}}</div>\n {{/if}}\n</div>", {
|
|
795
832
|
strictMode: true,
|
|
796
833
|
scope: () => ({
|
|
797
834
|
on,
|