@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.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +159 -2
  3. package/dist/accordion.d.ts +42 -0
  4. package/dist/accordion.jsx +64 -0
  5. package/dist/alert.d.ts +15 -0
  6. package/dist/alert.jsx +9 -0
  7. package/dist/badge.d.ts +2 -0
  8. package/dist/badge.jsx +3 -0
  9. package/dist/bulk-bar.d.ts +9 -0
  10. package/dist/bulk-bar.jsx +6 -0
  11. package/dist/button.d.ts +8 -0
  12. package/dist/button.jsx +9 -0
  13. package/dist/card.d.ts +17 -0
  14. package/dist/card.jsx +10 -0
  15. package/dist/checkbox.d.ts +9 -0
  16. package/dist/checkbox.jsx +3 -0
  17. package/dist/collapsible.d.ts +35 -0
  18. package/dist/collapsible.jsx +39 -0
  19. package/dist/composer.d.ts +7 -0
  20. package/dist/composer.jsx +5 -0
  21. package/dist/controllable.d.ts +11 -0
  22. package/dist/controllable.js +26 -0
  23. package/dist/description-list.d.ts +9 -0
  24. package/dist/description-list.jsx +6 -0
  25. package/dist/dialog.d.ts +49 -0
  26. package/dist/dialog.jsx +84 -0
  27. package/dist/divider.d.ts +2 -0
  28. package/dist/divider.jsx +3 -0
  29. package/dist/empty-state.d.ts +13 -0
  30. package/dist/empty-state.jsx +8 -0
  31. package/dist/events.d.ts +4 -0
  32. package/dist/events.js +6 -0
  33. package/dist/field.d.ts +40 -0
  34. package/dist/field.jsx +55 -0
  35. package/dist/index.d.ts +36 -0
  36. package/dist/index.js +36 -0
  37. package/dist/input.d.ts +2 -0
  38. package/dist/input.jsx +3 -0
  39. package/dist/lib/form-reset.d.ts +4 -0
  40. package/dist/lib/form-reset.js +17 -0
  41. package/dist/lib/toggle.d.ts +40 -0
  42. package/dist/lib/toggle.jsx +70 -0
  43. package/dist/list-row.d.ts +19 -0
  44. package/dist/list-row.jsx +11 -0
  45. package/dist/nav-bar.d.ts +7 -0
  46. package/dist/nav-bar.jsx +5 -0
  47. package/dist/page-header.d.ts +9 -0
  48. package/dist/page-header.jsx +6 -0
  49. package/dist/page.d.ts +9 -0
  50. package/dist/page.jsx +6 -0
  51. package/dist/part.d.ts +8 -0
  52. package/dist/part.jsx +10 -0
  53. package/dist/portal.d.ts +8 -0
  54. package/dist/portal.jsx +3 -0
  55. package/dist/progress.d.ts +8 -0
  56. package/dist/progress.jsx +3 -0
  57. package/dist/radio.d.ts +45 -0
  58. package/dist/radio.jsx +83 -0
  59. package/dist/select.d.ts +15 -0
  60. package/dist/select.jsx +33 -0
  61. package/dist/sidebar.d.ts +21 -0
  62. package/dist/sidebar.jsx +12 -0
  63. package/dist/skeleton.d.ts +2 -0
  64. package/dist/skeleton.jsx +3 -0
  65. package/dist/stat.d.ts +11 -0
  66. package/dist/stat.jsx +7 -0
  67. package/dist/switch.d.ts +9 -0
  68. package/dist/switch.jsx +3 -0
  69. package/dist/table.d.ts +17 -0
  70. package/dist/table.jsx +10 -0
  71. package/dist/tabs.d.ts +49 -0
  72. package/dist/tabs.jsx +68 -0
  73. package/dist/tag-input.d.ts +52 -0
  74. package/dist/tag-input.jsx +107 -0
  75. package/dist/text.d.ts +2 -0
  76. package/dist/text.jsx +3 -0
  77. package/dist/textarea.d.ts +2 -0
  78. package/dist/textarea.jsx +3 -0
  79. package/dist/tile.d.ts +15 -0
  80. package/dist/tile.jsx +9 -0
  81. package/package.json +277 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Journ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,160 @@
