@ark-ui/solid 3.5.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/cjs/index.js +608 -14
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +581 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/source/components/field/use-field.js +5 -3
- package/dist/source/components/fieldset/fieldset-context.jsx +2 -0
- package/dist/source/components/fieldset/fieldset-error-text.jsx +11 -0
- package/dist/source/components/fieldset/fieldset-helper-text.jsx +8 -0
- package/dist/source/components/fieldset/fieldset-legend.jsx +8 -0
- package/dist/source/components/fieldset/fieldset-root-provider.jsx +11 -0
- package/dist/source/components/fieldset/fieldset-root.jsx +18 -0
- package/dist/source/components/fieldset/fieldset.anatomy.js +3 -0
- package/dist/source/components/fieldset/fieldset.jsx +6 -0
- package/dist/source/components/fieldset/index.js +9 -0
- package/dist/source/components/fieldset/use-fieldset-context.js +6 -0
- package/dist/source/components/fieldset/use-fieldset.js +65 -0
- package/dist/source/components/highlight/highlight.jsx +20 -0
- package/dist/source/components/highlight/index.js +2 -0
- package/dist/source/components/highlight/use-highlight.js +42 -0
- package/dist/source/components/index.js +3 -0
- package/dist/source/components/select/select-hidden-select.jsx +1 -1
- package/dist/source/components/time-picker/index.js +16 -0
- package/dist/source/components/time-picker/time-picker-cell.jsx +18 -0
- package/dist/source/components/time-picker/time-picker-clear-trigger.jsx +8 -0
- package/dist/source/components/time-picker/time-picker-column.jsx +13 -0
- package/dist/source/components/time-picker/time-picker-content.jsx +13 -0
- package/dist/source/components/time-picker/time-picker-context.jsx +2 -0
- package/dist/source/components/time-picker/time-picker-control.jsx +8 -0
- package/dist/source/components/time-picker/time-picker-input.jsx +8 -0
- package/dist/source/components/time-picker/time-picker-label.jsx +8 -0
- package/dist/source/components/time-picker/time-picker-positioner.jsx +13 -0
- package/dist/source/components/time-picker/time-picker-root-provider.jsx +16 -0
- package/dist/source/components/time-picker/time-picker-root.jsx +39 -0
- package/dist/source/components/time-picker/time-picker-spacer.jsx +8 -0
- package/dist/source/components/time-picker/time-picker-trigger.jsx +8 -0
- package/dist/source/components/time-picker/time-picker.js +13 -0
- package/dist/source/components/time-picker/use-time-picker-column-props-context.js +5 -0
- package/dist/source/components/time-picker/use-time-picker-context.js +5 -0
- package/dist/source/components/time-picker/use-time-picker.js +23 -0
- package/dist/source/components/tooltip/tooltip-root.jsx +1 -0
- package/dist/types/components/dialog/dialog-root.d.ts +1 -1
- package/dist/types/components/fieldset/fieldset-context.d.ts +6 -0
- package/dist/types/components/fieldset/fieldset-error-text.d.ts +6 -0
- package/dist/types/components/fieldset/fieldset-helper-text.d.ts +6 -0
- package/dist/types/components/fieldset/fieldset-legend.d.ts +6 -0
- package/dist/types/components/fieldset/fieldset-root-provider.d.ts +11 -0
- package/dist/types/components/fieldset/fieldset-root.d.ts +10 -0
- package/dist/types/components/fieldset/fieldset.anatomy.d.ts +2 -0
- package/dist/types/components/fieldset/fieldset.d.ts +6 -0
- package/dist/types/components/fieldset/index.d.ts +9 -0
- package/dist/types/components/fieldset/use-fieldset-context.d.ts +4 -0
- package/dist/types/components/fieldset/use-fieldset.d.ts +49 -0
- package/dist/types/components/highlight/highlight.d.ts +8 -0
- package/dist/types/components/highlight/index.d.ts +2 -0
- package/dist/types/components/highlight/use-highlight.d.ts +31 -0
- package/dist/types/components/index.d.ts +3 -0
- package/dist/types/components/time-picker/index.d.ts +17 -0
- package/dist/types/components/time-picker/time-picker-cell.d.ts +12 -0
- package/dist/types/components/time-picker/time-picker-clear-trigger.d.ts +7 -0
- package/dist/types/components/time-picker/time-picker-column.d.ts +8 -0
- package/dist/types/components/time-picker/time-picker-content.d.ts +7 -0
- package/dist/types/components/time-picker/time-picker-context.d.ts +6 -0
- package/dist/types/components/time-picker/time-picker-control.d.ts +7 -0
- package/dist/types/components/time-picker/time-picker-input.d.ts +7 -0
- package/dist/types/components/time-picker/time-picker-label.d.ts +7 -0
- package/dist/types/components/time-picker/time-picker-positioner.d.ts +6 -0
- package/dist/types/components/time-picker/time-picker-root-provider.d.ts +12 -0
- package/dist/types/components/time-picker/time-picker-root.d.ts +9 -0
- package/dist/types/components/time-picker/time-picker-spacer.d.ts +7 -0
- package/dist/types/components/time-picker/time-picker-trigger.d.ts +7 -0
- package/dist/types/components/time-picker/time-picker.d.ts +14 -0
- package/dist/types/components/time-picker/use-time-picker-column-props-context.d.ts +5 -0
- package/dist/types/components/time-picker/use-time-picker-context.d.ts +4 -0
- package/dist/types/components/time-picker/use-time-picker.d.ts +31 -0
- package/dist/types/components/toast/index.d.ts +1 -1
- package/package.json +61 -57
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { getWindow } from '@zag-js/dom-query';
|
|
2
|
-
import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js';
|
|
2
|
+
import { createEffect, createMemo, createSignal, createUniqueId, onCleanup } from 'solid-js';
|
|
3
|
+
import { useFieldsetContext } from '../fieldset';
|
|
3
4
|
import { parts } from './field.anatomy';
|
|
4
5
|
export const useField = (props) => {
|
|
5
|
-
const
|
|
6
|
+
const fieldset = useFieldsetContext();
|
|
7
|
+
const { disabled = Boolean(fieldset?.().disabled), invalid = false, readOnly = false, required = false, } = props;
|
|
6
8
|
const [hasErrorText, setHasErrorText] = createSignal(false);
|
|
7
9
|
const [hasHelperText, setHasHelperText] = createSignal(false);
|
|
8
|
-
const id = props.id ??
|
|
10
|
+
const id = props.id ?? createUniqueId();
|
|
9
11
|
let rootRef;
|
|
10
12
|
const errorTextId = `field::${id}::error-text`;
|
|
11
13
|
const helperTextId = `field::${id}::helper-text`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { Show } from 'solid-js';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useFieldsetContext } from './use-fieldset-context';
|
|
5
|
+
export const FieldsetErrorText = (props) => {
|
|
6
|
+
const fieldset = useFieldsetContext();
|
|
7
|
+
const mergedProps = mergeProps(() => fieldset().getErrorTextProps(), props);
|
|
8
|
+
return (<Show when={fieldset().invalid}>
|
|
9
|
+
<ark.span {...mergedProps}/>
|
|
10
|
+
</Show>);
|
|
11
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useFieldsetContext } from './use-fieldset-context';
|
|
4
|
+
export const FieldsetHelperText = (props) => {
|
|
5
|
+
const fieldset = useFieldsetContext();
|
|
6
|
+
const mergedProps = mergeProps(() => fieldset().getHelperTextProps(), props);
|
|
7
|
+
return <ark.span {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useFieldsetContext } from './use-fieldset-context';
|
|
4
|
+
export const FieldsetLegend = (props) => {
|
|
5
|
+
const fieldset = useFieldsetContext();
|
|
6
|
+
const mergedProps = mergeProps(() => fieldset().getLegendProps(), props);
|
|
7
|
+
return <ark.legend {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { FieldsetProvider } from './use-fieldset-context';
|
|
5
|
+
export const FieldsetRootProvider = (props) => {
|
|
6
|
+
const [{ value: fieldset }, localProps] = createSplitProps()(props, ['value']);
|
|
7
|
+
const mergedProps = mergeProps(() => fieldset().getRootProps(), localProps);
|
|
8
|
+
return (<FieldsetProvider value={fieldset}>
|
|
9
|
+
<ark.fieldset {...mergedProps}/>
|
|
10
|
+
</FieldsetProvider>);
|
|
11
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useFieldset } from './use-fieldset';
|
|
5
|
+
import { FieldsetProvider } from './use-fieldset-context';
|
|
6
|
+
export const FieldsetRoot = (props) => {
|
|
7
|
+
const [useFieldsetProps, localProps] = createSplitProps()(props, [
|
|
8
|
+
'id',
|
|
9
|
+
'disabled',
|
|
10
|
+
'invalid',
|
|
11
|
+
]);
|
|
12
|
+
const fieldset = useFieldset(useFieldsetProps);
|
|
13
|
+
const mergedProps = mergeProps(() => fieldset().getRootProps(), localProps);
|
|
14
|
+
return (<FieldsetProvider value={fieldset}>
|
|
15
|
+
<ark.fieldset {...mergedProps}/>
|
|
16
|
+
</FieldsetProvider>);
|
|
17
|
+
};
|
|
18
|
+
FieldsetRoot.displayName = 'FieldsetRoot';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { FieldsetRoot as Root, } from './fieldset-root';
|
|
2
|
+
export { FieldsetRootProvider as RootProvider, } from './fieldset-root-provider';
|
|
3
|
+
export { FieldsetLegend as Legend, } from './fieldset-legend';
|
|
4
|
+
export { FieldsetHelperText as HelperText, } from './fieldset-helper-text';
|
|
5
|
+
export { FieldsetErrorText as ErrorText, } from './fieldset-error-text';
|
|
6
|
+
export { FieldsetContext as Context, } from './fieldset-context';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { FieldsetContext } from './fieldset-context';
|
|
2
|
+
export { FieldsetErrorText, } from './fieldset-error-text';
|
|
3
|
+
export { FieldsetHelperText, } from './fieldset-helper-text';
|
|
4
|
+
export { FieldsetRoot } from './fieldset-root';
|
|
5
|
+
export { FieldsetRootProvider, } from './fieldset-root-provider';
|
|
6
|
+
export { FieldsetLegend, } from './fieldset-legend';
|
|
7
|
+
export { fieldsetAnatomy } from './fieldset.anatomy';
|
|
8
|
+
export { useFieldsetContext } from './use-fieldset-context';
|
|
9
|
+
export * as Fieldset from './fieldset';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getWindow } from '@zag-js/dom-query';
|
|
2
|
+
import { createEffect, createMemo, createSignal, createUniqueId, onCleanup } from 'solid-js';
|
|
3
|
+
import { parts } from './fieldset.anatomy';
|
|
4
|
+
export const useFieldset = (props) => {
|
|
5
|
+
const { disabled = false, invalid = false } = props;
|
|
6
|
+
let rootRef;
|
|
7
|
+
const id = props.id ?? createUniqueId();
|
|
8
|
+
const errorTextId = `fieldset::${id}::error-text`;
|
|
9
|
+
const helperTextId = `fieldset::${id}::helper-text`;
|
|
10
|
+
const [hasErrorText, setHasErrorText] = createSignal(false);
|
|
11
|
+
const [hasHelperText, setHasHelperText] = createSignal(false);
|
|
12
|
+
createEffect(() => {
|
|
13
|
+
const rootNode = rootRef;
|
|
14
|
+
if (!rootNode)
|
|
15
|
+
return;
|
|
16
|
+
const win = getWindow(rootNode);
|
|
17
|
+
const doc = win.document;
|
|
18
|
+
const checkTextElements = () => {
|
|
19
|
+
setHasErrorText(!!doc.getElementById(errorTextId));
|
|
20
|
+
setHasHelperText(!!doc.getElementById(helperTextId));
|
|
21
|
+
};
|
|
22
|
+
checkTextElements();
|
|
23
|
+
const observer = new win.MutationObserver(checkTextElements);
|
|
24
|
+
observer.observe(rootNode, { childList: true, subtree: true });
|
|
25
|
+
onCleanup(() => observer.disconnect());
|
|
26
|
+
});
|
|
27
|
+
const labelIds = [];
|
|
28
|
+
if (hasErrorText() && invalid)
|
|
29
|
+
labelIds.push(errorTextId);
|
|
30
|
+
if (hasHelperText())
|
|
31
|
+
labelIds.push(helperTextId);
|
|
32
|
+
const getRootProps = () => ({
|
|
33
|
+
...parts.root.attrs,
|
|
34
|
+
disabled,
|
|
35
|
+
'data-disabled': dataAttr(disabled),
|
|
36
|
+
'data-invalid': dataAttr(invalid),
|
|
37
|
+
'aria-describedby': labelIds.join(' ') || undefined,
|
|
38
|
+
});
|
|
39
|
+
const getLegendProps = () => ({
|
|
40
|
+
...parts.legend.attrs,
|
|
41
|
+
'data-disabled': dataAttr(disabled),
|
|
42
|
+
'data-invalid': dataAttr(invalid),
|
|
43
|
+
});
|
|
44
|
+
const getHelperTextProps = () => ({
|
|
45
|
+
id: helperTextId,
|
|
46
|
+
...parts.helperText.attrs,
|
|
47
|
+
});
|
|
48
|
+
const getErrorTextProps = () => ({
|
|
49
|
+
id: errorTextId,
|
|
50
|
+
...parts.errorText.attrs,
|
|
51
|
+
'aria-live': 'polite',
|
|
52
|
+
});
|
|
53
|
+
return createMemo(() => ({
|
|
54
|
+
refs: {
|
|
55
|
+
rootRef,
|
|
56
|
+
},
|
|
57
|
+
disabled,
|
|
58
|
+
invalid,
|
|
59
|
+
getRootProps,
|
|
60
|
+
getLegendProps,
|
|
61
|
+
getHelperTextProps,
|
|
62
|
+
getErrorTextProps,
|
|
63
|
+
}));
|
|
64
|
+
};
|
|
65
|
+
const dataAttr = (condition) => (condition ? '' : undefined);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { For, Show } from 'solid-js';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { useHighlight } from './use-highlight';
|
|
4
|
+
export const Highlight = (props) => {
|
|
5
|
+
if (typeof props.text !== 'string') {
|
|
6
|
+
throw new Error('[ark-ui/highlight] text must be a string');
|
|
7
|
+
}
|
|
8
|
+
const [highlightProps, localProps] = createSplitProps()(props, [
|
|
9
|
+
'query',
|
|
10
|
+
'text',
|
|
11
|
+
'ignoreCase',
|
|
12
|
+
'matchAll',
|
|
13
|
+
]);
|
|
14
|
+
const chunks = useHighlight(highlightProps);
|
|
15
|
+
return (<For each={chunks()}>
|
|
16
|
+
{(chunk) => (<Show when={chunk.match} fallback={chunk.text}>
|
|
17
|
+
<mark {...localProps}>{chunk.text}</mark>
|
|
18
|
+
</Show>)}
|
|
19
|
+
</For>);
|
|
20
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createMemo } from 'solid-js';
|
|
2
|
+
const escapeRegexp = (term) => term.replace(/[|\\{}()[\]^$+*?.-]/g, (char) => `\\${char}`);
|
|
3
|
+
const buildRegex = (queryProp, flags) => {
|
|
4
|
+
const query = queryProp.filter(Boolean).map((text) => escapeRegexp(text));
|
|
5
|
+
return new RegExp(`(${query.join('|')})`, flags);
|
|
6
|
+
};
|
|
7
|
+
const getRegexFlags = (ignoreCase = true, matchAll = true) => `${ignoreCase ? 'i' : ''}${matchAll ? 'g' : ''}`;
|
|
8
|
+
const normalizeSpan = (spans, len) => {
|
|
9
|
+
const result = [];
|
|
10
|
+
const append = (start, end, match) => {
|
|
11
|
+
if (end - start > 0)
|
|
12
|
+
result.push({ start, end, match });
|
|
13
|
+
};
|
|
14
|
+
if (spans.length === 0) {
|
|
15
|
+
append(0, len, false);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
let lastIndex = 0;
|
|
19
|
+
for (const chunk of spans) {
|
|
20
|
+
append(lastIndex, chunk.start, false);
|
|
21
|
+
append(chunk.start, chunk.end, true);
|
|
22
|
+
lastIndex = chunk.end;
|
|
23
|
+
}
|
|
24
|
+
append(lastIndex, len, false);
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
const highlightWords = (props) => {
|
|
29
|
+
const flags = getRegexFlags(props.ignoreCase, props.matchAll);
|
|
30
|
+
const regex = buildRegex(Array.isArray(props.query) ? props.query : [props.query], flags);
|
|
31
|
+
const spans = [...props.text.matchAll(regex)].map((match) => ({
|
|
32
|
+
start: match.index || 0,
|
|
33
|
+
end: (match.index || 0) + match[0].length,
|
|
34
|
+
}));
|
|
35
|
+
return normalizeSpan(spans, props.text.length).map((chunk) => ({
|
|
36
|
+
text: props.text.slice(chunk.start, chunk.end),
|
|
37
|
+
match: !!chunk.match,
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
export const useHighlight = (props) => {
|
|
41
|
+
return createMemo(() => highlightWords(props));
|
|
42
|
+
};
|
|
@@ -11,8 +11,10 @@ export * from './dialog';
|
|
|
11
11
|
export * from './editable';
|
|
12
12
|
export * from './factory';
|
|
13
13
|
export * from './field';
|
|
14
|
+
export * from './fieldset';
|
|
14
15
|
export * from './file-upload';
|
|
15
16
|
export * from './format';
|
|
17
|
+
export * from './highlight';
|
|
16
18
|
export * from './hover-card';
|
|
17
19
|
export * from './menu';
|
|
18
20
|
export * from './number-input';
|
|
@@ -32,6 +34,7 @@ export * from './splitter';
|
|
|
32
34
|
export * from './switch';
|
|
33
35
|
export * from './tabs';
|
|
34
36
|
export * from './tags-input';
|
|
37
|
+
export * from './time-picker';
|
|
35
38
|
export * from './toast';
|
|
36
39
|
export * from './toggle-group';
|
|
37
40
|
export * from './tooltip';
|
|
@@ -13,7 +13,7 @@ export const SelectHiddenSelect = (props) => {
|
|
|
13
13
|
<option value=""/>
|
|
14
14
|
</Show>
|
|
15
15
|
<Index each={select().collection.items}>
|
|
16
|
-
{(
|
|
16
|
+
{(item) => (<option value={select().collection.getItemValue(item) ?? ''} disabled={select().collection.getItemDisabled(item)}/>)}
|
|
17
17
|
</Index>
|
|
18
18
|
</ark.select>);
|
|
19
19
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { TimePickerCell, } from './time-picker-cell';
|
|
2
|
+
export { TimePickerClearTrigger, } from './time-picker-clear-trigger';
|
|
3
|
+
export { TimePickerColumn, } from './time-picker-column';
|
|
4
|
+
export { TimePickerContent, } from './time-picker-content';
|
|
5
|
+
export { TimePickerContext, } from './time-picker-context';
|
|
6
|
+
export { TimePickerControl, } from './time-picker-control';
|
|
7
|
+
export { TimePickerInput, } from './time-picker-input';
|
|
8
|
+
export { TimePickerLabel, } from './time-picker-label';
|
|
9
|
+
export { TimePickerPositioner, } from './time-picker-positioner';
|
|
10
|
+
export { TimePickerRoot, } from './time-picker-root';
|
|
11
|
+
export { TimePickerRootProvider, } from './time-picker-root-provider';
|
|
12
|
+
export { TimePickerSpacer, } from './time-picker-spacer';
|
|
13
|
+
export { TimePickerTrigger, } from './time-picker-trigger';
|
|
14
|
+
export { useTimePicker } from './use-time-picker';
|
|
15
|
+
export { useTimePickerContext } from './use-time-picker-context';
|
|
16
|
+
export * as TimePicker from './time-picker';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { useTimePickerColumnPropsContext } from './use-time-picker-column-props-context';
|
|
5
|
+
import { useTimePickerContext } from './use-time-picker-context';
|
|
6
|
+
export const TimePickerCell = (props) => {
|
|
7
|
+
const [cellProps, localProps] = createSplitProps()(props, ['value']);
|
|
8
|
+
const timePicker = useTimePickerContext();
|
|
9
|
+
const columnProps = useTimePickerColumnPropsContext();
|
|
10
|
+
const unitToPropsMap = {
|
|
11
|
+
hour: () => timePicker().getHourCellProps(cellProps),
|
|
12
|
+
minute: () => timePicker().getMinuteCellProps(cellProps),
|
|
13
|
+
second: () => timePicker().getSecondCellProps(cellProps),
|
|
14
|
+
period: () => timePicker().getPeriodCellProps(cellProps),
|
|
15
|
+
};
|
|
16
|
+
const mergedProps = mergeProps(() => unitToPropsMap[columnProps.unit](), localProps);
|
|
17
|
+
return <ark.button {...mergedProps}/>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useTimePickerContext } from './use-time-picker-context';
|
|
4
|
+
export const TimePickerClearTrigger = (props) => {
|
|
5
|
+
const timePicker = useTimePickerContext();
|
|
6
|
+
const mergedProps = mergeProps(() => timePicker().getClearTriggerProps(), props);
|
|
7
|
+
return <ark.button {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { TimePickerColumnPropsProvider } from './use-time-picker-column-props-context';
|
|
5
|
+
import { useTimePickerContext } from './use-time-picker-context';
|
|
6
|
+
export const TimePickerColumn = (props) => {
|
|
7
|
+
const [columnProps, localProps] = createSplitProps()(props, ['unit']);
|
|
8
|
+
const timePicker = useTimePickerContext();
|
|
9
|
+
const mergedProps = mergeProps(() => timePicker().getColumnProps(columnProps), localProps);
|
|
10
|
+
return (<TimePickerColumnPropsProvider value={columnProps}>
|
|
11
|
+
<ark.div {...mergedProps}/>
|
|
12
|
+
</TimePickerColumnPropsProvider>);
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { Show } from 'solid-js';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { usePresenceContext } from '../presence';
|
|
5
|
+
import { useTimePickerContext } from './use-time-picker-context';
|
|
6
|
+
export const TimePickerContent = (props) => {
|
|
7
|
+
const timePicker = useTimePickerContext();
|
|
8
|
+
const presenceApi = usePresenceContext();
|
|
9
|
+
const mergedProps = mergeProps(() => timePicker().getContentProps(), () => presenceApi().presenceProps, props);
|
|
10
|
+
return (<Show when={!presenceApi().unmounted}>
|
|
11
|
+
<ark.div {...mergedProps}/>
|
|
12
|
+
</Show>);
|
|
13
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useTimePickerContext } from './use-time-picker-context';
|
|
4
|
+
export const TimePickerControl = (props) => {
|
|
5
|
+
const timePicker = useTimePickerContext();
|
|
6
|
+
const mergedProps = mergeProps(() => timePicker().getControlProps(), props);
|
|
7
|
+
return <ark.div {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useTimePickerContext } from './use-time-picker-context';
|
|
4
|
+
export const TimePickerInput = (props) => {
|
|
5
|
+
const timePicker = useTimePickerContext();
|
|
6
|
+
const mergedProps = mergeProps(() => timePicker().getInputProps(), props);
|
|
7
|
+
return <ark.input {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useTimePickerContext } from './use-time-picker-context';
|
|
4
|
+
export const TimePickerLabel = (props) => {
|
|
5
|
+
const timePicker = useTimePickerContext();
|
|
6
|
+
const mergedProps = mergeProps(() => timePicker().getLabelProps(), props);
|
|
7
|
+
return <ark.label {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { Show } from 'solid-js';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { usePresenceContext } from '../presence';
|
|
5
|
+
import { useTimePickerContext } from './use-time-picker-context';
|
|
6
|
+
export const TimePickerPositioner = (props) => {
|
|
7
|
+
const timePicker = useTimePickerContext();
|
|
8
|
+
const mergedProps = mergeProps(() => timePicker().getPositionerProps(), props);
|
|
9
|
+
const presenceApi = usePresenceContext();
|
|
10
|
+
return (<Show when={!presenceApi().unmounted}>
|
|
11
|
+
<ark.div {...mergedProps}/>
|
|
12
|
+
</Show>);
|
|
13
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { PresenceProvider, splitPresenceProps, usePresence, } from '../presence';
|
|
5
|
+
import { TimePickerProvider } from './use-time-picker-context';
|
|
6
|
+
export const TimePickerRootProvider = (props) => {
|
|
7
|
+
const [presenceProps, timePickerProps] = splitPresenceProps(props);
|
|
8
|
+
const [{ value: timePicker }, localProps] = createSplitProps()(timePickerProps, ['value']);
|
|
9
|
+
const apiPresence = usePresence(mergeProps(presenceProps, () => ({ present: timePicker().open })));
|
|
10
|
+
const mergedProps = mergeProps(() => timePicker().getRootProps(), localProps);
|
|
11
|
+
return (<TimePickerProvider value={timePicker}>
|
|
12
|
+
<PresenceProvider value={apiPresence}>
|
|
13
|
+
<ark.div {...mergedProps}/>
|
|
14
|
+
</PresenceProvider>
|
|
15
|
+
</TimePickerProvider>);
|
|
16
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { createSplitProps } from '../../utils/create-split-props';
|
|
3
|
+
import { ark } from '../factory';
|
|
4
|
+
import { PresenceProvider, splitPresenceProps, usePresence, } from '../presence';
|
|
5
|
+
import { useTimePicker } from './use-time-picker';
|
|
6
|
+
import { TimePickerProvider } from './use-time-picker-context';
|
|
7
|
+
export const TimePickerRoot = (props) => {
|
|
8
|
+
const [presenceProps, timePickerProps] = splitPresenceProps(props);
|
|
9
|
+
const [useTimePickerProps, localProps] = createSplitProps()(timePickerProps, [
|
|
10
|
+
'allowSeconds',
|
|
11
|
+
'defaultOpen',
|
|
12
|
+
'defaultValue',
|
|
13
|
+
'disableLayer',
|
|
14
|
+
'disabled',
|
|
15
|
+
'id',
|
|
16
|
+
'ids',
|
|
17
|
+
'locale',
|
|
18
|
+
'max',
|
|
19
|
+
'min',
|
|
20
|
+
'name',
|
|
21
|
+
'onFocusChange',
|
|
22
|
+
'onOpenChange',
|
|
23
|
+
'onValueChange',
|
|
24
|
+
'open',
|
|
25
|
+
'placeholder',
|
|
26
|
+
'positioning',
|
|
27
|
+
'readOnly',
|
|
28
|
+
'steps',
|
|
29
|
+
'value',
|
|
30
|
+
]);
|
|
31
|
+
const timePicker = useTimePicker(useTimePickerProps);
|
|
32
|
+
const apiPresence = usePresence(mergeProps(presenceProps, () => ({ present: timePicker().open })));
|
|
33
|
+
const mergedProps = mergeProps(() => timePicker().getRootProps(), localProps);
|
|
34
|
+
return (<TimePickerProvider value={timePicker}>
|
|
35
|
+
<PresenceProvider value={apiPresence}>
|
|
36
|
+
<ark.div {...mergedProps}/>
|
|
37
|
+
</PresenceProvider>
|
|
38
|
+
</TimePickerProvider>);
|
|
39
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useTimePickerContext } from './use-time-picker-context';
|
|
4
|
+
export const TimePickerSpacer = (props) => {
|
|
5
|
+
const timePicker = useTimePickerContext();
|
|
6
|
+
const mergedProps = mergeProps(() => timePicker().getSpacerProps(), props);
|
|
7
|
+
return <ark.div {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mergeProps } from '@zag-js/solid';
|
|
2
|
+
import { ark } from '../factory';
|
|
3
|
+
import { useTimePickerContext } from './use-time-picker-context';
|
|
4
|
+
export const TimePickerTrigger = (props) => {
|
|
5
|
+
const timePicker = useTimePickerContext();
|
|
6
|
+
const mergedProps = mergeProps(() => timePicker().getTriggerProps(), props);
|
|
7
|
+
return <ark.button {...mergedProps}/>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { TimePickerCell as Cell, } from './time-picker-cell';
|
|
2
|
+
export { TimePickerClearTrigger as ClearTrigger, } from './time-picker-clear-trigger';
|
|
3
|
+
export { TimePickerColumn as Column, } from './time-picker-column';
|
|
4
|
+
export { TimePickerContent as Content, } from './time-picker-content';
|
|
5
|
+
export { TimePickerContext as Context, } from './time-picker-context';
|
|
6
|
+
export { TimePickerControl as Control, } from './time-picker-control';
|
|
7
|
+
export { TimePickerInput as Input, } from './time-picker-input';
|
|
8
|
+
export { TimePickerLabel as Label, } from './time-picker-label';
|
|
9
|
+
export { TimePickerPositioner as Positioner, } from './time-picker-positioner';
|
|
10
|
+
export { TimePickerRoot as Root, } from './time-picker-root';
|
|
11
|
+
export { TimePickerRootProvider as RootProvider, } from './time-picker-root-provider';
|
|
12
|
+
export { TimePickerSpacer as Spacer, } from './time-picker-spacer';
|
|
13
|
+
export { TimePickerTrigger as Trigger, } from './time-picker-trigger';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { parseTime } from '@internationalized/date';
|
|
2
|
+
import { normalizeProps, useMachine } from '@zag-js/solid';
|
|
3
|
+
import * as timePicker from '@zag-js/time-picker';
|
|
4
|
+
import { createMemo, createUniqueId } from 'solid-js';
|
|
5
|
+
import { useEnvironmentContext, useLocaleContext } from '../../providers';
|
|
6
|
+
export const useTimePicker = (props = {}) => {
|
|
7
|
+
const locale = useLocaleContext();
|
|
8
|
+
const environment = useEnvironmentContext();
|
|
9
|
+
const id = createUniqueId();
|
|
10
|
+
const context = createMemo(() => ({
|
|
11
|
+
id,
|
|
12
|
+
dir: locale().dir,
|
|
13
|
+
getRootNode: environment().getRootNode,
|
|
14
|
+
open: props.defaultOpen,
|
|
15
|
+
'open.controlled': props.open !== undefined,
|
|
16
|
+
...props,
|
|
17
|
+
value: props.defaultValue ? parseTime(props.defaultValue) : undefined,
|
|
18
|
+
min: props.min ? parseTime(props.min) : undefined,
|
|
19
|
+
max: props.max ? parseTime(props.max) : undefined,
|
|
20
|
+
}));
|
|
21
|
+
const [state, send] = useMachine(timePicker.machine(context()), { context });
|
|
22
|
+
return createMemo(() => timePicker.connect(state, send, normalizeProps));
|
|
23
|
+
};
|
|
@@ -3,7 +3,7 @@ import { type UsePresenceProps } from '../presence';
|
|
|
3
3
|
import { type UseDialogProps } from './use-dialog';
|
|
4
4
|
export interface DialogRootBaseProps extends UseDialogProps, UsePresenceProps {
|
|
5
5
|
}
|
|
6
|
-
export interface DialogRootProps extends
|
|
6
|
+
export interface DialogRootProps extends DialogRootBaseProps {
|
|
7
7
|
children?: JSX.Element;
|
|
8
8
|
}
|
|
9
9
|
export declare const DialogRoot: (props: DialogRootProps) => JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { JSX } from 'solid-js';
|
|
2
|
+
import { type UseFieldsetContext } from './use-fieldset-context';
|
|
3
|
+
export interface FieldsetContextProps {
|
|
4
|
+
children: (context: UseFieldsetContext) => JSX.Element;
|
|
5
|
+
}
|
|
6
|
+
export declare const FieldsetContext: (props: FieldsetContextProps) => JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HTMLProps, type PolymorphicProps } from '../factory';
|
|
2
|
+
export interface FieldsetErrorTextBaseProps extends PolymorphicProps<'span'> {
|
|
3
|
+
}
|
|
4
|
+
export interface FieldsetErrorTextProps extends HTMLProps<'span'>, FieldsetErrorTextBaseProps {
|
|
5
|
+
}
|
|
6
|
+
export declare const FieldsetErrorText: (props: FieldsetErrorTextProps) => import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HTMLProps, type PolymorphicProps } from '../factory';
|
|
2
|
+
export interface FieldsetHelperTextBaseProps extends PolymorphicProps<'span'> {
|
|
3
|
+
}
|
|
4
|
+
export interface FieldsetHelperTextProps extends HTMLProps<'span'>, FieldsetHelperTextBaseProps {
|
|
5
|
+
}
|
|
6
|
+
export declare const FieldsetHelperText: (props: FieldsetHelperTextProps) => import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HTMLProps, type PolymorphicProps } from '../factory';
|
|
2
|
+
export interface FieldsetLegendBaseProps extends PolymorphicProps<'legend'> {
|
|
3
|
+
}
|
|
4
|
+
export interface FieldsetLegendProps extends HTMLProps<'legend'>, FieldsetLegendBaseProps {
|
|
5
|
+
}
|
|
6
|
+
export declare const FieldsetLegend: (props: FieldsetLegendProps) => import("solid-js").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type HTMLProps, type PolymorphicProps } from '../factory';
|
|
2
|
+
import type { UseFieldsetReturn } from './use-fieldset';
|
|
3
|
+
interface RootProviderProps {
|
|
4
|
+
value: UseFieldsetReturn;
|
|
5
|
+
}
|
|
6
|
+
export interface FieldsetRootProviderBaseProps extends RootProviderProps, PolymorphicProps<'fieldset'> {
|
|
7
|
+
}
|
|
8
|
+
export interface FieldsetRootProviderProps extends HTMLProps<'fieldset'>, FieldsetRootProviderBaseProps {
|
|
9
|
+
}
|
|
10
|
+
export declare const FieldsetRootProvider: (props: FieldsetRootProviderProps) => import("solid-js").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type HTMLProps, type PolymorphicProps } from '../factory';
|
|
2
|
+
import { type UseFieldsetProps } from './use-fieldset';
|
|
3
|
+
export interface FieldsetRootBaseProps extends UseFieldsetProps, PolymorphicProps<'fieldset'> {
|
|
4
|
+
}
|
|
5
|
+
export interface FieldsetRootProps extends HTMLProps<'fieldset'>, FieldsetRootBaseProps {
|
|
6
|
+
}
|
|
7
|
+
export declare const FieldsetRoot: {
|
|
8
|
+
(props: FieldsetRootProps): import("solid-js").JSX.Element;
|
|
9
|
+
displayName: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { FieldsetRoot as Root, type FieldsetRootProps as RootProps, type FieldsetRootBaseProps as RootBaseProps, } from './fieldset-root';
|
|
2
|
+
export { FieldsetRootProvider as RootProvider, type FieldsetRootProviderProps as RootProviderProps, type FieldsetRootProviderBaseProps as RootProviderBaseProps, } from './fieldset-root-provider';
|
|
3
|
+
export { FieldsetLegend as Legend, type FieldsetLegendProps as LegendProps, type FieldsetLegendBaseProps as LegendBaseProps, } from './fieldset-legend';
|
|
4
|
+
export { FieldsetHelperText as HelperText, type FieldsetHelperTextProps as HelperTextProps, type FieldsetHelperTextBaseProps as HelperTextBaseProps, } from './fieldset-helper-text';
|
|
5
|
+
export { FieldsetErrorText as ErrorText, type FieldsetErrorTextProps as ErrorTextProps, type FieldsetErrorTextBaseProps as ErrorTextBaseProps, } from './fieldset-error-text';
|
|
6
|
+
export { FieldsetContext as Context, type FieldsetContextProps as ContextProps, } from './fieldset-context';
|