@nxgt/material 3.34.0 → 3.35.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 (172) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +4 -4
  3. package/dist/{async-slice-C9q_eMJD.js → async-slice-BNI_F0jz.js} +2 -2
  4. package/dist/{button-CoAu_GuF.js → button-EMWOFSDB.js} +1 -1
  5. package/dist/charts.js +3 -3
  6. package/dist/{chip-Ch21Qbnj.js → chip-B6m3yagf.js} +1 -1
  7. package/dist/{code-editor-CEdEmolU.js → code-editor-BdiufnpC.js} +4 -4
  8. package/dist/code-editor.js +4 -4
  9. package/dist/{code-language-items-BNMM7YlZ.js → code-language-items-v5Rnq425.js} +2 -2
  10. package/dist/{components-BM9WHviO.js → components-jh9l5bIA.js} +16962 -14252
  11. package/dist/components.js +26 -26
  12. package/dist/{dialog-C_U4twIJ.js → dialog-Cdv9IXVo.js} +1 -1
  13. package/dist/dnd.js +1 -1
  14. package/dist/{dropdown-menu-DSgkmogX.js → dropdown-menu-CpSnRXd-.js} +1 -1
  15. package/dist/editor.js +7 -7
  16. package/dist/{empty-state-CJZ0sVE8.js → empty-state-DMr94lsF.js} +1 -1
  17. package/dist/hooks.js +2 -2
  18. package/dist/{i18n-provider-CLq-1Qgc.js → i18n-provider-A4mI4vc1.js} +1 -1
  19. package/dist/i18n.js +5 -5
  20. package/dist/{icon-badge-Dssl4rfn.js → icon-badge-BFScQnp9.js} +1 -1
  21. package/dist/lib/components/ui/collections/server-table/bulk-action-targets.d.ts +6 -5
  22. package/dist/lib/components/ui/collections/server-table/bulk-action.d.ts +6 -5
  23. package/dist/lib/components/ui/collections/server-table/partials/server-table-bulk-buttons.d.ts +6 -5
  24. package/dist/lib/components/ui/collections/server-table/selected-rows.d.ts +17 -0
  25. package/dist/lib/components/ui/collections/server-table/use-query-selection.d.ts +6 -1
  26. package/dist/lib/components/ui/collections/server-table/use-server-table-selection.d.ts +3 -1
  27. package/dist/lib/components/ui/collections/server-table/use-server-table.d.ts +1 -0
  28. package/dist/lib/components/ui/dates/picker-trigger/typed-box-compact.d.ts +12 -0
  29. package/dist/lib/components/ui/dates/picker-trigger/typed-box.d.ts +6 -2
  30. package/dist/lib/components/ui/dates/picker-trigger/typed-trigger.d.ts +3 -2
  31. package/dist/lib/components/ui/dates/time-field/index.d.ts +1 -0
  32. package/dist/lib/components/ui/dates/time-field/partials/time-field-body.d.ts +2 -1
  33. package/dist/lib/components/ui/dates/time-field/partials/time-field-entry.d.ts +1 -0
  34. package/dist/lib/components/ui/dates/time-field/partials/time-field-typed.d.ts +2 -2
  35. package/dist/lib/components/ui/dates/time-field/time-field.d.ts +6 -1
  36. package/dist/lib/components/ui/dates/time-field/time-string-field.d.ts +14 -0
  37. package/dist/lib/components/ui/fields/attributes/attribute-dialog.d.ts +3 -1
  38. package/dist/lib/components/ui/fields/attributes/attribute-form/attribute-form.d.ts +3 -1
  39. package/dist/lib/components/ui/fields/attributes/attribute-form/attribute-text-form-fields.d.ts +6 -0
  40. package/dist/lib/components/ui/fields/attributes/attribute-form/consts.d.ts +7 -6
  41. package/dist/lib/components/ui/fields/attributes/attribute-form/use-attribute-form.d.ts +44 -0
  42. package/dist/lib/components/ui/fields/attributes/attributes-editor.d.ts +22 -0
  43. package/dist/lib/components/ui/fields/attributes/attributes-field/attributes-dialog-field.d.ts +14 -0
  44. package/dist/lib/components/ui/fields/attributes/attributes-field/attributes-field.d.ts +14 -12
  45. package/dist/lib/components/ui/fields/attributes/attributes-field/attributes-inline-field.d.ts +8 -0
  46. package/dist/lib/components/ui/fields/attributes/attributes-field/use-dialog-field.d.ts +15 -0
  47. package/dist/lib/components/ui/fields/attributes/attributes-form-field/attributes-form-field.d.ts +7 -1
  48. package/dist/lib/components/ui/fields/attributes/attributes-summary.d.ts +22 -0
  49. package/dist/lib/components/ui/fields/attributes/index.d.ts +3 -0
  50. package/dist/lib/components/ui/fields/attributes/logic/names.d.ts +13 -0
  51. package/dist/lib/components/ui/fields/attributes/logic/order.d.ts +15 -0
  52. package/dist/lib/components/ui/fields/attributes/logic/reorder-keys.d.ts +9 -0
  53. package/dist/lib/components/ui/fields/attributes/logic/value.d.ts +42 -0
  54. package/dist/lib/components/ui/fields/attributes/models/attribute.d.ts +5 -1
  55. package/dist/lib/components/ui/fields/attributes/partials/attribute-row.d.ts +18 -0
  56. package/dist/lib/components/ui/fields/attributes/partials/default-choices.d.ts +5 -0
  57. package/dist/lib/components/ui/fields/attributes/partials/default-field.d.ts +12 -0
  58. package/dist/lib/components/ui/fields/attributes/partials/default-inputs.d.ts +16 -0
  59. package/dist/lib/components/ui/fields/attributes/partials/editor-notes.d.ts +11 -0
  60. package/dist/lib/components/ui/fields/attributes/partials/labeled.d.ts +10 -0
  61. package/dist/lib/components/ui/fields/attributes/partials/name-field.d.ts +15 -0
  62. package/dist/lib/components/ui/fields/attributes/partials/options-field.d.ts +11 -0
  63. package/dist/lib/components/ui/fields/attributes/partials/phone-sheet.d.ts +12 -0
  64. package/dist/lib/components/ui/fields/attributes/partials/reorder-handle.d.ts +19 -0
  65. package/dist/lib/components/ui/fields/attributes/partials/row-fields.d.ts +16 -0
  66. package/dist/lib/components/ui/fields/attributes/partials/row-footer.d.ts +12 -0
  67. package/dist/lib/components/ui/fields/attributes/partials/row-head.d.ts +12 -0
  68. package/dist/lib/components/ui/fields/attributes/partials/row-panel.d.ts +15 -0
  69. package/dist/lib/components/ui/fields/attributes/partials/rows-dnd.d.ts +11 -0
  70. package/dist/lib/components/ui/fields/attributes/partials/simple-fields.d.ts +20 -0
  71. package/dist/lib/components/ui/fields/attributes/partials/summary-item.d.ts +9 -0
  72. package/dist/lib/components/ui/fields/attributes/partials/type-icon.d.ts +13 -0
  73. package/dist/lib/components/ui/fields/attributes/partials/value-text.d.ts +12 -0
  74. package/dist/lib/components/ui/fields/attributes/schema.d.ts +32 -0
  75. package/dist/lib/components/ui/fields/attributes/use-announce.d.ts +14 -0
  76. package/dist/lib/components/ui/fields/attributes/use-attribute-text.d.ts +13 -0
  77. package/dist/lib/components/ui/fields/attributes/use-attributes-editor.d.ts +34 -0
  78. package/dist/lib/components/ui/fields/attributes/use-reorder.d.ts +26 -0
  79. package/dist/lib/components/ui/fields/contacts/contacts-dialog-form-field.d.ts +9 -0
  80. package/dist/lib/components/ui/fields/contacts/contacts-editor.d.ts +29 -0
  81. package/dist/lib/components/ui/fields/contacts/contacts-form-field.d.ts +14 -1
  82. package/dist/lib/components/ui/fields/contacts/contacts-summary.d.ts +23 -0
  83. package/dist/lib/components/ui/fields/contacts/index.d.ts +3 -0
  84. package/dist/lib/components/ui/fields/contacts/logic/check-contact.d.ts +11 -0
  85. package/dist/lib/components/ui/fields/contacts/logic/contact-action.d.ts +11 -0
  86. package/dist/lib/components/ui/fields/contacts/logic/duplicates.d.ts +17 -0
  87. package/dist/lib/components/ui/fields/contacts/logic/issues.d.ts +7 -0
  88. package/dist/lib/components/ui/fields/contacts/logic/primary.d.ts +33 -0
  89. package/dist/lib/components/ui/fields/contacts/models.d.ts +7 -0
  90. package/dist/lib/components/ui/fields/contacts/partials/contact-fields.d.ts +29 -0
  91. package/dist/lib/components/ui/fields/contacts/partials/contact-links.d.ts +15 -0
  92. package/dist/lib/components/ui/fields/contacts/partials/contact-row.d.ts +14 -0
  93. package/dist/lib/components/ui/fields/contacts/partials/phone-sheet.d.ts +14 -0
  94. package/dist/lib/components/ui/fields/contacts/partials/quick-add.d.ts +12 -0
  95. package/dist/lib/components/ui/fields/contacts/partials/row-actions.d.ts +16 -0
  96. package/dist/lib/components/ui/fields/contacts/partials/summary-item.d.ts +11 -0
  97. package/dist/lib/components/ui/fields/contacts/partials/summary-row.d.ts +14 -0
  98. package/dist/lib/components/ui/fields/contacts/partials/type-group.d.ts +15 -0
  99. package/dist/lib/components/ui/fields/contacts/partials/type-icon.d.ts +12 -0
  100. package/dist/lib/components/ui/fields/contacts/partials/value-field.d.ts +25 -0
  101. package/dist/lib/components/ui/fields/contacts/placeholders.d.ts +2 -0
  102. package/dist/lib/components/ui/fields/contacts/schema.d.ts +18 -0
  103. package/dist/lib/components/ui/fields/contacts/use-contact-text.d.ts +9 -0
  104. package/dist/lib/components/ui/fields/contacts/use-contacts-editor.d.ts +33 -0
  105. package/dist/lib/components/ui/fields/inline-editor/action-tone.d.ts +2 -0
  106. package/dist/lib/components/ui/fields/inline-editor/editor-header.d.ts +19 -0
  107. package/dist/lib/components/ui/fields/inline-editor/editor-sheet.d.ts +20 -0
  108. package/dist/lib/components/ui/fields/inline-editor/empty-summary.d.ts +19 -0
  109. package/dist/lib/components/ui/fields/inline-editor/use-focus-request.d.ts +13 -0
  110. package/dist/lib/components/ui/fields/inline-editor/use-row-ids.d.ts +13 -0
  111. package/dist/lib/components/ui/fields/opening-hours/consts.d.ts +17 -3
  112. package/dist/lib/components/ui/fields/opening-hours/index.d.ts +2 -0
  113. package/dist/lib/components/ui/fields/opening-hours/logic/edit-days.d.ts +9 -0
  114. package/dist/lib/components/ui/fields/opening-hours/logic/first-day.d.ts +14 -0
  115. package/dist/lib/components/ui/fields/opening-hours/logic/format.d.ts +6 -0
  116. package/dist/lib/components/ui/fields/opening-hours/logic/group.d.ts +13 -0
  117. package/dist/lib/components/ui/fields/opening-hours/logic/range-errors.d.ts +20 -0
  118. package/dist/lib/components/ui/fields/opening-hours/logic/status.d.ts +19 -0
  119. package/dist/lib/components/ui/fields/opening-hours/logic/week.d.ts +32 -0
  120. package/dist/lib/components/ui/fields/opening-hours/logic/zoned.d.ts +10 -0
  121. package/dist/lib/components/ui/fields/opening-hours/opening-hours-dialog-form-field.d.ts +10 -0
  122. package/dist/lib/components/ui/fields/opening-hours/opening-hours-editor.d.ts +26 -0
  123. package/dist/lib/components/ui/fields/opening-hours/opening-hours-form-field.d.ts +17 -1
  124. package/dist/lib/components/ui/fields/opening-hours/opening-hours-summary.d.ts +32 -0
  125. package/dist/lib/components/ui/fields/opening-hours/partials/copy-chips.d.ts +12 -0
  126. package/dist/lib/components/ui/fields/opening-hours/partials/copy-menu.d.ts +10 -0
  127. package/dist/lib/components/ui/fields/opening-hours/partials/day-controls.d.ts +14 -0
  128. package/dist/lib/components/ui/fields/opening-hours/partials/day-row.d.ts +15 -0
  129. package/dist/lib/components/ui/fields/opening-hours/partials/day-summary-row.d.ts +15 -0
  130. package/dist/lib/components/ui/fields/opening-hours/partials/group-row.d.ts +13 -0
  131. package/dist/lib/components/ui/fields/opening-hours/partials/phone-sheet.d.ts +18 -0
  132. package/dist/lib/components/ui/fields/opening-hours/partials/range-field-props.d.ts +28 -0
  133. package/dist/lib/components/ui/fields/opening-hours/partials/range-row.d.ts +24 -0
  134. package/dist/lib/components/ui/fields/opening-hours/partials/status-pill.d.ts +13 -0
  135. package/dist/lib/components/ui/fields/opening-hours/use-first-day.d.ts +8 -0
  136. package/dist/lib/components/ui/fields/opening-hours/use-hours-editor.d.ts +26 -0
  137. package/dist/lib/components/ui/fields/opening-hours/use-hours-text.d.ts +8 -0
  138. package/dist/lib/components/ui/fields/opening-hours/use-now.d.ts +6 -0
  139. package/dist/lib/i18n/resources/en/en.d.ts +75 -0
  140. package/dist/lib/i18n/resources/en/material.json.d.ts +86 -11
  141. package/dist/lib/i18n/resources/fr/fr.d.ts +75 -0
  142. package/dist/lib/i18n/resources/fr/material.json.d.ts +86 -11
  143. package/dist/lib/i18n/resources/resources.d.ts +150 -0
  144. package/dist/lib/i18n/translator.d.ts +1 -1
  145. package/dist/lib.js +1 -1
  146. package/dist/main.js +43 -43
  147. package/dist/map.js +4 -4
  148. package/dist/material.css +1 -1
  149. package/dist/pdf-reader.js +1 -1
  150. package/dist/print.js +2 -2
  151. package/dist/{public-CX7FN97X.js → public-CYdnlHqA.js} +6 -6
  152. package/dist/{rich-code-block-cc1NZtbD.js → rich-code-block-Bwhfhu7J.js} +4 -4
  153. package/dist/{sortable-provider-D43VdFMP.js → sortable-provider-CY_YD3Ee.js} +1 -1
  154. package/dist/{spinner-wKfFAVU9.js → spinner-CKlDba5I.js} +1 -1
  155. package/dist/{stored-language-D73ujVW4.js → stored-language-CfQGHLq9.js} +176 -22
  156. package/dist/theme-picker.js +2 -2
  157. package/dist/{theme-toggle-Drab-hke.js → theme-toggle--Zcf5AM8.js} +1 -1
  158. package/dist/{toolbar-items-D7R9YtYx.js → toolbar-items-B1W-uVHS.js} +2 -2
  159. package/dist/{translate-material-CdpLjkcD.js → translate-material-xDh10aWZ.js} +2 -2
  160. package/dist/{translator-BE-yEb0p.js → translator-BbOZntEF.js} +1 -1
  161. package/dist/{use-chat-composer-CpKh8564.js → use-chat-composer-CoyqPKbt.js} +12 -12
  162. package/dist/{use-heading-spy-DgWhvYfh.js → use-heading-spy-DXYCeegh.js} +1 -1
  163. package/dist/{use-material-translation-Da9Ponn5.js → use-material-translation-BK2YYCY3.js} +2 -2
  164. package/docs/components/data-table-filter-and-lists.md +10 -3
  165. package/docs/components/date-and-time.md +9 -1
  166. package/docs/components/form-fields.md +298 -67
  167. package/docs/guides/forms.md +18 -12
  168. package/docs/guides/i18n.md +1 -1
  169. package/docs/guides/ssr.md +1 -0
  170. package/docs/previews/form-fields-contacts.webp +0 -0
  171. package/docs/previews/form-fields-openinghours.webp +0 -0
  172. package/package.json +1 -1