1
- # Temporary Holding Version
1
+ # @journ/nude-solid
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Unstyled, composable UI primitives for SolidJS 2. Components expose behavior through context, native controls, and `data-slot` attributes. Consumers supply styles and icons.
4
+
5
+ This package is independent of React `@journ/nude`. It requires `solid-js` and `@solidjs/web` 2.0.4 or later within major version 2.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ pnpm add @journ/nude-solid solid-js@^2.0.4 @solidjs/web@^2.0.4
11
+ pnpm add -D vite @solidjs/vite-plugin
12
+ ```
13
+
14
+ Enable the Solid compiler in your Vite configuration:
15
+
16
+ ```ts
17
+ import solid from '@solidjs/vite-plugin'
18
+ import { defineConfig } from 'vite'
19
+
20
+ export default defineConfig({ plugins: [solid()] })
21
+ ```
22
+
23
+ Use `"jsx": "preserve"` and `"jsxImportSource": "@solidjs/web"` in your TypeScript configuration.
24
+
25
+ ## Compose parts
26
+
27
+ Stateful compounds expose a `Root` for local or controlled state, a `Provider` for external state, and individual DOM parts. Roots for Accordion, Collapsible, Dialog, Tabs, and TagInput render no DOM.
28
+
29
+ ```tsx
30
+ import { Tabs } from '@journ/nude-solid/tabs'
31
+
32
+ const Settings = () => (
33
+ <Tabs.Root defaultValue='profile'>
34
+ <Tabs.List aria-label='Settings'>
35
+ <Tabs.Trigger value='profile'>Profile</Tabs.Trigger>
36
+ <Tabs.Trigger value='security'>Security</Tabs.Trigger>
37
+ </Tabs.List>
38
+ <Tabs.Content value='profile'>Profile settings</Tabs.Content>
39
+ <Tabs.Content value='security'>Security settings</Tabs.Content>
40
+ </Tabs.Root>
41
+ )
42
+ ```
43
+
44
+ Tabs support arrow keys, Home, End, disabled items, vertical orientation, right-to-left navigation, and manual activation. Inactive panels stay mounted and hidden.
45
+
46
+ ## Own the state
47
+
48
+ Contexts expose reactive `state`, callable `actions`, and stable or reactive `meta`. Read reactive properties through their object. Preserve their getters when supplying an external provider.
49
+
50
+ ```tsx
51
+ import { createSignal } from 'solid-js'
52
+ import { Collapsible } from '@journ/nude-solid/collapsible'
53
+
54
+ const Details = () => {
55
+ const [open, setOpen] = createSignal(false)
56
+
57
+ return (
58
+ <Collapsible.Provider
59
+ state={{
60
+ get open() {
61
+ return open()
62
+ },
63
+ }}
64
+ actions={{ setOpen }}
65
+ meta={{ id: 'details', disabled: false }}
66
+ >
67
+ <Collapsible.Trigger>Details</Collapsible.Trigger>
68
+ <Collapsible.Content>Additional information</Collapsible.Content>
69
+ </Collapsible.Provider>
70
+ )
71
+ }
72
+ ```
73
+
74
+ Each stateful compound exports a `useX` function for custom parts. A missing provider throws Solid's context error. Checkbox and Switch share their toggle implementation but keep separate contexts.
75
+
76
+ Controlled values remain owned by the caller. Changes request updates through callbacks. `undefined` selects local state, while `null` and `false` remain valid controlled values. Defaults initialize once. `createControllable` also accepts functional updates, including several updates within one event.
77
+
78
+ ## Native form controls
79
+
80
+ Checkbox and Switch roots render labels. Add a `Control` to render the native checkbox input. Radio uses a fieldset, legend, labels, and native radio inputs. These controls retain native keyboard and form submission behavior.
81
+
82
+ ```tsx
83
+ import { Checkbox } from '@journ/nude-solid/checkbox'
84
+ import { Field } from '@journ/nude-solid/field'
85
+
86
+ const Preferences = () => (
87
+ <form>
88
+ <Field.Root required descriptionId='email-help'>
89
+ <Field.Label>Email</Field.Label>
90
+ <Field.Control name='email' type='email' />
91
+ <Field.Description id='email-help'>Use your work address.</Field.Description>
92
+ </Field.Root>
93
+ <Checkbox.Root name='updates' value='yes'>
94
+ <Checkbox.Control />
95
+ Receive updates
96
+ <Checkbox.Indicator>Enabled</Checkbox.Indicator>
97
+ </Checkbox.Root>
98
+ </form>
99
+ )
100
+ ```
101
+
102
+ Pass `descriptionId` and `errorId` to Field when rendering those optional parts. This avoids references to elements that do not exist. `Field.Control` renders an input. Use `useField` to wire a custom control.
103
+
104
+ `Select.Root` renders a native select. Compose it with `Select.Item` and `Select.Group`. `Progress` renders native progress and accepts `null` or an omitted value for indeterminate progress.
105
+
106
+ ## Native dialogs
107
+
108
+ `Dialog.Content` renders a native dialog. The browser handles the modal top layer, focus containment, Escape, and focus restoration. Give every dialog a title.
109
+
110
+ ```tsx
111
+ import { Dialog } from '@journ/nude-solid/dialog'
112
+
113
+ const Confirm = () => (
114
+ <Dialog.Root>
115
+ <Dialog.Trigger>Delete</Dialog.Trigger>
116
+ <Dialog.Content>
117
+ <Dialog.Title>Delete this file?</Dialog.Title>
118
+ <Dialog.Body>This action cannot be undone.</Dialog.Body>
119
+ <Dialog.Actions>
120
+ <Dialog.Close>Cancel</Dialog.Close>
121
+ </Dialog.Actions>
122
+ </Dialog.Content>
123
+ </Dialog.Root>
124
+ )
125
+ ```
126
+
127
+ Modal dialogs require native `HTMLDialogElement.showModal`. Dialogs enter the top layer after client rendering. `Portal` renders nothing on the server and mounts its children on the client.
128
+
129
+ ## Styling and customization
130
+
131
+ - Components set `data-slot` and expose relevant state through `data-state`, `data-disabled`, `data-pending`, and ARIA attributes.
132
+ - Pass Solid's `class`, `style`, and `ref` props directly. No component adds visual classes or inline styles.
133
+ - Structural parts accept a typed `as` prop for native tags or custom Solid components. For example, `<Card.Title as='h1'>Title</Card.Title>`.
134
+ - Consumer event handlers run before internal behavior. Call `preventDefault()` to cancel that behavior.
135
+ - `TagInput.Tags` supplies a default tag list. Compose `TagInput.Tag` and `TagInput.Remove` with `useTagInput` for a custom list.
136
+ - Tag input trims values, rejects duplicates without regard to case, preserves invalid text, and ignores IME confirmation keys.
137
+
138
+ ## Available components
139
+
140
+ | Category | Components |
141
+ | ----------- | ------------------------------------------------------------------------------------------------------------ |
142
+ | Interaction | Accordion, Button, Collapsible, Dialog, Tabs |
143
+ | Forms | Checkbox, Composer, Field, Input, Radio, Select, Switch, TagInput, Textarea |
144
+ | Feedback | Alert, Badge, EmptyState, Progress, Skeleton |
145
+ | Layout | BulkBar, Card, DescriptionList, Divider, ListRow, NavBar, Page, PageHeader, Sidebar, Stat, Table, Text, Tile |
146
+ | Utilities | Portal, createControllable, composeEventHandlers, part |
147
+
148
+ Every public module has a subpath export. A root export is also available. The advanced React widgets, including DataTable, Calendar, audio controls, and animated components, are not part of this initial Solid package.
149
+
150
+ ## Ladle previews
151
+
152
+ Run `pnpm nx run @journ/playground:dev`, then open **Nude Solid / Components** in Ladle. All 33 components have previews, and interactive examples include controls for their supported states.
153
+
154
+ ## Build and test
155
+
156
+ ```sh
157
+ pnpm nx run-many -t build typecheck test lint format:check test:package --projects=@journ/nude-solid
158
+ ```
159
+
160
+ The build emits declarations and preserves JSX. Each export includes the `solid` condition, so the consuming app compiles the components for its own browser, SSR, or hydration target. Use a Solid-aware bundler. Raw Node cannot import the JSX component output directly.
@@ -0,0 +1,42 @@
1
+ import type { JSX } from '@solidjs/web';
2
+ import { type ParentProps } from 'solid-js';
3
+ import { type ButtonProps } from './button.jsx';
4
+ type AccordionContextValue = {
5
+ state: {
6
+ readonly value: readonly string[];
7
+ };
8
+ actions: {
9
+ toggle: (value: string) => void;
10
+ };
11
+ meta: {
12
+ readonly multiple: boolean;
13
+ readonly disabled: boolean;
14
+ };
15
+ };
16
+ declare const useAccordion: () => AccordionContextValue;
17
+ declare const Provider: (props: ParentProps<AccordionContextValue>) => JSX.Element;
18
+ type AccordionProps = ParentProps<{
19
+ value?: readonly string[];
20
+ defaultValue?: readonly string[];
21
+ onValueChange?: (value: readonly string[]) => void;
22
+ multiple?: boolean;
23
+ disabled?: boolean;
24
+ }>;
25
+ declare const Root: (props: AccordionProps) => JSX.Element;
26
+ declare const Item: (props: JSX.HTMLAttributes<HTMLDivElement> & {
27
+ value: string;
28
+ disabled?: boolean;
29
+ }) => JSX.Element;
30
+ declare const Trigger: (props: ButtonProps) => JSX.Element;
31
+ declare const Content: (props: JSX.HTMLAttributes<HTMLDivElement>) => JSX.Element;
32
+ declare const Accordion: {
33
+ Root: typeof Root;
34
+ Provider: typeof Provider;
35
+ Frame: import("./part.jsx").Part<"div">;
36
+ Item: typeof Item;
37
+ Header: import("./part.jsx").Part<"h3">;
38
+ Trigger: typeof Trigger;
39
+ Content: typeof Content;
40
+ };
41
+ export { Accordion, useAccordion };
42
+ export type { AccordionContextValue, AccordionProps };
@@ -0,0 +1,64 @@
1
+ import { createContext, 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 ItemContext = createContext();
8
+ const useAccordion = () => useContext(Context);
9
+ const Provider = (props) => (<Context value={props}>{props.children}</Context>);
10
+ const Root = (props) => {
11
+ const [value, setValue] = createControllable({
12
+ value: () => props.value,
13
+ defaultValue: () => props.defaultValue ?? [],
14
+ onChange: next => props.onValueChange?.(next),
15
+ });
16
+ const toggle = (item) => {
17
+ if (props.disabled)
18
+ return;
19
+ setValue(current => current.includes(item) ? current.filter(entry => entry !== item) : props.multiple ? [...current, item] : [item]);
20
+ };
21
+ return (<Provider state={{
22
+ get value() {
23
+ return value();
24
+ },
25
+ }} actions={{ toggle }} meta={{
26
+ get multiple() {
27
+ return props.multiple ?? false;
28
+ },
29
+ get disabled() {
30
+ return props.disabled ?? false;
31
+ },
32
+ }}>
33
+ {props.children}
34
+ </Provider>);
35
+ };
36
+ const Item = (props) => {
37
+ const context = useAccordion();
38
+ const id = createUniqueId();
39
+ return (<ItemContext value={{
40
+ id,
41
+ get value() {
42
+ return props.value;
43
+ },
44
+ get disabled() {
45
+ return props.disabled || context.meta.disabled;
46
+ },
47
+ }}>
48
+ <div {...omit(props, 'value', 'disabled')} data-slot='accordion-item' data-state={context.state.value.includes(props.value) ? 'open' : 'closed'}/>
49
+ </ItemContext>);
50
+ };
51
+ const Trigger = (props) => {
52
+ const context = useAccordion();
53
+ const item = useContext(ItemContext);
54
+ return (<Button {...omit(props, 'onClick')} data-slot='accordion-trigger' id={`${item.id}-trigger`} aria-controls={`${item.id}-content`} aria-expanded={context.state.value.includes(item.value) ? 'true' : 'false'} disabled={item.disabled || props.disabled} onClick={event => composeEventHandlers(props.onClick, () => context.actions.toggle(item.value))(event)}/>);
55
+ };
56
+ const Content = (props) => {
57
+ const context = useAccordion();
58
+ const item = useContext(ItemContext);
59
+ return (<div {...props} data-slot='accordion-content' id={`${item.id}-content`} role='region' aria-labelledby={`${item.id}-trigger`} hidden={!context.state.value.includes(item.value)}/>);
60
+ };
61
+ const Header = part('h3', 'accordion-header');
62
+ const Frame = part('div', 'accordion');
63
+ const Accordion = { Root, Provider, Frame, Item, Header, Trigger, Content };
64
+ export { Accordion, useAccordion };
@@ -0,0 +1,15 @@
1
+ declare const Root: import("./part.jsx").Part<"div">;
2
+ declare const Icon: import("./part.jsx").Part<"span">;
3
+ declare const Body: import("./part.jsx").Part<"div">;
4
+ declare const Title: import("./part.jsx").Part<"p">;
5
+ declare const Description: import("./part.jsx").Part<"p">;
6
+ declare const Actions: import("./part.jsx").Part<"div">;
7
+ declare const Alert: {
8
+ Root: typeof Root;
9
+ Icon: typeof Icon;
10
+ Body: typeof Body;
11
+ Title: typeof Title;
12
+ Description: typeof Description;
13
+ Actions: typeof Actions;
14
+ };
15
+ export { Alert };
package/dist/alert.jsx ADDED
@@ -0,0 +1,9 @@
1
+ import { part } from './part.jsx';
2
+ const Root = part('div', 'alert', { role: 'alert' });
3
+ const Icon = part('span', 'alert-icon', { 'aria-hidden': 'true' });
4
+ const Body = part('div', 'alert-body');
5
+ const Title = part('p', 'alert-title');
6
+ const Description = part('p', 'alert-description');
7
+ const Actions = part('div', 'alert-actions');
8
+ const Alert = { Root, Icon, Body, Title, Description, Actions };
9
+ export { Alert };
@@ -0,0 +1,2 @@
1
+ declare const Badge: import("./part.jsx").Part<"span">;
2
+ export { Badge };
package/dist/badge.jsx ADDED
@@ -0,0 +1,3 @@
1
+ import { part } from './part.jsx';
2
+ const Badge = part('span', 'badge');
3
+ export { Badge };
@@ -0,0 +1,9 @@
1
+ declare const Root: import("./part.jsx").Part<"div">;
2
+ declare const Count: import("./part.jsx").Part<"p">;
3
+ declare const Actions: import("./part.jsx").Part<"div">;
4
+ declare const BulkBar: {
5
+ Root: typeof Root;
6
+ Count: typeof Count;
7
+ Actions: typeof Actions;
8
+ };
9
+ export { BulkBar };
@@ -0,0 +1,6 @@
1
+ import { part } from './part.jsx';
2
+ const Root = part('div', 'bulk-bar', { role: 'toolbar' });
3
+ const Count = part('p', 'bulk-bar-count', { 'aria-live': 'polite' });
4
+ const Actions = part('div', 'bulk-bar-actions');
5
+ const BulkBar = { Root, Count, Actions };
6
+ export { BulkBar };
@@ -0,0 +1,8 @@
1
+ import type { JSX } from '@solidjs/web';
2
+ type ButtonProps = Omit<JSX.ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> & {
3
+ pending?: boolean;
4
+ onClick?: JSX.EventHandler<HTMLButtonElement, MouseEvent>;
5
+ };
6
+ declare const Button: (props: ButtonProps) => JSX.Element;
7
+ export { Button };
8
+ export type { ButtonProps };
@@ -0,0 +1,9 @@
1
+ import { omit } from 'solid-js';
2
+ const Button = (props) => (<button data-slot='button' type='button' {...omit(props, 'pending', 'onClick')} aria-busy={props.pending ? 'true' : undefined} data-pending={props.pending || undefined} onClick={event => {
3
+ if (props.pending || props.disabled) {
4
+ event.preventDefault();
5
+ return;
6
+ }
7
+ props.onClick?.(event);
8
+ }}/>);
9
+ export { Button };
package/dist/card.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ declare const Root: import("./part.jsx").Part<"div">;
2
+ declare const Icon: import("./part.jsx").Part<"span">;
3
+ declare const Header: import("./part.jsx").Part<"div">;
4
+ declare const Title: import("./part.jsx").Part<"h3">;
5
+ declare const Description: import("./part.jsx").Part<"p">;
6
+ declare const Content: import("./part.jsx").Part<"div">;
7
+ declare const Footer: import("./part.jsx").Part<"footer">;
8
+ declare const Card: {
9
+ Root: typeof Root;
10
+ Icon: typeof Icon;
11
+ Header: typeof Header;
12
+ Title: typeof Title;
13
+ Description: typeof Description;
14
+ Content: typeof Content;
15
+ Footer: typeof Footer;
16
+ };
17
+ export { Card };
package/dist/card.jsx ADDED
@@ -0,0 +1,10 @@
1
+ import { part } from './part.jsx';
2
+ const Root = part('div', 'card');
3
+ const Icon = part('span', 'card-icon');
4
+ const Header = part('div', 'card-header');
5
+ const Title = part('h3', 'card-title');
6
+ const Description = part('p', 'card-description');
7
+ const Content = part('div', 'card-content');
8
+ const Footer = part('footer', 'card-footer');
9
+ const Card = { Root, Icon, Header, Title, Description, Content, Footer };
10
+ export { Card };
@@ -0,0 +1,9 @@
1
+ declare const useCheckbox: () => import("./checkbox.jsx").CheckboxContextValue, Checkbox: {
2
+ Root: (props: import("./checkbox.jsx").CheckboxProps) => import("@solidjs/web").JSX.Element;
3
+ Provider: (props: import("solid-js").ParentProps<import("./checkbox.jsx").CheckboxContextValue>) => import("@solidjs/web").JSX.Element;
4
+ Control: (props: import("./lib/toggle.jsx").ToggleControlProps) => import("@solidjs/web").JSX.Element;
5
+ Indicator: (props: import("@solidjs/web").JSX.HTMLAttributes<HTMLSpanElement>) => import("@solidjs/web").JSX.Element;
6
+ Thumb: (props: import("@solidjs/web").JSX.HTMLAttributes<HTMLSpanElement>) => import("@solidjs/web").JSX.Element;
7
+ };
8
+ export { Checkbox, useCheckbox };
9
+ export type { ToggleContextValue as CheckboxContextValue, ToggleProps as CheckboxProps } from './lib/toggle.jsx';
@@ -0,0 +1,3 @@
1
+ import { createToggle } from './lib/toggle.jsx';
2
+ const { useToggle: useCheckbox, ...Checkbox } = createToggle('checkbox');
3
+ export { Checkbox, useCheckbox };
@@ -0,0 +1,35 @@
1
+ import type { JSX } from '@solidjs/web';
2
+ import { type ParentProps } from 'solid-js';
3
+ import { type ButtonProps } from './button.jsx';
4
+ type CollapsibleContextValue = {
5
+ state: {
6
+ readonly open: boolean;
7
+ };
8
+ actions: {
9
+ setOpen: (open: boolean) => void;
10
+ };
11
+ meta: {
12
+ readonly id: string;
13
+ readonly disabled: boolean;
14
+ };
15
+ };
16
+ declare const useCollapsible: () => CollapsibleContextValue;
17
+ declare const Provider: (props: ParentProps<CollapsibleContextValue>) => JSX.Element;
18
+ type CollapsibleProps = ParentProps<{
19
+ open?: boolean;
20
+ defaultOpen?: boolean;
21
+ onOpenChange?: (open: boolean) => void;
22
+ disabled?: boolean;
23
+ }>;
24
+ declare const Root: (props: CollapsibleProps) => JSX.Element;
25
+ declare const Trigger: (props: ButtonProps) => JSX.Element;
26
+ declare const Content: (props: JSX.HTMLAttributes<HTMLDivElement>) => JSX.Element;
27
+ declare const Collapsible: {
28
+ Root: typeof Root;
29
+ Provider: typeof Provider;
30
+ Frame: import("./part.jsx").Part<"div">;
31
+ Trigger: typeof Trigger;
32
+ Content: typeof Content;
33
+ };
34
+ export { Collapsible, useCollapsible };
35
+ export type { CollapsibleContextValue, CollapsibleProps };
@@ -0,0 +1,39 @@
1
+ import { createContext, 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 useCollapsible = () => 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
+ get disabled() {
23
+ return props.disabled ?? false;
24
+ },
25
+ }}>
26
+ {props.children}
27
+ </Provider>);
28
+ };
29
+ const Trigger = (props) => {
30
+ const context = useCollapsible();
31
+ return (<Button {...omit(props, 'onClick')} data-slot='collapsible-trigger' disabled={context.meta.disabled || props.disabled} aria-expanded={context.state.open ? 'true' : 'false'} aria-controls={context.meta.id} onClick={event => composeEventHandlers(props.onClick, () => context.actions.setOpen(!context.state.open))(event)}/>);
32
+ };
33
+ const Content = (props) => {
34
+ const context = useCollapsible();
35
+ return (<div {...props} id={context.meta.id} data-slot='collapsible-content' data-state={context.state.open ? 'open' : 'closed'} hidden={!context.state.open}/>);
36
+ };
37
+ const Frame = part('div', 'collapsible');
38
+ const Collapsible = { Root, Provider, Frame, Trigger, Content };
39
+ export { Collapsible, useCollapsible };
@@ -0,0 +1,7 @@
1
+ declare const Root: import("./part.jsx").Part<"div">;
2
+ declare const Input: import("./part.jsx").Part<"input">;
3
+ declare const Composer: {
4
+ Root: typeof Root;
5
+ Input: typeof Input;
6
+ };
7
+ export { Composer };
@@ -0,0 +1,5 @@
1
+ import { part } from './part.jsx';
2
+ const Root = part('div', 'composer');
3
+ const Input = part('input', 'composer-input');
4
+ const Composer = { Root, Input };
5
+ export { Composer };
@@ -0,0 +1,11 @@
1
+ import { type Accessor } from 'solid-js';
2
+ type ControllableOptions<T> = {
3
+ value: Accessor<T | undefined>;
4
+ defaultValue: Accessor<T>;
5
+ onChange?: (value: T) => void;
6
+ equals?: (previous: T, next: T) => boolean;
7
+ };
8
+ type Controllable<T> = readonly [Accessor<T>, (next: T | ((previous: T) => T)) => void];
9
+ declare const createControllable: <T>(options: ControllableOptions<T>) => Controllable<T>;
10
+ export { createControllable };
11
+ export type { Controllable, ControllableOptions };
@@ -0,0 +1,26 @@
1
+ import { createMemo, createSignal, untrack } from 'solid-js';
2
+ const createControllable = (options) => {
3
+ const [internal, setInternal] = createSignal(() => {
4
+ const value = untrack(options.defaultValue);
5
+ return { previous: value, value };
6
+ });
7
+ const value = createMemo(() => {
8
+ const controlled = options.value();
9
+ return controlled === undefined ? internal().value : controlled;
10
+ });
11
+ const set = (next) => {
12
+ const resolve = (previous) => (typeof next === 'function' ? next(previous) : next);
13
+ const equals = options.equals ?? Object.is;
14
+ const controlled = options.value();
15
+ const change = controlled === undefined
16
+ ? setInternal(current => {
17
+ const value = resolve(current.value);
18
+ return { previous: current.value, value: equals(current.value, value) ? current.value : value };
19
+ })
20
+ : { previous: controlled, value: resolve(controlled) };
21
+ if (!equals(change.previous, change.value))
22
+ options.onChange?.(change.value);
23
+ };
24
+ return [value, set];
25
+ };
26
+ export { createControllable };
@@ -0,0 +1,9 @@
1
+ declare const Root: import("./part.jsx").Part<"dl">;
2
+ declare const Term: import("./part.jsx").Part<"dt">;
3
+ declare const Details: import("./part.jsx").Part<"dd">;
4
+ declare const DescriptionList: {
5
+ Root: typeof Root;
6
+ Term: typeof Term;
7
+ Details: typeof Details;
8
+ };
9
+ export { DescriptionList };
@@ -0,0 +1,6 @@
1
+ import { part } from './part.jsx';
2
+ const Root = part('dl', 'description-list');
3
+ const Term = part('dt', 'description-list-term');
4
+ const Details = part('dd', 'description-list-details');
5
+ const DescriptionList = { Root, Term, Details };
6
+ export { DescriptionList };
@@ -0,0 +1,49 @@
1
+ import type { JSX } from '@solidjs/web';
2
+ import { type ParentProps } from 'solid-js';
3
+ import { type ButtonProps } from './button.jsx';
4
+ type DialogContextValue = {
5
+ state: {
6
+ readonly open: boolean;
7
+ };
8
+ actions: {
9
+ setOpen: (open: boolean) => void;
10
+ };
11
+ meta: {
12
+ readonly id: string;
13
+ readonly titleId: string;
14
+ readonly descriptionId?: string;
15
+ readonly modal: boolean;
16
+ };
17
+ };
18
+ declare const useDialog: () => DialogContextValue;
19
+ declare const Provider: (props: ParentProps<DialogContextValue>) => JSX.Element;
20
+ type DialogProps = ParentProps<{
21
+ open?: boolean;
22
+ defaultOpen?: boolean;
23
+ onOpenChange?: (open: boolean) => void;
24
+ modal?: boolean;
25
+ descriptionId?: string;
26
+ }>;
27
+ declare const Root: (props: DialogProps) => JSX.Element;
28
+ declare const Trigger: (props: ButtonProps) => JSX.Element;
29
+ declare const Close: (props: ButtonProps) => JSX.Element;
30
+ type DialogContentProps = Omit<JSX.DialogHtmlAttributes<HTMLDialogElement>, 'open' | 'onCancel' | 'onClose'> & {
31
+ onCancel?: JSX.EventHandler<HTMLDialogElement, Event>;
32
+ onClose?: JSX.EventHandler<HTMLDialogElement, Event>;
33
+ };
34
+ declare const Content: (props: DialogContentProps) => JSX.Element;
35
+ declare const Title: (props: JSX.HTMLAttributes<HTMLHeadingElement>) => JSX.Element;
36
+ declare const Description: (props: JSX.HTMLAttributes<HTMLParagraphElement>) => JSX.Element;
37
+ declare const Dialog: {
38
+ Root: typeof Root;
39
+ Provider: typeof Provider;
40
+ Trigger: typeof Trigger;
41
+ Close: typeof Close;
42
+ Content: typeof Content;
43
+ Title: typeof Title;
44
+ Description: typeof Description;
45
+ Body: import("./part.jsx").Part<"div">;
46
+ Actions: import("./part.jsx").Part<"div">;
47
+ };
48
+ export { Dialog, useDialog };
49
+ export type { DialogContextValue, DialogProps, DialogContentProps };