frontile 0.18.0-beta.5 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/declarations/components/buttons/chip.d.ts +1 -1
  2. package/declarations/components/buttons/chip.d.ts.map +1 -1
  3. package/declarations/components/collections/dropdown/menu-context.d.ts +10 -0
  4. package/declarations/components/collections/dropdown/menu-context.d.ts.map +1 -1
  5. package/declarations/components/collections/dropdown/sub.d.ts +34 -0
  6. package/declarations/components/collections/dropdown/sub.d.ts.map +1 -1
  7. package/declarations/components/forms/autocomplete.d.ts +12 -12
  8. package/declarations/components/forms/date-input/clipboard.d.ts +34 -0
  9. package/declarations/components/forms/date-input/clipboard.d.ts.map +1 -0
  10. package/declarations/components/forms/date-input/date-input.d.ts +91 -0
  11. package/declarations/components/forms/date-input/date-input.d.ts.map +1 -0
  12. package/declarations/components/forms/date-input/segment-group.d.ts +130 -0
  13. package/declarations/components/forms/date-input/segment-group.d.ts.map +1 -0
  14. package/declarations/components/forms/date-input/segments.d.ts +137 -0
  15. package/declarations/components/forms/date-input/segments.d.ts.map +1 -0
  16. package/declarations/components/forms/date-input/types.d.ts +134 -0
  17. package/declarations/components/forms/date-input/types.d.ts.map +1 -0
  18. package/declarations/components/forms/date-input.d.ts +6 -0
  19. package/declarations/components/forms/date-input.d.ts.map +1 -0
  20. package/declarations/components/forms/date-picker/date-picker.d.ts +248 -15
  21. package/declarations/components/forms/date-picker/date-picker.d.ts.map +1 -1
  22. package/declarations/components/forms/date-picker/end-content.d.ts +33 -3
  23. package/declarations/components/forms/date-picker/end-content.d.ts.map +1 -1
  24. package/declarations/components/forms/date-picker/types.d.ts +30 -1
  25. package/declarations/components/forms/date-picker/types.d.ts.map +1 -1
  26. package/declarations/components/forms/field.d.ts +3 -0
  27. package/declarations/components/forms/field.d.ts.map +1 -1
  28. package/declarations/components/forms/index.d.ts +1 -0
  29. package/declarations/components/forms/index.d.ts.map +1 -1
  30. package/declarations/components/forms/input.d.ts +11 -11
  31. package/declarations/components/forms/native-select.d.ts +8 -8
  32. package/declarations/components/forms/select/select.d.ts +16 -16
  33. package/declarations/components/forms/textarea.d.ts +7 -7
  34. package/declarations/components/utilities/avatar.d.ts +35 -2
  35. package/declarations/components/utilities/avatar.d.ts.map +1 -1
  36. package/declarations/test-support.d.ts +30 -0
  37. package/declarations/test-support.d.ts.map +1 -1
  38. package/dist/components/buttons/chip.js.map +1 -1
  39. package/dist/components/collections/dropdown/menu-context.js.map +1 -1
  40. package/dist/components/collections/dropdown/sub.js +76 -11
  41. package/dist/components/collections/dropdown/sub.js.map +1 -1
  42. package/dist/components/forms/date-input/clipboard.js +162 -0
  43. package/dist/components/forms/date-input/clipboard.js.map +1 -0
  44. package/dist/components/forms/date-input/date-input.js +194 -0
  45. package/dist/components/forms/date-input/date-input.js.map +1 -0
  46. package/dist/components/forms/date-input/segment-group.js +271 -0
  47. package/dist/components/forms/date-input/segment-group.js.map +1 -0
  48. package/dist/components/forms/date-input/segments.js +379 -0
  49. package/dist/components/forms/date-input/segments.js.map +1 -0
  50. package/dist/components/forms/date-input/types.js +2 -0
  51. package/dist/components/forms/date-input/types.js.map +1 -0
  52. package/dist/components/forms/date-input.js +4 -0
  53. package/dist/components/forms/date-input.js.map +1 -0
  54. package/dist/components/forms/date-picker/date-picker.js +301 -14
  55. package/dist/components/forms/date-picker/date-picker.js.map +1 -1
  56. package/dist/components/forms/date-picker/end-content.js +17 -4
  57. package/dist/components/forms/date-picker/end-content.js.map +1 -1
  58. package/dist/components/forms/field.js +4 -1
  59. package/dist/components/forms/field.js.map +1 -1
  60. package/dist/components/forms/index.js +3 -0
  61. package/dist/components/forms/index.js.map +1 -1
  62. package/dist/components/utilities/avatar.js +30 -5
  63. package/dist/components/utilities/avatar.js.map +1 -1
  64. package/dist/forms.js +3 -0
  65. package/dist/forms.js.map +1 -1
  66. package/dist/index.js +3 -0
  67. package/dist/index.js.map +1 -1
  68. package/dist/test-support.js +480 -1
  69. package/dist/test-support.js.map +1 -1
  70. package/package.json +3 -3
@@ -1,3 +1,4 @@
1
+ import { concat } from '@ember/helper';
1
2
  import { CloseButton } from '../../buttons/close-button.js';
2
3
  import { e as IconCalendar } from '../../../icons-DZ61nCzv.js';
3
4
  import { precompileTemplate } from '@ember/template-compilation';
@@ -5,14 +6,26 @@ import { setComponentTemplate } from '@ember/component';
5
6
  import templateOnly from '@ember/component/template-only';
6
7
 
7
8
  /**
8
- * The cluster at the end of the field: exactly one of the clear button or the
9
- * calendar icon. Pointer events are off so a click anywhere in the field still
10
- * reaches the trigger; the clear button opts back in.
9
+ * The cluster at the end of the field.
10
+ *
11
+ * The segmented field shows the clear button *and* the calendar button: the
12
+ * calendar button is the only way to open the popover on that path, so
13
+ * swapping it out for a clear button would mean a clearable picker holding a
14
+ * value could not be picked from at all.
15
+ *
16
+ * The button-trigger path keeps the either/or it shipped with. There the
17
+ * trigger itself opens the popover and the calendar icon is decorative, so the
18
+ * clear button takes its place with nothing lost.
19
+ *
20
+ * Pointer events are off on that path so a click anywhere in the field still
21
+ * reaches the trigger; the clear button opts back in per element, and the
22
+ * segmented field turns them on for the whole cluster.
11
23
  */