@@ -0,0 +1,12 @@
1
+ import { Attribute } from '../models/attribute.js';
2
+ import { AttributeText } from '../use-attribute-text.js';
3
+ type ValueTextProps = {
4
+ attribute: Attribute;
5
+ text: AttributeText;
6
+ };
7
+ /**
8
+ * An attribute's default value as a row shows it: a Yes or No for a boolean,
9
+ * a swatch beside a colour, the unit after a number, a dash when there is none.
10
+ */
11
+ export declare function ValueText({ attribute, text }: ValueTextProps): import("react").JSX.Element;
12
+ export {};
@@ -0,0 +1,32 @@
1
+ import { default as z } from 'zod';
2
+ /** The codes an issue of {@link attributesListSchema} carries in `params.code`. */
3
+ export type AttributeIssueCode = 'empty' | 'duplicate' | 'option' | 'boolean' | 'number' | 'date';
4
+ /**
5
+ * The schema of a list of attributes with the rules the inline editor shows:
6
+ * a name that is set and that no other attribute has, and a default value
7
+ * that fits the type (a listed option, a boolean, a number, a date). An issue
8
+ * sits on the entry's `name` or `defaultValue`. Built on the first call, like
9
+ * `openingHoursListSchema`.
10
+ */
11
+ export declare const attributesListSchema: () => z.ZodArray<z.ZodObject<{
12
+ defaultValue: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
13
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
14
+ priority: z.ZodOptional<z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
15
+ label: z.ZodString;
16
+ options: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
17
+ type: z.ZodEnum<{
18
+ BOOLEAN: "BOOLEAN";
19
+ COLOR: "COLOR";
20
+ DATE: "DATE";
21
+ DATETIME: "DATETIME";
22
+ MULTI_SELECT: "MULTI_SELECT";
23
+ NUMBER: "NUMBER";
24
+ RICH_TEXT: "RICH_TEXT";
25
+ SELECT: "SELECT";
26
+ STRING: "STRING";
27
+ TEXT: "TEXT";
28
+ TIME: "TIME";
29
+ }>;
30
+ unit: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
+ name: z.ZodString;
32
+ }, z.core.$strip>>;
@@ -0,0 +1,14 @@
1
+ import { Attribute } from './models/attribute.js';
2
+ import { AttributeText } from './use-attribute-text.js';
3
+ declare const FALLBACKS: {
4
+ readonly lift: "Picked up {name}, position {position} of {count}. Use the arrow keys to move it, Space to drop it, Escape to cancel.";
5
+ readonly move: "{name} moved to position {position} of {count}.";
6
+ readonly drop: "{name} dropped at position {position} of {count}.";
7
+ readonly cancel: "Reorder cancelled. {name} is back at position {position} of {count}.";
8
+ };
9
+ /** The live region's text: what a reorder step says about one attribute. */
10
+ export declare function useAnnounce(value: Attribute[], text: AttributeText): {
11
+ message: string;
12
+ say: (step: keyof typeof FALLBACKS, index: number, place: number) => void;
13
+ };
14
+ export {};
@@ -0,0 +1,13 @@
1
+ import { NameIssue } from './logic/names.js';
2
+ import { Attribute } from './models/attribute.js';
3
+ /** The translator and the words the attribute components print with. */
4
+ export declare function useAttributeText(): {
5
+ t: (key: import('../../../../i18n/index.js').MaterialLocaleKey, fallback: string, options?: import('../../../../i18n/index.js').TranslationContext) => string;
6
+ language: "fr" | "en" | undefined;
7
+ typeName: (type: string) => string;
8
+ yesNo: (yes: boolean) => string;
9
+ /** What a row is called: its label, else its name, else "Untitled". */
10
+ title: (attribute: Attribute) => string;
11
+ nameMessage: (issue: NameIssue) => string;
12
+ };
13
+ export type AttributeText = ReturnType<typeof useAttributeText>;
@@ -0,0 +1,34 @@
1
+ import { Attribute } from './models/attribute.js';
2
+ import { AttributeText } from './use-attribute-text.js';
3
+ type Options = {
4
+ value: Attribute[];
5
+ onValueChange?: (value: Attribute[]) => void;
6
+ text: AttributeText;
7
+ };
8
+ /**
9
+ * The editor's state and edits over a controlled list: which row is open,
10
+ * change one attribute (a new type resets what no longer fits), remove one,
11
+ * add one, and the reorder of `useReorder`. Focus is handed to a control by
12
+ * name once the edit has rendered.
13
+ */
14
+ export declare function useAttributesEditor({ value, onValueChange, text }: Options): {
15
+ ids: string[];
16
+ openId: string | null;
17
+ reorder: {
18
+ order: number[];
19
+ message: string;
20
+ liftedId: string | null;
21
+ press: (id: string, key: string) => boolean;
22
+ dragTo: (from: string, to: string) => void;
23
+ release: () => void;
24
+ };
25
+ requestFocus: (name: string) => void;
26
+ focusKey: (name: string) => string;
27
+ toggle: (id: string) => void;
28
+ close: () => void;
29
+ change: (index: number, patch: Partial<Attribute>) => void;
30
+ remove: (index: number) => void;
31
+ add: () => void;
32
+ };
33
+ export type AttributesEditorState = ReturnType<typeof useAttributesEditor>;
34
+ export {};
@@ -0,0 +1,26 @@
1
+ import { Attribute } from './models/attribute.js';
2
+ import { AttributeText } from './use-attribute-text.js';
3
+ type Options = {
4
+ value: Attribute[];
5
+ ids: string[];
6
+ text: AttributeText;
7
+ commit: (next: Attribute[], ids: string[]) => void;
8
+ requestFocus: (key: string) => void;
9
+ };
10
+ /**
11
+ * Reordering by the keyboard and by the pointer. A key lifts a row; the
12
+ * arrows move a draft order the list shows; Space or Enter drops it (one
13
+ * change, with every `priority` set), Escape puts it back. Each step is said
14
+ * through `message`, for the live region.
15
+ */
16
+ export declare function useReorder({ value, ids, text, commit, requestFocus, }: Options): {
17
+ order: number[];
18
+ message: string;
19
+ liftedId: string | null;
20
+ press: (id: string, key: string) => boolean;
21
+ /** A pointer drag that ended over another row. */
22
+ dragTo: (from: string, to: string) => void;
23
+ /** The handle lost focus to another control: the row is dropped where it is. */
24
+ release: () => void;
25
+ };
26
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ComponentProps } from 'react';
2
+ import { UseControllerProps } from 'react-hook-form';
3
+ export type ContactsDialogFieldProps<T extends Record<string, any>> = Pick<UseControllerProps<T>, 'control' | 'name'> & {
4
+ className?: string;
5
+ disabled?: boolean;
6
+ label?: string;
7
+ } & Omit<ComponentProps<'div'>, 'name'>;
8
+ /** `ContactsFormField` with `editing="dialog"`: a list, and a dialog per contact. */
9
+ export declare function ContactsDialogField<T extends Record<string, any>>({ control, name, className, disabled, label, ...props }: ContactsDialogFieldProps<T>): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { ReactNode } from 'react';
2
+ import { HeadingLevel } from '../inline-editor/editor-header.js';
3
+ import { Contact } from './models.js';
4
+ export type ContactsEditorProps = {
5
+ value?: Contact[];
6
+ onValueChange?: (value: Contact[]) => void;
7
+ /** The heading; "Contacts" by default. */
8
+ label?: ReactNode;
9
+ /** The heading's level; `3` by default. The type headings sit one below it. */
10
+ headingLevel?: HeadingLevel;
11
+ /**
12
+ * `'list'` (the default): each type is one bordered list of rows.
13
+ * `'cards'`: each contact is its own tinted card, with a round tile for
14
+ * the primary one. The fields keep the library's field radius in both.
15
+ */
16
+ variant?: 'list' | 'cards';
17
+ disabled?: boolean;
18
+ className?: string;
19
+ };
20
+ /**
21
+ * Contacts edited in place, grouped by type: each row has its type icon, the
22
+ * type, value and label fields, call / write / open and copy actions, a star
23
+ * that makes it the primary contact of its type (shown first) and a remove
24
+ * button; "Add Contact" chips add one of a type. A wrong format or a duplicate
25
+ * is a `role="alert"` under its value. Below 640px each contact is a summary
26
+ * row that opens a bottom sheet with the same fields. It holds the value model
27
+ * of `Contacts` (`primary` is an optional addition).
28
+ */
29
+ export declare function ContactsEditor({ value, onValueChange, label, headingLevel, variant, disabled, className, }: ContactsEditorProps): import("react").JSX.Element;
@@ -4,5 +4,18 @@ export type ContactsFormFieldProps<T extends Record<string, any>> = Pick<UseCont
4
4
  className?: string;
