@journ/nude-solid 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +159 -2
- package/dist/accordion.d.ts +42 -0
- package/dist/accordion.jsx +64 -0
- package/dist/alert.d.ts +15 -0
- package/dist/alert.jsx +9 -0
- package/dist/badge.d.ts +2 -0
- package/dist/badge.jsx +3 -0
- package/dist/bulk-bar.d.ts +9 -0
- package/dist/bulk-bar.jsx +6 -0
- package/dist/button.d.ts +8 -0
- package/dist/button.jsx +9 -0
- package/dist/card.d.ts +17 -0
- package/dist/card.jsx +10 -0
- package/dist/checkbox.d.ts +9 -0
- package/dist/checkbox.jsx +3 -0
- package/dist/collapsible.d.ts +35 -0
- package/dist/collapsible.jsx +39 -0
- package/dist/composer.d.ts +7 -0
- package/dist/composer.jsx +5 -0
- package/dist/controllable.d.ts +11 -0
- package/dist/controllable.js +26 -0
- package/dist/description-list.d.ts +9 -0
- package/dist/description-list.jsx +6 -0
- package/dist/dialog.d.ts +49 -0
- package/dist/dialog.jsx +84 -0
- package/dist/divider.d.ts +2 -0
- package/dist/divider.jsx +3 -0
- package/dist/empty-state.d.ts +13 -0
- package/dist/empty-state.jsx +8 -0
- package/dist/events.d.ts +4 -0
- package/dist/events.js +6 -0
- package/dist/field.d.ts +40 -0
- package/dist/field.jsx +55 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +36 -0
- package/dist/input.d.ts +2 -0
- package/dist/input.jsx +3 -0
- package/dist/lib/form-reset.d.ts +4 -0
- package/dist/lib/form-reset.js +17 -0
- package/dist/lib/toggle.d.ts +40 -0
- package/dist/lib/toggle.jsx +70 -0
- package/dist/list-row.d.ts +19 -0
- package/dist/list-row.jsx +11 -0
- package/dist/nav-bar.d.ts +7 -0
- package/dist/nav-bar.jsx +5 -0
- package/dist/page-header.d.ts +9 -0
- package/dist/page-header.jsx +6 -0
- package/dist/page.d.ts +9 -0
- package/dist/page.jsx +6 -0
- package/dist/part.d.ts +8 -0
- package/dist/part.jsx +10 -0
- package/dist/portal.d.ts +8 -0
- package/dist/portal.jsx +3 -0
- package/dist/progress.d.ts +8 -0
- package/dist/progress.jsx +3 -0
- package/dist/radio.d.ts +45 -0
- package/dist/radio.jsx +83 -0
- package/dist/select.d.ts +15 -0
- package/dist/select.jsx +33 -0
- package/dist/sidebar.d.ts +21 -0
- package/dist/sidebar.jsx +12 -0
- package/dist/skeleton.d.ts +2 -0
- package/dist/skeleton.jsx +3 -0
- package/dist/stat.d.ts +11 -0
- package/dist/stat.jsx +7 -0
- package/dist/switch.d.ts +9 -0
- package/dist/switch.jsx +3 -0
- package/dist/table.d.ts +17 -0
- package/dist/table.jsx +10 -0
- package/dist/tabs.d.ts +49 -0
- package/dist/tabs.jsx +68 -0
- package/dist/tag-input.d.ts +52 -0
- package/dist/tag-input.jsx +107 -0
- package/dist/text.d.ts +2 -0
- package/dist/text.jsx +3 -0
- package/dist/textarea.d.ts +2 -0
- package/dist/textarea.jsx +3 -0
- package/dist/tile.d.ts +15 -0
- package/dist/tile.jsx +9 -0
- package/package.json +277 -3
package/dist/dialog.jsx
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createContext, createEffect, createUniqueId, omit, useContext } from 'solid-js';
|
|
2
|
+
import { Button } from './button.jsx';
|
|
3
|
+
import { createControllable } from './controllable.js';
|
|
4
|
+
import { composeEventHandlers } from './events.js';
|
|
5
|
+
import { part } from './part.jsx';
|
|
6
|
+
const Context = createContext();
|
|
7
|
+
const useDialog = () => useContext(Context);
|
|
8
|
+
const Provider = (props) => (<Context value={props}>{props.children}</Context>);
|
|
9
|
+
const Root = (props) => {
|
|
10
|
+
const id = createUniqueId();
|
|
11
|
+
const [open, setOpen] = createControllable({
|
|
12
|
+
value: () => props.open,
|
|
13
|
+
defaultValue: () => props.defaultOpen ?? false,
|
|
14
|
+
onChange: next => props.onOpenChange?.(next),
|
|
15
|
+
});
|
|
16
|
+
return (<Provider state={{
|
|
17
|
+
get open() {
|
|
18
|
+
return open();
|
|
19
|
+
},
|
|
20
|
+
}} actions={{ setOpen }} meta={{
|
|
21
|
+
id,
|
|
22
|
+
titleId: `${id}-title`,
|
|
23
|
+
get descriptionId() {
|
|
24
|
+
return props.descriptionId;
|
|
25
|
+
},
|
|
26
|
+
get modal() {
|
|
27
|
+
return props.modal ?? true;
|
|
28
|
+
},
|
|
29
|
+
}}>
|
|
30
|
+
{props.children}
|
|
31
|
+
</Provider>);
|
|
32
|
+
};
|
|
33
|
+
const Trigger = (props) => {
|
|
34
|
+
const context = useDialog();
|
|
35
|
+
return (<Button {...omit(props, 'onClick')} data-slot='dialog-trigger' aria-haspopup='dialog' aria-expanded={context.state.open ? 'true' : 'false'} aria-controls={context.meta.id} onClick={event => composeEventHandlers(props.onClick, () => context.actions.setOpen(true))(event)}/>);
|
|
36
|
+
};
|
|
37
|
+
const Close = (props) => {
|
|
38
|
+
const context = useDialog();
|
|
39
|
+
return (<Button {...omit(props, 'onClick')} data-slot='dialog-close' onClick={event => composeEventHandlers(props.onClick, () => context.actions.setOpen(false))(event)}/>);
|
|
40
|
+
};
|
|
41
|
+
const Content = (props) => {
|
|
42
|
+
const context = useDialog();
|
|
43
|
+
let element;
|
|
44
|
+
createEffect(() => ({ open: context.state.open, modal: context.meta.modal }), state => {
|
|
45
|
+
if (!element?.isConnected)
|
|
46
|
+
return;
|
|
47
|
+
if (state.open && !element.open) {
|
|
48
|
+
if (state.modal)
|
|
49
|
+
element.showModal();
|
|
50
|
+
else
|
|
51
|
+
element.show();
|
|
52
|
+
}
|
|
53
|
+
else if (!state.open && element.open)
|
|
54
|
+
element.close();
|
|
55
|
+
});
|
|
56
|
+
return (<dialog {...omit(props, 'ref', 'onCancel', 'onClose')} ref={[
|
|
57
|
+
props.ref,
|
|
58
|
+
next => {
|
|
59
|
+
element = next;
|
|
60
|
+
},
|
|
61
|
+
]} data-slot='dialog-content' id={context.meta.id} aria-labelledby={context.meta.titleId} aria-describedby={context.meta.descriptionId ?? props['aria-describedby']} onCancel={event => {
|
|
62
|
+
composeEventHandlers(props.onCancel, () => {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
context.actions.setOpen(false);
|
|
65
|
+
})(event);
|
|
66
|
+
}} onClose={event => {
|
|
67
|
+
composeEventHandlers(props.onClose, () => {
|
|
68
|
+
if (context.state.open && !event.currentTarget.open)
|
|
69
|
+
context.actions.setOpen(false);
|
|
70
|
+
})(event);
|
|
71
|
+
}}/>);
|
|
72
|
+
};
|
|
73
|
+
const Title = (props) => {
|
|
74
|
+
const context = useDialog();
|
|
75
|
+
return <h2 {...props} data-slot='dialog-title' id={context.meta.titleId}/>;
|
|
76
|
+
};
|
|
77
|
+
const Description = (props) => {
|
|
78
|
+
const context = useDialog();
|
|
79
|
+
return <p {...props} data-slot='dialog-description' id={context.meta.descriptionId ?? props.id}/>;
|
|
80
|
+
};
|
|
81
|
+
const Body = part('div', 'dialog-body');
|
|
82
|
+
const Actions = part('div', 'dialog-actions');
|
|
83
|
+
const Dialog = { Root, Provider, Trigger, Close, Content, Title, Description, Body, Actions };
|
|
84
|
+
export { Dialog, useDialog };
|
package/dist/divider.jsx
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const Root: import("./part.jsx").Part<"div">;
|
|
2
|
+
declare const Icon: import("./part.jsx").Part<"span">;
|
|
3
|
+
declare const Title: import("./part.jsx").Part<"h3">;
|
|
4
|
+
declare const Description: import("./part.jsx").Part<"p">;
|
|
5
|
+
declare const Actions: import("./part.jsx").Part<"div">;
|
|
6
|
+
declare const EmptyState: {
|
|
7
|
+
Root: typeof Root;
|
|
8
|
+
Icon: typeof Icon;
|
|
9
|
+
Title: typeof Title;
|
|
10
|
+
Description: typeof Description;
|
|
11
|
+
Actions: typeof Actions;
|
|
12
|
+
};
|
|
13
|
+
export { EmptyState };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { part } from './part.jsx';
|
|
2
|
+
const Root = part('div', 'empty-state');
|
|
3
|
+
const Icon = part('span', 'empty-state-icon', { 'aria-hidden': 'true' });
|
|
4
|
+
const Title = part('h3', 'empty-state-title');
|
|
5
|
+
const Description = part('p', 'empty-state-description');
|
|
6
|
+
const Actions = part('div', 'empty-state-actions');
|
|
7
|
+
const EmptyState = { Root, Icon, Title, Description, Actions };
|
|
8
|
+
export { EmptyState };
|
package/dist/events.d.ts
ADDED
package/dist/events.js
ADDED
package/dist/field.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { JSX } from '@solidjs/web';
|
|
2
|
+
import { type ParentProps } from 'solid-js';
|
|
3
|
+
type FieldContextValue = {
|
|
4
|
+
state: {
|
|
5
|
+
readonly invalid: boolean;
|
|
6
|
+
readonly disabled: boolean;
|
|
7
|
+
readonly required: boolean;
|
|
8
|
+
};
|
|
9
|
+
meta: {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly descriptionId?: string;
|
|
12
|
+
readonly errorId?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
declare const useField: () => FieldContextValue;
|
|
16
|
+
declare const Provider: (props: ParentProps<FieldContextValue>) => JSX.Element;
|
|
17
|
+
type FieldProps = JSX.HTMLAttributes<HTMLDivElement> & {
|
|
18
|
+
invalid?: boolean;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
descriptionId?: string;
|
|
22
|
+
errorId?: string;
|
|
23
|
+
};
|
|
24
|
+
declare const Root: (props: FieldProps) => JSX.Element;
|
|
25
|
+
declare const Label: (props: JSX.LabelHTMLAttributes<HTMLLabelElement>) => JSX.Element;
|
|
26
|
+
declare const Control: (props: JSX.InputHTMLAttributes<HTMLInputElement>) => JSX.Element;
|
|
27
|
+
declare const Description: (props: JSX.HTMLAttributes<HTMLParagraphElement>) => JSX.Element;
|
|
28
|
+
declare const FieldError: (props: JSX.HTMLAttributes<HTMLParagraphElement>) => JSX.Element;
|
|
29
|
+
declare const Field: {
|
|
30
|
+
Root: typeof Root;
|
|
31
|
+
Provider: typeof Provider;
|
|
32
|
+
Label: typeof Label;
|
|
33
|
+
Control: typeof Control;
|
|
34
|
+
Description: typeof Description;
|
|
35
|
+
Error: typeof FieldError;
|
|
36
|
+
Frame: import("./part.jsx").Part<"div">;
|
|
37
|
+
Action: import("./part.jsx").Part<"div">;
|
|
38
|
+
};
|
|
39
|
+
export { Field, useField };
|
|
40
|
+
export type { FieldContextValue, FieldProps };
|
package/dist/field.jsx
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Show, createContext, createUniqueId, omit, useContext } from 'solid-js';
|
|
2
|
+
import { part } from './part.jsx';
|
|
3
|
+
const Context = createContext();
|
|
4
|
+
const useField = () => useContext(Context);
|
|
5
|
+
const Provider = (props) => (<Context value={props}>{props.children}</Context>);
|
|
6
|
+
const Root = (props) => {
|
|
7
|
+
const id = createUniqueId();
|
|
8
|
+
return (<Provider state={{
|
|
9
|
+
get invalid() {
|
|
10
|
+
return props.invalid ?? false;
|
|
11
|
+
},
|
|
12
|
+
get disabled() {
|
|
13
|
+
return props.disabled ?? false;
|
|
14
|
+
},
|
|
15
|
+
get required() {
|
|
16
|
+
return props.required ?? false;
|
|
17
|
+
},
|
|
18
|
+
}} meta={{
|
|
19
|
+
get id() {
|
|
20
|
+
return typeof props.id === 'string' ? props.id : id;
|
|
21
|
+
},
|
|
22
|
+
get descriptionId() {
|
|
23
|
+
return props.descriptionId;
|
|
24
|
+
},
|
|
25
|
+
get errorId() {
|
|
26
|
+
return props.errorId;
|
|
27
|
+
},
|
|
28
|
+
}}>
|
|
29
|
+
<div {...omit(props, 'invalid', 'disabled', 'required', 'descriptionId', 'errorId', 'id')} data-slot='field' data-invalid={props.invalid || undefined} data-disabled={props.disabled || undefined}/>
|
|
30
|
+
</Provider>);
|
|
31
|
+
};
|
|
32
|
+
const Label = (props) => {
|
|
33
|
+
const field = useField();
|
|
34
|
+
return <label {...props} data-slot='field-label' for={field.meta.id}/>;
|
|
35
|
+
};
|
|
36
|
+
const Control = (props) => {
|
|
37
|
+
const field = useField();
|
|
38
|
+
return (<input {...props} data-slot='field-control' id={field.meta.id} disabled={field.state.disabled || props.disabled} required={field.state.required || props.required} aria-invalid={field.state.invalid ? 'true' : undefined} aria-describedby={[props['aria-describedby'], field.meta.descriptionId, field.state.invalid ? field.meta.errorId : undefined]
|
|
39
|
+
.filter(Boolean)
|
|
40
|
+
.join(' ') || undefined}/>);
|
|
41
|
+
};
|
|
42
|
+
const Description = (props) => {
|
|
43
|
+
const field = useField();
|
|
44
|
+
return <p {...props} data-slot='field-description' id={field.meta.descriptionId ?? props.id}/>;
|
|
45
|
+
};
|
|
46
|
+
const FieldError = (props) => {
|
|
47
|
+
const field = useField();
|
|
48
|
+
return (<Show when={field.state.invalid}>
|
|
49
|
+
<p {...props} data-slot='field-error' id={field.meta.errorId ?? props.id} role='alert'/>
|
|
50
|
+
</Show>);
|
|
51
|
+
};
|
|
52
|
+
const Frame = part('div', 'field-frame');
|
|
53
|
+
const Action = part('div', 'field-action');
|
|
54
|
+
const Field = { Root, Provider, Label, Control, Description, Error: FieldError, Frame, Action };
|
|
55
|
+
export { Field, useField };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export * from './accordion.jsx';
|
|
2
|
+
export * from './alert.jsx';
|
|
3
|
+
export * from './badge.jsx';
|
|
4
|
+
export * from './bulk-bar.jsx';
|
|
5
|
+
export * from './button.jsx';
|
|
6
|
+
export * from './card.jsx';
|
|
7
|
+
export * from './checkbox.jsx';
|
|
8
|
+
export * from './collapsible.jsx';
|
|
9
|
+
export * from './composer.jsx';
|
|
10
|
+
export * from './controllable.js';
|
|
11
|
+
export * from './description-list.jsx';
|
|
12
|
+
export * from './dialog.jsx';
|
|
13
|
+
export * from './divider.jsx';
|
|
14
|
+
export * from './empty-state.jsx';
|
|
15
|
+
export * from './events.js';
|
|
16
|
+
export * from './field.jsx';
|
|
17
|
+
export * from './input.jsx';
|
|
18
|
+
export * from './list-row.jsx';
|
|
19
|
+
export * from './nav-bar.jsx';
|
|
20
|
+
export * from './page-header.jsx';
|
|
21
|
+
export * from './page.jsx';
|
|
22
|
+
export * from './part.jsx';
|
|
23
|
+
export * from './portal.jsx';
|
|
24
|
+
export * from './progress.jsx';
|
|
25
|
+
export * from './radio.jsx';
|
|
26
|
+
export * from './select.jsx';
|
|
27
|
+
export * from './sidebar.jsx';
|
|
28
|
+
export * from './skeleton.jsx';
|
|
29
|
+
export * from './stat.jsx';
|
|
30
|
+
export * from './switch.jsx';
|
|
31
|
+
export * from './table.jsx';
|
|
32
|
+
export * from './tabs.jsx';
|
|
33
|
+
export * from './tag-input.jsx';
|
|
34
|
+
export * from './text.jsx';
|
|
35
|
+
export * from './textarea.jsx';
|
|
36
|
+
export * from './tile.jsx';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export * from './accordion.jsx';
|
|
2
|
+
export * from './alert.jsx';
|
|
3
|
+
export * from './badge.jsx';
|
|
4
|
+
export * from './bulk-bar.jsx';
|
|
5
|
+
export * from './button.jsx';
|
|
6
|
+
export * from './card.jsx';
|
|
7
|
+
export * from './checkbox.jsx';
|
|
8
|
+
export * from './collapsible.jsx';
|
|
9
|
+
export * from './composer.jsx';
|
|
10
|
+
export * from './controllable.js';
|
|
11
|
+
export * from './description-list.jsx';
|
|
12
|
+
export * from './dialog.jsx';
|
|
13
|
+
export * from './divider.jsx';
|
|
14
|
+
export * from './empty-state.jsx';
|
|
15
|
+
export * from './events.js';
|
|
16
|
+
export * from './field.jsx';
|
|
17
|
+
export * from './input.jsx';
|
|
18
|
+
export * from './list-row.jsx';
|
|
19
|
+
export * from './nav-bar.jsx';
|
|
20
|
+
export * from './page-header.jsx';
|
|
21
|
+
export * from './page.jsx';
|
|
22
|
+
export * from './part.jsx';
|
|
23
|
+
export * from './portal.jsx';
|
|
24
|
+
export * from './progress.jsx';
|
|
25
|
+
export * from './radio.jsx';
|
|
26
|
+
export * from './select.jsx';
|
|
27
|
+
export * from './sidebar.jsx';
|
|
28
|
+
export * from './skeleton.jsx';
|
|
29
|
+
export * from './stat.jsx';
|
|
30
|
+
export * from './switch.jsx';
|
|
31
|
+
export * from './table.jsx';
|
|
32
|
+
export * from './tabs.jsx';
|
|
33
|
+
export * from './tag-input.jsx';
|
|
34
|
+
export * from './text.jsx';
|
|
35
|
+
export * from './textarea.jsx';
|
|
36
|
+
export * from './tile.jsx';
|
package/dist/input.d.ts
ADDED
package/dist/input.jsx
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { onSettled } from 'solid-js';
|
|
2
|
+
const createFormReset = (element, reset) => {
|
|
3
|
+
onSettled(() => {
|
|
4
|
+
const form = element()?.form;
|
|
5
|
+
if (!form)
|
|
6
|
+
return;
|
|
7
|
+
const controller = new AbortController();
|
|
8
|
+
form.addEventListener('reset', event => {
|
|
9
|
+
queueMicrotask(() => {
|
|
10
|
+
if (!event.defaultPrevented && !controller.signal.aborted)
|
|
11
|
+
reset();
|
|
12
|
+
});
|
|
13
|
+
}, { signal: controller.signal });
|
|
14
|
+
return () => controller.abort();
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export { createFormReset };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { JSX } from '@solidjs/web';
|
|
2
|
+
import { type ParentProps } from 'solid-js';
|
|
3
|
+
type ToggleContextValue = {
|
|
4
|
+
state: {
|
|
5
|
+
readonly checked: boolean;
|
|
6
|
+
};
|
|
7
|
+
actions: {
|
|
8
|
+
setChecked: (checked: boolean) => void;
|
|
9
|
+
reset?: () => void;
|
|
10
|
+
};
|
|
11
|
+
meta: {
|
|
12
|
+
readonly disabled: boolean;
|
|
13
|
+
readonly required: boolean;
|
|
14
|
+
readonly name?: string;
|
|
15
|
+
readonly value?: string;
|
|
16
|
+
readonly id: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
type ToggleProps = Omit<JSX.LabelHTMLAttributes<HTMLLabelElement>, 'onChange'> & {
|
|
20
|
+
checked?: boolean;
|
|
21
|
+
defaultChecked?: boolean;
|
|
22
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
required?: boolean;
|
|
25
|
+
name?: string;
|
|
26
|
+
value?: string;
|
|
27
|
+
};
|
|
28
|
+
type ToggleControlProps = Omit<JSX.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'checked' | 'type'> & {
|
|
29
|
+
onChange?: JSX.EventHandler<HTMLInputElement, Event>;
|
|
30
|
+
};
|
|
31
|
+
declare const createToggle: (slot: 'checkbox' | 'switch') => {
|
|
32
|
+
Root: (props: ToggleProps) => JSX.Element;
|
|
33
|
+
Provider: (props: ParentProps<ToggleContextValue>) => JSX.Element;
|
|
34
|
+
Control: (props: ToggleControlProps) => JSX.Element;
|
|
35
|
+
Indicator: (props: JSX.HTMLAttributes<HTMLSpanElement>) => JSX.Element;
|
|
36
|
+
Thumb: (props: JSX.HTMLAttributes<HTMLSpanElement>) => JSX.Element;
|
|
37
|
+
useToggle: () => ToggleContextValue;
|
|
38
|
+
};
|
|
39
|
+
export { createToggle };
|
|
40
|
+
export type { ToggleContextValue, ToggleControlProps, ToggleProps };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Show, createContext, createUniqueId, omit, onSettled, useContext } from 'solid-js';
|
|
2
|
+
import { createControllable } from '../controllable.js';
|
|
3
|
+
import { composeEventHandlers } from '../events.js';
|
|
4
|
+
import { createFormReset } from './form-reset.js';
|
|
5
|
+
const createToggle = (slot) => {
|
|
6
|
+
const Context = createContext();
|
|
7
|
+
const useToggle = () => useContext(Context);
|
|
8
|
+
const Provider = (props) => (<Context value={props}>{props.children}</Context>);
|
|
9
|
+
const Root = (props) => {
|
|
10
|
+
const id = createUniqueId();
|
|
11
|
+
const [checked, setChecked] = createControllable({
|
|
12
|
+
value: () => props.checked,
|
|
13
|
+
defaultValue: () => props.defaultChecked ?? false,
|
|
14
|
+
onChange: next => props.onCheckedChange?.(next),
|
|
15
|
+
});
|
|
16
|
+
return (<Provider state={{
|
|
17
|
+
get checked() {
|
|
18
|
+
return checked();
|
|
19
|
+
},
|
|
20
|
+
}} actions={{ setChecked, reset: () => setChecked(props.defaultChecked ?? false) }} meta={{
|
|
21
|
+
id,
|
|
22
|
+
get disabled() {
|
|
23
|
+
return props.disabled ?? false;
|
|
24
|
+
},
|
|
25
|
+
get required() {
|
|
26
|
+
return props.required ?? false;
|
|
27
|
+
},
|
|
28
|
+
get name() {
|
|
29
|
+
return props.name;
|
|
30
|
+
},
|
|
31
|
+
get value() {
|
|
32
|
+
return props.value;
|
|
33
|
+
},
|
|
34
|
+
}}>
|
|
35
|
+
<label {...omit(props, 'checked', 'defaultChecked', 'onCheckedChange', 'disabled', 'required', 'name', 'value')} data-slot={slot} data-state={checked() ? 'checked' : 'unchecked'} data-disabled={props.disabled || undefined}/>
|
|
36
|
+
</Provider>);
|
|
37
|
+
};
|
|
38
|
+
const Control = (props) => {
|
|
39
|
+
const context = useToggle();
|
|
40
|
+
let element;
|
|
41
|
+
createFormReset(() => element, () => {
|
|
42
|
+
context.actions.reset?.();
|
|
43
|
+
onSettled(() => {
|
|
44
|
+
if (element)
|
|
45
|
+
element.checked = context.state.checked;
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return (<input {...omit(props, 'onChange', 'ref')} ref={[
|
|
49
|
+
props.ref,
|
|
50
|
+
next => {
|
|
51
|
+
element = next;
|
|
52
|
+
},
|
|
53
|
+
]} type='checkbox' role={slot === 'switch' ? 'switch' : undefined} data-slot={`${slot}-control`} id={context.meta.id} name={context.meta.name} value={context.meta.value} disabled={context.meta.disabled || props.disabled} required={context.meta.required || props.required} checked={context.state.checked} onChange={event => {
|
|
54
|
+
composeEventHandlers(props.onChange, () => context.actions.setChecked(event.currentTarget.checked))(event);
|
|
55
|
+
event.currentTarget.checked = context.state.checked;
|
|
56
|
+
}}/>);
|
|
57
|
+
};
|
|
58
|
+
const Indicator = (props) => {
|
|
59
|
+
const context = useToggle();
|
|
60
|
+
return (<Show when={context.state.checked}>
|
|
61
|
+
<span {...props} data-slot={`${slot}-indicator`} aria-hidden='true'/>
|
|
62
|
+
</Show>);
|
|
63
|
+
};
|
|
64
|
+
const Thumb = (props) => {
|
|
65
|
+
const context = useToggle();
|
|
66
|
+
return (<span {...props} data-slot={`${slot}-thumb`} data-state={context.state.checked ? 'checked' : 'unchecked'} aria-hidden='true'/>);
|
|
67
|
+
};
|
|
68
|
+
return { Root, Provider, Control, Indicator, Thumb, useToggle };
|
|
69
|
+
};
|
|
70
|
+
export { createToggle };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const Root: import("./part.jsx").Part<"div">;
|
|
2
|
+
declare const Button: import("./part.jsx").Part<"button">;
|
|
3
|
+
declare const Link: import("./part.jsx").Part<"a">;
|
|
4
|
+
declare const Leading: import("./part.jsx").Part<"span">;
|
|
5
|
+
declare const Content: import("./part.jsx").Part<"span">;
|
|
6
|
+
declare const Title: import("./part.jsx").Part<"span">;
|
|
7
|
+
declare const Subtitle: import("./part.jsx").Part<"span">;
|
|
8
|
+
declare const Trailing: import("./part.jsx").Part<"span">;
|
|
9
|
+
declare const ListRow: {
|
|
10
|
+
Root: typeof Root;
|
|
11
|
+
Button: typeof Button;
|
|
12
|
+
Link: typeof Link;
|
|
13
|
+
Leading: typeof Leading;
|
|
14
|
+
Content: typeof Content;
|
|
15
|
+
Title: typeof Title;
|
|
16
|
+
Subtitle: typeof Subtitle;
|
|
17
|
+
Trailing: typeof Trailing;
|
|
18
|
+
};
|
|
19
|
+
export { ListRow };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { part } from './part.jsx';
|
|
2
|
+
const Root = part('div', 'list-row');
|
|
3
|
+
const Button = part('button', 'list-row', { type: 'button' });
|
|
4
|
+
const Link = part('a', 'list-row');
|
|
5
|
+
const Leading = part('span', 'list-row-leading');
|
|
6
|
+
const Content = part('span', 'list-row-content');
|
|
7
|
+
const Title = part('span', 'list-row-title');
|
|
8
|
+
const Subtitle = part('span', 'list-row-subtitle');
|
|
9
|
+
const Trailing = part('span', 'list-row-trailing');
|
|
10
|
+
const ListRow = { Root, Button, Link, Leading, Content, Title, Subtitle, Trailing };
|
|
11
|
+
export { ListRow };
|
package/dist/nav-bar.jsx
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const Root: import("./part.jsx").Part<"header">;
|
|
2
|
+
declare const Title: import("./part.jsx").Part<"h1">;
|
|
3
|
+
declare const Actions: import("./part.jsx").Part<"div">;
|
|
4
|
+
declare const PageHeader: {
|
|
5
|
+
Root: typeof Root;
|
|
6
|
+
Title: typeof Title;
|
|
7
|
+
Actions: typeof Actions;
|
|
8
|
+
};
|
|
9
|
+
export { PageHeader };
|
package/dist/page.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const Root: import("./part.jsx").Part<"div">;
|
|
2
|
+
declare const Content: import("./part.jsx").Part<"main">;
|
|
3
|
+
declare const Footer: import("./part.jsx").Part<"div">;
|
|
4
|
+
declare const Page: {
|
|
5
|
+
Root: typeof Root;
|
|
6
|
+
Content: typeof Content;
|
|
7
|
+
Footer: typeof Footer;
|
|
8
|
+
};
|
|
9
|
+
export { Page };
|
package/dist/page.jsx
ADDED
package/dist/part.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ComponentProps, type JSX, type ValidComponent } from '@solidjs/web';
|
|
2
|
+
type PartProps<T extends ValidComponent> = ComponentProps<T> & {
|
|
3
|
+
as?: T;
|
|
4
|
+
};
|
|
5
|
+
type Part<T extends keyof JSX.IntrinsicElements> = <E extends ValidComponent = T>(props: PartProps<E>) => JSX.Element;
|
|
6
|
+
declare const part: <T extends keyof JSX.IntrinsicElements>(element: T, slot: string, defaults?: Partial<JSX.IntrinsicElements[T]>) => Part<T>;
|
|
7
|
+
export { part };
|
|
8
|
+
export type { Part, PartProps };
|
package/dist/part.jsx
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { dynamic } from '@solidjs/web';
|
|
2
|
+
import { merge, omit } from 'solid-js';
|
|
3
|
+
const part = (element, slot, defaults) => {
|
|
4
|
+
const Part = (props) => {
|
|
5
|
+
const Element = dynamic(() => props.as ?? element);
|
|
6
|
+
return (<Element {...merge(defaults ?? {}, omit(props, 'as'))} data-slot={slot}/>);
|
|
7
|
+
};
|
|
8
|
+
return Part;
|
|
9
|
+
};
|
|
10
|
+
export { part };
|
package/dist/portal.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type JSX } from '@solidjs/web';
|
|
2
|
+
import type { ParentProps } from 'solid-js';
|
|
3
|
+
type PortalProps = ParentProps<{
|
|
4
|
+
mount?: Element | ShadowRoot;
|
|
5
|
+
}>;
|
|
6
|
+
declare const Portal: (props: PortalProps) => JSX.Element;
|
|
7
|
+
export { Portal };
|
|
8
|
+
export type { PortalProps };
|
package/dist/portal.jsx
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JSX } from '@solidjs/web';
|
|
2
|
+
type ProgressProps = Omit<JSX.ProgressHTMLAttributes<HTMLProgressElement>, 'value' | 'max'> & {
|
|
3
|
+
value?: number | null;
|
|
4
|
+
max?: number;
|
|
5
|
+
};
|
|
6
|
+
declare const Progress: (props: ProgressProps) => JSX.Element;
|
|
7
|
+
export { Progress };
|
|
8
|
+
export type { ProgressProps };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { omit } from 'solid-js';
|
|
2
|
+
const Progress = (props) => (<progress {...omit(props, 'value', 'max')} data-slot='progress' max={Math.max(1, props.max ?? 100)} value={props.value == null ? undefined : Math.min(Math.max(0, props.value), Math.max(1, props.max ?? 100))}/>);
|
|
3
|
+
export { Progress };
|
package/dist/radio.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { JSX } from '@solidjs/web';
|
|
2
|
+
type RadioContextValue = {
|
|
3
|
+
state: {
|
|
4
|
+
readonly value: string | null;
|
|
5
|
+
};
|
|
6
|
+
actions: {
|
|
7
|
+
select: (value: string) => void;
|
|
8
|
+
};
|
|
9
|
+
meta: {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly disabled: boolean;
|
|
12
|
+
readonly required: boolean;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
declare const useRadio: () => RadioContextValue;
|
|
16
|
+
type RadioProps = Omit<JSX.FieldsetHTMLAttributes<HTMLFieldSetElement>, 'onChange' | 'disabled'> & {
|
|
17
|
+
value?: string | null;
|
|
18
|
+
defaultValue?: string | null;
|
|
19
|
+
onValueChange?: (value: string | null) => void;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
};
|
|
23
|
+
declare const Provider: (props: RadioContextValue & {
|
|
24
|
+
children?: JSX.Element;
|
|
25
|
+
}) => JSX.Element;
|
|
26
|
+
declare const Root: (props: RadioProps) => JSX.Element;
|
|
27
|
+
declare const Item: (props: JSX.LabelHTMLAttributes<HTMLLabelElement> & {
|
|
28
|
+
value: string;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
}) => JSX.Element;
|
|
31
|
+
type ControlProps = Omit<JSX.InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'type' | 'checked' | 'value'> & {
|
|
32
|
+
onChange?: JSX.EventHandler<HTMLInputElement, Event>;
|
|
33
|
+
};
|
|
34
|
+
declare const Control: (props: ControlProps) => JSX.Element;
|
|
35
|
+
declare const Indicator: (props: JSX.HTMLAttributes<HTMLSpanElement>) => JSX.Element;
|
|
36
|
+
declare const Radio: {
|
|
37
|
+
Root: typeof Root;
|
|
38
|
+
Provider: typeof Provider;
|
|
39
|
+
Legend: import("./part.jsx").Part<"legend">;
|
|
40
|
+
Item: typeof Item;
|
|
41
|
+
Control: typeof Control;
|
|
42
|
+
Indicator: typeof Indicator;
|
|
43
|
+
};
|
|
44
|
+
export { Radio, useRadio };
|
|
45
|
+
export type { RadioContextValue, RadioProps };
|