12
- const DatePickerEndContent = setComponentTemplate(precompileTemplate("<div data-part=\"end-content\" class={{@classes.endContent class=@userClasses.endContent endContentPointerEvents=(if @endContentPointerEvents @endContentPointerEvents \"none\")}} ...attributes>\n {{#if @isClearable}}\n <CloseButton @title=\"Clear\" @variant=\"soft\" @size=\"xs\" @class={{@classes.clearButton class=@userClasses.clearButton}} data-part=\"clear-button\" @onPress={{@onClear}} />\n {{else}}\n <IconCalendar data-part=\"icon\" class={{@classes.icon class=@userClasses.icon}} />\n {{/if}}\n</div>", {
24
+ const DatePickerEndContent = setComponentTemplate(precompileTemplate("<div data-part=\"end-content\" class={{@classes.endContent class=@userClasses.endContent endContentPointerEvents=(if @endContentPointerEvents @endContentPointerEvents \"none\")}} ...attributes>\n {{#if @isClearable}}\n <CloseButton @title=\"Clear\" @variant=\"soft\" @size=\"xs\" @class={{@classes.clearButton class=@userClasses.clearButton}} data-part=\"clear-button\" @onPress={{@onClear}} />\n {{/if}}\n\n {{#if @isEditable}}\n <button type=\"button\" data-part=\"calendar-button\" aria-haspopup=\"dialog\" aria-label={{if @label (concat \"Choose date, \" @label) \"Choose date\"}} disabled={{@isDisabled}} class={{@classes.calendarButton class=@userClasses.calendarButton}} {{@trigger}}>\n <IconCalendar data-part=\"icon\" class={{@classes.icon class=@userClasses.icon}} />\n </button>\n {{else}}\n {{!-- On the button-trigger path the icon is decorative and the clear\n button takes its place, so it only renders when there is no clear\n button to show. --}}\n {{#unless @isClearable}}\n <IconCalendar data-part=\"icon\" class={{@classes.icon class=@userClasses.icon}} />\n {{/unless}}\n {{/if}}\n</div>", {
13
25
  strictMode: true,
14
26
  scope: () => ({
15
27
  CloseButton,
28
+ concat,
16
29
  IconCalendar
17
30
  })
18
31
  }), templateOnly());
@@ -1 +1 @@
1
- {"version":3,"file":"end-content.js","sources":["../../../../src/components/forms/date-picker/end-content.gts"],"sourcesContent":["import type { TOC } from '@ember/component/template-only';\nimport type { SlotsToClasses, DatePickerSlots } from '@frontile/theme';\nimport type { DatePickerClasses } from './types';\nimport { CloseButton } from '../../buttons/close-button';\nimport { IconCalendar } from '../../../-private/icons';\n\ninterface DatePickerEndContentSignature {\n Args: {\n classes: DatePickerClasses;\n userClasses?: SlotsToClasses<DatePickerSlots>;\n isClearable: boolean;\n onClear: () => void;\n\n /**\n * Defaults to `none` so clicks fall through to the trigger; content that\n * needs its own events opts back in per element.\n *\n * The theme declares no default for this variant, so leaving it unset\n * yields neither class and the browser default (`auto`) wins -- which\n * makes the cluster sit over the right edge of the field and swallow\n * clicks on the calendar icon.\n */\n endContentPointerEvents?: 'none' | 'auto';\n };\n Element: HTMLDivElement;\n}\n\n/**\n * The cluster at the end of the field: exactly one of the clear button or the\n * calendar icon. Pointer events are off so a click anywhere in the field still\n * reaches the trigger; the clear button opts back in.\n */\nconst DatePickerEndContent: TOC<DatePickerEndContentSignature> = <template>\n <div\n data-part=\"end-content\"\n class={{@classes.endContent\n class=@userClasses.endContent\n endContentPointerEvents=(if\n @endContentPointerEvents @endContentPointerEvents \"none\"\n )\n }}\n ...attributes\n >\n {{#if @isClearable}}\n <CloseButton\n @title=\"Clear\"\n @variant=\"soft\"\n @size=\"xs\"\n @class={{@classes.clearButton class=@userClasses.clearButton}}\n data-part=\"clear-button\"\n @onPress={{@onClear}}\n />\n {{else}}\n <IconCalendar\n data-part=\"icon\"\n class={{@classes.icon class=@userClasses.icon}}\n />\n {{/if}}\n </div>\n</template>;\n\nexport { DatePickerEndContent, type DatePickerEndContentSignature };\n"],"names":["DatePickerEndContent","setComponentTemplate","precompileTemplate","strictMode","scope","CloseButton","IconCalendar","templateOnly"],"mappings":";;;;;;AA2BA;;;;AAIC;AACD,MAAMA,oBAA0B,GAAAC,oBAAA,CAAiCC,kBAAA,CAAA,wgBAAA,EA2BjE;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,WAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;;"}
1
+ {"version":3,"file":"end-content.js","sources":["../../../../src/components/forms/date-picker/end-content.gts"],"sourcesContent":["import type { TOC } from '@ember/component/template-only';\nimport { concat } from '@ember/helper';\nimport type { ModifierLike } from '@glint/template';\nimport type { SlotsToClasses, DatePickerSlots } from '@frontile/theme';\nimport type { DatePickerClasses } from './types';\nimport { CloseButton } from '../../buttons/close-button';\nimport { IconCalendar } from '../../../-private/icons';\n\ninterface DatePickerEndContentSignature {\n Args: {\n classes: DatePickerClasses;\n userClasses?: SlotsToClasses<DatePickerSlots>;\n isClearable: boolean;\n onClear: () => void;\n\n /**\n * Whether the field is segmented. There is no button trigger on that path,\n * so the calendar icon becomes the button that opens the popover -- the\n * one thing a segmented field cannot do by clicking the value itself,\n * because clicking a segment has to put the caret in it.\n */\n isEditable?: boolean;\n\n /**\n * The popover's `trigger` modifier, for the calendar button. Required\n * rather than optional because the calendar button is unreachable without\n * it, and an unapplied modifier is a silent dead control.\n */\n trigger: ModifierLike<{ Element: HTMLElement }>;\n\n /** Names the calendar button, which has no text of its own. */\n label?: string;\n isDisabled?: boolean;\n\n /**\n * Defaults to `none` so clicks fall through to the trigger; content that\n * needs its own events opts back in per element.\n *\n * The theme declares no default for this variant, so leaving it unset\n * yields neither class and the browser default (`auto`) wins -- which\n * makes the cluster sit over the right edge of the field and swallow\n * clicks on the calendar icon.\n */\n endContentPointerEvents?: 'none' | 'auto';\n };\n Element: HTMLDivElement;\n}\n\n/**\n * The cluster at the end of the field.\n *\n * The segmented field shows the clear button *and* the calendar button: the\n * calendar button is the only way to open the popover on that path, so\n * swapping it out for a clear button would mean a clearable picker holding a\n * value could not be picked from at all.\n *\n * The button-trigger path keeps the either/or it shipped with. There the\n * trigger itself opens the popover and the calendar icon is decorative, so the\n * clear button takes its place with nothing lost.\n *\n * Pointer events are off on that path so a click anywhere in the field still\n * reaches the trigger; the clear button opts back in per element, and the\n * segmented field turns them on for the whole cluster.\n */\nconst DatePickerEndContent: TOC<DatePickerEndContentSignature> = <template>\n <div\n data-part=\"end-content\"\n class={{@classes.endContent\n class=@userClasses.endContent\n endContentPointerEvents=(if\n @endContentPointerEvents @endContentPointerEvents \"none\"\n )\n }}\n ...attributes\n >\n {{#if @isClearable}}\n <CloseButton\n @title=\"Clear\"\n @variant=\"soft\"\n @size=\"xs\"\n @class={{@classes.clearButton class=@userClasses.clearButton}}\n data-part=\"clear-button\"\n @onPress={{@onClear}}\n />\n {{/if}}\n\n {{#if @isEditable}}\n <button\n type=\"button\"\n data-part=\"calendar-button\"\n aria-haspopup=\"dialog\"\n aria-label={{if @label (concat \"Choose date, \" @label) \"Choose date\"}}\n disabled={{@isDisabled}}\n class={{@classes.calendarButton class=@userClasses.calendarButton}}\n {{@trigger}}\n >\n <IconCalendar\n data-part=\"icon\"\n class={{@classes.icon class=@userClasses.icon}}\n />\n </button>\n {{else}}\n {{! On the button-trigger path the icon is decorative and the clear\n button takes its place, so it only renders when there is no clear\n button to show. }}\n {{#unless @isClearable}}\n <IconCalendar\n data-part=\"icon\"\n class={{@classes.icon class=@userClasses.icon}}\n />\n {{/unless}}\n {{/if}}\n </div>\n</template>;\n\nexport { DatePickerEndContent, type DatePickerEndContentSignature };\n"],"names":["DatePickerEndContent","setComponentTemplate","precompileTemplate","strictMode","scope","CloseButton","concat","IconCalendar","templateOnly"],"mappings":";;;;;;;AAgDA;;;;;;;;;;;;;;;AAeC;AACD,MAAMA,oBAA0B,GAAAC,oBAAA,CAAiCC,kBAAA,CAAA,qoCAAA,EAiDjE;EAAAC,UAAA,EAAA,IAAA;AAAAC,EAAAA,KAAA,EAAAA,OAAA;IAAAC,WAAA;IAAAC,MAAA;AAAAC,IAAAA;AAAA,GAAA;AAAU,CAAA,CAAA,EAAAC,YAAA,EAAA;;"}
@@ -4,6 +4,8 @@ import { get, action } from '@ember/object';
4
4
  import { debounce } from '@ember/runloop';
5
5
  import { Checkbox } from './checkbox.js';
6
6
  import { CheckboxGroup } from './checkbox-group.js';
7
+ import '@ember/debug';
8
+ import { DateInput } from './date-input/date-input.js';
7
9
  import { DatePicker } from './date-picker/date-picker.js';
8
10
  import { Input } from './input.js';
9
11
  import { InputOtp } from './input-otp.js';
@@ -83,7 +85,7 @@ class Field extends Component {
83
85
  decorateMethodV2(this.prototype, "handleBlur", [action]);
84
86
  }
85
87
  static {
86
- setComponentTemplate(precompileTemplate("{{!-- @glint-nocheck component generics (radio, radio-group, select) trigger: type instantiation is excessively deep and possibly infinite --}}\n{{yield (hash Checkbox=(component Checkbox name=@name errors=this.fieldErrors checked=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) CheckboxGroup=(component CheckboxGroup name=@name errors=this.fieldErrors isDisabled=@disabled) Input=(component Input name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur) InputOtp=(component InputOtp name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur) Radio=(component Radio name=@name errors=this.fieldErrors checkedValue=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) RadioGroup=(component RadioGroup name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange) SingleSelect=(component Select name=@name errors=this.fieldErrors selectedKey=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) MultiSelect=(component Select selectionMode=\"multiple\" name=@name errors=this.fieldErrors selectedKeys=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) DatePicker=(component DatePicker name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) DateRangePicker=(component DatePicker mode=\"range\" name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) Switch=(component Switch name=@name errors=this.fieldErrors isSelected=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) Textarea=(component Textarea name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur)) to=\"default\"}}", {
88
+ setComponentTemplate(precompileTemplate("{{!-- @glint-nocheck component generics (radio, radio-group, select) trigger: type instantiation is excessively deep and possibly infinite --}}\n{{yield (hash Checkbox=(component Checkbox name=@name errors=this.fieldErrors checked=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) CheckboxGroup=(component CheckboxGroup name=@name errors=this.fieldErrors isDisabled=@disabled) Input=(component Input name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur) InputOtp=(component InputOtp name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur) Radio=(component Radio name=@name errors=this.fieldErrors checkedValue=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) RadioGroup=(component RadioGroup name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange) SingleSelect=(component Select name=@name errors=this.fieldErrors selectedKey=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) MultiSelect=(component Select selectionMode=\"multiple\" name=@name errors=this.fieldErrors selectedKeys=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) DatePicker=(component DatePicker name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) DateRangePicker=(component DatePicker mode=\"range\" name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) DateInput=(component DateInput name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onBlur=this.handleBlur) Switch=(component Switch name=@name errors=this.fieldErrors isSelected=this.fieldValue isDisabled=@disabled onChange=this.handleChange onBlur=this.handleBlur) Textarea=(component Textarea name=@name errors=this.fieldErrors value=this.fieldValue isDisabled=@disabled onChange=this.handleChange onInput=this.handleInput onBlur=this.handleBlur)) to=\"default\"}}", {
87
89
  strictMode: true,
88
90
  scope: () => ({
89
91
  hash,
@@ -95,6 +97,7 @@ class Field extends Component {
95
97
  RadioGroup,
96
98
  Select,
97
99
  DatePicker,
100
+ DateInput,
98
101
  Switch,
99
102
  Textarea
100
103
  })
@@ -1 +1 @@
1
- {"version":3,"file":"field.js","sources":["../../../src/components/forms/field.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { action, get } from '@ember/object';\nimport { debounce } from '@ember/runloop';\nimport Checkbox from './checkbox';\nimport CheckboxGroup from './checkbox-group';\nimport DatePicker from './date-picker';\nimport Input from './input';\nimport InputOtp from './input-otp';\nimport Radio from './radio';\nimport RadioGroup from './radio-group';\nimport Select from './select';\nimport Switch from './switch';\nimport Textarea from './textarea';\n\nimport type { WithBoundArgs } from '@glint/template';\nimport type { FormDataCompiled, FormErrors } from './form';\nimport type { DatePickerSignature } from './date-picker';\nimport type { SelectSignature } from './select';\nimport type { WithBoundArgsForSignature } from './field-types';\n\ntype BoundSingleSelect<S = unknown> = WithBoundArgsForSignature<\n SelectSignature<S>,\n 'name' | 'errors' | 'selectedKey' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundMultiSelect<S = unknown> = WithBoundArgsForSignature<\n SelectSignature<S>,\n 'selectionMode' | 'name' | 'errors' | 'selectedKeys' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundDatePicker = WithBoundArgsForSignature<\n DatePickerSignature<'single'>,\n 'name' | 'errors' | 'value' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundDateRangePicker = WithBoundArgsForSignature<\n DatePickerSignature<'range'>,\n 'mode' | 'name' | 'errors' | 'value' | 'onBlur' | 'isDisabled'\n>;\n\ninterface FieldSignature<T extends Record<string, unknown> = FormDataCompiled> {\n Element: HTMLElement;\n Args: {\n /** The name of the form field. */\n name: string;\n /** The validation errors for the form, keyed by field name. */\n errors?: FormErrors;\n /** The form data as key/value pairs. */\n formData?: T;\n /** Whether the field should be disabled. */\n disabled?: boolean;\n /** When to run validation. */\n validateOn?: ('change' | 'input' | 'blur')[];\n /** Function to validate a single field by name. */\n validateField?: (data: T, name: string) => Promise<FormErrors | undefined>;\n };\n Blocks: {\n default: [\n {\n Checkbox: WithBoundArgs<\n typeof Checkbox,\n 'name' | 'errors' | 'checked' | 'onChange' | 'onBlur' | 'isDisabled'\n >;\n CheckboxGroup: WithBoundArgs<\n typeof CheckboxGroup,\n 'name' | 'errors' | 'isDisabled'\n >;\n Input: WithBoundArgs<\n typeof Input,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n InputOtp: WithBoundArgs<\n typeof InputOtp,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n Radio: WithBoundArgs<\n typeof Radio,\n | 'name'\n | 'errors'\n | 'checkedValue'\n | 'onChange'\n | 'onBlur'\n | 'isDisabled'\n >;\n RadioGroup: WithBoundArgs<\n typeof RadioGroup,\n 'name' | 'errors' | 'value' | 'onChange' | 'isDisabled'\n >;\n SingleSelect: BoundSingleSelect;\n MultiSelect: BoundMultiSelect;\n DatePicker: BoundDatePicker;\n DateRangePicker: BoundDateRangePicker;\n Switch: WithBoundArgs<\n typeof Switch,\n | 'name'\n | 'errors'\n | 'isSelected'\n | 'onChange'\n | 'onBlur'\n | 'isDisabled'\n >;\n Textarea: WithBoundArgs<\n typeof Textarea,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n }\n ];\n };\n}\n\n/**\n * Field is a component wrapper that provides conveniences for form fields.\n * It automatically binds the appropriate form errors by name to yielded\n * components.\n */\nclass Field<\n T extends Record<string, unknown> = FormDataCompiled\n> extends Component<FieldSignature<T>> {\n /**\n * Returns the validation errors for the field.\n * Supports dotted field names (e.g., 'profile.email').\n */\n get fieldErrors() {\n return this.args.errors?.[this.args.name];\n }\n\n /** The events on which validation should run. Defaults to ['change']. */\n get validateOn(): ('change' | 'input' | 'blur')[] {\n return this.args.validateOn ?? ['change'];\n }\n\n /**\n * Returns the current value for the field from formData.\n * Supports both flat and dotted field names (e.g., 'email' or 'profile.email').\n * Uses Ember's get() which handles both flat keys and dotted paths.\n */\n get fieldValue() {\n if (!this.args.formData) return undefined;\n\n return get(this.args.formData, this.args.name);\n }\n\n /**\n * Validates the field by calling the validateField function passed in args.\n */\n validateField() {\n this.args.validateField?.(this.args.formData as T, this.args.name);\n }\n\n /**\n * Validates the field on change if change validation is enabled.\n */\n @action\n handleChange() {\n if (this.validateOn?.includes('change')) {\n this.validateField();\n }\n }\n\n /**\n * Validates the field on input if input validation is enabled.\n * Debounces validation to avoid excessive validation calls on every keystroke.\n */\n @action\n handleInput() {\n if (this.validateOn?.includes('input')) {\n debounce(this, this.validateField, 300);\n }\n }\n\n /**\n * Validates the field on blur if blur validation is enabled.\n */\n @action\n handleBlur() {\n if (this.validateOn.includes('blur')) {\n this.validateField();\n }\n }\n\n <template>\n {{! @glint-nocheck component generics (radio, radio-group, select) trigger: type instantiation is excessively deep and possibly infinite }}\n {{yield\n (hash\n Checkbox=(component\n Checkbox\n name=@name\n errors=this.fieldErrors\n checked=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n CheckboxGroup=(component\n CheckboxGroup name=@name errors=this.fieldErrors isDisabled=@disabled\n )\n Input=(component\n Input\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n InputOtp=(component\n InputOtp\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n Radio=(component\n Radio\n name=@name\n errors=this.fieldErrors\n checkedValue=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n RadioGroup=(component\n RadioGroup\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n )\n SingleSelect=(component\n Select\n name=@name\n errors=this.fieldErrors\n selectedKey=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n MultiSelect=(component\n Select\n selectionMode=\"multiple\"\n name=@name\n errors=this.fieldErrors\n selectedKeys=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n DatePicker=(component\n DatePicker\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n DateRangePicker=(component\n DatePicker\n mode=\"range\"\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n Switch=(component\n Switch\n name=@name\n errors=this.fieldErrors\n isSelected=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n Textarea=(component\n Textarea\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n )\n to=\"default\"\n }}\n </template>\n}\n\nexport { Field, type FieldSignature };\nexport default Field;\n"],"names":["Field","Component","fieldErrors","args","errors","name","validateOn","fieldValue","formData","undefined","get","validateField","handleChange","includes","n","prototype","action","handleInput","debounce","handleBlur","setComponentTemplate","precompileTemplate","strictMode","scope","hash","Checkbox","CheckboxGroup","Input","InputOtp","Radio","RadioGroup","Select","DatePicker","Switch","Textarea"],"mappings":";;;;;;;;;;;;;;;;;;AAiIA;;;;;AAKA,MAAMA,KAAA,SAEIC,SAAA,CAAyB;AACjC;;;AAGC;EACD,IAAIC,WAAAA,GAAc;IAChB,OAAO,IAAI,CAACC,IAAI,CAACC,MAAM,GAAG,IAAI,CAACD,IAAI,CAACE,IAAI,CAAC;AAC3C,EAAA;AAEA;EACA,IAAIC,UAAAA,GAA8C;IAChD,OAAO,IAAI,CAACH,IAAI,CAACG,UAAU,IAAI,CAAC,QAAA,CAAS;AAC3C,EAAA;AAEA;;;;AAIC;EACD,IAAIC,UAAAA,GAAa;IACf,IAAI,CAAC,IAAI,CAACJ,IAAI,CAACK,QAAQ,EAAE,OAAOC,SAAA;AAEhC,IAAA,OAAOC,GAAA,CAAI,IAAI,CAACP,IAAI,CAACK,QAAQ,EAAE,IAAI,CAACL,IAAI,CAACE,IAAI,CAAA;AAC/C,EAAA;AAEA;;AAEC;AACDM,EAAAA,aAAAA,GAAgB;AACd,IAAA,IAAI,CAACR,IAAI,CAACQ,aAAa,GAAG,IAAI,CAACR,IAAI,CAACK,QAAQ,EAAO,IAAI,CAACL,IAAI,CAACE,IAAI,CAAA;AACnE,EAAA;AAEA;;AAEC;AAEDO,EAAAA,YAAAA,GAAe;IACb,IAAI,IAAI,CAACN,UAAU,EAAEO,SAAS,QAAA,CAAA,EAAW;MACvC,IAAI,CAACF,aAAa,EAAA;AACpB,IAAA;AACF,EAAA;AAEA;;;AAGC;AAHD,EAAA;IAAAG,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAPCC,MAAA,CAAA,CAAA;AAAA;AAYDC,EAAAA,WAAAA,GAAc;IACZ,IAAI,IAAI,CAACX,UAAU,EAAEO,SAAS,OAAA,CAAA,EAAU;MACtCK,QAAA,CAAS,IAAI,EAAE,IAAI,CAACP,aAAa,EAAE,GAAA,CAAA;AACrC,IAAA;AACF,EAAA;AAEA;;AAEC;AAFD,EAAA;IAAAG,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,aAAA,EAAA,CAPCC,MAAA,CAAA,CAAA;AAAA;AAWDG,EAAAA,UAAAA,GAAa;IACX,IAAI,IAAI,CAACb,UAAU,CAACO,QAAQ,CAAC,MAAA,CAAA,EAAS;MACpC,IAAI,CAACF,aAAa,EAAA;AACpB,IAAA;AACF,EAAA;AAAA,EAAA;IAAAG,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CALCC,MAAA,CAAA,CAAA;AAAA;AAOD,EAAA;IAAAI,oBAAA,CAAAC,kBAAA,CAAA,8+DAAA,EA6GA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,IAAA;QAAAC,QAAA;QAAAC,aAAA;QAAAC,KAAA;QAAAC,QAAA;QAAAC,KAAA;QAAAC,UAAA;QAAAC,MAAA;QAAAC,UAAA;QAAAC,MAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
1
+ {"version":3,"file":"field.js","sources":["../../../src/components/forms/field.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { hash } from '@ember/helper';\nimport { action, get } from '@ember/object';\nimport { debounce } from '@ember/runloop';\nimport Checkbox from './checkbox';\nimport CheckboxGroup from './checkbox-group';\nimport DateInput from './date-input';\nimport DatePicker from './date-picker';\nimport Input from './input';\nimport InputOtp from './input-otp';\nimport Radio from './radio';\nimport RadioGroup from './radio-group';\nimport Select from './select';\nimport Switch from './switch';\nimport Textarea from './textarea';\n\nimport type { WithBoundArgs } from '@glint/template';\nimport type { FormDataCompiled, FormErrors } from './form';\nimport type { DateInputSignature } from './date-input';\nimport type { DatePickerSignature } from './date-picker';\nimport type { SelectSignature } from './select';\nimport type { WithBoundArgsForSignature } from './field-types';\n\ntype BoundSingleSelect<S = unknown> = WithBoundArgsForSignature<\n SelectSignature<S>,\n 'name' | 'errors' | 'selectedKey' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundMultiSelect<S = unknown> = WithBoundArgsForSignature<\n SelectSignature<S>,\n 'selectionMode' | 'name' | 'errors' | 'selectedKeys' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundDatePicker = WithBoundArgsForSignature<\n DatePickerSignature<'single'>,\n 'name' | 'errors' | 'value' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundDateInput = WithBoundArgsForSignature<\n DateInputSignature,\n 'name' | 'errors' | 'value' | 'onBlur' | 'isDisabled'\n>;\n\ntype BoundDateRangePicker = WithBoundArgsForSignature<\n DatePickerSignature<'range'>,\n 'mode' | 'name' | 'errors' | 'value' | 'onBlur' | 'isDisabled'\n>;\n\ninterface FieldSignature<T extends Record<string, unknown> = FormDataCompiled> {\n Element: HTMLElement;\n Args: {\n /** The name of the form field. */\n name: string;\n /** The validation errors for the form, keyed by field name. */\n errors?: FormErrors;\n /** The form data as key/value pairs. */\n formData?: T;\n /** Whether the field should be disabled. */\n disabled?: boolean;\n /** When to run validation. */\n validateOn?: ('change' | 'input' | 'blur')[];\n /** Function to validate a single field by name. */\n validateField?: (data: T, name: string) => Promise<FormErrors | undefined>;\n };\n Blocks: {\n default: [\n {\n Checkbox: WithBoundArgs<\n typeof Checkbox,\n 'name' | 'errors' | 'checked' | 'onChange' | 'onBlur' | 'isDisabled'\n >;\n CheckboxGroup: WithBoundArgs<\n typeof CheckboxGroup,\n 'name' | 'errors' | 'isDisabled'\n >;\n Input: WithBoundArgs<\n typeof Input,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n InputOtp: WithBoundArgs<\n typeof InputOtp,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n Radio: WithBoundArgs<\n typeof Radio,\n | 'name'\n | 'errors'\n | 'checkedValue'\n | 'onChange'\n | 'onBlur'\n | 'isDisabled'\n >;\n RadioGroup: WithBoundArgs<\n typeof RadioGroup,\n 'name' | 'errors' | 'value' | 'onChange' | 'isDisabled'\n >;\n SingleSelect: BoundSingleSelect;\n MultiSelect: BoundMultiSelect;\n DatePicker: BoundDatePicker;\n DateRangePicker: BoundDateRangePicker;\n DateInput: BoundDateInput;\n Switch: WithBoundArgs<\n typeof Switch,\n | 'name'\n | 'errors'\n | 'isSelected'\n | 'onChange'\n | 'onBlur'\n | 'isDisabled'\n >;\n Textarea: WithBoundArgs<\n typeof Textarea,\n | 'name'\n | 'errors'\n | 'value'\n | 'onChange'\n | 'onInput'\n | 'onBlur'\n | 'isDisabled'\n >;\n }\n ];\n };\n}\n\n/**\n * Field is a component wrapper that provides conveniences for form fields.\n * It automatically binds the appropriate form errors by name to yielded\n * components.\n */\nclass Field<\n T extends Record<string, unknown> = FormDataCompiled\n> extends Component<FieldSignature<T>> {\n /**\n * Returns the validation errors for the field.\n * Supports dotted field names (e.g., 'profile.email').\n */\n get fieldErrors() {\n return this.args.errors?.[this.args.name];\n }\n\n /** The events on which validation should run. Defaults to ['change']. */\n get validateOn(): ('change' | 'input' | 'blur')[] {\n return this.args.validateOn ?? ['change'];\n }\n\n /**\n * Returns the current value for the field from formData.\n * Supports both flat and dotted field names (e.g., 'email' or 'profile.email').\n * Uses Ember's get() which handles both flat keys and dotted paths.\n */\n get fieldValue() {\n if (!this.args.formData) return undefined;\n\n return get(this.args.formData, this.args.name);\n }\n\n /**\n * Validates the field by calling the validateField function passed in args.\n */\n validateField() {\n this.args.validateField?.(this.args.formData as T, this.args.name);\n }\n\n /**\n * Validates the field on change if change validation is enabled.\n */\n @action\n handleChange() {\n if (this.validateOn?.includes('change')) {\n this.validateField();\n }\n }\n\n /**\n * Validates the field on input if input validation is enabled.\n * Debounces validation to avoid excessive validation calls on every keystroke.\n */\n @action\n handleInput() {\n if (this.validateOn?.includes('input')) {\n debounce(this, this.validateField, 300);\n }\n }\n\n /**\n * Validates the field on blur if blur validation is enabled.\n */\n @action\n handleBlur() {\n if (this.validateOn.includes('blur')) {\n this.validateField();\n }\n }\n\n <template>\n {{! @glint-nocheck component generics (radio, radio-group, select) trigger: type instantiation is excessively deep and possibly infinite }}\n {{yield\n (hash\n Checkbox=(component\n Checkbox\n name=@name\n errors=this.fieldErrors\n checked=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n CheckboxGroup=(component\n CheckboxGroup name=@name errors=this.fieldErrors isDisabled=@disabled\n )\n Input=(component\n Input\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n InputOtp=(component\n InputOtp\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n Radio=(component\n Radio\n name=@name\n errors=this.fieldErrors\n checkedValue=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n RadioGroup=(component\n RadioGroup\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n )\n SingleSelect=(component\n Select\n name=@name\n errors=this.fieldErrors\n selectedKey=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n MultiSelect=(component\n Select\n selectionMode=\"multiple\"\n name=@name\n errors=this.fieldErrors\n selectedKeys=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n DatePicker=(component\n DatePicker\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n DateRangePicker=(component\n DatePicker\n mode=\"range\"\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n DateInput=(component\n DateInput\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onBlur=this.handleBlur\n )\n Switch=(component\n Switch\n name=@name\n errors=this.fieldErrors\n isSelected=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onBlur=this.handleBlur\n )\n Textarea=(component\n Textarea\n name=@name\n errors=this.fieldErrors\n value=this.fieldValue\n isDisabled=@disabled\n onChange=this.handleChange\n onInput=this.handleInput\n onBlur=this.handleBlur\n )\n )\n to=\"default\"\n }}\n </template>\n}\n\nexport { Field, type FieldSignature };\nexport default Field;\n"],"names":["Field","Component","fieldErrors","args","errors","name","validateOn","fieldValue","formData","undefined","get","validateField","handleChange","includes","n","prototype","action","handleInput","debounce","handleBlur","setComponentTemplate","precompileTemplate","strictMode","scope","hash","Checkbox","CheckboxGroup","Input","InputOtp","Radio","RadioGroup","Select","DatePicker","DateInput","Switch","Textarea"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyIA;;;;;AAKA,MAAMA,KAAA,SAEIC,SAAA,CAAyB;AACjC;;;AAGC;EACD,IAAIC,WAAAA,GAAc;IAChB,OAAO,IAAI,CAACC,IAAI,CAACC,MAAM,GAAG,IAAI,CAACD,IAAI,CAACE,IAAI,CAAC;AAC3C,EAAA;AAEA;EACA,IAAIC,UAAAA,GAA8C;IAChD,OAAO,IAAI,CAACH,IAAI,CAACG,UAAU,IAAI,CAAC,QAAA,CAAS;AAC3C,EAAA;AAEA;;;;AAIC;EACD,IAAIC,UAAAA,GAAa;IACf,IAAI,CAAC,IAAI,CAACJ,IAAI,CAACK,QAAQ,EAAE,OAAOC,SAAA;AAEhC,IAAA,OAAOC,GAAA,CAAI,IAAI,CAACP,IAAI,CAACK,QAAQ,EAAE,IAAI,CAACL,IAAI,CAACE,IAAI,CAAA;AAC/C,EAAA;AAEA;;AAEC;AACDM,EAAAA,aAAAA,GAAgB;AACd,IAAA,IAAI,CAACR,IAAI,CAACQ,aAAa,GAAG,IAAI,CAACR,IAAI,CAACK,QAAQ,EAAO,IAAI,CAACL,IAAI,CAACE,IAAI,CAAA;AACnE,EAAA;AAEA;;AAEC;AAEDO,EAAAA,YAAAA,GAAe;IACb,IAAI,IAAI,CAACN,UAAU,EAAEO,SAAS,QAAA,CAAA,EAAW;MACvC,IAAI,CAACF,aAAa,EAAA;AACpB,IAAA;AACF,EAAA;AAEA;;;AAGC;AAHD,EAAA;IAAAG,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,cAAA,EAAA,CAPCC,MAAA,CAAA,CAAA;AAAA;AAYDC,EAAAA,WAAAA,GAAc;IACZ,IAAI,IAAI,CAACX,UAAU,EAAEO,SAAS,OAAA,CAAA,EAAU;MACtCK,QAAA,CAAS,IAAI,EAAE,IAAI,CAACP,aAAa,EAAE,GAAA,CAAA;AACrC,IAAA;AACF,EAAA;AAEA;;AAEC;AAFD,EAAA;IAAAG,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,aAAA,EAAA,CAPCC,MAAA,CAAA,CAAA;AAAA;AAWDG,EAAAA,UAAAA,GAAa;IACX,IAAI,IAAI,CAACb,UAAU,CAACO,QAAQ,CAAC,MAAA,CAAA,EAAS;MACpC,IAAI,CAACF,aAAa,EAAA;AACpB,IAAA;AACF,EAAA;AAAA,EAAA;IAAAG,gBAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,YAAA,EAAA,CALCC,MAAA,CAAA,CAAA;AAAA;AAOD,EAAA;IAAAI,oBAAA,CAAAC,kBAAA,CAAA,mnEAAA,EAqHA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;QAAAC,IAAA;QAAAC,QAAA;QAAAC,aAAA;QAAAC,KAAA;QAAAC,QAAA;QAAAC,KAAA;QAAAC,UAAA;QAAAC,MAAA;QAAAC,UAAA;QAAAC,SAAA;QAAAC,MAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
@@ -17,6 +17,9 @@ export { FormControl } from './form-control.js';
17
17
  export { Switch } from './switch.js';
18
18
  export { DatePicker } from './date-picker/date-picker.js';
19
19
  export { formatValue, isEmptyValue, parseDate, parseRange, toWire } from './date-picker/value.js';
20
+ export { BOUNDS, DEFAULT_FORMAT, applyDigit, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, toDate, toNumericFormat, withValue } from './date-input/segments.js';
21
+ export { formatForClipboard, parsePasted, splitRange } from './date-input/clipboard.js';
22
+ export { DateInput } from './date-input/date-input.js';
20
23
  export { StandardValidator } from '../../utils/standard-validator.js';
21
24
  export { deepEqual, flattenData, hasNestedData, unflattenData } from '../../utils/nested-data.js';
22
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,18 +1,41 @@
1
1
  import Component from '@glimmer/component';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import { action } from '@ember/object';
4
+ import { on } from '@ember/modifier';
2
5
  import { useStyles } from '@frontile/theme';
3
6
  import { precompileTemplate } from '@ember/template-compilation';
4
7
  import { setComponentTemplate } from '@ember/component';
8
+ import { d as decorateFieldV2, i as initializeDeferredDecorator, a as decorateMethodV2 } from '../../runtime--fcdnjmJ-BOdRhmsS.js';
5
9
 
6
10
  class Avatar extends Component {
11
+ static {
12
+ decorateFieldV2(this.prototype, "failedSrc", [tracked]);
13
+ }
14
+ #failedSrc = (initializeDeferredDecorator(this, "failedSrc"), void 0); // Keyed by URL rather than a boolean, so a new `@src` is tried afresh
15
+ // without having to reset anything when the argument changes.
7
16
  get classes() {
8
17
  const {
9
18
  avatar
10
19
  } = useStyles();
11
20
  return avatar({
12
21
  size: this.args.size,
13
- shape: this.args.shape
22
+ shape: this.args.shape,
23
+ fit: this.args.fit,
24
+ isBordered: this.args.isBordered
14
25
  });
15
26
  }
27
+ get hasImage() {
28
+ const {
29
+ src
30
+ } = this.args;
31
+ return Boolean(src) && src !== this.failedSrc;
32
+ }
33
+ handleImageError() {
34
+ this.failedSrc = this.args.src;
35
+ }
36
+ static {
37
+ decorateMethodV2(this.prototype, "handleImageError", [action]);
38
+ }
16
39
  get initials() {
17
40
  const {
18
41
  name,
@@ -27,19 +50,21 @@ class Avatar extends Component {
27
50
  }
28
51
  get shouldShowInitials() {
29
52
  const {
30
- src,
31
53
  name,
32
54
  firstName,
33
55
  lastName
34
56
  } = this.args;
35
- if (src) {
57
+ if (this.hasImage) {
36
58
  return false;
37
59
  }
38
60
  return Boolean(name || firstName || lastName);
39
61
  }
40
62
  static {
41
- setComponentTemplate(precompileTemplate("<span class={{this.classes.base class=@classes.base}} data-component=\"avatar\" data-part=\"base\" ...attributes>\n {{#if this.shouldShowInitials}}\n {{!-- role=\"img\" makes the contents presentational, so the initials stop\n being read. Only claim the role when there is an @alt to name it with;\n otherwise leave the letters as plain text. --}}\n <span aria-label={{@alt}} class={{this.classes.name class=@classes.name}} data-part=\"name\" role={{if @alt \"img\"}}>\n {{this.initials}}\n </span>\n {{/if}}\n {{#if @src}}\n {{!-- An omitted alt makes screen readers fall back to the URL. An empty\n one marks the image decorative, which is right beside a visible name. --}}\n <img class={{this.classes.img class=@classes.img}} data-part=\"img\" src={{@src}} alt={{if @alt @alt \"\"}} />\n {{/if}}\n</span>", {
42
- strictMode: true
63
+ setComponentTemplate(precompileTemplate("<span class={{this.classes.base class=@classes.base}} data-component=\"avatar\" data-part=\"base\" ...attributes>\n {{#if this.shouldShowInitials}}\n {{!-- role=\"img\" makes the contents presentational, so the initials stop\n being read. Only claim the role when there is an @alt to name it with;\n otherwise leave the letters as plain text. --}}\n <span aria-label={{@alt}} class={{this.classes.name class=@classes.name}} data-part=\"name\" role={{if @alt \"img\"}}>\n {{this.initials}}\n </span>\n {{/if}}\n {{#if this.hasImage}}\n {{!-- An omitted alt makes screen readers fall back to the URL. An empty\n one marks the image decorative, which is right beside a visible name. --}}\n <img class={{this.classes.img class=@classes.img}} data-part=\"img\" src={{@src}} alt={{if @alt @alt \"\"}} {{on \"error\" this.handleImageError}} />\n {{/if}}\n</span>", {
64
+ strictMode: true,
65
+ scope: () => ({
66
+ on
67
+ })
43
68
  }), this);
44
69
  }
45
70
  }
@@ -1 +1 @@
1
- {"version":3,"file":"avatar.js","sources":["../../../src/components/utilities/avatar.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport {\n useStyles,\n type AvatarVariants,\n type AvatarSlots,\n type SlotsToClasses\n} from '@frontile/theme';\n\ninterface AvatarSignature {\n Args: {\n /**\n * Controls the size of the avatar.\n *\n * @defaultValue 'md'\n */\n size?: AvatarVariants['size'];\n\n /**\n * Defines the shape of the avatar.\n *\n * @defaultValue 'circle'\n */\n shape?: AvatarVariants['shape'];\n\n /**\n * URL of the image to be displayed in the avatar.\n * If provided, the image will be used instead of initials.\n *\n */\n src?: string | null;\n\n /**\n * Full name of the user, used to generate initials.\n * If `@firstName` and `@lastName` are not provided, initials will be\n * derived from this property.\n */\n name?: string;\n\n /**\n * First name of the user, used to generate initials.\n * If `@name` is not provided, initials will be generated from\n * `@firstName` and `@lastName`.\n */\n firstName?: string;\n\n /**\n * Last name of the user, used to generate initials.\n * If `@name` is not provided, initials will be generated from\n * `@firstName` and `@lastName`.\n */\n lastName?: string;\n\n /**\n * Alternative text for accessibility.\n * If `@src` is provided, this text will be used as the `alt`\n * attribute for the image.\n * If only initials are displayed, this text will be read by screen readers.\n */\n alt?: string;\n\n /**\n * Custom CSS classes for styling different slots within the avatar component.\n */\n classes?: SlotsToClasses<AvatarSlots>;\n };\n\n /**\n * The root element of the avatar component, which is an HTML `<span>` tag.\n */\n Element: HTMLSpanElement;\n}\n\nclass Avatar extends Component<AvatarSignature> {\n get classes() {\n const { avatar } = useStyles();\n return avatar({\n size: this.args.size,\n shape: this.args.shape\n });\n }\n\n get initials() {\n const { name, firstName, lastName } = this.args;\n\n if (name) {\n return name\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((word) => word.charAt(0))\n .join('')\n .toUpperCase();\n }\n\n const initials = [firstName?.charAt(0), lastName?.charAt(0)]\n .filter(Boolean)\n .join('')\n .toUpperCase();\n\n return initials;\n }\n\n get shouldShowInitials() {\n const { src, name, firstName, lastName } = this.args;\n if (src) {\n return false;\n }\n\n return Boolean(name || firstName || lastName);\n }\n\n <template>\n <span\n class={{this.classes.base class=@classes.base}}\n data-component=\"avatar\"\n data-part=\"base\"\n ...attributes\n >\n {{#if this.shouldShowInitials}}\n {{! role=\"img\" makes the contents presentational, so the initials stop\n being read. Only claim the role when there is an @alt to name it with;\n otherwise leave the letters as plain text. }}\n <span\n aria-label={{@alt}}\n class={{this.classes.name class=@classes.name}}\n data-part=\"name\"\n role={{if @alt \"img\"}}\n >\n {{this.initials}}\n </span>\n {{/if}}\n {{#if @src}}\n {{! An omitted alt makes screen readers fall back to the URL. An empty\n one marks the image decorative, which is right beside a visible name. }}\n <img\n class={{this.classes.img class=@classes.img}}\n data-part=\"img\"\n src={{@src}}\n alt={{if @alt @alt \"\"}}\n />\n {{/if}}\n </span>\n </template>\n}\n\nexport { Avatar };\nexport default Avatar;\n"],"names":["Avatar","Component","classes","avatar","useStyles","size","args","shape","initials","name","firstName","lastName","trim","split","slice","map","word","charAt","join","toUpperCase","filter","Boolean","shouldShowInitials","src","setComponentTemplate","precompileTemplate","strictMode"],"mappings":";;;;;AAwEA,MAAMA,eAAeC,SAAA,CAAU;EAC7B,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAQ,GAAGC,SAAA,EAAA;AACnB,IAAA,OAAOD,MAAA,CAAO;AACZE,MAAAA,IAAA,EAAM,IAAI,CAACC,IAAI,CAACD,IAAI;AACpBE,MAAAA,KAAA,EAAO,IAAI,CAACD,IAAI,CAACC;AACnB,KAAA,CAAA;AACF,EAAA;EAEA,IAAIC,QAAAA,GAAW;IACb,MAAM;MAAEC,IAAI;MAAEC,SAAS;AAAEC,MAAAA;KAAU,GAAG,IAAI,CAACL,IAAI;AAE/C,IAAA,IAAIG,IAAA,EAAM;AACR,MAAA,OAAOA,IAAA,CACJG,IAAI,EAAA,CACJC,KAAK,CAAC,KAAA,CAAA,CACNC,KAAK,CAAC,CAAA,EAAG,CAAA,CAAA,CACTC,GAAG,CAAEC,QAASA,IAAA,CAAKC,MAAM,CAAC,CAAA,CAAA,CAAA,CAC1BC,IAAI,CAAC,EAAA,CAAA,CACLC,WAAW,EAAA;AAChB,IAAA;AAEA,IAAA,MAAMX,QAAA,GAAW,CAACE,SAAA,EAAWO,MAAA,CAAO,CAAA,CAAA,EAAIN,QAAA,EAAUM,MAAA,CAAO,CAAA,CAAA,CAAG,CACzDG,MAAM,CAACC,OAAA,CAAA,CACPH,IAAI,CAAC,IACLC,WAAW,EAAA;AAEd,IAAA,OAAOX,QAAA;AACT,EAAA;EAEA,IAAIc,kBAAAA,GAAqB;IACvB,MAAM;MAAEC,GAAG;MAAEd,IAAI;MAAEC,SAAS;AAAEC,MAAAA;KAAU,GAAG,IAAI,CAACL,IAAI;AACpD,IAAA,IAAIiB,GAAA,EAAK;AACP,MAAA,OAAO,KAAA;AACT,IAAA;AAEA,IAAA,OAAOF,OAAA,CAAQZ,QAAQC,SAAA,IAAaC,QAAA,CAAA;AACtC,EAAA;AAEA,EAAA;IAAAa,oBAAA,CAAAC,kBAAA,CAAA,00BAAA,EA+BA;MAAAC,UAAA,EAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
1
+ {"version":3,"file":"avatar.js","sources":["../../../src/components/utilities/avatar.gts"],"sourcesContent":["import Component from '@glimmer/component';\nimport { tracked } from '@glimmer/tracking';\nimport { action } from '@ember/object';\nimport { on } from '@ember/modifier';\nimport {\n useStyles,\n type AvatarVariants,\n type AvatarSlots,\n type SlotsToClasses\n} from '@frontile/theme';\n\ninterface AvatarSignature {\n Args: {\n /**\n * Controls the size of the avatar.\n *\n * @defaultValue 'md'\n */\n size?: AvatarVariants['size'];\n\n /**\n * Defines the shape of the avatar.\n *\n * @defaultValue 'circle'\n */\n shape?: AvatarVariants['shape'];\n\n /**\n * How the image fills the avatar. `cover` crops the image to fill the\n * avatar, which suits photos. `contain` shows the whole image, inset from\n * the edge, which suits logos and wordmarks.\n *\n * @defaultValue 'cover'\n */\n fit?: AvatarVariants['fit'];\n\n /**\n * Draws a faint hairline just inside the avatar's edge. Pass `false` to\n * remove it.\n *\n * @defaultValue true\n */\n isBordered?: boolean;\n\n /**\n * URL of the image to be displayed in the avatar.\n * If provided, the image will be used instead of initials. If the image\n * fails to load, the avatar falls back to the initials, or to an empty\n * plate when there is no name.\n */\n src?: string | null;\n\n /**\n * Full name of the user, used to generate initials.\n * If `@firstName` and `@lastName` are not provided, initials will be\n * derived from this property.\n */\n name?: string;\n\n /**\n * First name of the user, used to generate initials.\n * If `@name` is not provided, initials will be generated from\n * `@firstName` and `@lastName`.\n */\n firstName?: string;\n\n /**\n * Last name of the user, used to generate initials.\n * If `@name` is not provided, initials will be generated from\n * `@firstName` and `@lastName`.\n */\n lastName?: string;\n\n /**\n * Alternative text for accessibility.\n * If `@src` is provided, this text will be used as the `alt`\n * attribute for the image.\n * If only initials are displayed, this text will be read by screen readers.\n */\n alt?: string;\n\n /**\n * Custom CSS classes for styling different slots within the avatar component.\n */\n classes?: SlotsToClasses<AvatarSlots>;\n };\n\n /**\n * The root element of the avatar component, which is an HTML `<span>` tag.\n */\n Element: HTMLSpanElement;\n}\n\nclass Avatar extends Component<AvatarSignature> {\n // Keyed by URL rather than a boolean, so a new `@src` is tried afresh\n // without having to reset anything when the argument changes.\n @tracked failedSrc?: string | null;\n\n get classes() {\n const { avatar } = useStyles();\n return avatar({\n size: this.args.size,\n shape: this.args.shape,\n fit: this.args.fit,\n isBordered: this.args.isBordered\n });\n }\n\n get hasImage() {\n const { src } = this.args;\n return Boolean(src) && src !== this.failedSrc;\n }\n\n @action\n handleImageError() {\n this.failedSrc = this.args.src;\n }\n\n get initials() {\n const { name, firstName, lastName } = this.args;\n\n if (name) {\n return name\n .trim()\n .split(/\\s+/)\n .slice(0, 2)\n .map((word) => word.charAt(0))\n .join('')\n .toUpperCase();\n }\n\n const initials = [firstName?.charAt(0), lastName?.charAt(0)]\n .filter(Boolean)\n .join('')\n .toUpperCase();\n\n return initials;\n }\n\n get shouldShowInitials() {\n const { name, firstName, lastName } = this.args;\n if (this.hasImage) {\n return false;\n }\n\n return Boolean(name || firstName || lastName);\n }\n\n <template>\n <span\n class={{this.classes.base class=@classes.base}}\n data-component=\"avatar\"\n data-part=\"base\"\n ...attributes\n >\n {{#if this.shouldShowInitials}}\n {{! role=\"img\" makes the contents presentational, so the initials stop\n being read. Only claim the role when there is an @alt to name it with;\n otherwise leave the letters as plain text. }}\n <span\n aria-label={{@alt}}\n class={{this.classes.name class=@classes.name}}\n data-part=\"name\"\n role={{if @alt \"img\"}}\n >\n {{this.initials}}\n </span>\n {{/if}}\n {{#if this.hasImage}}\n {{! An omitted alt makes screen readers fall back to the URL. An empty\n one marks the image decorative, which is right beside a visible name. }}\n <img\n class={{this.classes.img class=@classes.img}}\n data-part=\"img\"\n src={{@src}}\n alt={{if @alt @alt \"\"}}\n {{on \"error\" this.handleImageError}}\n />\n {{/if}}\n </span>\n </template>\n}\n\nexport { Avatar };\nexport default Avatar;\n"],"names":["Avatar","Component","g","prototype","tracked","i","classes","avatar","useStyles","size","args","shape","fit","isBordered","hasImage","src","Boolean","failedSrc","handleImageError","n","action","initials","name","firstName","lastName","trim","split","slice","map","word","charAt","join","toUpperCase","filter","shouldShowInitials","setComponentTemplate","precompileTemplate","strictMode","scope","on"],"mappings":";;;;;;;;;AA6FA,MAAMA,eAAeC,SAAA,CAAU;AAAA,EAAA;IAAAC,eAAA,CAAA,IAAA,CAAAC,SAAA,EAAA,WAAA,EAAA,CAG5BC,OAAA,CAAA,CAAA;AAAA;EAAA,UAAA,IAAAC,2BAAA,CAAA,IAAA,EAAA,WAAA,CAAA,EAAA,MAAA,EAAA;AADD;EAGA,IAAIC,OAAAA,GAAU;IACZ,MAAM;AAAEC,MAAAA;KAAQ,GAAGC,SAAA,EAAA;AACnB,IAAA,OAAOD,MAAA,CAAO;AACZE,MAAAA,IAAA,EAAM,IAAI,CAACC,IAAI,CAACD,IAAI;AACpBE,MAAAA,KAAA,EAAO,IAAI,CAACD,IAAI,CAACC,KAAK;AACtBC,MAAAA,GAAA,EAAK,IAAI,CAACF,IAAI,CAACE,GAAG;AAClBC,MAAAA,UAAA,EAAY,IAAI,CAACH,IAAI,CAACG;AACxB,KAAA,CAAA;AACF,EAAA;EAEA,IAAIC,QAAAA,GAAW;IACb,MAAM;AAAEC,MAAAA;KAAK,GAAG,IAAI,CAACL,IAAI;IACzB,OAAOM,OAAA,CAAQD,GAAA,CAAA,IAAQA,GAAA,KAAQ,IAAI,CAACE,SAAS;AAC/C,EAAA;AAGAC,EAAAA,gBAAAA,GAAmB;AACjB,IAAA,IAAI,CAACD,SAAS,GAAG,IAAI,CAACP,IAAI,CAACK,GAAG;AAChC,EAAA;AAAA,EAAA;IAAAI,gBAAA,CAAA,IAAA,CAAAhB,SAAA,EAAA,kBAAA,EAAA,CAHCiB,MAAA,CAAA,CAAA;AAAA;EAKD,IAAIC,QAAAA,GAAW;IACb,MAAM;MAAEC,IAAI;MAAEC,SAAS;AAAEC,MAAAA;KAAU,GAAG,IAAI,CAACd,IAAI;AAE/C,IAAA,IAAIY,IAAA,EAAM;AACR,MAAA,OAAOA,IAAA,CACJG,IAAI,EAAA,CACJC,KAAK,CAAC,KAAA,CAAA,CACNC,KAAK,CAAC,CAAA,EAAG,CAAA,CAAA,CACTC,GAAG,CAAEC,QAASA,IAAA,CAAKC,MAAM,CAAC,CAAA,CAAA,CAAA,CAC1BC,IAAI,CAAC,EAAA,CAAA,CACLC,WAAW,EAAA;AAChB,IAAA;AAEA,IAAA,MAAMX,QAAA,GAAW,CAACE,SAAA,EAAWO,MAAA,CAAO,CAAA,CAAA,EAAIN,QAAA,EAAUM,MAAA,CAAO,CAAA,CAAA,CAAG,CACzDG,MAAM,CAACjB,OAAA,CAAA,CACPe,IAAI,CAAC,IACLC,WAAW,EAAA;AAEd,IAAA,OAAOX,QAAA;AACT,EAAA;EAEA,IAAIa,kBAAAA,GAAqB;IACvB,MAAM;MAAEZ,IAAI;MAAEC,SAAS;AAAEC,MAAAA;KAAU,GAAG,IAAI,CAACd,IAAI;IAC/C,IAAI,IAAI,CAACI,QAAQ,EAAE;AACjB,MAAA,OAAO,KAAA;AACT,IAAA;AAEA,IAAA,OAAOE,OAAA,CAAQM,QAAQC,SAAA,IAAaC,QAAA,CAAA;AACtC,EAAA;AAEA,EAAA;IAAAW,oBAAA,CAAAC,kBAAA,CAAA,03BAAA,EAgCA;MAAAC,UAAA,EAAA,IAAA;AAAAC,MAAAA,KAAA,EAAAA,OAAA;AAAAC,QAAAA;AAAA,OAAA;KAAU,CAAA,EAAV,IAAW,CAAA;AAAD;AACZ;;"}
package/dist/forms.js CHANGED
@@ -17,6 +17,9 @@ export { FormControl } from './components/forms/form-control.js';
17
17
  export { Switch } from './components/forms/switch.js';
18
18
  export { DatePicker } from './components/forms/date-picker/date-picker.js';
19
19
  export { formatValue, isEmptyValue, parseDate, parseRange, toWire } from './components/forms/date-picker/value.js';
20
+ export { BOUNDS, DEFAULT_FORMAT, applyDigit, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, toDate, toNumericFormat, withValue } from './components/forms/date-input/segments.js';
21
+ export { formatForClipboard, parsePasted, splitRange } from './components/forms/date-input/clipboard.js';
22
+ export { DateInput } from './components/forms/date-input/date-input.js';
20
23
  export { StandardValidator } from './utils/standard-validator.js';
21
24
  export { deepEqual, flattenData, hasNestedData, unflattenData } from './utils/nested-data.js';
22
25
  //# sourceMappingURL=forms.js.map
package/dist/forms.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"forms.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"forms.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -34,6 +34,9 @@ export { FormControl } from './components/forms/form-control.js';
34
34
  export { Switch } from './components/forms/switch.js';
35
35
  export { DatePicker } from './components/forms/date-picker/date-picker.js';
36
36
  export { formatValue, isEmptyValue, parseDate, parseRange, toWire } from './components/forms/date-picker/value.js';
37
+ export { BOUNDS, DEFAULT_FORMAT, applyDigit, buildParts, carryOver, clearSegment, commitSegment, daysInMonth, deleteDigit, displaySegment, emptySegment, findSegment, fromDate, hasDateChanged, hasTextualMonth, isSegment, resolveSegmentFormat, resolveTwoDigitYear, step, toDate, toNumericFormat, withValue } from './components/forms/date-input/segments.js';
38
+ export { formatForClipboard, parsePasted, splitRange } from './components/forms/date-input/clipboard.js';
39
+ export { DateInput } from './components/forms/date-input/date-input.js';
37
40
  export { StandardValidator } from './utils/standard-validator.js';
38
41
  export { deepEqual, flattenData, hasNestedData, unflattenData } from './utils/nested-data.js';
39
42
  export { Overlay } from './components/overlays/overlay.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}