5
5
  disabled?: boolean;
6
6
  label?: string;
7
+ /**
8
+ * `'inline'` (the default) edits the contacts in place
9
+ * (`ContactsEditor`); `'dialog'` keeps the list and the dialog that edits
10
+ * one contact at a time.
11
+ */
12
+ editing?: 'inline' | 'dialog';
13
+ /** `editing="inline"` only: `'list'` (default) or `'cards'`. */
14
+ variant?: 'list' | 'cards';
7
15
  } & Omit<ComponentProps<'div'>, 'name'>;
8
- export declare function ContactsFormField<T extends Record<string, any>>({ control, name, className, disabled, label, ...props }: ContactsFormFieldProps<T>): import("react").JSX.Element;
16
+ /**
17
+ * Contacts in a React Hook Form field (an array of `{ type, value, label?,
18
+ * primary? }`). Inline by default; `editing="dialog"` is today's list and
19
+ * dialog.
20
+ */
21
+ export declare function ContactsFormField<T extends Record<string, any>>({ editing, variant, ...props }: ContactsFormFieldProps<T>): import("react").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { ReactNode } from 'react';
2
+ import { Contact } from './models.js';
3
+ export type ContactsSummaryProps = {
4
+ /** The contacts, in the value model of `Contacts`. */
5
+ data?: Contact[] | null;
6
+ /** Names the region; "Contacts" by default. */
7
+ label?: string;
8
+ /** `'list'` (the default) or `'cards'`, as in `ContactsEditor`. */
9
+ variant?: 'list' | 'cards';
10
+ className?: string;
11
+ /**
12
+ * What shows when there is nothing to list. A quiet "No contacts" by default; your
13
+ * node replaces it, and `null` renders nothing.
14
+ */
15
+ empty?: ReactNode;
16
+ };
17
+ /**
18
+ * The read-only counterpart of `ContactsEditor`: the contacts by type, the
19
+ * primary one first in its type and marked, each with its type icon, its
20
+ * value as a link (call, write, open) and a copy button. With nothing to list it shows
21
+ * a quiet "No contacts" (see `empty`; `empty={null}` renders nothing).
22
+ */
23
+ export declare function ContactsSummary({ data, label, variant, className, empty, }: ContactsSummaryProps): import("react").JSX.Element;
@@ -1,5 +1,8 @@
1
1
  export * from './contact-dialog.js';
