@inkra/react 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +316 -2
- package/THIRD_PARTY_NOTICES.md +39 -0
- package/Yozai-OFL.txt +94 -0
- package/dist/Button.d.ts +36 -0
- package/dist/Button.js +89 -0
- package/dist/PencilIcon.d.ts +22 -0
- package/dist/PencilIcon.js +210 -0
- package/dist/PencilLine.d.ts +10 -0
- package/dist/PencilLine.js +91 -0
- package/dist/PencilSurface.d.ts +19 -0
- package/dist/PencilSurface.js +19 -0
- package/dist/PencilText.d.ts +16 -0
- package/dist/PencilText.js +338 -0
- package/dist/accordion/Accordion.d.ts +27 -0
- package/dist/accordion/Accordion.js +40 -0
- package/dist/accordion/index.d.ts +2 -0
- package/dist/accordion/index.js +1 -0
- package/dist/alert-dialog/index.d.ts +64 -0
- package/dist/alert-dialog/index.js +109 -0
- package/dist/assets/ui-hand-yozai.woff2 +0 -0
- package/dist/audio-player/index.d.ts +60 -0
- package/dist/audio-player/index.js +101 -0
- package/dist/breadcrumb/index.d.ts +16 -0
- package/dist/breadcrumb/index.js +25 -0
- package/dist/calendar/index.d.ts +21 -0
- package/dist/calendar/index.js +41 -0
- package/dist/carousel/index.d.ts +51 -0
- package/dist/carousel/index.js +290 -0
- package/dist/choice-grid/index.d.ts +38 -0
- package/dist/choice-grid/index.js +85 -0
- package/dist/color-picker/color.d.ts +15 -0
- package/dist/color-picker/color.js +55 -0
- package/dist/color-picker/index.d.ts +31 -0
- package/dist/color-picker/index.js +69 -0
- package/dist/command/index.d.ts +23 -0
- package/dist/command/index.js +39 -0
- package/dist/content/index.d.ts +106 -0
- package/dist/content/index.js +80 -0
- package/dist/context-menu/index.d.ts +76 -0
- package/dist/context-menu/index.js +240 -0
- package/dist/data-table/index.d.ts +47 -0
- package/dist/data-table/index.js +91 -0
- package/dist/date-picker/index.d.ts +50 -0
- package/dist/date-picker/index.js +180 -0
- package/dist/day-agenda/index.d.ts +43 -0
- package/dist/day-agenda/index.js +47 -0
- package/dist/day-agenda/layout.d.ts +20 -0
- package/dist/day-agenda/layout.js +60 -0
- package/dist/display/ProgressRing.d.ts +6 -0
- package/dist/display/ProgressRing.js +146 -0
- package/dist/display/index.d.ts +59 -0
- package/dist/display/index.js +75 -0
- package/dist/dockable-panel/index.d.ts +41 -0
- package/dist/dockable-panel/index.js +253 -0
- package/dist/dockable-panel/model.d.ts +21 -0
- package/dist/dockable-panel/model.js +61 -0
- package/dist/drawer/index.d.ts +63 -0
- package/dist/drawer/index.js +86 -0
- package/dist/dropdown-menu/index.d.ts +34 -0
- package/dist/dropdown-menu/index.js +40 -0
- package/dist/editable/index.d.ts +53 -0
- package/dist/editable/index.js +162 -0
- package/dist/empty/index.d.ts +21 -0
- package/dist/empty/index.js +23 -0
- package/dist/flip/index.d.ts +49 -0
- package/dist/flip/index.js +138 -0
- package/dist/form/EditablePencilText.d.ts +13 -0
- package/dist/form/EditablePencilText.js +323 -0
- package/dist/form/Field.d.ts +13 -0
- package/dist/form/Field.js +26 -0
- package/dist/form/Input.d.ts +27 -0
- package/dist/form/Input.js +97 -0
- package/dist/form/InputAction.d.ts +7 -0
- package/dist/form/InputAction.js +24 -0
- package/dist/form/Textarea.d.ts +17 -0
- package/dist/form/Textarea.js +102 -0
- package/dist/form/context.d.ts +12 -0
- package/dist/form/context.js +10 -0
- package/dist/form/controlProps.d.ts +23 -0
- package/dist/form/controlProps.js +20 -0
- package/dist/form/index.d.ts +7 -0
- package/dist/form/index.js +3 -0
- package/dist/form/types.d.ts +6 -0
- package/dist/form/types.js +1 -0
- package/dist/heatmap/index.d.ts +59 -0
- package/dist/heatmap/index.js +248 -0
- package/dist/hotkey/index.d.ts +37 -0
- package/dist/hotkey/index.js +130 -0
- package/dist/hotkey/model.d.ts +27 -0
- package/dist/hotkey/model.js +97 -0
- package/dist/hover-card/index.d.ts +33 -0
- package/dist/hover-card/index.js +141 -0
- package/dist/image-cropper/index.d.ts +82 -0
- package/dist/image-cropper/index.js +261 -0
- package/dist/image-cropper/model.d.ts +42 -0
- package/dist/image-cropper/model.js +94 -0
- package/dist/image-viewer/index.d.ts +79 -0
- package/dist/image-viewer/index.js +220 -0
- package/dist/image-viewer/model.d.ts +9 -0
- package/dist/image-viewer/model.js +18 -0
- package/dist/images/layers-2x.png +0 -0
- package/dist/images/layers.png +0 -0
- package/dist/images/marker-icon.png +0 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +69 -0
- package/dist/input-number/index.d.ts +16 -0
- package/dist/input-number/index.js +77 -0
- package/dist/internal/InputActionContext.d.ts +1 -0
- package/dist/internal/InputActionContext.js +3 -0
- package/dist/internal/cache.d.ts +14 -0
- package/dist/internal/cache.js +54 -0
- package/dist/internal/line.d.ts +4 -0
- package/dist/internal/line.js +21 -0
- package/dist/internal/paper.d.ts +1 -0
- package/dist/internal/paper.js +65 -0
- package/dist/internal/random.d.ts +3 -0
- package/dist/internal/random.js +30 -0
- package/dist/internal/recovery.d.ts +1 -0
- package/dist/internal/recovery.js +52 -0
- package/dist/internal/renderTokens.d.ts +10 -0
- package/dist/internal/renderTokens.js +13 -0
- package/dist/internal/stroke.d.ts +24 -0
- package/dist/internal/stroke.js +144 -0
- package/dist/internal/surfaceRenderer.d.ts +41 -0
- package/dist/internal/surfaceRenderer.js +178 -0
- package/dist/internal/textQueue.d.ts +1 -0
- package/dist/internal/textQueue.js +37 -0
- package/dist/internal/textRenderer.d.ts +28 -0
- package/dist/internal/textRenderer.js +239 -0
- package/dist/internal/travelIcons.d.ts +24 -0
- package/dist/internal/travelIcons.js +14 -0
- package/dist/internal/useBrowserLayoutEffect.d.ts +2 -0
- package/dist/internal/useBrowserLayoutEffect.js +3 -0
- package/dist/internal/usePencilSurface.d.ts +3 -0
- package/dist/internal/usePencilSurface.js +116 -0
- package/dist/internal/useSelectionDrawing.d.ts +2 -0
- package/dist/internal/useSelectionDrawing.js +90 -0
- package/dist/internal/wash.d.ts +16 -0
- package/dist/internal/wash.js +149 -0
- package/dist/journey-map/MapScale.d.ts +4 -0
- package/dist/journey-map/MapScale.js +54 -0
- package/dist/journey-map/index.d.ts +39 -0
- package/dist/journey-map/index.js +197 -0
- package/dist/journey-map/terrain.d.ts +8 -0
- package/dist/journey-map/terrain.js +127 -0
- package/dist/keypad/index.d.ts +23 -0
- package/dist/keypad/index.js +63 -0
- package/dist/keypad/model.d.ts +20 -0
- package/dist/keypad/model.js +33 -0
- package/dist/layout/index.d.ts +63 -0
- package/dist/layout/index.js +62 -0
- package/dist/log/index.d.ts +45 -0
- package/dist/log/index.js +159 -0
- package/dist/log/model.d.ts +16 -0
- package/dist/log/model.js +13 -0
- package/dist/node-graph/index.d.ts +123 -0
- package/dist/node-graph/index.js +304 -0
- package/dist/number-ticker/index.d.ts +29 -0
- package/dist/number-ticker/index.js +132 -0
- package/dist/number-ticker/model.d.ts +8 -0
- package/dist/number-ticker/model.js +34 -0
- package/dist/overflow-list/index.d.ts +39 -0
- package/dist/overflow-list/index.js +230 -0
- package/dist/overflow-list/layout.d.ts +19 -0
- package/dist/overflow-list/layout.js +44 -0
- package/dist/overlay/Overlay.d.ts +65 -0
- package/dist/overlay/Overlay.js +77 -0
- package/dist/overlay/Popover.d.ts +43 -0
- package/dist/overlay/Popover.js +45 -0
- package/dist/overlay/index.d.ts +4 -0
- package/dist/overlay/index.js +2 -0
- package/dist/overlay/themeBridge.d.ts +8 -0
- package/dist/overlay/themeBridge.js +98 -0
- package/dist/pagination/index.d.ts +23 -0
- package/dist/pagination/index.js +41 -0
- package/dist/pagination/model.d.ts +4 -0
- package/dist/pagination/model.js +42 -0
- package/dist/pan-zoom/index.d.ts +71 -0
- package/dist/pan-zoom/index.js +175 -0
- package/dist/pencil.d.ts +10 -0
- package/dist/pencil.js +39 -0
- package/dist/radar/index.d.ts +54 -0
- package/dist/radar/index.js +220 -0
- package/dist/range-slider/index.d.ts +16 -0
- package/dist/range-slider/index.js +22 -0
- package/dist/rating/index.d.ts +28 -0
- package/dist/rating/index.js +127 -0
- package/dist/resizable/index.d.ts +32 -0
- package/dist/resizable/index.js +50 -0
- package/dist/scroll-area/index.d.ts +36 -0
- package/dist/scroll-area/index.js +44 -0
- package/dist/segmented-progress/SegmentedProgress.d.ts +17 -0
- package/dist/segmented-progress/SegmentedProgress.js +42 -0
- package/dist/select/MultipleSelect.d.ts +44 -0
- package/dist/select/MultipleSelect.js +124 -0
- package/dist/select/SearchableSelect.d.ts +45 -0
- package/dist/select/SearchableSelect.js +50 -0
- package/dist/select/Select.d.ts +109 -0
- package/dist/select/Select.js +205 -0
- package/dist/select/index.d.ts +4 -0
- package/dist/select/index.js +2 -0
- package/dist/selection/Checkbox.d.ts +9 -0
- package/dist/selection/Checkbox.js +37 -0
- package/dist/selection/RadioGroup.d.ts +23 -0
- package/dist/selection/RadioGroup.js +82 -0
- package/dist/selection/Switch.d.ts +8 -0
- package/dist/selection/Switch.js +36 -0
- package/dist/selection/index.d.ts +6 -0
- package/dist/selection/index.js +3 -0
- package/dist/selection/useNativeChecked.d.ts +13 -0
- package/dist/selection/useNativeChecked.js +27 -0
- package/dist/slider/index.d.ts +11 -0
- package/dist/slider/index.js +45 -0
- package/dist/slot/index.d.ts +24 -0
- package/dist/slot/index.js +29 -0
- package/dist/sortable/index.d.ts +50 -0
- package/dist/sortable/index.js +278 -0
- package/dist/sortable/model.d.ts +30 -0
- package/dist/sortable/model.js +64 -0
- package/dist/sparkline/index.d.ts +19 -0
- package/dist/sparkline/index.js +240 -0
- package/dist/sparkline/model.d.ts +16 -0
- package/dist/sparkline/model.js +28 -0
- package/dist/steps/index.d.ts +16 -0
- package/dist/steps/index.js +37 -0
- package/dist/styles.css +8226 -0
- package/dist/tabs/index.d.ts +22 -0
- package/dist/tabs/index.js +42 -0
- package/dist/tag-input/index.d.ts +69 -0
- package/dist/tag-input/index.js +325 -0
- package/dist/tag-input/model.d.ts +14 -0
- package/dist/tag-input/model.js +38 -0
- package/dist/time-picker/index.d.ts +15 -0
- package/dist/time-picker/index.js +168 -0
- package/dist/timeline/index.d.ts +14 -0
- package/dist/timeline/index.js +16 -0
- package/dist/toast/index.d.ts +27 -0
- package/dist/toast/index.js +36 -0
- package/dist/toggle-group/index.d.ts +17 -0
- package/dist/toggle-group/index.js +26 -0
- package/dist/tokens.css +356 -0
- package/dist/tooltip/Tooltip.d.ts +24 -0
- package/dist/tooltip/Tooltip.js +32 -0
- package/dist/tooltip/index.d.ts +2 -0
- package/dist/tooltip/index.js +1 -0
- package/dist/transfer/index.d.ts +64 -0
- package/dist/transfer/index.js +174 -0
- package/dist/transfer/model.d.ts +12 -0
- package/dist/transfer/model.js +33 -0
- package/dist/tree/index.d.ts +39 -0
- package/dist/tree/index.js +36 -0
- package/dist/tree-select/index.d.ts +59 -0
- package/dist/tree-select/index.js +142 -0
- package/dist/tree-select/model.d.ts +31 -0
- package/dist/tree-select/model.js +135 -0
- package/dist/typewriter/index.d.ts +21 -0
- package/dist/typewriter/index.js +101 -0
- package/dist/typewriter/model.d.ts +7 -0
- package/dist/typewriter/model.js +45 -0
- package/dist/upload/index.d.ts +59 -0
- package/dist/upload/index.js +230 -0
- package/dist/virtual-list/index.d.ts +44 -0
- package/dist/virtual-list/index.js +128 -0
- package/dist/virtual-list/model.d.ts +7 -0
- package/dist/virtual-list/model.js +27 -0
- package/package.json +119 -4
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useEffect, useId, useImperativeHandle, useRef, useState } from 'react';
|
|
3
|
+
import { Button } from '../Button.js';
|
|
4
|
+
import { useResolvedControlProps } from '../form/controlProps.js';
|
|
5
|
+
import { mergeAriaIds, useFieldContext } from '../form/context.js';
|
|
6
|
+
import { useBrowserLayoutEffect } from '../internal/useBrowserLayoutEffect.js';
|
|
7
|
+
import { PencilIcon } from '../PencilIcon.js';
|
|
8
|
+
import { PencilText } from '../PencilText.js';
|
|
9
|
+
import { PencilLine } from '../PencilLine.js';
|
|
10
|
+
import { Popover } from '../overlay/Popover.js';
|
|
11
|
+
import { RadioGroup, RadioGroupItem } from '../selection/RadioGroup.js';
|
|
12
|
+
const clockPaths = [
|
|
13
|
+
{ d: 'M12 22a10 10 0 1 0 0-20 10 10 0 0 0 0 20Z' },
|
|
14
|
+
{ d: 'M12 6v6l4 2' },
|
|
15
|
+
];
|
|
16
|
+
const clearPaths = [{ d: 'M18 6 6 18' }, { d: 'm6 6 12 12' }];
|
|
17
|
+
const pad = (value) => {
|
|
18
|
+
const [whole, fraction] = String(value).split('.');
|
|
19
|
+
return `${whole.padStart(2, '0')}${fraction ? `.${fraction}` : ''}`;
|
|
20
|
+
};
|
|
21
|
+
const times = (length, start = 0) => Array.from({ length }, (_, index) => index + start);
|
|
22
|
+
function partsOf(value) {
|
|
23
|
+
if (!/^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d{1,3})?)?$/.test(value))
|
|
24
|
+
return undefined;
|
|
25
|
+
const [hour, minute, second = 0] = value.split(':').map(Number);
|
|
26
|
+
return [hour, minute, second];
|
|
27
|
+
}
|
|
28
|
+
function TimeColumn({ name, label, value, options, onChange, format = pad }) {
|
|
29
|
+
return _jsx(RadioGroup, { name: name, label: label, value: String(value), variant: "segmented", className: "inkra-time-picker__column", onValueChange: next => onChange(Number(next)), children: options.map(option => _jsx(RadioGroupItem, { value: String(option), label: format(option) }, option)) });
|
|
30
|
+
}
|
|
31
|
+
export const TimePicker = forwardRef(function TimePicker(allProps, forwardedRef) {
|
|
32
|
+
const { value, defaultValue, onValueChange, onChange, onClear, clearable = true, clearButtonLabel, hourCycle = 'h24', locale, lang, showSeconds = false, step, min, max, name, form, id, disabled, readOnly, required, invalid, 'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage, 'aria-invalid': ariaInvalid, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, className, style, size = 'md', fullWidth = true, startIcon, endIcon, endAction, startAction, prefix, suffix, placeholder, seed, variant = 'outline', textAlign = 'start', loading, classNames, ...nativeProps } = allProps;
|
|
33
|
+
const generatedId = useId();
|
|
34
|
+
const field = useFieldContext();
|
|
35
|
+
const inputRef = useRef(null);
|
|
36
|
+
const triggerRef = useRef(null);
|
|
37
|
+
const contentRef = useRef(null);
|
|
38
|
+
const initialValue = useRef(String(defaultValue ?? value ?? ''));
|
|
39
|
+
const controlled = Object.prototype.hasOwnProperty.call(allProps, 'value');
|
|
40
|
+
const [internalValue, setInternalValue] = useState(() => String(defaultValue ?? ''));
|
|
41
|
+
const [open, setOpen] = useState(false);
|
|
42
|
+
const [draft, setDraft] = useState('00:00');
|
|
43
|
+
const [draftValid, setDraftValid] = useState(true);
|
|
44
|
+
const [constraintInvalid, setConstraintInvalid] = useState(false);
|
|
45
|
+
useImperativeHandle(forwardedRef, () => inputRef.current);
|
|
46
|
+
const state = useResolvedControlProps({
|
|
47
|
+
id: id ?? `inkra-time-picker-${generatedId}`, disabled, readOnly, required, invalid,
|
|
48
|
+
'aria-describedby': ariaDescribedBy, 'aria-errormessage': ariaErrorMessage, 'aria-invalid': ariaInvalid,
|
|
49
|
+
});
|
|
50
|
+
const currentValue = controlled ? String(value ?? '') : internalValue;
|
|
51
|
+
const secondsVisible = showSeconds || (step !== undefined && step !== 'any' && Number(step) % 60 !== 0);
|
|
52
|
+
const resolvedStep = step ?? (secondsVisible ? 1 : 60);
|
|
53
|
+
const stepBase = String(defaultValue ?? initialValue.current);
|
|
54
|
+
const resolvedLocale = locale ?? lang ?? (hourCycle === 'h12' ? 'en-US' : 'en-GB');
|
|
55
|
+
const zh = resolvedLocale.toLowerCase().startsWith('zh');
|
|
56
|
+
const copy = zh
|
|
57
|
+
? { title: '选择时间', hour: '时', minute: '分', second: '秒', period: '时段', am: '上午', pm: '下午',
|
|
58
|
+
done: '确定', cancel: '取消', clear: '清空时间', invalid: '请选择符合时间范围和步进的时间。' }
|
|
59
|
+
: { title: 'Choose time', hour: 'Hour', minute: 'Minute', second: 'Second', period: 'Period', am: 'AM', pm: 'PM',
|
|
60
|
+
done: 'Apply', cancel: 'Cancel', clear: 'Clear time', invalid: 'Choose a time within the allowed range and step.' };
|
|
61
|
+
const currentParts = partsOf(currentValue);
|
|
62
|
+
const displayValue = currentParts
|
|
63
|
+
? new Intl.DateTimeFormat(resolvedLocale, {
|
|
64
|
+
hour: '2-digit', minute: '2-digit', ...(secondsVisible ? { second: '2-digit' } : {}),
|
|
65
|
+
hourCycle: hourCycle === 'h12' ? 'h12' : 'h23',
|
|
66
|
+
}).format(new Date(2000, 0, 1, ...currentParts))
|
|
67
|
+
: placeholder ?? copy.title;
|
|
68
|
+
const canClear = clearable && Boolean(currentValue) && !state.disabled && !state.readOnly;
|
|
69
|
+
const valueId = field ? `${state.id}-value` : undefined;
|
|
70
|
+
const [hour, minute, second] = partsOf(draft) ?? [0, 0, 0];
|
|
71
|
+
const validDraft = (candidate = draft) => {
|
|
72
|
+
// Native validation owns overnight ranges, fractional steps and step bases.
|
|
73
|
+
const input = document.createElement('input');
|
|
74
|
+
input.type = 'time';
|
|
75
|
+
if (min !== undefined)
|
|
76
|
+
input.min = String(min);
|
|
77
|
+
if (max !== undefined)
|
|
78
|
+
input.max = String(max);
|
|
79
|
+
input.step = String(resolvedStep);
|
|
80
|
+
input.defaultValue = stepBase;
|
|
81
|
+
input.required = true;
|
|
82
|
+
input.value = candidate;
|
|
83
|
+
return input.validity.valid;
|
|
84
|
+
};
|
|
85
|
+
const updateOpen = (next) => {
|
|
86
|
+
if (next && (state.disabled || state.readOnly))
|
|
87
|
+
return;
|
|
88
|
+
if (next) {
|
|
89
|
+
const initial = partsOf(currentValue) ? currentValue : partsOf(String(min)) ? String(min) : '00:00';
|
|
90
|
+
const nextDraft = secondsVisible && initial.length === 5 ? `${initial}:00` : initial;
|
|
91
|
+
setDraft(nextDraft);
|
|
92
|
+
setDraftValid(validDraft(nextDraft));
|
|
93
|
+
}
|
|
94
|
+
setOpen(next);
|
|
95
|
+
};
|
|
96
|
+
const updatePart = (part, next) => {
|
|
97
|
+
const values = [hour, minute, second];
|
|
98
|
+
values[part] = next;
|
|
99
|
+
const nextDraft = values.slice(0, secondsVisible ? 3 : 2).map(pad).join(':');
|
|
100
|
+
setDraft(nextDraft);
|
|
101
|
+
setDraftValid(validDraft(nextDraft));
|
|
102
|
+
};
|
|
103
|
+
const commit = (next, reason) => {
|
|
104
|
+
if (!controlled)
|
|
105
|
+
setInternalValue(next);
|
|
106
|
+
setConstraintInvalid(false);
|
|
107
|
+
onValueChange?.(next, { reason });
|
|
108
|
+
setOpen(false);
|
|
109
|
+
};
|
|
110
|
+
useEffect(() => { setDraftValid(validDraft()); }, [draft, min, max, resolvedStep, stepBase]);
|
|
111
|
+
useBrowserLayoutEffect(() => {
|
|
112
|
+
// React's controlled value attribute must not move the native step base on each edit.
|
|
113
|
+
if (inputRef.current)
|
|
114
|
+
inputRef.current.defaultValue = stepBase;
|
|
115
|
+
}, [currentValue, stepBase]);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
const input = inputRef.current;
|
|
118
|
+
let timer;
|
|
119
|
+
const reset = (event) => {
|
|
120
|
+
clearTimeout(timer);
|
|
121
|
+
timer = setTimeout(() => {
|
|
122
|
+
if (event.defaultPrevented)
|
|
123
|
+
return;
|
|
124
|
+
if (!controlled)
|
|
125
|
+
setInternalValue(String(defaultValue ?? ''));
|
|
126
|
+
else if (input)
|
|
127
|
+
input.value = currentValue;
|
|
128
|
+
setConstraintInvalid(false);
|
|
129
|
+
setOpen(false);
|
|
130
|
+
}, 0);
|
|
131
|
+
};
|
|
132
|
+
input?.form?.addEventListener('reset', reset);
|
|
133
|
+
return () => { clearTimeout(timer); input?.form?.removeEventListener('reset', reset); };
|
|
134
|
+
}, [controlled, currentValue, defaultValue, form]);
|
|
135
|
+
useEffect(() => { if (state.disabled || state.readOnly)
|
|
136
|
+
setOpen(false); }, [state.disabled, state.readOnly]);
|
|
137
|
+
return _jsxs(Popover.Root, { open: open, onOpenChange: updateOpen, children: [_jsxs("div", { className: ['inkra-time-picker', classNames?.root, className].filter(Boolean).join(' '), style: style, dir: nativeProps.dir, "data-full-width": fullWidth, "data-invalid": state.invalid || constraintInvalid || undefined, "data-readonly": state.readOnly || undefined, "data-disabled": state.disabled || undefined, children: [startAction, _jsx(Popover.Trigger, { asChild: true, children: _jsxs(Button, { className: ['inkra-time-picker__trigger', classNames?.control].filter(Boolean).join(' '), id: state.id, ref: triggerRef, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": mergeAriaIds(state.describedBy, valueId), "aria-invalid": constraintInvalid || state.ariaInvalid, "aria-errormessage": state.errorMessage, "aria-required": state.required || undefined, "aria-readonly": state.readOnly || undefined, disabled: state.disabled, fullWidth: true, align: textAlign, variant: variant === 'soft' ? 'secondary' : variant === 'underline' ? 'outline' : variant, size: size, seed: seed, loading: loading, autoFocus: nativeProps.autoFocus, startIcon: startIcon ?? _jsx(PencilIcon, { paths: clockPaths, sourceSize: 24, size: 22 }), endIcon: endIcon, children: [prefix, _jsx(PencilText, { children: displayValue }), suffix] }) }), valueId && _jsx("span", { className: "inkra-time-picker__accessible-value", id: valueId, children: displayValue }), clearable && _jsx(Button, { className: "inkra-time-picker__clear", "aria-label": clearButtonLabel ?? copy.clear, title: clearButtonLabel ?? copy.clear, "aria-hidden": !canClear || undefined, disabled: !canClear, tabIndex: canClear ? 0 : -1, variant: "outline", size: "icon", onClick: event => {
|
|
138
|
+
commit('', 'clear');
|
|
139
|
+
onClear?.(event);
|
|
140
|
+
triggerRef.current?.focus({ preventScroll: true });
|
|
141
|
+
}, children: _jsx(PencilIcon, { paths: clearPaths, sourceSize: 24, size: 22 }) }), endAction, _jsx("input", { ...nativeProps, ref: inputRef, type: "time", className: "inkra-time-picker__native", id: `${state.id}-native`, "aria-hidden": "true", tabIndex: -1, name: name, form: form, value: currentValue, min: min, max: max, step: resolvedStep, lang: lang ?? resolvedLocale, "data-hour-cycle": hourCycle, disabled: state.disabled, readOnly: state.readOnly, required: state.required, onChange: event => {
|
|
142
|
+
if (!controlled)
|
|
143
|
+
setInternalValue(event.currentTarget.value);
|
|
144
|
+
onChange?.(event);
|
|
145
|
+
onValueChange?.(event.currentTarget.value, { reason: 'input' });
|
|
146
|
+
}, onFocus: event => { nativeProps.onFocus?.(event); triggerRef.current?.focus({ preventScroll: true }); }, onInvalid: event => {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
setConstraintInvalid(true);
|
|
149
|
+
triggerRef.current?.focus();
|
|
150
|
+
nativeProps.onInvalid?.(event);
|
|
151
|
+
} })] }), _jsx(Popover.Portal, { children: _jsxs(Popover.Content, { className: "inkra-time-picker__popover", ref: contentRef, align: "start", sideOffset: 8, collisionPadding: 12, "aria-label": copy.title, onOpenAutoFocus: event => {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
requestAnimationFrame(() => {
|
|
154
|
+
const content = contentRef.current;
|
|
155
|
+
content?.querySelectorAll('input:checked').forEach(input => {
|
|
156
|
+
const scroll = input.closest('.inkra-radio-group__items');
|
|
157
|
+
const item = input.closest('.inkra-radio-group__item');
|
|
158
|
+
if (scroll && item)
|
|
159
|
+
scroll.scrollTop += item.getBoundingClientRect().top - scroll.getBoundingClientRect().top - 88;
|
|
160
|
+
});
|
|
161
|
+
(content?.querySelector('input:checked')
|
|
162
|
+
?? content?.querySelector('input'))?.focus({ preventScroll: true });
|
|
163
|
+
});
|
|
164
|
+
}, children: [_jsx(Popover.Title, { children: copy.title }), _jsx(PencilLine, {}), _jsxs("div", { className: "inkra-time-picker__columns", children: [_jsx(TimeColumn, { name: `${generatedId}-hour`, label: copy.hour, value: hourCycle === 'h12' ? hour % 12 || 12 : hour, options: hourCycle === 'h12' ? times(12, 1) : times(24), onChange: next => updatePart(0, hourCycle === 'h12' ? next % 12 + (hour >= 12 ? 12 : 0) : next) }), _jsx(TimeColumn, { name: `${generatedId}-minute`, label: copy.minute, value: minute, options: times(60), onChange: next => updatePart(1, next) }), secondsVisible && _jsx(TimeColumn, { name: `${generatedId}-second`, label: copy.second, value: Math.floor(second), options: times(60), onChange: next => updatePart(2, next) }), hourCycle === 'h12' && _jsx(TimeColumn, { name: `${generatedId}-period`, label: copy.period, value: hour >= 12 ? 1 : 0, options: [0, 1], format: next => next ? copy.pm : copy.am, onChange: next => updatePart(0, hour % 12 + next * 12) })] }), !draftValid && _jsx(PencilText, { as: "p", className: "inkra-time-picker__error", role: "status", children: copy.invalid }), _jsx(PencilLine, {}), _jsxs("div", { className: "inkra-time-picker__footer", children: [_jsx(Popover.Close, { asChild: true, children: _jsx(Button, { variant: "outline", children: copy.cancel }) }), _jsx(Button, { disabled: !draftValid || state.disabled || state.readOnly, onClick: () => {
|
|
165
|
+
if (validDraft())
|
|
166
|
+
commit(draft, 'input');
|
|
167
|
+
}, children: copy.done })] })] }) })] });
|
|
168
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type OlHTMLAttributes, type ReactNode } from 'react';
|
|
2
|
+
export interface TimelineItem {
|
|
3
|
+
id: string;
|
|
4
|
+
date: ReactNode;
|
|
5
|
+
dateTime?: string;
|
|
6
|
+
title: ReactNode;
|
|
7
|
+
description?: ReactNode;
|
|
8
|
+
content?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export interface TimelineProps extends Omit<OlHTMLAttributes<HTMLOListElement>, 'children'> {
|
|
11
|
+
items: readonly TimelineItem[];
|
|
12
|
+
orientation?: 'horizontal' | 'vertical';
|
|
13
|
+
}
|
|
14
|
+
export declare const Timeline: import("react").ForwardRefExoticComponent<TimelineProps & import("react").RefAttributes<HTMLOListElement>>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import { PencilIcon } from '../PencilIcon.js';
|
|
4
|
+
import { PencilLine } from '../PencilLine.js';
|
|
5
|
+
import { PencilSurface } from '../PencilSurface.js';
|
|
6
|
+
import { PencilText } from '../PencilText.js';
|
|
7
|
+
const markerPaths = [
|
|
8
|
+
{ d: 'M16 7a9 9 0 1 0 0 18 9 9 0 0 0 0-18Z' },
|
|
9
|
+
{ d: 'M16 11v6l4 3' },
|
|
10
|
+
];
|
|
11
|
+
const copy = (value) => typeof value === 'string' ? _jsx(PencilText, { children: value }) : value;
|
|
12
|
+
export const Timeline = forwardRef(function Timeline({ 'aria-label': ariaLabel = 'Timeline', className, items, orientation = 'vertical', ...props }, ref) {
|
|
13
|
+
return _jsx("ol", { ...props, ref: ref, "aria-label": ariaLabel, className: ['inkra-timeline', className].filter(Boolean).join(' '), "data-orientation": orientation, children: items.map((item, index) => _jsxs("li", { className: "inkra-timeline__item", children: [_jsxs("span", { className: "inkra-timeline__rail", "aria-hidden": "true", children: [_jsx(PencilSurface, { as: "span", className: "inkra-timeline__marker", variant: "quiet", radius: 8, seed: `timeline-${item.id}`, children: _jsx(PencilIcon, { paths: markerPaths, size: 24, sourceSize: 32 }) }), index < items.length - 1 && _jsx(PencilLine, { className: "inkra-timeline__connector", orientation: orientation === 'vertical' ? 'vertical' : 'horizontal', seed: `timeline-line-${item.id}` })] }), _jsxs("div", { className: "inkra-timeline__body", children: [item.dateTime
|
|
14
|
+
? _jsx("time", { className: "inkra-timeline__date", dateTime: item.dateTime, children: copy(item.date) })
|
|
15
|
+
: _jsx("span", { className: "inkra-timeline__date", children: copy(item.date) }), _jsx("div", { className: "inkra-timeline__title", children: copy(item.title) }), item.description != null && _jsx("div", { className: "inkra-timeline__description", children: copy(item.description) }), item.content != null && _jsx("div", { className: "inkra-timeline__content", children: item.content })] })] }, item.id)) });
|
|
16
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Toast as BaseToast } from '@base-ui/react/toast';
|
|
2
|
+
import type { ToastManager as BaseToastManager } from '@base-ui/react/toast';
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
export type ToastPlacement = 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end';
|
|
5
|
+
export type ToastTone = 'neutral' | 'success' | 'warning' | 'danger' | 'info';
|
|
6
|
+
export type ToastSwipeDirection = 'up' | 'down' | 'left' | 'right';
|
|
7
|
+
export type ToastManager<Data extends object = any> = BaseToastManager<Data>;
|
|
8
|
+
export interface ToastProviderProps {
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
limit?: number;
|
|
12
|
+
toastManager?: ToastManager;
|
|
13
|
+
placement?: ToastPlacement;
|
|
14
|
+
swipeDirection?: ToastSwipeDirection | ToastSwipeDirection[];
|
|
15
|
+
closeLabel?: string;
|
|
16
|
+
viewportLabel?: string;
|
|
17
|
+
viewportClassName?: string;
|
|
18
|
+
}
|
|
19
|
+
declare function Provider({ children, closeLabel, limit, placement, swipeDirection, timeout, toastManager, viewportClassName, viewportLabel, }: ToastProviderProps): import("react").JSX.Element;
|
|
20
|
+
export declare const useToastManager: typeof BaseToast.useToastManager;
|
|
21
|
+
export declare const createToastManager: typeof BaseToast.createToastManager;
|
|
22
|
+
export declare const Toast: {
|
|
23
|
+
Provider: typeof Provider;
|
|
24
|
+
useToastManager: typeof BaseToast.useToastManager;
|
|
25
|
+
createToastManager: typeof BaseToast.createToastManager;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Toast as BaseToast } from '@base-ui/react/toast';
|
|
3
|
+
import { Button } from '../Button.js';
|
|
4
|
+
import { PencilIcon } from '../PencilIcon.js';
|
|
5
|
+
import { PencilSurface } from '../PencilSurface.js';
|
|
6
|
+
import { PencilText } from '../PencilText.js';
|
|
7
|
+
import { PortalThemeBridge, PortalThemeProvider, usePortalTriggerRef, } from '../overlay/themeBridge.js';
|
|
8
|
+
const closePaths = [
|
|
9
|
+
{ d: 'M6 6 18 18' },
|
|
10
|
+
{ d: 'M18 6 6 18' },
|
|
11
|
+
];
|
|
12
|
+
function text(content) {
|
|
13
|
+
return typeof content === 'string' ? _jsx(PencilText, { children: content }) : content;
|
|
14
|
+
}
|
|
15
|
+
function toneOf(type) {
|
|
16
|
+
return type === 'success' || type === 'warning' || type === 'danger' || type === 'info'
|
|
17
|
+
? type
|
|
18
|
+
: 'neutral';
|
|
19
|
+
}
|
|
20
|
+
function ToastThemeAnchor() {
|
|
21
|
+
const ref = usePortalTriggerRef(null);
|
|
22
|
+
return _jsx("span", { "aria-hidden": "true", className: "inkra-toast__theme-anchor", ref: ref });
|
|
23
|
+
}
|
|
24
|
+
function ToastQueue({ closeLabel, placement, swipeDirection, viewportClassName, viewportLabel, }) {
|
|
25
|
+
const { toasts } = BaseToast.useToastManager();
|
|
26
|
+
return (_jsx(BaseToast.Portal, { children: _jsx(PortalThemeBridge, { children: _jsx(BaseToast.Viewport, { "aria-label": viewportLabel, className: ['inkra-toast__viewport', viewportClassName].filter(Boolean).join(' '), "data-placement": placement, children: toasts.map((toastItem) => {
|
|
27
|
+
const tone = toneOf(toastItem.type);
|
|
28
|
+
return (_jsxs(BaseToast.Root, { className: "inkra-toast__root", "data-tone": tone, swipeDirection: swipeDirection, toast: toastItem, children: [_jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-toast__surface", seed: `toast-${toastItem.id}-${toastItem.updateKey ?? 0}`, variant: tone === 'neutral' ? 'paper' : 'quiet' }), _jsxs(BaseToast.Content, { className: "inkra-toast__content", children: [_jsxs("div", { className: "inkra-toast__copy", children: [toastItem.title != null && (_jsx(BaseToast.Title, { className: "inkra-toast__title", children: text(toastItem.title) })), toastItem.description != null && (_jsx(BaseToast.Description, { className: "inkra-toast__description", children: text(toastItem.description) }))] }), _jsxs("div", { className: "inkra-toast__actions", children: [toastItem.actionProps?.children != null && (_jsx(BaseToast.Action, { className: "inkra-toast__action", render: _jsx(Button, { size: "sm", variant: "outline" }) })), _jsx(BaseToast.Close, { "aria-label": closeLabel, className: "inkra-toast__close", render: _jsx(Button, { size: "icon-sm", variant: "ghost" }), children: _jsx(PencilIcon, { paths: closePaths, size: 20, sourceSize: 24, decorative: true }) })] })] })] }, toastItem.id));
|
|
29
|
+
}) }) }) }));
|
|
30
|
+
}
|
|
31
|
+
function Provider({ children, closeLabel = 'Close notification', limit, placement = 'bottom-end', swipeDirection = ['down', 'right'], timeout, toastManager, viewportClassName, viewportLabel = 'Notifications', }) {
|
|
32
|
+
return (_jsx(PortalThemeProvider, { children: _jsxs(BaseToast.Provider, { limit: limit, timeout: timeout, toastManager: toastManager, children: [_jsx(ToastThemeAnchor, {}), children, _jsx(ToastQueue, { closeLabel: closeLabel, placement: placement, swipeDirection: swipeDirection, viewportClassName: viewportClassName, viewportLabel: viewportLabel })] }) }));
|
|
33
|
+
}
|
|
34
|
+
export const useToastManager = BaseToast.useToastManager;
|
|
35
|
+
export const createToastManager = BaseToast.createToastManager;
|
|
36
|
+
export const Toast = { Provider, useToastManager, createToastManager };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Toggle as BaseToggle } from '@base-ui/react/toggle';
|
|
2
|
+
import { ToggleGroup as BaseToggleGroup } from '@base-ui/react/toggle-group';
|
|
3
|
+
import type { ReactElement, ReactNode, RefAttributes } from 'react';
|
|
4
|
+
export interface ToggleGroupRootProps<Value extends string = string> extends BaseToggleGroup.Props<Value> {
|
|
5
|
+
size?: 'sm' | 'md' | 'lg';
|
|
6
|
+
}
|
|
7
|
+
type RootComponent = <Value extends string = string>(props: ToggleGroupRootProps<Value> & RefAttributes<HTMLDivElement>) => ReactElement;
|
|
8
|
+
export interface ToggleGroupItemProps<Value extends string = string> extends BaseToggle.Props<Value> {
|
|
9
|
+
startIcon?: ReactNode;
|
|
10
|
+
endIcon?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
type ItemComponent = <Value extends string = string>(props: ToggleGroupItemProps<Value> & RefAttributes<HTMLButtonElement>) => ReactElement;
|
|
13
|
+
export declare const ToggleGroup: {
|
|
14
|
+
Root: RootComponent;
|
|
15
|
+
Item: ItemComponent;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DirectionProvider } from '@base-ui/react/direction-provider';
|
|
3
|
+
import { Toggle as BaseToggle } from '@base-ui/react/toggle';
|
|
4
|
+
import { ToggleGroup as BaseToggleGroup } from '@base-ui/react/toggle-group';
|
|
5
|
+
import { createContext, forwardRef, useContext } from 'react';
|
|
6
|
+
import { PencilLine } from '../PencilLine.js';
|
|
7
|
+
import { PencilSurface } from '../PencilSurface.js';
|
|
8
|
+
import { PencilText } from '../PencilText.js';
|
|
9
|
+
function classes(base, className) {
|
|
10
|
+
if (typeof className === 'function') {
|
|
11
|
+
return (state) => [base, className(state)].filter(Boolean).join(' ');
|
|
12
|
+
}
|
|
13
|
+
return [base, className].filter(Boolean).join(' ');
|
|
14
|
+
}
|
|
15
|
+
const OrientationContext = createContext('horizontal');
|
|
16
|
+
const RootImplementation = forwardRef(function ToggleGroupRoot({ children, className, dir, orientation = 'horizontal', size = 'md', ...props }, ref) {
|
|
17
|
+
const direction = dir === 'rtl' ? 'rtl' : 'ltr';
|
|
18
|
+
return (_jsx(DirectionProvider, { direction: direction, children: _jsx(OrientationContext.Provider, { value: orientation, children: _jsxs(BaseToggleGroup, { ...props, className: classes('inkra-toggle-group', className), "data-size": size, dir: dir, orientation: orientation, ref: ref, children: [_jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-toggle-group__outline", seed: "toggle-group-outline", variant: "outline" }), children] }) }) }));
|
|
19
|
+
});
|
|
20
|
+
const ItemImplementation = forwardRef(function ToggleGroupItem({ children, className, endIcon, startIcon, value, ...props }, ref) {
|
|
21
|
+
const orientation = useContext(OrientationContext);
|
|
22
|
+
return (_jsxs(BaseToggle, { ...props, className: classes('inkra-toggle-group__item', className), ref: ref, value: value, children: [_jsx(PencilLine, { className: "inkra-toggle-group__divider", orientation: orientation === 'horizontal' ? 'vertical' : 'horizontal', seed: `toggle-${value ?? 'item'}-divider` }), _jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-toggle-group__selection", seed: `toggle-${value ?? 'item'}`, variant: "selection" }), _jsx(PencilSurface, { "aria-hidden": "true", as: "span", className: "inkra-toggle-group__focus", seed: `toggle-${value ?? 'item'}-focus`, variant: "outline" }), startIcon != null && _jsx("span", { "aria-hidden": "true", className: "inkra-toggle-group__icon", children: startIcon }), _jsx("span", { className: "inkra-toggle-group__label", children: typeof children === 'string' ? _jsx(PencilText, { children: children }) : children }), endIcon != null && _jsx("span", { "aria-hidden": "true", className: "inkra-toggle-group__icon", children: endIcon })] }));
|
|
23
|
+
});
|
|
24
|
+
const Root = RootImplementation;
|
|
25
|
+
const Item = ItemImplementation;
|
|
26
|
+
export const ToggleGroup = { Root, Item };
|