@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.
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +24 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +48 -0
- package/dist/components/Breadcrumb/Breadcrumb.module.js +10 -0
- package/dist/components/Breadcrumb/Breadcrumb_module.css +49 -0
- package/dist/components/CardList/CardList.d.ts +30 -0
- package/dist/components/CardList/CardList.js +35 -0
- package/dist/components/CardList/CardList.module.js +7 -0
- package/dist/components/CardList/CardList_module.css +20 -0
- package/dist/components/DatePicker/Calendar.d.ts +19 -0
- package/dist/components/DatePicker/Calendar.js +207 -0
- package/dist/components/DatePicker/DatePicker.d.ts +72 -0
- package/dist/components/DatePicker/DatePicker.js +116 -0
- package/dist/components/DatePicker/DatePicker.module.js +14 -0
- package/dist/components/DatePicker/DatePicker_module.css +112 -0
- package/dist/components/DatePicker/calendarDate.d.ts +46 -0
- package/dist/components/DatePicker/calendarDate.js +117 -0
- package/dist/components/Descriptions/Descriptions.d.ts +25 -0
- package/dist/components/Descriptions/Descriptions.js +44 -0
- package/dist/components/Descriptions/Descriptions.module.js +8 -0
- package/dist/components/Descriptions/Descriptions_module.css +47 -0
- package/dist/components/Field/Field.d.ts +1 -1
- package/dist/components/Field/Field.js +7 -1
- package/dist/components/Field/PickerField.d.ts +41 -0
- package/dist/components/Field/PickerField.js +115 -0
- package/dist/components/Field/PickerField.module.js +8 -0
- package/dist/components/Field/PickerField_module.css +36 -0
- package/dist/components/FilterBar/FilterBar.d.ts +55 -0
- package/dist/components/FilterBar/FilterBar.js +138 -0
- package/dist/components/FilterBar/FilterBar.module.js +13 -0
- package/dist/components/FilterBar/FilterBar_module.css +98 -0
- package/dist/components/Form/Form.d.ts +48 -0
- package/dist/components/Form/Form.js +38 -0
- package/dist/components/Form/Form.module.js +5 -0
- package/dist/components/Form/FormContext.d.ts +15 -0
- package/dist/components/Form/FormContext.js +20 -0
- package/dist/components/Form/Form_module.css +6 -0
- package/dist/components/PageShell/PageShell.d.ts +27 -0
- package/dist/components/PageShell/PageShell.js +35 -0
- package/dist/components/PageShell/PageShell.module.js +9 -0
- package/dist/components/PageShell/PageShell_module.css +56 -0
- package/dist/components/Segmented/Segmented.d.ts +49 -0
- package/dist/components/Segmented/Segmented.js +55 -0
- package/dist/components/Segmented/Segmented.module.js +7 -0
- package/dist/components/Segmented/Segmented_module.css +75 -0
- package/dist/components/Steps/Steps.d.ts +30 -0
- package/dist/components/Steps/Steps.js +63 -0
- package/dist/components/Steps/Steps.module.js +10 -0
- package/dist/components/Steps/Steps_module.css +126 -0
- package/dist/components/TextArea/TextArea.d.ts +16 -0
- package/dist/components/TextArea/TextArea.js +28 -0
- package/dist/components/TextArea/TextArea.module.js +5 -0
- package/dist/components/TextArea/TextArea_module.css +12 -0
- package/dist/components/TimePicker/TimePicker.d.ts +19 -0
- package/dist/components/TimePicker/TimePicker.js +17 -0
- package/dist/components/Timeline/Timeline.d.ts +39 -0
- package/dist/components/Timeline/Timeline.js +109 -0
- package/dist/components/Timeline/Timeline.module.js +12 -0
- package/dist/components/Timeline/Timeline_module.css +99 -0
- package/dist/components/Toolbar/InsideToolbarContext.d.ts +6 -0
- package/dist/components/Toolbar/InsideToolbarContext.js +3 -0
- package/dist/components/Toolbar/Toolbar.d.ts +46 -0
- package/dist/components/Toolbar/Toolbar.js +43 -0
- package/dist/components/Toolbar/Toolbar.module.js +7 -0
- package/dist/components/Toolbar/Toolbar_module.css +26 -0
- package/dist/components/Tree/Tree.d.ts +81 -0
- package/dist/components/Tree/Tree.js +232 -0
- package/dist/components/Tree/Tree.module.js +12 -0
- package/dist/components/Tree/Tree_module.css +124 -0
- package/dist/components/Tree/treeIndex.d.ts +23 -0
- package/dist/components/Tree/treeIndex.js +33 -0
- package/dist/components/TreeSelect/TreeSelect.d.ts +61 -0
- package/dist/components/TreeSelect/TreeSelect.js +117 -0
- package/dist/components/TreeSelect/TreeSelect.module.js +7 -0
- package/dist/components/TreeSelect/TreeSelect_module.css +22 -0
- package/dist/components/Upload/Upload.d.ts +66 -0
- package/dist/components/Upload/Upload.js +287 -0
- package/dist/components/Upload/Upload.module.js +12 -0
- package/dist/components/Upload/Upload_module.css +96 -0
- package/dist/components/ViewField/ViewField.d.ts +26 -0
- package/dist/components/ViewField/ViewField.js +29 -0
- package/dist/components/ViewField/ViewField.module.js +6 -0
- package/dist/components/ViewField/ViewField_module.css +17 -0
- package/dist/hooks/useFormReset.d.ts +10 -0
- package/dist/hooks/useFormReset.js +34 -0
- package/dist/icons/CalendarIcon.d.ts +2 -0
- package/dist/icons/CalendarIcon.js +26 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +17 -0
- package/dist/styles/pair.module.js +6 -0
- package/dist/styles/pair_module.css +18 -0
- package/package.json +2 -2
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Toggle } from "@base-ui/react/toggle";
|
|
3
|
+
import { ToggleGroup } from "@base-ui/react/toggle-group";
|
|
4
|
+
import { useContext, useState } from "react";
|
|
5
|
+
import { InsideToolbarContext } from "../Toolbar/InsideToolbarContext.js";
|
|
6
|
+
import Segmented_module from "./Segmented.module.js";
|
|
7
|
+
function chosenIndexOf(options, value) {
|
|
8
|
+
const namedIndex = options.findIndex((option)=>option.value === value);
|
|
9
|
+
return -1 === namedIndex ? options.findIndex((option)=>!option.disabled) : namedIndex;
|
|
10
|
+
}
|
|
11
|
+
function Segmented({ options, value, defaultValue, onValueChange, size = 'md', 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy }) {
|
|
12
|
+
const insideToolbar = useContext(InsideToolbarContext);
|
|
13
|
+
const [heldValue, setHeldValue] = useState(defaultValue);
|
|
14
|
+
const [focusedValue, setFocusedValue] = useState(null);
|
|
15
|
+
const chosenIndex = chosenIndexOf(options, value ?? heldValue);
|
|
16
|
+
const focusIsInside = options.some((option)=>option.value === focusedValue && !option.disabled);
|
|
17
|
+
const chosenOption = options[chosenIndex];
|
|
18
|
+
const placesTabStop = !insideToolbar && !focusIsInside && chosenOption && !chosenOption.disabled;
|
|
19
|
+
return /*#__PURE__*/ jsx(ToggleGroup, {
|
|
20
|
+
className: Segmented_module.root,
|
|
21
|
+
"data-size": size,
|
|
22
|
+
"aria-label": ariaLabel,
|
|
23
|
+
"aria-labelledby": ariaLabelledBy,
|
|
24
|
+
value: -1 === chosenIndex ? [] : [
|
|
25
|
+
String(chosenIndex)
|
|
26
|
+
],
|
|
27
|
+
onBlur: (event)=>{
|
|
28
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setFocusedValue(null);
|
|
29
|
+
},
|
|
30
|
+
onValueChange: (nextIndexes)=>{
|
|
31
|
+
const nextOption = options[Number(nextIndexes[0] ?? -1)];
|
|
32
|
+
if (!nextOption) return;
|
|
33
|
+
setHeldValue(nextOption.value);
|
|
34
|
+
onValueChange?.(nextOption.value);
|
|
35
|
+
},
|
|
36
|
+
children: options.map((option, index)=>/*#__PURE__*/ jsxs(Toggle, {
|
|
37
|
+
className: Segmented_module.option,
|
|
38
|
+
value: String(index),
|
|
39
|
+
disabled: option.disabled,
|
|
40
|
+
onFocus: ()=>setFocusedValue(option.value),
|
|
41
|
+
...placesTabStop ? {
|
|
42
|
+
tabIndex: index === chosenIndex ? 0 : -1
|
|
43
|
+
} : null,
|
|
44
|
+
children: [
|
|
45
|
+
option.icon ? /*#__PURE__*/ jsx("span", {
|
|
46
|
+
className: Segmented_module.icon,
|
|
47
|
+
"aria-hidden": "true",
|
|
48
|
+
children: option.icon
|
|
49
|
+
}) : null,
|
|
50
|
+
option.label
|
|
51
|
+
]
|
|
52
|
+
}, option.value))
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export { Segmented };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
.root-FcEzI {
|
|
2
|
+
gap: var(--space-1);
|
|
3
|
+
max-width: 100%;
|
|
4
|
+
padding: var(--space-1);
|
|
5
|
+
border: 1px solid var(--color-border-strong);
|
|
6
|
+
border-radius: var(--radius-md);
|
|
7
|
+
background: var(--color-surface-2);
|
|
8
|
+
flex-wrap: wrap;
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.option-l_IQ8 {
|
|
13
|
+
justify-content: center;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: var(--space-2);
|
|
16
|
+
min-height: var(--size-touch);
|
|
17
|
+
min-width: var(--size-touch);
|
|
18
|
+
padding: var(--space-1) var(--space-3);
|
|
19
|
+
border-radius: var(--radius-sm);
|
|
20
|
+
color: var(--color-text-muted);
|
|
21
|
+
font-size: var(--text-md);
|
|
22
|
+
font-weight: 500;
|
|
23
|
+
line-height: var(--leading-snug);
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
transition-property: background-color, color;
|
|
26
|
+
transition-duration: var(--motion-duration-1);
|
|
27
|
+
transition-timing-function: var(--motion-ease);
|
|
28
|
+
-webkit-tap-highlight-color: transparent;
|
|
29
|
+
background: none;
|
|
30
|
+
border: 0;
|
|
31
|
+
flex: auto;
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.root-FcEzI[data-size="sm"] .option-l_IQ8 {
|
|
36
|
+
min-width: 2.5rem;
|
|
37
|
+
min-height: 2.5rem;
|
|
38
|
+
font-size: var(--text-sm);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@media (hover: hover) {
|
|
42
|
+
.option-l_IQ8:hover:not([data-disabled], [data-pressed]) {
|
|
43
|
+
background: var(--color-surface-3);
|
|
44
|
+
color: var(--color-text);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.option-l_IQ8[data-pressed] {
|
|
49
|
+
background: var(--color-accent);
|
|
50
|
+
color: var(--color-accent-text);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@media (forced-colors: active) {
|
|
54
|
+
.option-l_IQ8[data-pressed] {
|
|
55
|
+
forced-color-adjust: none;
|
|
56
|
+
color: highlighttext;
|
|
57
|
+
background: highlight;
|
|
58
|
+
outline-color: canvastext;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.option-l_IQ8[data-disabled] {
|
|
63
|
+
cursor: not-allowed;
|
|
64
|
+
opacity: .45;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.icon-kkAqg {
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.icon-kkAqg > svg {
|
|
72
|
+
width: 1rem;
|
|
73
|
+
height: 1rem;
|
|
74
|
+
}
|
|
75
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface StepsItem {
|
|
3
|
+
/** Identifies the step across renders. */
|
|
4
|
+
id: string;
|
|
5
|
+
title: ReactNode;
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export type StepStatus = 'complete' | 'active' | 'error' | 'upcoming';
|
|
9
|
+
export interface StepsProps {
|
|
10
|
+
items: StepsItem[];
|
|
11
|
+
/**
|
|
12
|
+
* The current step, zero-based. Below zero nothing has started; at `items.length` or above
|
|
13
|
+
* everything is complete. Neither case has a current step, so nothing is marked as one.
|
|
14
|
+
*/
|
|
15
|
+
current: number;
|
|
16
|
+
/** How the current step is going. */
|
|
17
|
+
currentStatus?: 'active' | 'error';
|
|
18
|
+
/** `horizontal` applies from the `sm` breakpoint up; below it the steps always stack. */
|
|
19
|
+
orientation?: 'horizontal' | 'vertical';
|
|
20
|
+
/** Names the list. */
|
|
21
|
+
'aria-label'?: string;
|
|
22
|
+
/** The words each status is stated in, for an app that is not in English. */
|
|
23
|
+
statusLabels?: Partial<Record<StepStatus, string>>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Progress through a sequence. A display only: nothing here can be focused or activated. Each
|
|
27
|
+
* step's status is stated in visually hidden text, so colour and the drawn marker, which is
|
|
28
|
+
* hidden from assistive technology, are never the only signal.
|
|
29
|
+
*/
|
|
30
|
+
export declare function Steps({ items, current, currentStatus, orientation, 'aria-label': ariaLabel, statusLabels, }: StepsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CheckIcon } from "../../icons/CheckIcon.js";
|
|
3
|
+
import a11y_module from "../../styles/a11y.module.js";
|
|
4
|
+
import Steps_module from "./Steps.module.js";
|
|
5
|
+
const DEFAULT_STATUS_LABELS = {
|
|
6
|
+
complete: 'Completed',
|
|
7
|
+
active: 'Current',
|
|
8
|
+
error: 'Error',
|
|
9
|
+
upcoming: 'Not started'
|
|
10
|
+
};
|
|
11
|
+
function statusOf(index, current, currentStatus) {
|
|
12
|
+
if (index < current) return 'complete';
|
|
13
|
+
return index === current ? currentStatus : 'upcoming';
|
|
14
|
+
}
|
|
15
|
+
function markerOf(status, index) {
|
|
16
|
+
if ('complete' === status) return /*#__PURE__*/ jsx(CheckIcon, {});
|
|
17
|
+
return 'error' === status ? '!' : index + 1;
|
|
18
|
+
}
|
|
19
|
+
function Steps({ items, current, currentStatus = 'active', orientation = 'horizontal', 'aria-label': ariaLabel, statusLabels }) {
|
|
20
|
+
const labels = {
|
|
21
|
+
...DEFAULT_STATUS_LABELS,
|
|
22
|
+
...statusLabels
|
|
23
|
+
};
|
|
24
|
+
return /*#__PURE__*/ jsx("ol", {
|
|
25
|
+
role: "list",
|
|
26
|
+
className: Steps_module.list,
|
|
27
|
+
"data-orientation": orientation,
|
|
28
|
+
"aria-label": ariaLabel,
|
|
29
|
+
children: items.map((item, index)=>{
|
|
30
|
+
const status = statusOf(index, current, currentStatus);
|
|
31
|
+
return /*#__PURE__*/ jsxs("li", {
|
|
32
|
+
className: Steps_module.item,
|
|
33
|
+
"data-status": status,
|
|
34
|
+
"aria-current": index === current ? 'step' : void 0,
|
|
35
|
+
children: [
|
|
36
|
+
/*#__PURE__*/ jsx("span", {
|
|
37
|
+
className: Steps_module.marker,
|
|
38
|
+
"aria-hidden": "true",
|
|
39
|
+
children: markerOf(status, index)
|
|
40
|
+
}),
|
|
41
|
+
/*#__PURE__*/ jsxs("span", {
|
|
42
|
+
className: Steps_module.body,
|
|
43
|
+
children: [
|
|
44
|
+
/*#__PURE__*/ jsx("span", {
|
|
45
|
+
className: Steps_module.title,
|
|
46
|
+
children: item.title
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ jsx("span", {
|
|
49
|
+
className: a11y_module.visuallyHidden,
|
|
50
|
+
children: labels[status]
|
|
51
|
+
}),
|
|
52
|
+
item.description ? /*#__PURE__*/ jsx("span", {
|
|
53
|
+
className: Steps_module.description,
|
|
54
|
+
children: item.description
|
|
55
|
+
}) : null
|
|
56
|
+
]
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
}, item.id);
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
export { Steps };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
.list-hpIu5 {
|
|
2
|
+
flex-direction: column;
|
|
3
|
+
margin: 0;
|
|
4
|
+
padding: 0;
|
|
5
|
+
list-style: none;
|
|
6
|
+
display: flex;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.item-PEG_P {
|
|
10
|
+
--step-marker-size: 1.75rem;
|
|
11
|
+
gap: var(--space-3);
|
|
12
|
+
min-width: 0;
|
|
13
|
+
padding-block-end: var(--space-4);
|
|
14
|
+
display: flex;
|
|
15
|
+
position: relative;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.item-PEG_P:last-child {
|
|
19
|
+
padding-block-end: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.item-PEG_P:not(:last-child):before {
|
|
23
|
+
content: "";
|
|
24
|
+
inset-block: var(--step-marker-size) 0;
|
|
25
|
+
background: var(--color-border-strong);
|
|
26
|
+
width: 1px;
|
|
27
|
+
position: absolute;
|
|
28
|
+
inset-inline-start: calc(var(--step-marker-size) / 2);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.item-PEG_P[data-status="complete"]:before {
|
|
32
|
+
background: var(--color-accent);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.marker-ETCZc {
|
|
36
|
+
width: var(--step-marker-size);
|
|
37
|
+
height: var(--step-marker-size);
|
|
38
|
+
border: 1px solid var(--color-border-strong);
|
|
39
|
+
border-radius: var(--radius-full);
|
|
40
|
+
color: var(--color-text-muted);
|
|
41
|
+
font-size: var(--text-sm);
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
line-height: var(--leading-snug);
|
|
44
|
+
flex: none;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
align-items: center;
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.marker-ETCZc > svg {
|
|
51
|
+
width: 1rem;
|
|
52
|
+
height: 1rem;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.item-PEG_P[data-status="complete"] .marker-ETCZc {
|
|
56
|
+
border-color: var(--color-accent);
|
|
57
|
+
background: var(--color-accent);
|
|
58
|
+
color: var(--color-accent-text);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.item-PEG_P[data-status="active"] .marker-ETCZc {
|
|
62
|
+
border-color: var(--color-accent);
|
|
63
|
+
background: var(--color-accent-soft);
|
|
64
|
+
color: var(--color-text);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.item-PEG_P[data-status="error"] .marker-ETCZc {
|
|
68
|
+
border-color: var(--color-danger);
|
|
69
|
+
background: var(--color-danger-surface);
|
|
70
|
+
color: var(--color-text);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.body-KsZkq {
|
|
74
|
+
gap: var(--space-1);
|
|
75
|
+
min-width: 0;
|
|
76
|
+
overflow-wrap: anywhere;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
padding-block-start: var(--space-1);
|
|
79
|
+
display: flex;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.title-TEL7i {
|
|
83
|
+
color: var(--color-text);
|
|
84
|
+
font-size: var(--text-sm);
|
|
85
|
+
font-weight: 500;
|
|
86
|
+
line-height: var(--leading-snug);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.item-PEG_P[data-status="upcoming"] .title-TEL7i {
|
|
90
|
+
color: var(--color-text-muted);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.item-PEG_P[aria-current] .title-TEL7i {
|
|
94
|
+
font-weight: 600;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.description-Iud3V {
|
|
98
|
+
color: var(--color-text-muted);
|
|
99
|
+
font-size: var(--text-sm);
|
|
100
|
+
line-height: var(--leading-snug);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@media (width >= 40rem) {
|
|
104
|
+
.list-hpIu5[data-orientation="horizontal"] {
|
|
105
|
+
flex-direction: row;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.list-hpIu5[data-orientation="horizontal"] .item-PEG_P {
|
|
109
|
+
flex-direction: column;
|
|
110
|
+
flex: 1 1 0;
|
|
111
|
+
padding-block-end: 0;
|
|
112
|
+
padding-inline-end: var(--space-3);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.list-hpIu5[data-orientation="horizontal"] .item-PEG_P:last-child {
|
|
116
|
+
padding-inline-end: 0;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.list-hpIu5[data-orientation="horizontal"] .item-PEG_P:not(:last-child):before {
|
|
120
|
+
inset-block: calc(var(--step-marker-size) / 2) auto;
|
|
121
|
+
inset-inline: var(--step-marker-size) 0;
|
|
122
|
+
width: auto;
|
|
123
|
+
height: 1px;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export interface TextAreaProps extends Omit<ComponentPropsWithoutRef<'textarea'>, 'className' | 'style' | 'value' | 'defaultValue' | 'onChange' | 'required' | 'name' | 'disabled' | 'children'> {
|
|
3
|
+
value?: string;
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
/** Base UI reports the new value directly; there is no event to read `.target.value` off. */
|
|
6
|
+
onValueChange?: (value: string) => void;
|
|
7
|
+
/** The visible height in lines; with `autoResize`, the height it starts from and never shrinks under. */
|
|
8
|
+
rows?: number;
|
|
9
|
+
/**
|
|
10
|
+
* Grows with the content through CSS `field-sizing: content`. A browser without it keeps a
|
|
11
|
+
* normal textarea that the user can drag taller, so nothing is lost and no script measures.
|
|
12
|
+
*/
|
|
13
|
+
autoResize?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Goes inside `Field`, which supplies `name`, `disabled`, `required`, the label and the messages. */
|
|
16
|
+
export declare function TextArea({ value, defaultValue, onValueChange, rows, autoResize, ...rest }: TextAreaProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Input } from "@base-ui/react/input";
|
|
3
|
+
import field_module from "../../styles/field.module.js";
|
|
4
|
+
import { useFieldRequired } from "../Field/Field.js";
|
|
5
|
+
import TextArea_module from "./TextArea.module.js";
|
|
6
|
+
function TextArea({ value, defaultValue, onValueChange, rows = 4, autoResize = false, ...rest }) {
|
|
7
|
+
const required = useFieldRequired();
|
|
8
|
+
const rowsStyle = autoResize ? {
|
|
9
|
+
'--text-area-rows': rows
|
|
10
|
+
} : void 0;
|
|
11
|
+
return /*#__PURE__*/ jsx(Input, {
|
|
12
|
+
className: [
|
|
13
|
+
field_module.control,
|
|
14
|
+
TextArea_module.root
|
|
15
|
+
].join(' '),
|
|
16
|
+
value: value,
|
|
17
|
+
defaultValue: defaultValue,
|
|
18
|
+
onValueChange: (nextValue)=>onValueChange?.(nextValue),
|
|
19
|
+
required: required,
|
|
20
|
+
render: /*#__PURE__*/ jsx("textarea", {
|
|
21
|
+
...rest,
|
|
22
|
+
rows: rows,
|
|
23
|
+
style: rowsStyle,
|
|
24
|
+
"data-auto-resize": autoResize ? '' : void 0
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export { TextArea };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export interface TimePickerProps extends Omit<ComponentPropsWithoutRef<'input'>, 'className' | 'style' | 'type' | 'value' | 'defaultValue' | 'onChange' | 'required' | 'name' | 'disabled' | 'min' | 'max' | 'step' | 'children'> {
|
|
3
|
+
/** `HH:mm`, or `''` for no time. A string the browser cannot read as a time shows as empty. */
|
|
4
|
+
value?: string;
|
|
5
|
+
defaultValue?: string;
|
|
6
|
+
/** `HH:mm`, or `''` once cleared. A `step` under 60 adds seconds: `HH:mm:ss`. */
|
|
7
|
+
onValueChange?: (value: string) => void;
|
|
8
|
+
/** The earliest time, `HH:mm`. A later one is `rangeUnderflow` to the browser and to `Form`. */
|
|
9
|
+
min?: string;
|
|
10
|
+
/** The latest time, `HH:mm`. */
|
|
11
|
+
max?: string;
|
|
12
|
+
/** The granularity in seconds, as the native attribute has it: 900 is every quarter hour. */
|
|
13
|
+
step?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Goes inside `Field`. The native control is the choice here: it handles locale, 12 or 24-hour
|
|
17
|
+
* entry, the keyboard and mobile wheels, and none of that is worth rebuilding.
|
|
18
|
+
*/
|
|
19
|
+
export declare function TimePicker({ value, defaultValue, onValueChange, ...rest }: TimePickerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Input } from "@base-ui/react/input";
|
|
3
|
+
import field_module from "../../styles/field.module.js";
|
|
4
|
+
import { useFieldRequired } from "../Field/Field.js";
|
|
5
|
+
function TimePicker({ value, defaultValue, onValueChange, ...rest }) {
|
|
6
|
+
const required = useFieldRequired();
|
|
7
|
+
return /*#__PURE__*/ jsx(Input, {
|
|
8
|
+
...rest,
|
|
9
|
+
className: field_module.control,
|
|
10
|
+
type: "time",
|
|
11
|
+
value: value,
|
|
12
|
+
defaultValue: defaultValue,
|
|
13
|
+
onValueChange: (nextValue)=>onValueChange?.(nextValue),
|
|
14
|
+
required: required
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export { TimePicker };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export type TimelineTone = 'neutral' | 'accent' | 'success' | 'danger';
|
|
3
|
+
export interface TimelineItem {
|
|
4
|
+
/** Identifies the entry across renders. */
|
|
5
|
+
id: string;
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* ISO 8601: `YYYY`, `YYYY-MM`, `YYYY-MM-DD`, or a date and time such as `2026-03-08T09:30:00Z`.
|
|
9
|
+
* Without a time it is a place on the calendar and shifts in no time zone; a time is shown in the
|
|
10
|
+
* viewer's zone. The source string stays in `<time datetime>`, with any offset written in full as
|
|
11
|
+
* `+05:00`, which HTML and `Date` can both read. Anything else is shown as written, without a
|
|
12
|
+
* `<time>`.
|
|
13
|
+
*/
|
|
14
|
+
timestamp?: string;
|
|
15
|
+
description?: ReactNode;
|
|
16
|
+
/** Stated in text as well as colour. Left out, the entry looks neutral and says nothing of it. */
|
|
17
|
+
tone?: TimelineTone;
|
|
18
|
+
}
|
|
19
|
+
export interface TimelineProps {
|
|
20
|
+
/** Drawn in the order given, which is the app's to decide. */
|
|
21
|
+
items: TimelineItem[];
|
|
22
|
+
/**
|
|
23
|
+
* A BCP 47 tag for the dates, always on the Gregorian calendar. Left out, the browser's own; a tag
|
|
24
|
+
* it cannot read counts as left out. That default can differ between a server's render and the
|
|
25
|
+
* browser's, which passing `locale` avoids. A time also differs by the viewer's time zone, which
|
|
26
|
+
* `locale` does not cover: leave timestamps with a time out of a server's render.
|
|
27
|
+
*/
|
|
28
|
+
locale?: string;
|
|
29
|
+
/** Names the list. */
|
|
30
|
+
'aria-label'?: string;
|
|
31
|
+
/** The words each tone is stated in, for an app that is not in English. */
|
|
32
|
+
toneLabels?: Partial<Record<TimelineTone, string>>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A chronological record. A display only: nothing here can be focused or activated. A tone is said
|
|
36
|
+
* in visible words beside the time, because forced colours flatten every tint here to the same
|
|
37
|
+
* thing, and the words are what still tells a failure from a success.
|
|
38
|
+
*/
|
|
39
|
+
export declare function Timeline({ items, locale, 'aria-label': ariaLabel, toneLabels }: TimelineProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { dateFormatter, parseIsoDate, usableLocale } from "../DatePicker/calendarDate.js";
|
|
3
|
+
import Timeline_module from "./Timeline.module.js";
|
|
4
|
+
const DEFAULT_TONE_LABELS = {
|
|
5
|
+
neutral: 'Note',
|
|
6
|
+
accent: 'Highlight',
|
|
7
|
+
success: 'Success',
|
|
8
|
+
danger: 'Problem'
|
|
9
|
+
};
|
|
10
|
+
const DATE_AND_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}(:?\d{2})?)?$/;
|
|
11
|
+
const OFFSET = /([+-]\d{2}):?(\d{2})?$/;
|
|
12
|
+
const YEAR_OR_MONTH = /^(?!0000)\d{4}(-\d{2})?$/;
|
|
13
|
+
function formatTimestamp(source, locale) {
|
|
14
|
+
if (null !== parseIsoDate(source)) return {
|
|
15
|
+
text: dateFormatter(locale, {
|
|
16
|
+
dateStyle: 'medium'
|
|
17
|
+
}).format(source),
|
|
18
|
+
dateTime: source
|
|
19
|
+
};
|
|
20
|
+
if (YEAR_OR_MONTH.test(source)) {
|
|
21
|
+
const hasMonth = source.length > 4;
|
|
22
|
+
const firstDay = hasMonth ? `${source}-01` : `${source}-01-01`;
|
|
23
|
+
if (null === parseIsoDate(firstDay)) return null;
|
|
24
|
+
const fields = hasMonth ? {
|
|
25
|
+
year: 'numeric',
|
|
26
|
+
month: 'short'
|
|
27
|
+
} : {
|
|
28
|
+
year: 'numeric'
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
text: dateFormatter(locale, fields).format(firstDay),
|
|
32
|
+
dateTime: source
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (!DATE_AND_TIME.test(source) || null === parseIsoDate(source.slice(0, 10))) return null;
|
|
36
|
+
const dateTime = source.replace(OFFSET, (_whole, hours, minutes)=>`${hours}:${minutes ?? '00'}`);
|
|
37
|
+
const instant = new Date(dateTime);
|
|
38
|
+
return Number.isNaN(instant.getTime()) ? null : {
|
|
39
|
+
text: new Intl.DateTimeFormat(locale, {
|
|
40
|
+
dateStyle: 'medium',
|
|
41
|
+
timeStyle: 'short',
|
|
42
|
+
calendar: 'gregory'
|
|
43
|
+
}).format(instant),
|
|
44
|
+
dateTime
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function Timestamp({ source, locale }) {
|
|
48
|
+
const formatted = formatTimestamp(source, locale);
|
|
49
|
+
return null === formatted ? /*#__PURE__*/ jsx("span", {
|
|
50
|
+
children: source
|
|
51
|
+
}) : /*#__PURE__*/ jsx("time", {
|
|
52
|
+
dateTime: formatted.dateTime,
|
|
53
|
+
children: formatted.text
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function hasDescription(description) {
|
|
57
|
+
return null != description && false !== description && '' !== description;
|
|
58
|
+
}
|
|
59
|
+
function Timeline({ items, locale, 'aria-label': ariaLabel, toneLabels }) {
|
|
60
|
+
if (0 === items.length) return null;
|
|
61
|
+
const resolvedLocale = usableLocale(locale);
|
|
62
|
+
const words = {
|
|
63
|
+
...DEFAULT_TONE_LABELS,
|
|
64
|
+
...toneLabels
|
|
65
|
+
};
|
|
66
|
+
return /*#__PURE__*/ jsx("ol", {
|
|
67
|
+
role: "list",
|
|
68
|
+
className: Timeline_module.list,
|
|
69
|
+
"aria-label": ariaLabel,
|
|
70
|
+
children: items.map((item)=>/*#__PURE__*/ jsxs("li", {
|
|
71
|
+
className: Timeline_module.item,
|
|
72
|
+
"data-tone": item.tone ?? 'neutral',
|
|
73
|
+
children: [
|
|
74
|
+
/*#__PURE__*/ jsx("span", {
|
|
75
|
+
className: Timeline_module.marker,
|
|
76
|
+
"data-marker": "",
|
|
77
|
+
"aria-hidden": "true"
|
|
78
|
+
}),
|
|
79
|
+
/*#__PURE__*/ jsxs("div", {
|
|
80
|
+
className: Timeline_module.body,
|
|
81
|
+
children: [
|
|
82
|
+
/*#__PURE__*/ jsx("div", {
|
|
83
|
+
className: Timeline_module.title,
|
|
84
|
+
children: item.title
|
|
85
|
+
}),
|
|
86
|
+
item.timestamp || item.tone ? /*#__PURE__*/ jsxs("div", {
|
|
87
|
+
className: Timeline_module.meta,
|
|
88
|
+
children: [
|
|
89
|
+
item.timestamp ? /*#__PURE__*/ jsx(Timestamp, {
|
|
90
|
+
source: item.timestamp,
|
|
91
|
+
locale: resolvedLocale
|
|
92
|
+
}) : null,
|
|
93
|
+
item.tone ? /*#__PURE__*/ jsx("span", {
|
|
94
|
+
className: Timeline_module.tone,
|
|
95
|
+
children: words[item.tone]
|
|
96
|
+
}) : null
|
|
97
|
+
]
|
|
98
|
+
}) : null,
|
|
99
|
+
hasDescription(item.description) ? /*#__PURE__*/ jsx("div", {
|
|
100
|
+
className: Timeline_module.description,
|
|
101
|
+
children: item.description
|
|
102
|
+
}) : null
|
|
103
|
+
]
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
}, item.id))
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
export { Timeline };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "./Timeline_module.css";
|
|
2
|
+
const Timeline_module = {
|
|
3
|
+
list: "list-idznt",
|
|
4
|
+
item: "item-qvxp0",
|
|
5
|
+
marker: "marker-bb9HI",
|
|
6
|
+
body: "body-Ebp5l",
|
|
7
|
+
title: "title-ppcg_",
|
|
8
|
+
meta: "meta-Qkwq4",
|
|
9
|
+
tone: "tone-AP_HF",
|
|
10
|
+
description: "description-lVcj_"
|
|
11
|
+
};
|
|
12
|
+
export default Timeline_module;
|