2
2
  export * from './contacts.js';
3
+ export * from './contacts-editor.js';
3
4
  export * from './contacts-form-field.js';
5
+ export * from './contacts-summary.js';
4
6
  export * from './models.js';
7
+ export * from './schema.js';
5
8
  export * from './utils.js';
@@ -0,0 +1,11 @@
1
+ import { ContactType } from '../models.js';
2
+ /** `empty` is not an error by itself: the row is still being typed. */
3
+ export type ContactCheck = 'empty' | 'ok' | 'bad';
4
+ /** The address of a website, `http:` or `https:` only. */
5
+ export declare function parseWebsite(value: string): URL | null;
6
+ /**
7
+ * The format check of one value: an email has an `@` and a dot, a website is
8
+ * an `http(s)` address, and a phone, mobile or fax number is 7 to 15 digits
9
+ * with the usual separators. It checks the shape, not that the line exists.
10
+ */
11
+ export declare function checkContact(type: ContactType, value: string): ContactCheck;
@@ -0,0 +1,11 @@
1
+ import { ContactType } from '../models.js';
2
+ /** What a contact can do for a person: call it, write to it, open it. */
3
+ export type ContactAction = {
4
+ kind: 'call' | 'email' | 'open';
5
+ href: string;
6
+ };
7
+ /**
8
+ * The link a contact offers, or `null` (a fax number, or a value that is not
9
+ * well-formed). A website opens only if it is an `http(s)` address.
10
+ */
11
+ export declare function contactAction(type: ContactType, value: string): ContactAction | null;
@@ -0,0 +1,17 @@
1
+ import { ContactType } from '../models.js';
2
+ type Keyed = {
3
+ type: ContactType;
4
+ value: string;
5
+ };
6
+ /**
7
+ * What makes two contacts the same: the type and the value without its
8
+ * formatting (digits and `+` for a number, lower case for an email, the
9
+ * address without a trailing slash for a website).
10
+ */
11
+ export declare function contactKey({ type, value }: Keyed): string;
12
+ /**
13
+ * The index of the earlier contact this one repeats, or `-1`. A blank value
14
+ * repeats nothing, and the first of two equal contacts is not the duplicate.
15
+ */
16
+ export declare function duplicateOf(items: readonly Keyed[], index: number): number;
17
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Contact } from '../models.js';
2
+ /**
3
+ * How many contacts have a wrong format or repeat an earlier one. A format is
4
+ * judged only once its field was left (`left` holds the left rows' indexes),
5
+ * a duplicate at once.
6
+ */
7
+ export declare function contactIssues(items: readonly Contact[], left: ReadonlySet<number>): number;
@@ -0,0 +1,33 @@
1
+ import { ContactType } from '../models.js';
2
+ type Marked = {
3
+ type: ContactType;
4
+ primary?: boolean | null;
5
+ };
6
+ /** The types in the order the editor and the summary list them. */
7
+ export declare const CONTACT_TYPE_ORDER: readonly ContactType[];
8
+ /**
9
+ * Whether the contact is the primary one of its type. A value that marks
10
+ * several of a type is read as marking the first only: one primary per type.
11
+ */
12
+ export declare function isPrimary(items: readonly Marked[], index: number): boolean;
13
+ /**
14
+ * Marks the contact primary and clears the others of its type, or clears it
15
+ * when it was the primary one. The flag is left off, not `false`, where it
16
+ * is not set.
17
+ */
18
+ export declare function togglePrimary<T extends Marked>(items: T[], index: number): T[];
19
+ export type ContactEntry<T> = {
20
+ contact: T;
21
+ index: number;
22
+ };
23
+ export type ContactGroup<T> = {
24
+ type: ContactType;
25
+ entries: ContactEntry<T>[];
26
+ };
27
+ /**
28
+ * The contacts by type, in {@link CONTACT_TYPE_ORDER}, the primary one first
29
+ * in its group and the rest in their order. Each entry keeps its index in
30
+ * `items`, so an edit still reaches the right one.
31
+ */
32
+ export declare function groupContacts<T extends Marked>(items: readonly T[]): ContactGroup<T>[];
33
+ export {};
@@ -17,9 +17,16 @@ export type Contact = {
17
17
  * @example Accueil
18
18
  */
19
19
  label?: string | null;
20
+ /**
21
+ * @description The contact to use first among those of its type. One per
22
+ * type: the inline editor keeps it so, and the first marked one wins in a
23
+ * value that marks several.
24
+ */
25
+ primary?: boolean | null;
20
26
  };
