@calcifer-design/ui 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/components/Breadcrumb/Breadcrumb.d.ts +24 -0
  2. package/dist/components/Breadcrumb/Breadcrumb.js +48 -0
  3. package/dist/components/Breadcrumb/Breadcrumb.module.js +10 -0
  4. package/dist/components/Breadcrumb/Breadcrumb_module.css +49 -0
  5. package/dist/components/CardList/CardList.d.ts +30 -0
  6. package/dist/components/CardList/CardList.js +35 -0
  7. package/dist/components/CardList/CardList.module.js +7 -0
  8. package/dist/components/CardList/CardList_module.css +20 -0
  9. package/dist/components/DatePicker/Calendar.d.ts +19 -0
  10. package/dist/components/DatePicker/Calendar.js +207 -0
  11. package/dist/components/DatePicker/DatePicker.d.ts +72 -0
  12. package/dist/components/DatePicker/DatePicker.js +116 -0
  13. package/dist/components/DatePicker/DatePicker.module.js +14 -0
  14. package/dist/components/DatePicker/DatePicker_module.css +112 -0
  15. package/dist/components/DatePicker/calendarDate.d.ts +46 -0
  16. package/dist/components/DatePicker/calendarDate.js +117 -0
  17. package/dist/components/Descriptions/Descriptions.d.ts +25 -0
  18. package/dist/components/Descriptions/Descriptions.js +44 -0
  19. package/dist/components/Descriptions/Descriptions.module.js +8 -0
  20. package/dist/components/Descriptions/Descriptions_module.css +47 -0
  21. package/dist/components/Field/Field.d.ts +1 -1
  22. package/dist/components/Field/Field.js +7 -1
  23. package/dist/components/Field/PickerField.d.ts +41 -0
  24. package/dist/components/Field/PickerField.js +115 -0
  25. package/dist/components/Field/PickerField.module.js +8 -0
  26. package/dist/components/Field/PickerField_module.css +36 -0
  27. package/dist/components/FilterBar/FilterBar.d.ts +55 -0
  28. package/dist/components/FilterBar/FilterBar.js +138 -0
  29. package/dist/components/FilterBar/FilterBar.module.js +13 -0
  30. package/dist/components/FilterBar/FilterBar_module.css +98 -0
  31. package/dist/components/Form/Form.d.ts +48 -0
  32. package/dist/components/Form/Form.js +38 -0
  33. package/dist/components/Form/Form.module.js +5 -0
  34. package/dist/components/Form/FormContext.d.ts +15 -0
  35. package/dist/components/Form/FormContext.js +20 -0
  36. package/dist/components/Form/Form_module.css +6 -0
  37. package/dist/components/PageShell/PageShell.d.ts +27 -0
  38. package/dist/components/PageShell/PageShell.js +35 -0
  39. package/dist/components/PageShell/PageShell.module.js +9 -0
  40. package/dist/components/PageShell/PageShell_module.css +56 -0
  41. package/dist/components/Segmented/Segmented.d.ts +49 -0
  42. package/dist/components/Segmented/Segmented.js +55 -0
  43. package/dist/components/Segmented/Segmented.module.js +7 -0
  44. package/dist/components/Segmented/Segmented_module.css +75 -0
  45. package/dist/components/Steps/Steps.d.ts +30 -0
  46. package/dist/components/Steps/Steps.js +63 -0
  47. package/dist/components/Steps/Steps.module.js +10 -0
  48. package/dist/components/Steps/Steps_module.css +126 -0
  49. package/dist/components/TextArea/TextArea.d.ts +16 -0
  50. package/dist/components/TextArea/TextArea.js +28 -0
  51. package/dist/components/TextArea/TextArea.module.js +5 -0
  52. package/dist/components/TextArea/TextArea_module.css +12 -0
  53. package/dist/components/TimePicker/TimePicker.d.ts +19 -0
  54. package/dist/components/TimePicker/TimePicker.js +17 -0
  55. package/dist/components/Timeline/Timeline.d.ts +39 -0
  56. package/dist/components/Timeline/Timeline.js +109 -0
  57. package/dist/components/Timeline/Timeline.module.js +12 -0
  58. package/dist/components/Timeline/Timeline_module.css +99 -0
  59. package/dist/components/Toolbar/InsideToolbarContext.d.ts +6 -0
  60. package/dist/components/Toolbar/InsideToolbarContext.js +3 -0
  61. package/dist/components/Toolbar/Toolbar.d.ts +46 -0
  62. package/dist/components/Toolbar/Toolbar.js +43 -0
  63. package/dist/components/Toolbar/Toolbar.module.js +7 -0
  64. package/dist/components/Toolbar/Toolbar_module.css +26 -0
  65. package/dist/components/Tree/Tree.d.ts +81 -0
  66. package/dist/components/Tree/Tree.js +232 -0
  67. package/dist/components/Tree/Tree.module.js +12 -0
  68. package/dist/components/Tree/Tree_module.css +124 -0
  69. package/dist/components/Tree/treeIndex.d.ts +23 -0
  70. package/dist/components/Tree/treeIndex.js +33 -0
  71. package/dist/components/TreeSelect/TreeSelect.d.ts +61 -0
  72. package/dist/components/TreeSelect/TreeSelect.js +117 -0
  73. package/dist/components/TreeSelect/TreeSelect.module.js +7 -0
  74. package/dist/components/TreeSelect/TreeSelect_module.css +22 -0
  75. package/dist/components/Upload/Upload.d.ts +66 -0
  76. package/dist/components/Upload/Upload.js +287 -0
  77. package/dist/components/Upload/Upload.module.js +12 -0
  78. package/dist/components/Upload/Upload_module.css +96 -0
  79. package/dist/components/ViewField/ViewField.d.ts +26 -0
  80. package/dist/components/ViewField/ViewField.js +29 -0
  81. package/dist/components/ViewField/ViewField.module.js +6 -0
  82. package/dist/components/ViewField/ViewField_module.css +17 -0
  83. package/dist/hooks/useFormReset.d.ts +10 -0
  84. package/dist/hooks/useFormReset.js +34 -0
  85. package/dist/icons/CalendarIcon.d.ts +2 -0
  86. package/dist/icons/CalendarIcon.js +26 -0
  87. package/dist/index.d.ts +34 -0
  88. package/dist/index.js +17 -0
  89. package/dist/styles/pair.module.js +6 -0
  90. package/dist/styles/pair_module.css +18 -0
  91. package/package.json +2 -2
