@mszczygiel-projects/ui-core-shared 0.0.0-stage → 1.0.0-alpha.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 (118) hide show
  1. package/README.md +4 -2
  2. package/dist/components/accordion-item.d.ts +86 -0
  3. package/dist/components/accordion-item.js +51 -0
  4. package/dist/components/accordion.d.ts +33 -0
  5. package/dist/components/accordion.js +23 -0
  6. package/dist/components/badge.d.ts +82 -0
  7. package/dist/components/badge.js +37 -0
  8. package/dist/components/breadcrumbs.d.ts +93 -0
  9. package/dist/components/breadcrumbs.js +52 -0
  10. package/dist/components/button.d.ts +98 -0
  11. package/dist/components/button.js +42 -0
  12. package/dist/components/calendar.d.ts +100 -0
  13. package/dist/components/calendar.js +72 -0
  14. package/dist/components/checkbox-field.d.ts +107 -0
  15. package/dist/components/checkbox-field.js +48 -0
  16. package/dist/components/chip.d.ts +113 -0
  17. package/dist/components/chip.js +41 -0
  18. package/dist/components/combobox.d.ts +119 -0
  19. package/dist/components/combobox.js +75 -0
  20. package/dist/components/component.d.ts +76 -0
  21. package/dist/components/component.js +9 -0
  22. package/dist/components/date-field.d.ts +106 -0
  23. package/dist/components/date-field.js +72 -0
  24. package/dist/components/date-time-field.d.ts +85 -0
  25. package/dist/components/date-time-field.js +65 -0
  26. package/dist/components/dialog.d.ts +136 -0
  27. package/dist/components/dialog.js +54 -0
  28. package/dist/components/drawer.d.ts +54 -0
  29. package/dist/components/drawer.js +42 -0
  30. package/dist/components/file-input-field.d.ts +137 -0
  31. package/dist/components/file-input-field.js +92 -0
  32. package/dist/components/icon-button.d.ts +98 -0
  33. package/dist/components/icon-button.js +29 -0
  34. package/dist/components/index.d.ts +3 -0
  35. package/dist/components/index.js +75 -0
  36. package/dist/components/link-button.d.ts +78 -0
  37. package/dist/components/link-button.js +29 -0
  38. package/dist/components/listbox.d.ts +135 -0
  39. package/dist/components/listbox.js +73 -0
  40. package/dist/components/loader.d.ts +40 -0
  41. package/dist/components/loader.js +20 -0
  42. package/dist/components/menu.d.ts +132 -0
  43. package/dist/components/menu.js +56 -0
  44. package/dist/components/notification.d.ts +95 -0
  45. package/dist/components/notification.js +47 -0
  46. package/dist/components/number-field.d.ts +81 -0
  47. package/dist/components/number-field.js +65 -0
  48. package/dist/components/pagination.d.ts +102 -0
  49. package/dist/components/pagination.js +68 -0
  50. package/dist/components/password-field.d.ts +75 -0
  51. package/dist/components/password-field.js +56 -0
  52. package/dist/components/popover.d.ts +86 -0
  53. package/dist/components/popover.js +44 -0
  54. package/dist/components/radio-field.d.ts +48 -0
  55. package/dist/components/radio-field.js +46 -0
  56. package/dist/components/radio-group.d.ts +81 -0
  57. package/dist/components/radio-group.js +35 -0
  58. package/dist/components/search-field.d.ts +62 -0
  59. package/dist/components/search-field.js +57 -0
  60. package/dist/components/select-field.d.ts +86 -0
  61. package/dist/components/select-field.js +71 -0
  62. package/dist/components/split-button.d.ts +91 -0
  63. package/dist/components/split-button.js +80 -0
  64. package/dist/components/switch-field.d.ts +82 -0
  65. package/dist/components/switch-field.js +54 -0
  66. package/dist/components/tab.d.ts +72 -0
  67. package/dist/components/tab.js +58 -0
  68. package/dist/components/tabs.d.ts +89 -0
  69. package/dist/components/tabs.js +46 -0
  70. package/dist/components/text-field.d.ts +183 -0
  71. package/dist/components/text-field.js +66 -0
  72. package/dist/components/textarea-field.d.ts +78 -0
  73. package/dist/components/textarea-field.js +53 -0
  74. package/dist/components/time-field.d.ts +66 -0
  75. package/dist/components/time-field.js +41 -0
  76. package/dist/components/tooltip.d.ts +55 -0
  77. package/dist/components/tooltip.js +34 -0
  78. package/dist/utils/accordion-navigation.d.ts +8 -0
  79. package/dist/utils/accordion-navigation.js +37 -0
  80. package/dist/utils/breadcrumb-list.d.ts +22 -0
  81. package/dist/utils/breadcrumb-list.js +23 -0
  82. package/dist/utils/calendar-grid.d.ts +211 -0
  83. package/dist/utils/calendar-grid.js +482 -0
  84. package/dist/utils/date-time.d.ts +18 -0
  85. package/dist/utils/date-time.js +89 -0
  86. package/dist/utils/date.d.ts +96 -0
  87. package/dist/utils/date.js +301 -0
  88. package/dist/utils/drag-dismiss.d.ts +39 -0
  89. package/dist/utils/drag-dismiss.js +47 -0
  90. package/dist/utils/file-selection.d.ts +75 -0
  91. package/dist/utils/file-selection.js +118 -0
  92. package/dist/utils/listbox-navigation.d.ts +56 -0
  93. package/dist/utils/listbox-navigation.js +157 -0
  94. package/dist/utils/locale.d.ts +12 -0
  95. package/dist/utils/locale.js +29 -0
  96. package/dist/utils/menu-navigation.d.ts +24 -0
  97. package/dist/utils/menu-navigation.js +54 -0
  98. package/dist/utils/numeric.d.ts +84 -0
  99. package/dist/utils/numeric.js +279 -0
  100. package/dist/utils/one-of.d.ts +6 -0
  101. package/dist/utils/one-of.js +8 -0
  102. package/dist/utils/paginate.d.ts +36 -0
  103. package/dist/utils/paginate.js +50 -0
  104. package/dist/utils/parsed-input.d.ts +32 -0
  105. package/dist/utils/parsed-input.js +17 -0
  106. package/dist/utils/radio-navigation.d.ts +9 -0
  107. package/dist/utils/radio-navigation.js +28 -0
  108. package/dist/utils/scroll-lock.d.ts +19 -0
  109. package/dist/utils/scroll-lock.js +43 -0
  110. package/dist/utils/tabs-navigation.d.ts +21 -0
  111. package/dist/utils/tabs-navigation.js +53 -0
  112. package/dist/utils/text.d.ts +21 -0
  113. package/dist/utils/text.js +61 -0
  114. package/dist/utils/time.d.ts +28 -0
  115. package/dist/utils/time.js +61 -0
  116. package/dist/utils/tooltip-group.d.ts +9 -0
  117. package/dist/utils/tooltip-group.js +33 -0
  118. package/package.json +295 -3
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # @mszczygiel-projects/ui-core-shared
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ What the web components and the React components of UI Core Library share: the specification of each component, with its props, allowed values and defaults, and pure functions that are safe for server rendering. Applications rarely import it directly; both component packages depend on it.
4
+
5
+ Each module has a subpath, such as `./button` or `./one-of`, and none has side effects. The [documentation site](https://mszczygiel-projects.github.io/ui-core-library/) documents the components.
@@ -0,0 +1,86 @@
1
+ /** The specification of AccordionItem. */
2
+ export declare const accordionItem: {
3
+ readonly name: "AccordionItem";
4
+ readonly tag: "ui-accordion-item";
5
+ readonly category: "Content";
6
+ readonly status: "done";
7
+ readonly figma: "3215:68";
8
+ readonly partOf: "Accordion";
9
+ readonly design: {
10
+ readonly flags: readonly ["open", "disabled"];
11
+ readonly booleans: readonly [];
12
+ readonly codeOnly: readonly ["headingLevel"];
13
+ readonly previews: {
14
+ readonly interaction: {
15
+ readonly options: readonly ["rest", "active", "focus"];
16
+ readonly default: "rest";
17
+ readonly note: "Previews hover and press (active) and keyboard focus of the heading. Leave it at rest in a design.";
18
+ };
19
+ };
20
+ };
21
+ readonly summary: "One section of an Accordion: a heading that shows and hides its content.";
22
+ readonly options: {};
23
+ readonly labels: readonly [];
24
+ readonly parts: readonly ["base", "heading", "trigger", "label", "icon", "panel"];
25
+ readonly slots: readonly [];
26
+ readonly events: readonly ["ui-open-change"];
27
+ readonly stories: readonly [];
28
+ readonly exceptions: readonly [{
29
+ readonly items: readonly ["defaultOpen"];
30
+ readonly reason: "React uses defaultOpen for an uncontrolled initial state. The web component uses its open attribute for that, and its property for the current state.";
31
+ }, {
32
+ readonly items: readonly ["ui-open-change"];
33
+ readonly reason: "The web component dispatches the event before the section opens or closes, and an author may cancel it, as for Popover. Find in page and a link to a text fragment open a closed section with the reason find, whatever the page answers, since the browser has already revealed the match.";
34
+ }, {
35
+ readonly items: readonly ["headingLevel"];
36
+ readonly reason: "The level of the heading follows the outline of the page, which the component cannot know. It is a number, not a set of strings, since it is the level of an HTML heading.";
37
+ }];
38
+ };
39
+ /** The levels of the heading of a section, from h2 to h6. */
40
+ export declare const accordionHeadingLevels: readonly [2, 3, 4, 5, 6];
41
+ /** The level of the heading of a section. */
42
+ export type AccordionHeadingLevel = (typeof accordionHeadingLevels)[number];
43
+ /** The level of a heading when none is given or the given one is not a heading of a section. */
44
+ export declare const defaultAccordionHeadingLevel: AccordionHeadingLevel;
45
+ /** The given level when it is a level of a section heading, the default otherwise. */
46
+ export declare function accordionHeadingLevel(level: unknown): AccordionHeadingLevel;
47
+ /**
48
+ * What asked a section to open or close: a press on its heading, find in page or a link to a text
49
+ * fragment in its closed content, or, in React, another section that opened while `multiple` is
50
+ * off.
51
+ */
52
+ export type AccordionItemOpenChangeReason = 'trigger' | 'find' | 'group';
53
+ /**
54
+ * What accompanies a section that opens or closes. The package knows no browser types, so each
55
+ * implementation names the type of the event.
56
+ */
57
+ export interface AccordionItemOpenChangeDetails<OriginalEvent> {
58
+ readonly reason: AccordionItemOpenChangeReason;
59
+ /** The click, the `beforematch` event or the event that opened another section. */
60
+ readonly originalEvent: OriginalEvent;
61
+ }
62
+ /** The detail of `ui-open-change`: the new state and what asked for it. */
63
+ export interface AccordionItemOpenChangeDetail<OriginalEvent> extends AccordionItemOpenChangeDetails<OriginalEvent> {
64
+ readonly value: boolean;
65
+ }
66
+ /** The props both implementations of AccordionItem share. */
67
+ export interface AccordionItemProps {
68
+ /** The text of the heading, which names the section and its content. */
69
+ label: string;
70
+ /**
71
+ * Whether the content shows. A press on the heading opens and closes it, and find in page opens
72
+ * it on a match in its content. The closed content stays in the page, hidden.
73
+ * @default false
74
+ */
75
+ open?: boolean;
76
+ /**
77
+ * Keeps the section as it is and removes its heading from keyboard navigation.
78
+ * @default false
79
+ */
80
+ disabled?: boolean;
81
+ /**
82
+ * The level of the heading, from 2 to 6, which follows the outline of the page.
83
+ * @default 3
84
+ */
85
+ headingLevel?: AccordionHeadingLevel;
86
+ }
@@ -0,0 +1,51 @@
1
+ import { defineComponent } from "./component.js";
2
+ /** The specification of AccordionItem. */
3
+ export const accordionItem = defineComponent({
4
+ name: 'AccordionItem',
5
+ tag: 'ui-accordion-item',
6
+ category: 'Content',
7
+ status: 'done',
8
+ figma: '3215:68',
9
+ partOf: 'Accordion',
10
+ design: {
11
+ flags: ['open', 'disabled'],
12
+ booleans: [],
13
+ codeOnly: ['headingLevel'],
14
+ previews: {
15
+ interaction: {
16
+ options: ['rest', 'active', 'focus'],
17
+ default: 'rest',
18
+ note: 'Previews hover and press (active) and keyboard focus of the heading. Leave it at rest in a design.',
19
+ },
20
+ },
21
+ },
22
+ summary: 'One section of an Accordion: a heading that shows and hides its content.',
23
+ options: {},
24
+ labels: [],
25
+ parts: ['base', 'heading', 'trigger', 'label', 'icon', 'panel'],
26
+ slots: [],
27
+ events: ['ui-open-change'],
28
+ stories: [],
29
+ exceptions: [
30
+ {
31
+ items: ['defaultOpen'],
32
+ reason: 'React uses defaultOpen for an uncontrolled initial state. The web component uses its open attribute for that, and its property for the current state.',
33
+ },
34
+ {
35
+ items: ['ui-open-change'],
36
+ reason: 'The web component dispatches the event before the section opens or closes, and an author may cancel it, as for Popover. Find in page and a link to a text fragment open a closed section with the reason find, whatever the page answers, since the browser has already revealed the match.',
37
+ },
38
+ {
39
+ items: ['headingLevel'],
40
+ reason: 'The level of the heading follows the outline of the page, which the component cannot know. It is a number, not a set of strings, since it is the level of an HTML heading.',
41
+ },
42
+ ],
43
+ });
44
+ /** The levels of the heading of a section, from h2 to h6. */
45
+ export const accordionHeadingLevels = [2, 3, 4, 5, 6];
46
+ /** The level of a heading when none is given or the given one is not a heading of a section. */
47
+ export const defaultAccordionHeadingLevel = 3;
48
+ /** The given level when it is a level of a section heading, the default otherwise. */
49
+ export function accordionHeadingLevel(level) {
50
+ return (accordionHeadingLevels.find((candidate) => candidate === level) ?? defaultAccordionHeadingLevel);
51
+ }
@@ -0,0 +1,33 @@
1
+ /** The specification of Accordion. */
2
+ export declare const accordion: {
3
+ readonly name: "Accordion";
4
+ readonly tag: "ui-accordion";
5
+ readonly category: "Content";
6
+ readonly status: "done";
7
+ readonly figma: "3215:70";
8
+ readonly design: {
9
+ readonly flags: readonly [];
10
+ readonly booleans: readonly [];
11
+ readonly codeOnly: readonly ["multiple"];
12
+ readonly previews: {};
13
+ };
14
+ readonly summary: "A stack of sections whose headings show and hide their content.";
15
+ readonly options: {};
16
+ readonly labels: readonly [];
17
+ readonly parts: readonly ["base"];
18
+ readonly slots: readonly [];
19
+ readonly events: readonly [];
20
+ readonly stories: readonly ["Playground", "Multiple", "WithDisabledItem", "OnSurfaces"];
21
+ readonly exceptions: readonly [{
22
+ readonly items: readonly ["ui-open-change"];
23
+ readonly reason: "Each AccordionItem reports its own request to open or close. When one opens and multiple is off, the group closes the others by setting their open, which the web component reports as nothing, since setting open reports nothing. React calls onOpenChange of each closed item with the reason group, because a controlled item stays open until its parent agrees.";
24
+ }];
25
+ };
26
+ /** The props both implementations of Accordion share. */
27
+ export interface AccordionProps {
28
+ /**
29
+ * Lets several sections stay open at once. Without it, opening a section closes the others.
30
+ * @default false
31
+ */
32
+ multiple?: boolean;
33
+ }
@@ -0,0 +1,23 @@
1
+ import { defineComponent } from "./component.js";
2
+ /** The specification of Accordion. */
3
+ export const accordion = defineComponent({
4
+ name: 'Accordion',
5
+ tag: 'ui-accordion',
6
+ category: 'Content',
7
+ status: 'done',
8
+ figma: '3215:70',
9
+ design: { flags: [], booleans: [], codeOnly: ['multiple'], previews: {} },
10
+ summary: 'A stack of sections whose headings show and hide their content.',
11
+ options: {},
12
+ labels: [],
13
+ parts: ['base'],
14
+ slots: [],
15
+ events: [],
16
+ stories: ['Playground', 'Multiple', 'WithDisabledItem', 'OnSurfaces'],
17
+ exceptions: [
18
+ {
19
+ items: ['ui-open-change'],
20
+ reason: 'Each AccordionItem reports its own request to open or close. When one opens and multiple is off, the group closes the others by setting their open, which the web component reports as nothing, since setting open reports nothing. React calls onOpenChange of each closed item with the reason group, because a controlled item stays open until its parent agrees.',
21
+ },
22
+ ],
23
+ });
@@ -0,0 +1,82 @@
1
+ import { type OptionOf } from './component.ts';
2
+ /** The specification of Badge. */
3
+ export declare const badge: {
4
+ readonly name: "Badge";
5
+ readonly tag: "ui-badge";
6
+ readonly category: "Feedback";
7
+ readonly status: "done";
8
+ readonly figma: "2037:98";
9
+ readonly design: {
10
+ readonly flags: readonly [];
11
+ readonly booleans: readonly [];
12
+ readonly codeOnly: readonly [];
13
+ readonly previews: {
14
+ readonly content: {
15
+ readonly options: readonly ["label", "icon"];
16
+ readonly default: "label";
17
+ readonly note: "Chooses the layout of a badge with text, or with only the leading content, such as an icon. Code derives it from the content.";
18
+ };
19
+ };
20
+ };
21
+ readonly summary: "Marks a status, a category or a count with a short label and any content before or after it.";
22
+ readonly options: {
23
+ readonly tone: {
24
+ readonly options: readonly ["neutral", "brand", "info", "success", "warning", "error"];
25
+ readonly default: "neutral";
26
+ };
27
+ readonly variant: {
28
+ readonly options: readonly ["solid", "subtle"];
29
+ readonly default: "solid";
30
+ };
31
+ readonly size: {
32
+ readonly options: readonly ["small", "medium"];
33
+ readonly default: "medium";
34
+ };
35
+ readonly shape: {
36
+ readonly options: readonly ["rounded", "square"];
37
+ readonly default: "rounded";
38
+ };
39
+ };
40
+ readonly labels: readonly [];
41
+ readonly parts: readonly ["base", "leading", "label", "trailing"];
42
+ readonly slots: readonly ["leading", "trailing"];
43
+ readonly events: readonly [];
44
+ readonly stories: readonly ["Playground", "Variants", "Shapes", "WithIcon", "StatusDot", "OnSurfaces"];
45
+ readonly exceptions: readonly [];
46
+ };
47
+ /** The meaning a badge carries: none, the brand, or one of the feedback tones. */
48
+ export type BadgeTone = OptionOf<typeof badge, 'tone'>;
49
+ /** The emphasis of a badge: a strong fill or a light tint. */
50
+ export type BadgeVariant = OptionOf<typeof badge, 'variant'>;
51
+ /** The sizes of a badge, each following the density. */
52
+ export type BadgeSize = OptionOf<typeof badge, 'size'>;
53
+ /** The corners of a badge: a pill or a small radius. */
54
+ export type BadgeShape = OptionOf<typeof badge, 'shape'>;
55
+ /** The props both implementations of Badge share. */
56
+ export interface BadgeProps {
57
+ /**
58
+ * The meaning the badge carries.
59
+ * @default 'neutral'
60
+ */
61
+ tone?: BadgeTone;
62
+ /**
63
+ * The emphasis of the badge.
64
+ * @default 'solid'
65
+ */
66
+ variant?: BadgeVariant;
67
+ /**
68
+ * The size, which follows the density.
69
+ * @default 'medium'
70
+ */
71
+ size?: BadgeSize;
72
+ /**
73
+ * The corners of the badge.
74
+ * @default 'rounded'
75
+ */
76
+ shape?: BadgeShape;
77
+ /**
78
+ * The accessible name of a badge that shows no text, only its leading or trailing content. A
79
+ * badge with text is named by its text, and an author's `aria-label` wins.
80
+ */
81
+ label?: string;
82
+ }
@@ -0,0 +1,37 @@
1
+ import { defineComponent } from "./component.js";
2
+ /** The specification of Badge. */
3
+ export const badge = defineComponent({
4
+ name: 'Badge',
5
+ tag: 'ui-badge',
6
+ category: 'Feedback',
7
+ status: 'done',
8
+ figma: '2037:98',
9
+ design: {
10
+ flags: [],
11
+ booleans: [],
12
+ codeOnly: [],
13
+ previews: {
14
+ content: {
15
+ options: ['label', 'icon'],
16
+ default: 'label',
17
+ note: 'Chooses the layout of a badge with text, or with only the leading content, such as an icon. Code derives it from the content.',
18
+ },
19
+ },
20
+ },
21
+ summary: 'Marks a status, a category or a count with a short label and any content before or after it.',
22
+ options: {
23
+ tone: {
24
+ options: ['neutral', 'brand', 'info', 'success', 'warning', 'error'],
25
+ default: 'neutral',
26
+ },
27
+ variant: { options: ['solid', 'subtle'], default: 'solid' },
28
+ size: { options: ['small', 'medium'], default: 'medium' },
29
+ shape: { options: ['rounded', 'square'], default: 'rounded' },
30
+ },
31
+ labels: [],
32
+ parts: ['base', 'leading', 'label', 'trailing'],
33
+ slots: ['leading', 'trailing'],
34
+ events: [],
35
+ stories: ['Playground', 'Variants', 'Shapes', 'WithIcon', 'StatusDot', 'OnSurfaces'],
36
+ exceptions: [],
37
+ });
@@ -0,0 +1,93 @@
1
+ import { type OptionOf } from './component.ts';
2
+ /** The specification of Breadcrumbs. */
3
+ export declare const breadcrumbs: {
4
+ readonly name: "Breadcrumbs";
5
+ readonly tag: "ui-breadcrumbs";
6
+ readonly category: "Navigation";
7
+ readonly status: "done";
8
+ readonly figma: "2334:2878";
9
+ readonly design: {
10
+ readonly flags: readonly [];
11
+ readonly booleans: readonly [];
12
+ readonly codeOnly: readonly ["items", "label"];
13
+ readonly previews: {
14
+ readonly collapsed: {
15
+ readonly options: readonly ["false", "true"];
16
+ readonly default: "false";
17
+ readonly note: "Previews a container narrower than breakpoint/sm, where the items before the last two hide behind an ellipsis. Code collapses from the width of the container.";
18
+ };
19
+ };
20
+ };
21
+ readonly summary: "A trail of links from the top of a site down to the current page.";
22
+ readonly options: {
23
+ readonly size: {
24
+ readonly options: readonly ["small", "medium"];
25
+ readonly default: "medium";
26
+ };
27
+ readonly separator: {
28
+ readonly options: readonly ["chevron", "slash"];
29
+ readonly default: "chevron";
30
+ };
31
+ };
32
+ readonly labels: readonly ["label"];
33
+ readonly parts: readonly ["base", "list", "item", "link", "text", "current", "item-icon", "item-label", "separator", "ellipsis"];
34
+ readonly slots: readonly [];
35
+ readonly events: readonly ["ui-navigate"];
36
+ readonly stories: readonly ["Playground", "Collapsed", "OnSurfaces"];
37
+ readonly exceptions: readonly [{
38
+ readonly items: readonly ["size"];
39
+ readonly reason: "A trail sits in running text or a page header, so it has the small and medium sizes of body text and no large one.";
40
+ }, {
41
+ readonly items: readonly ["items"];
42
+ readonly reason: "The trail is data, like the options of a list, so that its last item is always the current page. The icon of an item is an SVG string of the icon package in the web component and a React node in React, since data cannot carry a slot.";
43
+ }];
44
+ };
45
+ /** The sizes of a trail, each following the density. */
46
+ export type BreadcrumbsSize = OptionOf<typeof breadcrumbs, 'size'>;
47
+ /** The mark between two items. It follows the direction of the text. */
48
+ export type BreadcrumbsSeparator = OptionOf<typeof breadcrumbs, 'separator'>;
49
+ /** One step of the trail. `Icon` is the type each implementation uses for a decorative icon. */
50
+ export interface BreadcrumbsItem<Icon = never> {
51
+ /** The text of the item, which also names its link. */
52
+ readonly label: string;
53
+ /** The address of the page. An item without one is text, and the last item never links. */
54
+ readonly href?: string;
55
+ /** A decorative icon before the label, such as a home icon on the first item. */
56
+ readonly icon?: Icon;
57
+ /**
58
+ * Shows the icon alone. The label still names the item for assistive technology but takes no
59
+ * space. It applies only to an item with an icon.
60
+ */
61
+ readonly iconOnly?: boolean;
62
+ }
63
+ /**
64
+ * What accompanies a press on a link: the item, its index and the native event. The package knows
65
+ * no browser types, so each implementation names the type of the event.
66
+ */
67
+ export interface BreadcrumbsNavigateDetails<OriginalEvent, Icon = never> {
68
+ readonly item: BreadcrumbsItem<Icon>;
69
+ readonly index: number;
70
+ readonly originalEvent: OriginalEvent;
71
+ }
72
+ /** The detail of `ui-navigate`. */
73
+ export type BreadcrumbsNavigateDetail<OriginalEvent, Icon = never> = BreadcrumbsNavigateDetails<OriginalEvent, Icon>;
74
+ /**
75
+ * The props both implementations of Breadcrumbs share. `Icon` is the type of the icons of the
76
+ * items, which each implementation names.
77
+ */
78
+ export interface BreadcrumbsProps<Icon = unknown> {
79
+ /** The steps from the top of the site to the current page, which is the last one. */
80
+ items?: readonly BreadcrumbsItem<Icon>[];
81
+ /** The accessible name of the navigation, falling back to `labels.breadcrumbs.label`. */
82
+ label?: string;
83
+ /**
84
+ * The size of the text, which follows the density.
85
+ * @default 'medium'
86
+ */
87
+ size?: BreadcrumbsSize;
88
+ /**
89
+ * The mark between two items.
90
+ * @default 'chevron'
91
+ */
92
+ separator?: BreadcrumbsSeparator;
93
+ }
@@ -0,0 +1,52 @@
1
+ import { defineComponent } from "./component.js";
2
+ /** The specification of Breadcrumbs. */
3
+ export const breadcrumbs = defineComponent({
4
+ name: 'Breadcrumbs',
5
+ tag: 'ui-breadcrumbs',
6
+ category: 'Navigation',
7
+ status: 'done',
8
+ figma: '2334:2878',
9
+ design: {
10
+ flags: [],
11
+ booleans: [],
12
+ codeOnly: ['items', 'label'],
13
+ previews: {
14
+ collapsed: {
15
+ options: ['false', 'true'],
16
+ default: 'false',
17
+ note: 'Previews a container narrower than breakpoint/sm, where the items before the last two hide behind an ellipsis. Code collapses from the width of the container.',
18
+ },
19
+ },
20
+ },
21
+ summary: 'A trail of links from the top of a site down to the current page.',
22
+ options: {
23
+ size: { options: ['small', 'medium'], default: 'medium' },
24
+ separator: { options: ['chevron', 'slash'], default: 'chevron' },
25
+ },
26
+ labels: ['label'],
27
+ parts: [
28
+ 'base',
29
+ 'list',
30
+ 'item',
31
+ 'link',
32
+ 'text',
33
+ 'current',
34
+ 'item-icon',
35
+ 'item-label',
36
+ 'separator',
37
+ 'ellipsis',
38
+ ],
39
+ slots: [],
40
+ events: ['ui-navigate'],
41
+ stories: ['Playground', 'Collapsed', 'OnSurfaces'],
42
+ exceptions: [
43
+ {
44
+ items: ['size'],
45
+ reason: 'A trail sits in running text or a page header, so it has the small and medium sizes of body text and no large one.',
46
+ },
47
+ {
48
+ items: ['items'],
49
+ reason: 'The trail is data, like the options of a list, so that its last item is always the current page. The icon of an item is an SVG string of the icon package in the web component and a React node in React, since data cannot carry a slot.',
50
+ },
51
+ ],
52
+ });
@@ -0,0 +1,98 @@
1
+ import { type OptionOf } from './component.ts';
2
+ /** The specification of Button. */
3
+ export declare const button: {
4
+ readonly name: "Button";
5
+ readonly tag: "ui-button";
6
+ readonly category: "Actions";
7
+ readonly status: "done";
8
+ readonly figma: "179:100";
9
+ readonly design: {
10
+ readonly flags: readonly ["disabled", "loading"];
11
+ readonly booleans: readonly [];
12
+ readonly codeOnly: readonly ["type"];
13
+ readonly previews: {
14
+ readonly interaction: {
15
+ readonly options: readonly ["rest", "active", "focus"];
16
+ readonly default: "rest";
17
+ readonly note: "Previews hover and press (active) and keyboard focus. Leave it at rest in a design.";
18
+ };
19
+ };
20
+ };
21
+ readonly summary: "Triggers an action, with optional icons and a loading state.";
22
+ readonly options: {
23
+ readonly variant: {
24
+ readonly options: readonly ["primary", "secondary", "outline", "ghost", "danger"];
25
+ readonly default: "primary";
26
+ };
27
+ readonly size: {
28
+ readonly options: readonly ["small", "medium", "large"];
29
+ readonly default: "medium";
30
+ };
31
+ readonly shape: {
32
+ readonly options: readonly ["square", "rounded"];
33
+ readonly default: "square";
34
+ };
35
+ readonly type: {
36
+ readonly options: readonly ["button", "submit", "reset"];
37
+ readonly default: "button";
38
+ };
39
+ };
40
+ readonly labels: readonly ["loading"];
41
+ readonly parts: readonly ["base", "wrapper", "content", "leading-icon", "label", "trailing-icon", "loader"];
42
+ readonly slots: readonly ["leading-icon", "trailing-icon"];
43
+ readonly events: readonly [];
44
+ readonly stories: readonly ["Playground", "Variants", "Shapes", "WithIcons", "OnSurfaces"];
45
+ readonly exceptions: readonly [{
46
+ readonly items: readonly ["form", "validity", "validationMessage", "willValidate"];
47
+ readonly reason: "The web component exposes its form-associated state as read-only properties. React exposes the native state through its ref, and its form prop is the native form ID attribute.";
48
+ }];
49
+ };
50
+ /** The visual emphasis of an action. */
51
+ export type ButtonVariant = OptionOf<typeof button, 'variant'>;
52
+ /** The sizes of an action, each following the density. */
53
+ export type ButtonSize = OptionOf<typeof button, 'size'>;
54
+ /** The corners of an action: the radius of the control family or a pill. */
55
+ export type ButtonShape = OptionOf<typeof button, 'shape'>;
56
+ /** The native action performed after an uncancelled click. */
57
+ export type ButtonType = OptionOf<typeof button, 'type'>;
58
+ /** The props both implementations of Button share. */
59
+ export interface ButtonProps {
60
+ /**
61
+ * The visual emphasis of the action.
62
+ * @default 'primary'
63
+ */
64
+ variant?: ButtonVariant;
65
+ /**
66
+ * The size, which follows the density.
67
+ * @default 'medium'
68
+ */
69
+ size?: ButtonSize;
70
+ /**
71
+ * The corners of the action.
72
+ * @default 'square'
73
+ */
74
+ shape?: ButtonShape;
75
+ /**
76
+ * Disables interaction and removes the control from keyboard navigation.
77
+ * @default false
78
+ */
79
+ disabled?: boolean;
80
+ /**
81
+ * Blocks activation while keeping focus, width and the accessible name.
82
+ * @default false
83
+ */
84
+ loading?: boolean;
85
+ /**
86
+ * The native form action; an ordinary action does not submit.
87
+ * @default 'button'
88
+ */
89
+ type?: ButtonType;
90
+ /** The name of the form entry, submitted only when this button submits. */
91
+ name?: string;
92
+ /** The value submitted with the name; it identifies the action and is not edited. */
93
+ value?: string;
94
+ /** An accessible name replacing the visible content. An author's `aria-label` wins. */
95
+ label?: string;
96
+ /** The description of the loading state, falling back to `labels.button.loading`. */
97
+ loadingLabel?: string;
98
+ }
@@ -0,0 +1,42 @@
1
+ import { defineComponent } from "./component.js";
2
+ /** The specification of Button. */
3
+ export const button = defineComponent({
4
+ name: 'Button',
5
+ tag: 'ui-button',
6
+ category: 'Actions',
7
+ status: 'done',
8
+ figma: '179:100',
9
+ design: {
10
+ flags: ['disabled', 'loading'],
11
+ booleans: [],
12
+ codeOnly: ['type'],
13
+ previews: {
14
+ interaction: {
15
+ options: ['rest', 'active', 'focus'],
16
+ default: 'rest',
17
+ note: 'Previews hover and press (active) and keyboard focus. Leave it at rest in a design.',
18
+ },
19
+ },
20
+ },
21
+ summary: 'Triggers an action, with optional icons and a loading state.',
22
+ options: {
23
+ variant: {
24
+ options: ['primary', 'secondary', 'outline', 'ghost', 'danger'],
25
+ default: 'primary',
26
+ },
27
+ size: { options: ['small', 'medium', 'large'], default: 'medium' },
28
+ shape: { options: ['square', 'rounded'], default: 'square' },
29
+ type: { options: ['button', 'submit', 'reset'], default: 'button' },
30
+ },
31
+ labels: ['loading'],
32
+ parts: ['base', 'wrapper', 'content', 'leading-icon', 'label', 'trailing-icon', 'loader'],
33
+ slots: ['leading-icon', 'trailing-icon'],
34
+ events: [],
35
+ stories: ['Playground', 'Variants', 'Shapes', 'WithIcons', 'OnSurfaces'],
36
+ exceptions: [
37
+ {
38
+ items: ['form', 'validity', 'validationMessage', 'willValidate'],
39
+ reason: 'The web component exposes its form-associated state as read-only properties. React exposes the native state through its ref, and its form prop is the native form ID attribute.',
40
+ },
41
+ ],
42
+ });