21
27
  export type ContactFieldValue = {
22
28
  type: ContactType;
23
29
  value: string;
24
30
  label?: string;
31
+ primary?: boolean;
25
32
  };
@@ -0,0 +1,29 @@
1
+ import { Contact } from '../models.js';
2
+ import { ContactText } from '../use-contact-text.js';
3
+ type ContactFieldsProps = {
4
+ text: ContactText;
5
+ contact: Contact;
6
+ /** Its index in the whole value, for the duplicate check. */
7
+ index: number;
8
+ items: readonly Contact[];
9
+ /** The contact's stable row id: names the controls focus returns to. */
10
+ rowId: string;
11
+ /** The value field was left: its format is judged. */
12
+ left: boolean;
13
+ onLeave: () => void;
14
+ /** Scopes a focus name to this editor. */
15
+ focusKey: (name: string) => string;
16
+ /** Each contact's place in its type's group, 1-based: the accessible names. */
17
+ positions: ReadonlyMap<number, number>;
18
+ disabled?: boolean;
19
+ /** One column: the sheet's layout. */
20
+ stacked?: boolean;
21
+ onChange: (patch: Partial<Contact>) => void;
22
+ };
23
+ /**
24
+ * The three fields of one contact (type, value, label) with the messages that
25
+ * belong to the value: a wrong format, a duplicate or, once left, an empty
26
+ * value. Each message is a `role="alert"` linked to the value field.
27
+ */
28
+ export declare function ContactFields({ text, contact, index, items, rowId, left, onLeave, focusKey, positions, disabled, stacked, onChange, }: ContactFieldsProps): import("react").JSX.Element;
29
+ export {};
@@ -0,0 +1,15 @@
1
+ import { Contact } from '../models.js';
2
+ import { ContactText } from '../use-contact-text.js';
3
+ type ContactLinksProps = {
4
+ text: ContactText;
5
+ contact: Contact;
6
+ size?: 'sm' | 'default';
7
+ className?: string;
8
+ };
9
+ /**
10
+ * What a person can do with a contact: call it, write to it or open it (a
11
+ * link, only when the value is well-formed) and copy it ("Copied" is
12
+ * announced). Used by the editor's rows and by the summary.
13
+ */
14
+ export declare function ContactLinks({ text, contact, size, className, }: ContactLinksProps): import("react").JSX.Element;
15
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Contact } from '../models.js';
2
+ import { ContactText } from '../use-contact-text.js';
3
+ import { ContactsEditorState } from '../use-contacts-editor.js';
4
+ export type ContactRowProps = {
5
+ text: ContactText;
6
+ editor: ContactsEditorState;
7
+ items: Contact[];
8
+ index: number;
9
+ positions: ReadonlyMap<number, number>;
10
+ variant: 'list' | 'cards';
11
+ disabled?: boolean;
12
+ };
13
+ /** One contact on a tablet or a desktop: its icon, its fields and its actions. */
14
+ export declare function ContactRow({ text, editor, items, index, positions, variant, disabled, }: ContactRowProps): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { Contact } from '../models.js';
2
+ import { ContactText } from '../use-contact-text.js';
3
+ import { ContactsEditorState } from '../use-contacts-editor.js';
4
+ type PhoneSheetProps = {
5
+ text: ContactText;
6
+ editor: ContactsEditorState;
7
+ items: Contact[];
8
+ positions: ReadonlyMap<number, number>;
9
+ variant: 'list' | 'cards';
10
+ disabled?: boolean;
11
+ };
12
+ /** A phone's editor for one contact: the same fields and actions, in a bottom sheet. */
13
+ export declare function PhoneSheet({ text, editor, items, positions, variant, disabled, }: PhoneSheetProps): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,12 @@
1
+ import { ContactType } from '../models.js';
2
+ import { ContactText } from '../use-contact-text.js';
3
+ type QuickAddProps = {
4
+ text: ContactText;
5
+ disabled?: boolean;
6
+ /** The scoped focus key of a control, so a remove can return to the chip. */
7
+ focusKey: (name: string) => string;
8
+ onAdd: (type: ContactType) => void;
9
+ };
10
+ /** "Add Contact" and one chip per type: adds an empty contact of that type. */
11
+ export declare function QuickAdd({ text: { t, typeName }, disabled, focusKey, onAdd, }: QuickAddProps): import("react").JSX.Element;
12
+ export {};
@@ -0,0 +1,16 @@
1
+ import { ContactText } from '../use-contact-text.js';
2
+ type RowActionsProps = {
3
+ text: ContactText;
4
+ primary: boolean;
5
+ /** Names the contact in the remove button: "Remove Phone 1". */
6
+ typeName: string;
7
+ position: number;
8
+ /** The star's scoped focus key, so focus can return to it after the row moves. */
9
+ starFocusKey?: string;
10
+ disabled?: boolean;
11
+ onPrimary: () => void;
12
+ onRemove: () => void;
13
+ };
14
+ /** The star that makes a contact the primary one of its type, and the trash. */
15
+ export declare function RowActions({ text: { t }, primary, typeName, position, starFocusKey, disabled, onPrimary, onRemove, }: RowActionsProps): import("react").JSX.Element;
16
+ export {};
@@ -0,0 +1,11 @@
1
+ import { Contact } from '../models.js';
2
+ import { ContactText } from '../use-contact-text.js';
3
+ type SummaryItemProps = {
4
+ text: ContactText;
5
+ contact: Contact;
6
+ primary: boolean;
7
+ variant: 'list' | 'cards';
8
+ };
9
+ /** One contact in the read-only summary: icon, label, value, a primary mark and its actions. */
10
+ export declare function SummaryItem({ text, contact, primary, variant, }: SummaryItemProps): import("react").JSX.Element;
11
+ export {};
@@ -0,0 +1,14 @@
1
+ import { Contact } from '../models.js';
2
+ import { ContactText } from '../use-contact-text.js';
3
+ type SummaryRowProps = {
4
+ text: ContactText;
5
+ items: Contact[];
6
+ index: number;
7
+ primary: boolean;
8
+ variant: 'list' | 'cards';
9
+ disabled?: boolean;
10
+ onOpen: () => void;
11
+ };
12
+ /** A contact on a phone: label, value and a mark for primary or a problem; it opens the sheet. */
13
+ export declare function SummaryRow({ text: { t, typeName }, items, index, primary, variant, disabled, onOpen, }: SummaryRowProps): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ import { ContactType } from '../models.js';
3
+ import { ContactText } from '../use-contact-text.js';
4
+ type TypeGroupProps = {
5
+ text: ContactText;
6
+ type: ContactType;
7
+ count: number;
8
+ variant: 'list' | 'cards';
9
+ /** The type heading's level; `4` by default. */
10
+ headingLevel?: number;
11
+ children: ReactNode;
12
+ };
13
+ /** One type's contacts under its heading: a bordered card, or a stack of cards. */
14
+ export declare function TypeGroup({ text: { t, typeName }, type, count, variant, headingLevel, children, }: TypeGroupProps): import("react").JSX.Element;
15
+ export {};
@@ -0,0 +1,12 @@
1
+ import { ContactType } from '../models.js';
2
+ type TypeIconProps = {
3
+ type: ContactType;
4
+ /** `cards` rounds the tile more, like the rest of the cards variant. */
5
+ variant?: 'list' | 'cards';
6
+ /** The primary contact of its type, tinted stronger in the cards variant. */
7
+ primary?: boolean;
8
+ className?: string;
9
+ };
10
+ /** The tile with a contact type's icon; decoration, the row names the type. */
11
+ export declare function TypeIcon({ type, variant, primary, className }: TypeIconProps): import("react").JSX.Element;
12
+ export {};
@@ -0,0 +1,25 @@
1
+ import { Contact } from '../models.js';
2
+ import { ContactText } from '../use-contact-text.js';
3
+ type ValueFieldProps = {
4
+ text: ContactText;
5
+ contact: Contact;
6
+ index: number;
7
+ items: readonly Contact[];
8
+ /** The name of this field's focus key, and how a name is scoped. */
9
+ focusName: string;
10
+ focusKey: (name: string) => string;
11
+ positions: ReadonlyMap<number, number>;
12
+ /** The field was left: a wrong format or an empty value shows. */
13
+ left: boolean;
14
+ onLeave: () => void;
15
+ disabled?: boolean;
16
+ onChange: (patch: Partial<Contact>) => void;
17
+ };
18
+ /**
19
+ * The value input and the messages that belong to it: a wrong format, a
20
+ * duplicate (live) or, once the field was left, a wrong format or an empty
21
+ * value. Each message is a
22
+ * `role="alert"` the input is described by.
23
+ */
24
+ export declare function ValueField({ text, contact, index, items, focusName, focusKey, positions, left, onLeave, disabled, onChange, }: ValueFieldProps): import("react").JSX.Element;
25
+ export {};