@@ -0,0 +1,55 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface FilterBarFilter {
3
+ /** What `onRemoveFilter` reports. */
4
+ id: string;
5
+ /** The chip's text, and the end of its remove button's name. */
6
+ label: string;
7
+ }
8
+ export interface FilterBarLabels {
9
+ /** Names the list of chips. */
10
+ activeFilters: string;
11
+ /** The name of one chip's remove button. */
12
+ removeFilter: (label: string) => string;
13
+ /** The words on the button that clears every filter. */
14
+ clearAll: string;
15
+ /** Shown beside the chips, and announced when the count changes. */
16
+ resultCount: (count: number) => string;
17
+ }
18
+ interface FilterBarBaseProps {
19
+ /** The filter controls, each with its own label: a `Select`, a `DatePicker`, a `Segmented`. */
20
+ children?: ReactNode;
21
+ /** Shown as chips, in this order. Which filters are on, and what they do, is the app's. */
22
+ activeFilters?: FilterBarFilter[];
23
+ /** One filter's `id`. Each chip has a named remove button while this is given. */
24
+ onRemoveFilter?: (id: string) => void;
25
+ /** A button clears all the chips while this is given and there are chips to clear. */
26
+ onClearAll?: () => void;
27
+ /** Shown beside the chips and announced politely when it changes, not when first shown. */
28
+ resultCount?: number;
29
+ /** The words the bar says itself, for an app that is not in English. */
30
+ labels?: Partial<FilterBarLabels>;
31
+ }
32
+ interface FilterBarWithSearch extends FilterBarBaseProps {
33
+ /** Controlled, like the filters: the bar holds no filter state of its own. */
34
+ searchValue: string;
35
+ onSearchChange: (value: string) => void;
36
+ /** The search input's visible label and accessible name. */
37
+ searchLabel: string;
38
+ }
39
+ interface FilterBarWithoutSearch extends FilterBarBaseProps {
40
+ searchValue?: undefined;
41
+ onSearchChange?: undefined;
42
+ searchLabel?: undefined;
43
+ }
44
+ export type FilterBarProps = FilterBarWithSearch | FilterBarWithoutSearch;
45
+ /**
46
+ * The row above a results list: a search, slots for filter controls, the active filters as chips
47
+ * and the count. It holds no filter logic, and only says what the app asked for.
48
+ *
49
+ * Focus does not go with what it was on. A removed chip hands it to the next chip, else the one
50
+ * before; when no chip is left, or Clear all has gone, it passes to the first thing here that can
51
+ * take it, usually the search, and at the last to the bar itself. It waits as long as the app takes
52
+ * to remove the chip, and lets go if the user moves on first.
53
+ */
54
+ export declare function FilterBar({ searchValue, onSearchChange, searchLabel, children, activeFilters, onRemoveFilter, onClearAll, resultCount, labels, }: FilterBarProps): import("react").JSX.Element;
55
+ export {};
@@ -0,0 +1,138 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useLayoutEffect, useRef, useState } from "react";
3
+ import { CloseIcon } from "../../icons/CloseIcon.js";
4
+ import { Button } from "../Button/Button.js";
5
+ import { Field } from "../Field/Field.js";
6
+ import { LiveRegion } from "../LiveRegion/LiveRegion.js";
7
+ import { Tag } from "../Tag/Tag.js";
8
+ import { TextInput } from "../TextInput/TextInput.js";
9
+ import FilterBar_module from "./FilterBar.module.js";
10
+ const DEFAULT_LABELS = {
11
+ activeFilters: 'Active filters',
12
+ removeFilter: (label)=>`Remove filter ${label}`,
13
+ clearAll: 'Clear all',
14
+ resultCount: (count)=>`${count} ${1 === count ? 'result' : 'results'}`
15
+ };
16
+ const FOCUSABLE = 'input:not([disabled],[type="hidden"]),button:not([disabled]),select:not([disabled]),textarea:not([disabled]),a[href],[tabindex="0"]';
17
+ function FilterBar({ searchValue, onSearchChange, searchLabel, children, activeFilters = [], onRemoveFilter, onClearAll, resultCount, labels }) {
18
+ const words = {
19
+ ...DEFAULT_LABELS,
20
+ ...labels
21
+ };
22
+ const rootRef = useRef(null);
23
+ const removeButtons = useRef(new Map());
24
+ const focusedPart = useRef(null);
25
+ const previousFilters = useRef(activeFilters);
26
+ const hasClearAll = void 0 !== onClearAll && activeFilters.length > 0;
27
+ const [announcement, setAnnouncement] = useState('');
28
+ const [announcedCount, setAnnouncedCount] = useState(resultCount);
29
+ if (resultCount !== announcedCount) {
30
+ setAnnouncedCount(resultCount);
31
+ setAnnouncement(void 0 === resultCount ? '' : words.resultCount(resultCount));
32
+ }
33
+ useLayoutEffect(()=>{
34
+ const part = focusedPart.current;
35
+ const earlier = previousFilters.current;
36
+ previousFilters.current = activeFilters;
37
+ if (null === part) return;
38
+ const { filterId } = part;
39
+ if (null === filterId ? hasClearAll : removeButtons.current.has(filterId)) return;
40
+ const position = earlier.findIndex((filter)=>filter.id === filterId);
41
+ const survivor = [
42
+ ...earlier.slice(position + 1),
43
+ ...earlier.slice(0, position).reverse()
44
+ ].map((filter)=>removeButtons.current.get(filter.id)).find((button)=>void 0 !== button);
45
+ const root = rootRef.current;
46
+ focusedPart.current = null;
47
+ (survivor ?? root?.querySelector(FOCUSABLE) ?? root)?.focus();
48
+ });
49
+ const hasSummary = activeFilters.length > 0 || void 0 !== resultCount;
50
+ return /*#__PURE__*/ jsxs("div", {
51
+ ref: rootRef,
52
+ className: FilterBar_module.root,
53
+ tabIndex: -1,
54
+ children: [
55
+ void 0 !== onSearchChange || children ? /*#__PURE__*/ jsxs("div", {
56
+ className: FilterBar_module.controls,
57
+ children: [
58
+ void 0 === onSearchChange ? null : /*#__PURE__*/ jsx("div", {
59
+ className: FilterBar_module.search,
60
+ children: /*#__PURE__*/ jsx(Field, {
61
+ label: searchLabel,
62
+ children: /*#__PURE__*/ jsx(TextInput, {
63
+ type: "search",
64
+ value: searchValue,
65
+ onValueChange: (value)=>onSearchChange(value)
66
+ })
67
+ })
68
+ }),
69
+ children
70
+ ]
71
+ }) : null,
72
+ hasSummary ? /*#__PURE__*/ jsxs("div", {
73
+ className: FilterBar_module.summary,
74
+ children: [
75
+ void 0 === resultCount ? null : /*#__PURE__*/ jsx("span", {
76
+ className: FilterBar_module.count,
77
+ children: words.resultCount(resultCount)
78
+ }),
79
+ activeFilters.length > 0 ? /*#__PURE__*/ jsx("ul", {
80
+ role: "list",
81
+ className: FilterBar_module.chips,
82
+ "aria-label": words.activeFilters,
83
+ children: activeFilters.map((filter)=>/*#__PURE__*/ jsx("li", {
84
+ className: FilterBar_module.chip,
85
+ children: /*#__PURE__*/ jsxs(Tag, {
86
+ children: [
87
+ /*#__PURE__*/ jsx("span", {
88
+ className: FilterBar_module.chipLabel,
89
+ children: filter.label
90
+ }),
91
+ void 0 === onRemoveFilter ? null : /*#__PURE__*/ jsx("button", {
92
+ ref: (element)=>{
93
+ if (null !== element) removeButtons.current.set(filter.id, element);
94
+ return ()=>{
95
+ removeButtons.current.delete(filter.id);
96
+ };
97
+ },
98
+ type: "button",
99
+ className: FilterBar_module.remove,
100
+ "aria-label": words.removeFilter(filter.label),
101
+ onClick: ()=>onRemoveFilter(filter.id),
102
+ onFocus: ()=>{
103
+ focusedPart.current = {
104
+ filterId: filter.id
105
+ };
106
+ },
107
+ onBlur: ()=>{
108
+ focusedPart.current = null;
109
+ },
110
+ children: /*#__PURE__*/ jsx(CloseIcon, {})
111
+ })
112
+ ]
113
+ })
114
+ }, filter.id))
115
+ }) : null,
116
+ hasClearAll ? /*#__PURE__*/ jsx(Button, {
117
+ variant: "ghost",
118
+ size: "sm",
119
+ onClick: ()=>onClearAll(),
120
+ onFocus: ()=>{
121
+ focusedPart.current = {
122
+ filterId: null
123
+ };
124
+ },
125
+ onBlur: ()=>{
126
+ focusedPart.current = null;
127
+ },
128
+ children: words.clearAll
129
+ }) : null
130
+ ]
131
+ }) : null,
132
+ /*#__PURE__*/ jsx(LiveRegion, {
133
+ message: announcement
134
+ })
135
+ ]
136
+ });
137
+ }
138
+ export { FilterBar };
@@ -0,0 +1,13 @@
1
+ import "./FilterBar_module.css";
2
+ const FilterBar_module = {
3
+ root: "root-qnTXQ",
4
+ controls: "controls-UYZLG",
5
+ search: "search-tu3RA",
6
+ summary: "summary-CSd_P",
7
+ count: "count-dGqXH",
8
+ chips: "chips-BHcAD",
9
+ chip: "chip-wCX2N",
10
+ chipLabel: "chipLabel-lhx4e",
11
+ remove: "remove-RNUMA"
12
+ };
13
+ export default FilterBar_module;
@@ -0,0 +1,98 @@
1
+ .root-qnTXQ {
2
+ gap: var(--space-3);
3
+ flex-direction: column;
4
+ min-width: 0;
5
+ display: flex;
6
+ }
7
+
8
+ .controls-UYZLG {
9
+ align-items: flex-end;
10
+ gap: var(--space-3);
11
+ flex-wrap: wrap;
12
+ display: flex;
13
+ }
14
+
15
+ .controls-UYZLG > * {
16
+ min-width: 0;
17
+ max-width: 100%;
18
+ }
19
+
20
+ .search-tu3RA {
21
+ flex: 16rem;
22
+ }
23
+
24
+ .summary-CSd_P {
25
+ align-items: center;
26
+ gap: var(--space-2);
27
+ flex-wrap: wrap;
28
+ display: flex;
29
+ }
30
+
31
+ .count-dGqXH {
32
+ color: var(--color-text-muted);
33
+ font-size: var(--text-sm);
34
+ line-height: var(--leading-snug);
35
+ }
36
+
37
+ .chips-BHcAD {
38
+ gap: var(--space-2);
39
+ flex-wrap: wrap;
40
+ min-width: 0;
41
+ margin: 0;
42
+ padding: 0;
43
+ list-style: none;
44
+ display: flex;
45
+ }
46
+
47
+ .chip-wCX2N {
48
+ min-width: 0;
49
+ max-width: 100%;
50
+ }
51
+
52
+ .chipLabel-lhx4e {
53
+ min-width: 0;
54
+ padding-block: var(--space-1);
55
+ white-space: normal;
56
+ overflow-wrap: anywhere;
57
+ }
58
+
59
+ .remove-RNUMA {
60
+ width: 1.5rem;
61
+ height: 1.5rem;
62
+ border-radius: var(--radius-full);
63
+ color: var(--color-text-muted);
64
+ cursor: pointer;
65
+ transition-property: background-color, color;
66
+ transition-duration: var(--motion-duration-1);
67
+ transition-timing-function: var(--motion-ease);
68
+ -webkit-tap-highlight-color: transparent;
69
+ background: none;
70
+ border: 0;
71
+ flex: none;
72
+ justify-content: center;
73
+ align-items: center;
74
+ margin-inline-start: var(--space-1);
75
+ padding: 0;
76
+ display: inline-flex;
77
+ position: relative;
78
+ }
79
+
80
+ .remove-RNUMA:after {
81
+ --remove-reach: calc(var(--space-2) * -1);
82
+ content: "";
83
+ inset: var(--remove-reach);
84
+ position: absolute;
85
+ }
86
+
87
+ .remove-RNUMA > svg {
88
+ width: .875rem;
89
+ height: .875rem;
90
+ }
91
+
92
+ @media (hover: hover) {
93
+ .remove-RNUMA:hover {
94
+ background: var(--color-surface-3);
95
+ color: var(--color-text);
96
+ }
97
+ }
98
+
@@ -0,0 +1,48 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface FormProps<Values extends object = Record<string, unknown>> {
3
+ /**
4
+ * The values as a plain object keyed by field `name`, once nothing is invalid. A text control
5
+ * or a `Select` gives a string, `''` when empty; a `RadioGroup` a string or `null`; `Checkbox`
6
+ * and `Switch` a boolean; `DatePicker` a `YYYY-MM-DD` string or `null`; `TreeSelect` a node's `id`
7
+ * or `null`; and `Upload` an array of `File`s, empty when none is chosen and an array even without
8
+ * `multiple`. A disabled control is left out, as a browser leaves it out, and so is an input that
9
+ * is not one of the library's: a raw `<input name>` has no field frame to report through. The
10
+ * browser's own submit never happens, so `Form` takes no `action`.
11
+ */
12
+ onSubmit: (values: Values) => void;
13
+ /**
14
+ * Messages keyed by field `name`, typically from a server. Each shows on the matching control,
15
+ * marks it invalid and goes away when that control's value changes. While one is showing the
16
+ * form does not submit: submitting moves focus to the first such control instead, so a message
17
+ * the user cannot fix by editing that field belongs in an `Alert`. Pass a new object to set them
18
+ * again; an object with the same messages, as an inline literal makes on every render, does not
19
+ * bring back one that was cleared, until the form has been submitted since.
20
+ *
21
+ * So the parent must drop an entry once a submit succeeds: a stale one comes back on its next
22
+ * render, and then blocks the following submit.
23
+ *
24
+ * A disabled control shows no message and does not stop the submit, which is Base UI's rule.
25
+ */
26
+ errors?: Record<string, string>;
27
+ /**
28
+ * Leave this on. `false` hands validation to the browser's bubble, which cannot report on the
29
+ * hidden inputs `Select`, `Checkbox`, `RadioGroup` and `Switch` submit with: `required` on one
30
+ * of those then blocks the submit with nothing on screen. On, `required` and the other
31
+ * constraints still block, and the message shows on the control's own frame.
32
+ */
33
+ noValidate?: boolean;
34
+ children: ReactNode;
35
+ /** Lets a submit button outside the form point at it with `form`. */
36
+ id?: string;
37
+ 'aria-label'?: string;
38
+ 'aria-labelledby'?: string;
39
+ }
40
+ /**
41
+ * Collects values, shows validation messages and moves focus to the first invalid control. Every
42
+ * field frame in the library works inside it; no field needs telling.
43
+ *
44
+ * A `type="reset"` button does not reset every control here: messages stay, and a `Select` or a
45
+ * `Checkbox` keeps its state where a text input does not. To start over, remount the form with a
46
+ * new `key`, which is the supported way and clears all of it.
47
+ */
48
+ export declare function Form<Values extends object = Record<string, unknown>>({ onSubmit, errors, noValidate, children, id, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, }: FormProps<Values>): import("react").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Form } from "@base-ui/react/form";
3
+ import { useState } from "react";
4
+ import { FormValuesContext } from "./FormContext.js";
5
+ import Form_module from "./Form.module.js";
6
+ function holdsSameMessages(first, second) {
7
+ const firstEntries = Object.entries(first ?? {});
8
+ return firstEntries.length === Object.keys(second ?? {}).length && firstEntries.every(([name, message])=>second?.[name] === message);
9
+ }
10
+ function Form_Form({ onSubmit, errors, noValidate = true, children, id, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy }) {
11
+ const [overriddenValues] = useState(()=>new Map());
12
+ const [heldErrors, setHeldErrors] = useState(errors);
13
+ const [submittedSinceHeld, setSubmittedSinceHeld] = useState(false);
14
+ if (errors !== heldErrors && (submittedSinceHeld || !holdsSameMessages(errors, heldErrors))) {
15
+ setHeldErrors(errors);
16
+ setSubmittedSinceHeld(false);
17
+ }
18
+ return /*#__PURE__*/ jsx(FormValuesContext.Provider, {
19
+ value: overriddenValues,
20
+ children: /*#__PURE__*/ jsx(Form, {
21
+ className: Form_module.root,
22
+ id: id,
23
+ "aria-label": ariaLabel,
24
+ "aria-labelledby": ariaLabelledBy,
25
+ noValidate: noValidate,
26
+ errors: heldErrors,
27
+ onFormSubmit: (values)=>{
28
+ setSubmittedSinceHeld(true);
29
+ onSubmit({
30
+ ...values,
31
+ ...Object.fromEntries(overriddenValues)
32
+ });
33
+ },
34
+ children: children
35
+ })
36
+ });
37
+ }
38
+ export { Form_Form as Form };
@@ -0,0 +1,5 @@
1
+ import "./Form_module.css";
2
+ const Form_module = {
3
+ root: "root-ontz3"
4
+ };
5
+ export default Form_module;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * What a control hands `Form` when the value Base UI would read off its DOM element is not the one
3
+ * a caller wants: an `Upload`'s `File`s rather than a file input's fake path, a `DatePicker`'s
4
+ * `null` rather than an empty string. `null` here means no `Form` is around, which is also how
5
+ * `FieldMessages` knows to leave a plain `<form>`'s frames exactly as they were. Internal: not
6
+ * exported from `src/index.ts`, like `InsideToolbarContext`.
7
+ */
8
+ export declare const FormValuesContext: import("react").Context<Map<string, unknown> | null>;
9
+ /** Internal. True inside a `Form`, whose error entries only Base UI's own error part can read. */
10
+ export declare function useInsideForm(): boolean;
11
+ /**
12
+ * Internal. Submits `value` under `name` in place of what Base UI reads. Leave `name` undefined
13
+ * for a disabled control: it submits nothing, as a disabled input does.
14
+ */
15
+ export declare function useFormValue(name: string | undefined, value: unknown): void;
@@ -0,0 +1,20 @@
1
+ import { createContext, useContext, useEffect } from "react";
2
+ const FormValuesContext = createContext(null);
3
+ function useInsideForm() {
4
+ return null !== useContext(FormValuesContext);
5
+ }
6
+ function useFormValue(name, value) {
7
+ const values = useContext(FormValuesContext);
8
+ useEffect(()=>{
9
+ if (null === values || void 0 === name) return;
10
+ values.set(name, value);
11
+ return ()=>{
12
+ values.delete(name);
13
+ };
14
+ }, [
15
+ values,
16
+ name,
17
+ value
18
+ ]);
19
+ }
20
+ export { FormValuesContext, useFormValue, useInsideForm };
@@ -0,0 +1,6 @@
1
+ .root-ontz3 {
2
+ gap: var(--space-5);
3
+ flex-direction: column;
4
+ display: flex;
5
+ }
6
+
@@ -0,0 +1,27 @@
1
+ import type { ReactNode } from 'react';
2
+ interface PageShellBaseProps {
3
+ /** Becomes the `banner` landmark, as long as the shell is not inside a sectioning element. */
4
+ header?: ReactNode;
5
+ /** Becomes the `contentinfo` landmark, on the same condition as `header`. */
6
+ footer?: ReactNode;
7
+ /** The page's content: the `main` landmark. */
8
+ children: ReactNode;
9
+ /** The id of `main`, which the skip link targets. */
10
+ mainId?: string;
11
+ /** The skip link's text; `SkipLink`'s own default applies otherwise. */
12
+ skipLinkLabel?: ReactNode;
13
+ }
14
+ interface PageShellWithSidebar extends PageShellBaseProps {
15
+ /** Becomes a `complementary` landmark, stacked above the content at narrow widths. */
16
+ sidebar: ReactNode;
17
+ /** The sidebar's landmark name. Required with it: a page may have several, and each needs one. */
18
+ sidebarLabel: string;
19
+ }
20
+ interface PageShellWithoutSidebar extends PageShellBaseProps {
21
+ sidebar?: undefined;
22
+ sidebarLabel?: undefined;
23
+ }
24
+ export type PageShellProps = PageShellWithSidebar | PageShellWithoutSidebar;
25
+ /** The page's landmarks, in reading order, with a skip link in front of them. */
26
+ export declare function PageShell({ header, sidebar, sidebarLabel, footer, children, mainId, skipLinkLabel, }: PageShellProps): import("react").JSX.Element;
27
+ export {};
@@ -0,0 +1,35 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { SkipLink } from "../SkipLink/SkipLink.js";
3
+ import PageShell_module from "./PageShell.module.js";
4
+ function PageShell({ header, sidebar, sidebarLabel, footer, children, mainId = 'main', skipLinkLabel }) {
5
+ return /*#__PURE__*/ jsxs("div", {
6
+ className: PageShell_module.root,
7
+ "data-has-sidebar": sidebar ? '' : void 0,
8
+ children: [
9
+ /*#__PURE__*/ jsx(SkipLink, {
10
+ targetId: mainId,
11
+ children: skipLinkLabel
12
+ }),
13
+ header ? /*#__PURE__*/ jsx("header", {
14
+ className: PageShell_module.header,
15
+ children: header
16
+ }) : null,
17
+ sidebar ? /*#__PURE__*/ jsx("aside", {
18
+ className: PageShell_module.sidebar,
19
+ "aria-label": sidebarLabel,
20
+ children: sidebar
21
+ }) : null,
22
+ /*#__PURE__*/ jsx("main", {
23
+ id: mainId,
24
+ className: PageShell_module.main,
25
+ tabIndex: -1,
26
+ children: children
27
+ }),
28
+ footer ? /*#__PURE__*/ jsx("footer", {
29
+ className: PageShell_module.footer,
30
+ children: footer
31
+ }) : null
32
+ ]
33
+ });
34
+ }
35
+ export { PageShell };
@@ -0,0 +1,9 @@
1
+ import "./PageShell_module.css";
2
+ const PageShell_module = {
3
+ root: "root-GtYdg",
4
+ header: "header-YzERL",
5
+ sidebar: "sidebar-acwxu",
6
+ main: "main-A7fFb",
7
+ footer: "footer-O0lU7"
8
+ };
9
+ export default PageShell_module;
@@ -0,0 +1,56 @@
1
+ .root-GtYdg {
2
+ grid-template: "header"
3
+ "sidebar"
4
+ "main" 1fr
5
+ "footer"
6
+ / minmax(0, 1fr);
7
+ min-height: 100dvh;
8
+ display: grid;
9
+ position: relative;
10
+ }
11
+
12
+ .header-YzERL {
13
+ padding: var(--space-3) var(--space-4);
14
+ border-bottom: 1px solid var(--color-border);
15
+ grid-area: header;
16
+ }
17
+
18
+ .sidebar-acwxu {
19
+ padding: var(--space-4);
20
+ border-bottom: 1px solid var(--color-border);
21
+ grid-area: sidebar;
22
+ }
23
+
24
+ .main-A7fFb {
25
+ padding: var(--space-5) var(--space-4);
26
+ grid-area: main;
27
+ }
28
+
29
+ .main-A7fFb:focus-visible {
30
+ outline-offset: calc(var(--focus-ring-width) * -1);
31
+ }
32
+
33
+ .footer-O0lU7 {
34
+ padding: var(--space-3) var(--space-4);
35
+ border-top: 1px solid var(--color-border);
36
+ grid-area: footer;
37
+ }
38
+
39
+ @media (width >= 48rem) {
40
+ .root-GtYdg[data-has-sidebar] {
41
+ grid-template: "header header"
42
+ "sidebar main" 1fr
43
+ "footer footer"
44
+ / 16rem minmax(0, 1fr);
45
+ }
46
+
47
+ .sidebar-acwxu {
48
+ border-inline-end: 1px solid var(--color-border);
49
+ border-bottom: 0;
50
+ }
51
+
52
+ .main-A7fFb {
53
+ padding-inline: var(--space-5);
54
+ }
55
+ }
56
+
@@ -0,0 +1,49 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface SegmentedOption {
3
+ /** What `value` and `onValueChange` speak in. The empty string is a value like any other. */
4
+ value: string;
5
+ /** The visible text, and the option's accessible name. */
6
+ label: string;
7
+ /** Sits before the label. Decorative: it stays out of the accessible name. */
8
+ icon?: ReactNode;
9
+ disabled?: boolean;
10
+ }
11
+ interface SegmentedBaseProps {
12
+ options: SegmentedOption[];
13
+ /**
14
+ * Controlled. Pair it with `onValueChange`; use `defaultValue` for an uncontrolled one. A value
15
+ * no option holds shows the first enabled option as chosen, and reports nothing.
16
+ */
17
+ value?: string;
18
+ /** Leave this and `value` out, or name no option, and the first enabled option is chosen. */
19
+ defaultValue?: string;
20
+ /**
21
+ * The newly chosen option's value. One argument, as on every other control in the library, and
22
+ * it fires only for a change: pressing the option already chosen reports nothing.
23
+ */
24
+ onValueChange?: (value: string) => void;
25
+ size?: 'sm' | 'md';
26
+ }
27
+ interface SegmentedNamedByLabel extends SegmentedBaseProps {
28
+ /** Names the group. One of this and `aria-labelledby` is required. */
29
+ 'aria-label': string;
30
+ 'aria-labelledby'?: undefined;
31
+ }
32
+ interface SegmentedNamedByElement extends SegmentedBaseProps {
33
+ 'aria-label'?: undefined;
34
+ /** The id of the element that names the group. */
35
+ 'aria-labelledby': string;
36
+ }
37
+ export type SegmentedProps = SegmentedNamedByLabel | SegmentedNamedByElement;
38
+ /**
39
+ * Choose exactly one of a few options. Each is a toggle button, and the group is one tab stop
40
+ * whose arrow keys, Home and End move focus without changing the choice.
41
+ *
42
+ * Tab lands on the chosen option. Base UI's `ToggleGroup` has no prop for that and roves from the
43
+ * first enabled option, so while focus is outside the group each `Toggle` is told its `tabIndex`.
44
+ * Inside it Base UI roves as usual: an override there would leave the chosen option as a second
45
+ * stop on the way out. A disabled chosen option cannot take focus, so Base UI decides then too,
46
+ * and inside a `Toolbar` the toolbar owns the stop.
47
+ */
48
+ export declare function Segmented({ options, value, defaultValue, onValueChange, size, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, }: SegmentedProps): import("react").JSX.Element;
49
+ export {};