@kirana-ui/react 0.2.0 → 0.4.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/CHANGELOG.md +140 -0
- package/llms.txt +1800 -187
- package/package.json +48 -3
- package/skills/kirana-ui-primitives/SKILL.md +53 -12
- package/src/accordion.d.ts +2 -2
- package/src/accordion.js +3 -2
- package/src/accordion.js.map +1 -1
- package/src/alert-dialog.d.ts +2 -2
- package/src/autocomplete.d.ts +2 -2
- package/src/autosize.d.ts +1 -1
- package/src/avatar.d.ts +28 -7
- package/src/avatar.js +22 -9
- package/src/avatar.js.map +1 -1
- package/src/button.d.ts +5 -2
- package/src/button.js +4 -1
- package/src/button.js.map +1 -1
- package/src/calendar.d.ts +23 -8
- package/src/calendar.js +50 -13
- package/src/calendar.js.map +1 -1
- package/src/carousel.d.ts +6 -3
- package/src/carousel.js +1 -1
- package/src/carousel.js.map +1 -1
- package/src/checkbox-group-context.d.ts +4 -0
- package/src/checkbox-group-context.js +7 -0
- package/src/checkbox-group-context.js.map +1 -0
- package/src/checkbox-group.d.ts +15 -0
- package/src/checkbox-group.js +30 -0
- package/src/checkbox-group.js.map +1 -0
- package/src/checkbox.d.ts +7 -2
- package/src/checkbox.js +9 -3
- package/src/checkbox.js.map +1 -1
- package/src/collapsible.d.ts +1 -1
- package/src/color-picker.d.ts +61 -0
- package/src/color-picker.js +119 -0
- package/src/color-picker.js.map +1 -0
- package/src/combobox.d.ts +54 -5
- package/src/combobox.js +49 -8
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +4 -4
- package/src/command.js +2 -1
- package/src/command.js.map +1 -1
- package/src/date-field.d.ts +2 -2
- package/src/date-field.js +3 -2
- package/src/date-field.js.map +1 -1
- package/src/date-picker.d.ts +33 -11
- package/src/date-picker.js +22 -5
- package/src/date-picker.js.map +1 -1
- package/src/dialog.d.ts +11 -6
- package/src/dialog.js +27 -8
- package/src/dialog.js.map +1 -1
- package/src/direction.d.ts +1 -1
- package/src/direction.js +1 -1
- package/src/editable.d.ts +32 -0
- package/src/editable.js +63 -0
- package/src/editable.js.map +1 -0
- package/src/field.d.ts +1 -1
- package/src/fieldset.d.ts +1 -1
- package/src/file-upload.d.ts +54 -0
- package/src/file-upload.js +96 -0
- package/src/file-upload.js.map +1 -0
- package/src/form.d.ts +1 -1
- package/src/hover-popup.d.ts +1 -1
- package/src/hover-popup.js +1 -1
- package/src/index.d.ts +28 -7
- package/src/index.js +12 -1
- package/src/input.d.ts +1 -1
- package/src/input.js +1 -1
- package/src/label.d.ts +1 -1
- package/src/listbox.d.ts +1 -1
- package/src/listbox.js +1 -1
- package/src/menu.d.ts +5 -5
- package/src/menu.js +14 -9
- package/src/menu.js.map +1 -1
- package/src/menubar.d.ts +2 -2
- package/src/menubar.js +4 -2
- package/src/menubar.js.map +1 -1
- package/src/message-scroller.d.ts +1 -1
- package/src/navigation-menu.d.ts +5 -5
- package/src/navigation-menu.js +14 -4
- package/src/navigation-menu.js.map +1 -1
- package/src/number-field.d.ts +11 -2
- package/src/number-field.js +20 -3
- package/src/number-field.js.map +1 -1
- package/src/otp.d.ts +3 -2
- package/src/otp.js +10 -2
- package/src/otp.js.map +1 -1
- package/src/pagination.d.ts +1 -1
- package/src/password-input.d.ts +23 -0
- package/src/password-input.js +40 -0
- package/src/password-input.js.map +1 -0
- package/src/popover.d.ts +12 -4
- package/src/popover.js +14 -1
- package/src/popover.js.map +1 -1
- package/src/qr-code.d.ts +1 -1
- package/src/radio-group.d.ts +4 -2
- package/src/radio-group.js +6 -3
- package/src/radio-group.js.map +1 -1
- package/src/rating.d.ts +28 -0
- package/src/rating.js +59 -0
- package/src/rating.js.map +1 -0
- package/src/resizable.d.ts +1 -1
- package/src/resizable.js +1 -1
- package/src/runtime.d.ts +18 -8
- package/src/runtime.js +24 -5
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +1 -1
- package/src/scroll-area.js +1 -1
- package/src/select.d.ts +17 -6
- package/src/select.js +6 -3
- package/src/select.js.map +1 -1
- package/src/separator.d.ts +1 -1
- package/src/slider.d.ts +2 -2
- package/src/slider.js +3 -2
- package/src/slider.js.map +1 -1
- package/src/steps.d.ts +51 -0
- package/src/steps.js +69 -0
- package/src/steps.js.map +1 -0
- package/src/switch.d.ts +2 -1
- package/src/switch.js +1 -1
- package/src/switch.js.map +1 -1
- package/src/tabs.d.ts +2 -2
- package/src/tabs.js +4 -3
- package/src/tabs.js.map +1 -1
- package/src/tags-input.d.ts +47 -0
- package/src/tags-input.js +92 -0
- package/src/tags-input.js.map +1 -0
- package/src/time-field.d.ts +32 -0
- package/src/time-field.js +67 -0
- package/src/time-field.js.map +1 -0
- package/src/toast.d.ts +1 -1
- package/src/toggle-group.d.ts +2 -2
- package/src/toggle-group.js +4 -3
- package/src/toggle-group.js.map +1 -1
- package/src/toggle.d.ts +1 -1
- package/src/toggle.js +1 -1
- package/src/toolbar.d.ts +14 -6
- package/src/toolbar.js +19 -9
- package/src/toolbar.js.map +1 -1
- package/src/tour.d.ts +61 -0
- package/src/tour.js +68 -0
- package/src/tour.js.map +1 -0
- package/src/tree.d.ts +45 -0
- package/src/tree.js +93 -0
- package/src/tree.js.map +1 -0
- package/src/use-render.d.ts +1 -1
- package/src/use-render.js +1 -1
- package/src/use-render.js.map +1 -1
- package/src/value-bar.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kirana-ui/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Kirana UI Primitives for React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "The Kirana authors",
|
|
@@ -47,6 +47,10 @@
|
|
|
47
47
|
"types": "./src/checkbox.d.ts",
|
|
48
48
|
"default": "./src/checkbox.js"
|
|
49
49
|
},
|
|
50
|
+
"./checkbox-group": {
|
|
51
|
+
"types": "./src/checkbox-group.d.ts",
|
|
52
|
+
"default": "./src/checkbox-group.js"
|
|
53
|
+
},
|
|
50
54
|
"./collapsible": {
|
|
51
55
|
"types": "./src/collapsible.d.ts",
|
|
52
56
|
"default": "./src/collapsible.js"
|
|
@@ -135,6 +139,46 @@
|
|
|
135
139
|
"types": "./src/pagination.d.ts",
|
|
136
140
|
"default": "./src/pagination.js"
|
|
137
141
|
},
|
|
142
|
+
"./rating": {
|
|
143
|
+
"types": "./src/rating.d.ts",
|
|
144
|
+
"default": "./src/rating.js"
|
|
145
|
+
},
|
|
146
|
+
"./steps": {
|
|
147
|
+
"types": "./src/steps.d.ts",
|
|
148
|
+
"default": "./src/steps.js"
|
|
149
|
+
},
|
|
150
|
+
"./editable": {
|
|
151
|
+
"types": "./src/editable.d.ts",
|
|
152
|
+
"default": "./src/editable.js"
|
|
153
|
+
},
|
|
154
|
+
"./password-input": {
|
|
155
|
+
"types": "./src/password-input.d.ts",
|
|
156
|
+
"default": "./src/password-input.js"
|
|
157
|
+
},
|
|
158
|
+
"./tags-input": {
|
|
159
|
+
"types": "./src/tags-input.d.ts",
|
|
160
|
+
"default": "./src/tags-input.js"
|
|
161
|
+
},
|
|
162
|
+
"./file-upload": {
|
|
163
|
+
"types": "./src/file-upload.d.ts",
|
|
164
|
+
"default": "./src/file-upload.js"
|
|
165
|
+
},
|
|
166
|
+
"./time-field": {
|
|
167
|
+
"types": "./src/time-field.d.ts",
|
|
168
|
+
"default": "./src/time-field.js"
|
|
169
|
+
},
|
|
170
|
+
"./tree": {
|
|
171
|
+
"types": "./src/tree.d.ts",
|
|
172
|
+
"default": "./src/tree.js"
|
|
173
|
+
},
|
|
174
|
+
"./color-picker": {
|
|
175
|
+
"types": "./src/color-picker.d.ts",
|
|
176
|
+
"default": "./src/color-picker.js"
|
|
177
|
+
},
|
|
178
|
+
"./tour": {
|
|
179
|
+
"types": "./src/tour.d.ts",
|
|
180
|
+
"default": "./src/tour.js"
|
|
181
|
+
},
|
|
138
182
|
"./date-picker": {
|
|
139
183
|
"types": "./src/date-picker.d.ts",
|
|
140
184
|
"default": "./src/date-picker.js"
|
|
@@ -226,7 +270,7 @@
|
|
|
226
270
|
"./package.json": "./package.json"
|
|
227
271
|
},
|
|
228
272
|
"dependencies": {
|
|
229
|
-
"@kirana-ui/core": "0.
|
|
273
|
+
"@kirana-ui/core": "0.4.0"
|
|
230
274
|
},
|
|
231
275
|
"peerDependencies": {
|
|
232
276
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -250,6 +294,7 @@
|
|
|
250
294
|
"REFERENCE.md",
|
|
251
295
|
"llms.txt",
|
|
252
296
|
"skills",
|
|
253
|
-
"LICENSE"
|
|
297
|
+
"LICENSE",
|
|
298
|
+
"CHANGELOG.md"
|
|
254
299
|
]
|
|
255
300
|
}
|
|
@@ -33,10 +33,16 @@ from one core. The package for a framework is all a project installs.
|
|
|
33
33
|
A popup that is placed against its trigger (a popover, a menu, a select, a combobox, a
|
|
34
34
|
tooltip, a hover card) is `Portal > Positioner > Popup`: the `Positioner` takes `side`
|
|
35
35
|
(also `inline-start` and `inline-end`, which turn with the reading direction, and which
|
|
36
|
-
`data-side` then says), `align`, `sideOffset
|
|
36
|
+
`data-side` then says), `align`, `sideOffset` and `alignOffset` (a number, or a function
|
|
37
|
+
of the anchor's and the positioner's sizes), `collisionPadding` (a number, or one a side),
|
|
38
|
+
`collisionBoundary`, `collisionAvoidance`, `sticky`, `arrowPadding`, `positionMethod`, and
|
|
37
39
|
`anchor` for another element than its trigger to be placed against (an element, the
|
|
38
|
-
framework's own ref to one, or a function that gives one). A
|
|
39
|
-
|
|
40
|
+
framework's own ref to one, or a function that gives one). A popup that holds an `Arrow`
|
|
41
|
+
is given `position: relative`, so the arrow is placed in it through its entrance and
|
|
42
|
+
after. A popover may have a `Backdrop` in its portal, is `modal` (`true`: the page is
|
|
43
|
+
inert and does not scroll; `"trap-focus"`: only Tab is kept inside), and its trigger's
|
|
44
|
+
`openOnHover` lets the pointer open it too. A dialog, an alert dialog and a drawer have
|
|
45
|
+
no positioner: `Portal > Backdrop` and `Popup`, placed by the design.
|
|
40
46
|
3. Style by attributes and variables, never by guessing class names:
|
|
41
47
|
- a boolean state is present or absent: `[data-open]`, never `[data-open="true"]`;
|
|
42
48
|
- an entrance starts from `[data-starting-style]`, an exit ends at
|
|
@@ -46,17 +52,19 @@ from one core. The package for a framework is all a project installs.
|
|
|
46
52
|
4. A value is controlled when given (`value` + `onValueChange`) and the component's own
|
|
47
53
|
otherwise (`defaultValue`). A callback beside a value the component holds is
|
|
48
54
|
`(value, details)`, and `details.cancel()` keeps the value as it was. A callback that
|
|
49
|
-
reports something that happened (`
|
|
50
|
-
|
|
55
|
+
reports something that happened (`onClearErrors`, `onMonthChange`) takes only that. The
|
|
56
|
+
names are Base UI's: `loopFocus`, `disablePointerDismissal`, a multiple Select's or
|
|
57
|
+
Combobox's list in `value`, One-Time Code's `validationType` and `onValueComplete`, a
|
|
58
|
+
toast's `timeout`; the older names still work and are marked deprecated.
|
|
51
59
|
5. A control with a `name` is submitted with its form and follows the form's reset. Wrap it
|
|
52
60
|
in `Field` for a label, a description and validation. `readOnly` and `keepMounted` are
|
|
53
61
|
props of the parts `llms.txt` lists them for, and of no others.
|
|
54
62
|
|
|
55
63
|
Per framework: React takes `render` for another element; Vue takes `as` / `as-child`, binds
|
|
56
64
|
with `v-model:value` and names props in kebab case; Svelte takes a `child` snippet and
|
|
57
|
-
`bind:value`; Solid takes `as` and `render`; Angular's parts are directives on your own
|
|
58
|
-
elements (`<button
|
|
59
|
-
a part that comes and goes is structural (`*
|
|
65
|
+
`bind:value`; Solid (2, with `@solidjs/web`) takes `as` and `render`; Angular's parts are directives on your own
|
|
66
|
+
elements (`<button kpDialogTrigger>`), bound with `[(value)]`, with `[kpId]` for an id, and
|
|
67
|
+
a part that comes and goes is structural (`*kpDialogPortal`, `*kpTabsPanel`: the list is in
|
|
60
68
|
`llms.txt`); custom elements name each part with `kui-part` inside `<kui-dialog>`.
|
|
61
69
|
|
|
62
70
|
Composing a part with another element: with React's `render={<a … />}` and Vue's `as-child`
|
|
@@ -72,9 +80,24 @@ the text a part writes (`Meter.Value`, `Select.Value`) stay inside it on React a
|
|
|
72
80
|
`props().children` on Solid, and are given to a Svelte `child` snippet to render
|
|
73
81
|
(`{ props, state, input }`, `{ props, state, text }`). A handler given to a part is typed
|
|
74
82
|
with `preventKiranaHandler()` (`PartEvent`, exported by each package). For an element of the
|
|
75
|
-
design system's own
|
|
76
|
-
`@kirana-ui/react/use-render`,
|
|
77
|
-
|
|
83
|
+
design system's own composed as a part is, use `useRender` and `mergeProps` from
|
|
84
|
+
`@kirana-ui/react/use-render`, `Primitive` from `@kirana-ui/vue/primitive`, or `Primitive`
|
|
85
|
+
and `mergeProps` from `@kirana-ui/solid/primitive` and `@kirana-ui/svelte/primitive` (Solid's
|
|
86
|
+
`as` and `render`, Svelte's `as` and `child`, a `state` written as `data-*`); never write
|
|
87
|
+
another merge. On Angular such an element is a directive of your own with host bindings, and
|
|
88
|
+
custom elements need nothing: the page writes its own element.
|
|
89
|
+
|
|
90
|
+
A design system on Angular hosts each primitive in a directive of its own
|
|
91
|
+
(`hostDirectives: [{ directive: KpDialog, inputs: [...], outputs: [...] }]`), exposing what
|
|
92
|
+
its callers set; gives the primitive the rest with `hostInputs(KpTooltip, { delay: () => 0 })`
|
|
93
|
+
in its constructor (each value a function read like a signal, so `computed` values follow;
|
|
94
|
+
an input the element binds wins), never a subclass of the primitive; draws a structural part
|
|
95
|
+
(`kpDialogPortal`) in a component's template around `<ng-content />` (a part given to it finds
|
|
96
|
+
its root where it is written); and names its own directives as it likes, `kui…` included:
|
|
97
|
+
the primitives are `kp…` so that no design system's selector is theirs (two directives with
|
|
98
|
+
one selector both match, silently, and a component whose selector is its host's recurses).
|
|
99
|
+
Tooltips need no provider on any
|
|
100
|
+
framework: a design system passes `delay` on its own tooltip root (`hostInputs` on Angular).
|
|
78
101
|
|
|
79
102
|
## When something is wrong
|
|
80
103
|
|
|
@@ -115,7 +138,25 @@ component's ref, kind, label, state and actions), `act({ steps: [{ ref, action,
|
|
|
115
138
|
through the component's own handlers: its callback runs with `details.source === "agent"`
|
|
116
139
|
and may cancel. Give every control an accessible name (a `<label>`, `aria-label`): it is how
|
|
117
140
|
an agent finds it. Mark a destructive control `data-agent-confirm="what it does"`, private
|
|
118
|
-
regions `data-agent-hidden`, secrets `data-agent-secret
|
|
141
|
+
regions `data-agent-hidden`, secrets `data-agent-secret` (whatever is inside is listed with its
|
|
142
|
+
name and its actions, never its value, its choices or whether it is checked). A bridge given a
|
|
143
|
+
`root` also reads what was opened from inside it (a dialog, a menu, a select's list), by the
|
|
144
|
+
`aria-controls` of what opened it. A step names its control by ref, by its label, by words of
|
|
145
|
+
the label, by the text of its row or by one of its choices; a name two controls answer to
|
|
146
|
+
fails with both. `subscribe((changed, changes) => …)` says of each change its `key`, `value`,
|
|
147
|
+
`previous`, `source` and `reason`; `record()` keeps a person's changes in `history()` beside
|
|
148
|
+
the agent's, each with its `source` and a sentence (`text`), and `undoSource("agent")` takes
|
|
149
|
+
back only the agent's. `stage({ steps })` shows a suggestion in the controls and gives
|
|
150
|
+
`revert()` and `keep()`. `act` takes a `signal`; `timeout` bounds a wait for `allow` or
|
|
151
|
+
`confirm`. A component of your own is read through `kinds` (`AgentKind`: a selector, `read`,
|
|
152
|
+
`perform`). A slider's `setValue` fails with what the slider holds when
|
|
153
|
+
its range or step does not hold the value asked for, and so does a spin button's (a Date or
|
|
154
|
+
Time Field's part, typed as a person types it). The thumbs of a range named by their group
|
|
155
|
+
are told apart by their place (`"Price, 1 of 2"`). A list of several values (a listbox, a
|
|
156
|
+
select with `multiple`, a tree) says `values` and takes a list in `setValue`; a closed
|
|
157
|
+
select's are known once its list has been read. A tree is one component: its shown nodes
|
|
158
|
+
are its `items` (with `level` below the top and `open` for a branch), and `setValue`,
|
|
159
|
+
`open` and `close` take a node's name. `allow(action)` is the policy,
|
|
119
160
|
asked for every step; `confirm(action)` is a person's answer, asked for a step on something
|
|
120
161
|
marked `data-agent-confirm`, and without it such a step fails with "Needs a person" whatever
|
|
121
162
|
`allow` says. Never write `confirm: () => true`: open a dialog and resolve with what the
|
package/src/accordion.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
-
import { StateOf } from "@kirana-ui/core";
|
|
3
2
|
import { ReactElement } from "react";
|
|
3
|
+
import { StateOf } from "@kirana-ui/core";
|
|
4
4
|
import { AccordionProps } from "@kirana-ui/core/accordion";
|
|
5
5
|
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
6
|
type Parts = Vocabulary["accordion"];
|
|
@@ -8,7 +8,7 @@ type Parts = Vocabulary["accordion"];
|
|
|
8
8
|
export type RootProps<Value = unknown> = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<AccordionProps<Value>, "id"> & {
|
|
9
9
|
id?: string;
|
|
10
10
|
}>;
|
|
11
|
-
declare function Root<Value = unknown>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, id, ...rest }: RootProps<Value>): ReactElement;
|
|
11
|
+
declare function Root<Value = unknown>({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus, id, ...rest }: RootProps<Value>): ReactElement;
|
|
12
12
|
export type ItemProps = PartComponentProps<"div", StateOf<Parts["item"]>, {
|
|
13
13
|
/**
|
|
14
14
|
* What tells this item from the others: it is in the accordion's `value` while the item is
|
package/src/accordion.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DirectionContext } from "./direction-context.js";
|
|
2
2
|
import { PartElement, parts, useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
|
|
3
|
-
import { defined, within } from "@kirana-ui/core";
|
|
4
3
|
import { createContext, useContext, useId, useMemo } from "react";
|
|
4
|
+
import { defined, within } from "@kirana-ui/core";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { createAccordion } from "@kirana-ui/core/accordion";
|
|
7
7
|
// src/accordion.tsx
|
|
@@ -17,7 +17,7 @@ function useItem(part) {
|
|
|
17
17
|
if (!item) throw new Error(`<Accordion.${part}> must be inside <Accordion.Item>`);
|
|
18
18
|
return item;
|
|
19
19
|
}
|
|
20
|
-
function Root({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, id, ...rest }) {
|
|
20
|
+
function Root({ value, defaultValue, onValueChange, multiple, disabled, orientation, loop, loopFocus, id, ...rest }) {
|
|
21
21
|
const direction = useContext(DirectionContext) ?? void 0;
|
|
22
22
|
const create = within(createAccordion, { direction });
|
|
23
23
|
const controller = useController(create, {
|
|
@@ -28,6 +28,7 @@ function Root({ value, defaultValue, onValueChange, multiple, disabled, orientat
|
|
|
28
28
|
disabled,
|
|
29
29
|
orientation,
|
|
30
30
|
loop,
|
|
31
|
+
loopFocus,
|
|
31
32
|
id
|
|
32
33
|
});
|
|
33
34
|
return /* @__PURE__ */ jsx(Context.Provider, {
|
package/src/accordion.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accordion.js","names":[],"sources":["../../../../packages/react/src/accordion.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createAccordion } from \"@kirana-ui/core/accordion\"\nimport type {\n AccordionItem,\n AccordionProps,\n Accordion as Controller,\n} from \"@kirana-ui/core/accordion\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport {\n PartElement,\n parts,\n useController,\n useMount,\n useOptions,\n usePart,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"accordion\"]\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<AccordionItem | null>(null)\n\nfunction useAccordion(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Accordion.${part}> must be inside <Accordion.Root>`)\n return controller\n}\n\nfunction useItem(part: string): AccordionItem {\n const item = useContext(ItemContext)\n if (!item) throw new Error(`<Accordion.${part}> must be inside <Accordion.Item>`)\n return item\n}\n\n/** `Value` is what tells an item from the others: the type of `value`'s entries. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<AccordionProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n multiple,\n disabled,\n orientation,\n loop,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createAccordion<Value>, { direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n multiple,\n disabled,\n orientation,\n loop,\n id,\n })\n return (\n <Context.Provider value={controller}>\n <PartElement of={controller.root} tag=\"div\" {...rest} />\n </Context.Provider>\n )\n}\n\nexport type ItemProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"item\"]>,\n {\n /**\n * What tells this item from the others: it is in the accordion's `value` while the item is\n * open. An item that is given none makes its own.\n */\n value?: unknown\n /** Disables this item: it cannot be opened or closed. */\n disabled?: boolean\n }\n>\n\nfunction Item({ value, disabled, ...rest }: ItemProps): ReactElement {\n const controller = useAccordion(\"Item\")\n const options = useOptions({ disabled })\n const generated = useId()\n const key = value === undefined ? generated : value\n const item = useMemo(\n () => controller.item(key, () => defined(options.get())),\n [controller, key, options]\n )\n useMount(item)\n return (\n <ItemContext.Provider value={item}>\n <PartElement of={item.root} tag=\"div\" {...rest} />\n </ItemContext.Provider>\n )\n}\n\nexport type HeaderProps = PartComponentProps<\"h3\", StateOf<Parts[\"header\"]>>\nexport type TriggerProps = PartComponentProps<\"button\", StateOf<Parts[\"trigger\"]>>\n\nconst Header = (props: HeaderProps) => usePart(useItem(\"Header\").header, \"h3\", props)\nconst Trigger = (props: TriggerProps) => usePart(useItem(\"Trigger\").trigger, \"button\", props)\n\nexport type PanelProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"panel\"]>,\n {\n /** Keeps the closed panel in the page, `hidden`. */\n keepMounted?: boolean\n }\n>\n\nfunction Panel({ keepMounted, ...props }: PanelProps): ReactElement | null {\n const item = useItem(\"Panel\")\n const mounted = useSignal(item.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={item.panel} tag=\"div\" {...props} />\n}\n\nexport const Accordion = /* @__PURE__ */ parts(\"Accordion\", { Root, Item, Header, Trigger, Panel })\n"],"mappings":";;;;;;;AA0BA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAAoC,IAAI;AAE5D,SAAS,aAAa,MAA0B;CAC9C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CACtF,OAAO;AACT;AAEA,SAAS,QAAQ,MAA6B;CAC5C,MAAM,OAAO,WAAW,WAAW;CACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CAChF,OAAO;AACT;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,UACA,UACA,aACA,MACA,IACA,GAAG,QAC8B;CACjC,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,iBAAwB,EAAE,UAAU,CAAC;CAC3D,MAAM,aAAyB,cAAc,QAAQ;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CACvC,CAAA;AAEtB;AAgBA,SAAS,KAAK,EAAE,OAAO,UAAU,GAAG,QAAiC;CACnE,MAAM,aAAa,aAAa,MAAM;CACtC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,YAAY,MAAM;CACxB,MAAM,MAAM,UAAU,KAAA,IAAY,YAAY;CAC9C,MAAM,OAAO,cACL,WAAW,KAAK,WAAW,QAAQ,QAAQ,IAAI,CAAC,CAAC,GACvD;EAAC;EAAY;EAAK;CAAO,CAC3B;CACA,SAAS,IAAI;CACb,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,aAAD;GAAa,IAAI,KAAK;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CAC7B,CAAA;AAE1B;AAKA,MAAM,UAAU,UAAuB,QAAQ,QAAQ,QAAQ,CAAC,CAAC,QAAQ,MAAM,KAAK;AACpF,MAAM,WAAW,UAAwB,QAAQ,QAAQ,SAAS,CAAC,CAAC,SAAS,UAAU,KAAK;AAW5F,SAAS,MAAM,EAAE,aAAa,GAAG,SAA0C;CACzE,MAAM,OAAO,QAAQ,OAAO;CAE5B,IAAI,CADY,UAAU,KAAK,OACpB,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,KAAK;EAAO,KAAI;EAAM,GAAI;CAAQ,CAAA;AAC5D;AAEA,MAAa,YAA4B,sBAAM,aAAa;CAAE;CAAM;CAAM;CAAQ;CAAS;AAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"accordion.js","names":[],"sources":["../../../../packages/react/src/accordion.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createAccordion } from \"@kirana-ui/core/accordion\"\nimport type {\n AccordionItem,\n AccordionProps,\n Accordion as Controller,\n} from \"@kirana-ui/core/accordion\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport {\n PartElement,\n parts,\n useController,\n useMount,\n useOptions,\n usePart,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"accordion\"]\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<AccordionItem | null>(null)\n\nfunction useAccordion(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Accordion.${part}> must be inside <Accordion.Root>`)\n return controller\n}\n\nfunction useItem(part: string): AccordionItem {\n const item = useContext(ItemContext)\n if (!item) throw new Error(`<Accordion.${part}> must be inside <Accordion.Item>`)\n return item\n}\n\n/** `Value` is what tells an item from the others: the type of `value`'s entries. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<AccordionProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n multiple,\n disabled,\n orientation,\n loop,\n loopFocus,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createAccordion<Value>, { direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n multiple,\n disabled,\n orientation,\n loop,\n loopFocus,\n id,\n })\n return (\n <Context.Provider value={controller}>\n <PartElement of={controller.root} tag=\"div\" {...rest} />\n </Context.Provider>\n )\n}\n\nexport type ItemProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"item\"]>,\n {\n /**\n * What tells this item from the others: it is in the accordion's `value` while the item is\n * open. An item that is given none makes its own.\n */\n value?: unknown\n /** Disables this item: it cannot be opened or closed. */\n disabled?: boolean\n }\n>\n\nfunction Item({ value, disabled, ...rest }: ItemProps): ReactElement {\n const controller = useAccordion(\"Item\")\n const options = useOptions({ disabled })\n const generated = useId()\n const key = value === undefined ? generated : value\n const item = useMemo(\n () => controller.item(key, () => defined(options.get())),\n [controller, key, options]\n )\n useMount(item)\n return (\n <ItemContext.Provider value={item}>\n <PartElement of={item.root} tag=\"div\" {...rest} />\n </ItemContext.Provider>\n )\n}\n\nexport type HeaderProps = PartComponentProps<\"h3\", StateOf<Parts[\"header\"]>>\nexport type TriggerProps = PartComponentProps<\"button\", StateOf<Parts[\"trigger\"]>>\n\nconst Header = (props: HeaderProps) => usePart(useItem(\"Header\").header, \"h3\", props)\nconst Trigger = (props: TriggerProps) => usePart(useItem(\"Trigger\").trigger, \"button\", props)\n\nexport type PanelProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"panel\"]>,\n {\n /** Keeps the closed panel in the page, `hidden`. */\n keepMounted?: boolean\n }\n>\n\nfunction Panel({ keepMounted, ...props }: PanelProps): ReactElement | null {\n const item = useItem(\"Panel\")\n const mounted = useSignal(item.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={item.panel} tag=\"div\" {...props} />\n}\n\nexport const Accordion = /* @__PURE__ */ parts(\"Accordion\", { Root, Item, Header, Trigger, Panel })\n"],"mappings":";;;;;;;AA0BA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAAoC,IAAI;AAE5D,SAAS,aAAa,MAA0B;CAC9C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CACtF,OAAO;AACT;AAEA,SAAS,QAAQ,MAA6B;CAC5C,MAAM,OAAO,WAAW,WAAW;CACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,cAAc,KAAK,kCAAkC;CAChF,OAAO;AACT;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,UACA,UACA,aACA,MACA,WACA,IACA,GAAG,QAC8B;CACjC,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,iBAAwB,EAAE,UAAU,CAAC;CAC3D,MAAM,aAAyB,cAAc,QAAQ;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CACvC,CAAA;AAEtB;AAgBA,SAAS,KAAK,EAAE,OAAO,UAAU,GAAG,QAAiC;CACnE,MAAM,aAAa,aAAa,MAAM;CACtC,MAAM,UAAU,WAAW,EAAE,SAAS,CAAC;CACvC,MAAM,YAAY,MAAM;CACxB,MAAM,MAAM,UAAU,KAAA,IAAY,YAAY;CAC9C,MAAM,OAAO,cACL,WAAW,KAAK,WAAW,QAAQ,QAAQ,IAAI,CAAC,CAAC,GACvD;EAAC;EAAY;EAAK;CAAO,CAC3B;CACA,SAAS,IAAI;CACb,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,aAAD;GAAa,IAAI,KAAK;GAAM,KAAI;GAAM,GAAI;EAAO,CAAA;CAC7B,CAAA;AAE1B;AAKA,MAAM,UAAU,UAAuB,QAAQ,QAAQ,QAAQ,CAAC,CAAC,QAAQ,MAAM,KAAK;AACpF,MAAM,WAAW,UAAwB,QAAQ,QAAQ,SAAS,CAAC,CAAC,SAAS,UAAU,KAAK;AAW5F,SAAS,MAAM,EAAE,aAAa,GAAG,SAA0C;CACzE,MAAM,OAAO,QAAQ,OAAO;CAE5B,IAAI,CADY,UAAU,KAAK,OACpB,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,KAAK;EAAO,KAAI;EAAM,GAAI;CAAQ,CAAA;AAC5D;AAEA,MAAa,YAA4B,sBAAM,aAAa;CAAE;CAAM;CAAM;CAAQ;CAAS;AAAM,CAAC"}
|
package/src/alert-dialog.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PortalProps } from "./runtime.js";
|
|
2
|
-
import { AlertDialog, AlertRootProps, BackdropProps, CloseProps, DescriptionProps, PopupProps, TitleProps, TriggerProps } from "./dialog.js";
|
|
3
|
-
export { AlertDialog, type BackdropProps, type CloseProps, type DescriptionProps, type PopupProps, type PortalProps, type AlertRootProps as RootProps, type TitleProps, type TriggerProps };
|
|
2
|
+
import { AlertDialog, AlertRootProps, BackdropProps, CloseProps, DescriptionProps, PopupProps, TitleProps, TriggerProps, ViewportProps } from "./dialog.js";
|
|
3
|
+
export { AlertDialog, type BackdropProps, type CloseProps, type DescriptionProps, type PopupProps, type PortalProps, type AlertRootProps as RootProps, type TitleProps, type TriggerProps, type ViewportProps };
|
package/src/autocomplete.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { PortalProps } from "./runtime.js";
|
|
2
|
-
import { Autocomplete, AutocompleteRootProps, ClearProps, EmptyProps, GroupLabelProps, GroupProps, InputProps, ItemProps, ListProps, PopupProps, PositionerProps, SeparatorProps, TriggerProps } from "./combobox.js";
|
|
3
|
-
export { Autocomplete, type ClearProps, type EmptyProps, type GroupLabelProps, type GroupProps, type InputProps, type ItemProps, type ListProps, type PopupProps, type PortalProps, type PositionerProps, type AutocompleteRootProps as RootProps, type SeparatorProps, type TriggerProps };
|
|
2
|
+
import { Autocomplete, AutocompleteRootProps, ClearProps, CollectionProps, EmptyProps, GroupLabelProps, GroupProps, InputProps, ItemProps, ListProps, PopupProps, PositionerProps, SeparatorProps, StatusProps, TriggerProps } from "./combobox.js";
|
|
3
|
+
export { Autocomplete, type ClearProps, type CollectionProps, type EmptyProps, type GroupLabelProps, type GroupProps, type InputProps, type ItemProps, type ListProps, type PopupProps, type PortalProps, type PositionerProps, type AutocompleteRootProps as RootProps, type SeparatorProps, type StatusProps, type TriggerProps };
|
package/src/autosize.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
-
import { StateOf } from "@kirana-ui/core";
|
|
3
2
|
import { ReactElement } from "react";
|
|
3
|
+
import { StateOf } from "@kirana-ui/core";
|
|
4
4
|
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
5
5
|
export type TextareaProps = PartComponentProps<"textarea", StateOf<Vocabulary["autosize"]["textarea"]>>;
|
|
6
6
|
/** A `<textarea>` as tall as its text. It takes what a `<textarea>` takes. */
|
package/src/avatar.d.ts
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
-
import {
|
|
2
|
+
import { AvatarFallbackProps, AvatarImageProps } from "@kirana-ui/core/avatar";
|
|
3
3
|
import { ReactElement } from "react";
|
|
4
|
+
import { StateOf } from "@kirana-ui/core";
|
|
4
5
|
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
5
6
|
type Parts = Vocabulary["avatar"];
|
|
6
7
|
export type RootProps = PartComponentProps<"span", StateOf<Parts["root"]>>;
|
|
7
8
|
declare function Root(props: RootProps): ReactElement;
|
|
8
|
-
export type ImageProps = PartComponentProps<"img", StateOf<Parts["image"]
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
export type ImageProps = PartComponentProps<"img", StateOf<Parts["image"]>, {
|
|
10
|
+
/**
|
|
11
|
+
* Called each time the picture's loading status changes: `loading` once it has an address,
|
|
12
|
+
* then `loaded` or `error`; `idle` again when its address is taken away. The root says the
|
|
13
|
+
* same in `data-image-loading-status`.
|
|
14
|
+
*/
|
|
15
|
+
onLoadingStatusChange?: AvatarImageProps["onLoadingStatusChange"];
|
|
16
|
+
/**
|
|
17
|
+
* Keeps the element in the page while the picture loads, as Base UI's: it loads the
|
|
18
|
+
* picture itself (`loading="lazy"` works), and until it has loaded it is `aria-hidden`,
|
|
19
|
+
* with `data-loading` or `data-error` for the design to hide or fade it by. Default:
|
|
20
|
+
* `false`, the element is drawn once the picture has loaded.
|
|
21
|
+
*/
|
|
22
|
+
keepMounted?: boolean;
|
|
23
|
+
}>;
|
|
24
|
+
/** The picture: in the page once `src` has loaded, or all along with `keepMounted`. */
|
|
25
|
+
declare function Image({ src, onLoadingStatusChange, keepMounted, ...props }: ImageProps): ReactElement | null;
|
|
26
|
+
export type FallbackProps = PartComponentProps<"span", StateOf<Parts["fallback"]>, {
|
|
27
|
+
/**
|
|
28
|
+
* How long to wait before showing, in milliseconds, so a picture that loads sooner never
|
|
29
|
+
* lets the fallback be seen. Read once. Default: `0`, at once.
|
|
30
|
+
*/
|
|
31
|
+
delay?: AvatarFallbackProps["delay"];
|
|
32
|
+
}>;
|
|
33
|
+
/** What shows until the picture has loaded, or when it cannot; after `delay`, when given one. */
|
|
34
|
+
declare function Fallback({ delay, ...props }: FallbackProps): ReactElement | null;
|
|
14
35
|
export declare const Avatar: {
|
|
15
36
|
readonly Root: typeof Root;
|
|
16
37
|
readonly Image: typeof Image;
|
package/src/avatar.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PartElement, parts, useController, useIsomorphicLayoutEffect, useSignal } from "./runtime.js";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
1
|
+
import { PartElement, parts, useController, useIsomorphicLayoutEffect, useMount, useSignal } from "./runtime.js";
|
|
4
2
|
import { createAvatar } from "@kirana-ui/core/avatar";
|
|
3
|
+
import { createContext, useContext, useRef, useState } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
// src/avatar.tsx
|
|
6
6
|
const Context = createContext(null);
|
|
7
7
|
function useAvatar(part) {
|
|
@@ -20,21 +20,34 @@ function Root(props) {
|
|
|
20
20
|
})
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
/** The picture: in the page once `src` has loaded
|
|
24
|
-
function Image({ src, ...props }) {
|
|
23
|
+
/** The picture: in the page once `src` has loaded, or all along with `keepMounted`. */
|
|
24
|
+
function Image({ src, onLoadingStatusChange, keepMounted, ...props }) {
|
|
25
25
|
const controller = useAvatar("Image");
|
|
26
26
|
useIsomorphicLayoutEffect(() => controller.source.set(src), [controller, src]);
|
|
27
|
-
|
|
27
|
+
const told = useRef(onLoadingStatusChange);
|
|
28
|
+
told.current = onLoadingStatusChange;
|
|
29
|
+
const [report] = useState(() => controller.statusReport(() => told.current));
|
|
30
|
+
useMount(report);
|
|
31
|
+
const mounted = useSignal(controller.imageMounted);
|
|
32
|
+
if (keepMounted) return /* @__PURE__ */ jsx(PartElement, {
|
|
33
|
+
of: controller.keptImage,
|
|
34
|
+
tag: "img",
|
|
35
|
+
src,
|
|
36
|
+
...props
|
|
37
|
+
});
|
|
38
|
+
if (!mounted) return null;
|
|
28
39
|
return /* @__PURE__ */ jsx(PartElement, {
|
|
29
40
|
of: controller.image,
|
|
30
41
|
tag: "img",
|
|
31
42
|
...props
|
|
32
43
|
});
|
|
33
44
|
}
|
|
34
|
-
/** What shows until the picture has loaded, or when it cannot. */
|
|
35
|
-
function Fallback(props) {
|
|
45
|
+
/** What shows until the picture has loaded, or when it cannot; after `delay`, when given one. */
|
|
46
|
+
function Fallback({ delay, ...props }) {
|
|
36
47
|
const controller = useAvatar("Fallback");
|
|
37
|
-
|
|
48
|
+
const [presence] = useState(() => controller.fallbackPresence({ delay }));
|
|
49
|
+
useMount(presence);
|
|
50
|
+
if (!useSignal(presence.shown)) return null;
|
|
38
51
|
return /* @__PURE__ */ jsx(PartElement, {
|
|
39
52
|
of: controller.fallback,
|
|
40
53
|
tag: "span",
|
package/src/avatar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avatar.js","names":[],"sources":["../../../../packages/react/src/avatar.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createAvatar } from \"@kirana-ui/core/avatar\"\nimport type {
|
|
1
|
+
{"version":3,"file":"avatar.js","names":[],"sources":["../../../../packages/react/src/avatar.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createAvatar } from \"@kirana-ui/core/avatar\"\nimport type {\n AvatarFallbackProps,\n AvatarImageProps,\n Avatar as Controller,\n} from \"@kirana-ui/core/avatar\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useRef, useState } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport {\n PartElement,\n parts,\n useController,\n useIsomorphicLayoutEffect,\n useMount,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"avatar\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useAvatar(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Avatar.${part}> must be inside <Avatar.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\"span\", StateOf<Parts[\"root\"]>>\n\nfunction Root(props: RootProps): ReactElement {\n const controller = useController(createAvatar, {})\n return (\n <Context.Provider value={controller}>\n <PartElement of={controller.root} tag=\"span\" {...props} />\n </Context.Provider>\n )\n}\n\nexport type ImageProps = PartComponentProps<\n \"img\",\n StateOf<Parts[\"image\"]>,\n {\n /**\n * Called each time the picture's loading status changes: `loading` once it has an address,\n * then `loaded` or `error`; `idle` again when its address is taken away. The root says the\n * same in `data-image-loading-status`.\n */\n onLoadingStatusChange?: AvatarImageProps[\"onLoadingStatusChange\"]\n /**\n * Keeps the element in the page while the picture loads, as Base UI's: it loads the\n * picture itself (`loading=\"lazy\"` works), and until it has loaded it is `aria-hidden`,\n * with `data-loading` or `data-error` for the design to hide or fade it by. Default:\n * `false`, the element is drawn once the picture has loaded.\n */\n keepMounted?: boolean\n }\n>\n\n/** The picture: in the page once `src` has loaded, or all along with `keepMounted`. */\nfunction Image({\n src,\n onLoadingStatusChange,\n keepMounted,\n ...props\n}: ImageProps): ReactElement | null {\n const controller = useAvatar(\"Image\")\n // After the render commits, never during it: the load it starts changes the status, which\n // other parts are drawn from, and React forbids updating them mid-render.\n useIsomorphicLayoutEffect(() => controller.source.set(src), [controller, src])\n const told = useRef(onLoadingStatusChange)\n told.current = onLoadingStatusChange\n const [report] = useState(() => controller.statusReport(() => told.current))\n useMount(report)\n const mounted = useSignal(controller.imageMounted)\n if (keepMounted) return <PartElement of={controller.keptImage} tag=\"img\" src={src} {...props} />\n // From when it has loaded, and through its exit.\n if (!mounted) return null\n return <PartElement of={controller.image} tag=\"img\" {...props} />\n}\n\nexport type FallbackProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"fallback\"]>,\n {\n /**\n * How long to wait before showing, in milliseconds, so a picture that loads sooner never\n * lets the fallback be seen. Read once. Default: `0`, at once.\n */\n delay?: AvatarFallbackProps[\"delay\"]\n }\n>\n\n/** What shows until the picture has loaded, or when it cannot; after `delay`, when given one. */\nfunction Fallback({ delay, ...props }: FallbackProps): ReactElement | null {\n const controller = useAvatar(\"Fallback\")\n const [presence] = useState(() => controller.fallbackPresence({ delay }))\n useMount(presence)\n const shown = useSignal(presence.shown)\n if (!shown) return null\n return <PartElement of={controller.fallback} tag=\"span\" {...props} />\n}\n\nexport const Avatar = /* @__PURE__ */ parts(\"Avatar\", { Root, Image, Fallback })\n"],"mappings":";;;;;AAuBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,UAAU,MAA0B;CAC3C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,WAAW,KAAK,+BAA+B;CAChF,OAAO;AACT;AAIA,SAAS,KAAK,OAAgC;CAC5C,MAAM,aAAa,cAAc,cAAc,CAAC,CAAC;CACjD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACvB,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAO,GAAI;EAAQ,CAAA;CACzC,CAAA;AAEtB;;AAuBA,SAAS,MAAM,EACb,KACA,uBACA,aACA,GAAG,SAC+B;CAClC,MAAM,aAAa,UAAU,OAAO;CAGpC,gCAAgC,WAAW,OAAO,IAAI,GAAG,GAAG,CAAC,YAAY,GAAG,CAAC;CAC7E,MAAM,OAAO,OAAO,qBAAqB;CACzC,KAAK,UAAU;CACf,MAAM,CAAC,UAAU,eAAe,WAAW,mBAAmB,KAAK,OAAO,CAAC;CAC3E,SAAS,MAAM;CACf,MAAM,UAAU,UAAU,WAAW,YAAY;CACjD,IAAI,aAAa,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAW,KAAI;EAAW;EAAK,GAAI;CAAQ,CAAA;CAE/F,IAAI,CAAC,SAAS,OAAO;CACrB,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAO,KAAI;EAAM,GAAI;CAAQ,CAAA;AAClE;;AAeA,SAAS,SAAS,EAAE,OAAO,GAAG,SAA6C;CACzE,MAAM,aAAa,UAAU,UAAU;CACvC,MAAM,CAAC,YAAY,eAAe,WAAW,iBAAiB,EAAE,MAAM,CAAC,CAAC;CACxE,SAAS,QAAQ;CAEjB,IAAI,CADU,UAAU,SAAS,KACxB,GAAG,OAAO;CACnB,OAAO,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAU,KAAI;EAAO,GAAI;CAAQ,CAAA;AACtE;AAEA,MAAa,SAAyB,sBAAM,UAAU;CAAE;CAAM;CAAO;AAAS,CAAC"}
|
package/src/button.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
-
import { StateOf } from "@kirana-ui/core";
|
|
3
2
|
import { ReactElement } from "react";
|
|
3
|
+
import { StateOf } from "@kirana-ui/core";
|
|
4
4
|
import { ButtonProps as ButtonProps$1 } from "@kirana-ui/core/button";
|
|
5
5
|
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
6
|
export type ButtonProps = PartComponentProps<"button", StateOf<Vocabulary["button"]["root"]>, ButtonProps$1>;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one; a
|
|
9
|
+
* link that navigates (`render={<a href="/x" />}`) stays a link.
|
|
10
|
+
*/
|
|
8
11
|
export declare const Button: ({ disabled, focusableWhenDisabled, nativeButton, ...rest }: ButtonProps) => ReactElement;
|
|
9
12
|
//# sourceMappingURL=button.d.ts.map
|
package/src/button.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { component, useController, usePart } from "./runtime.js";
|
|
2
2
|
import { createButton } from "@kirana-ui/core/button";
|
|
3
3
|
// src/button.tsx
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one; a
|
|
6
|
+
* link that navigates (`render={<a href="/x" />}`) stays a link.
|
|
7
|
+
*/
|
|
5
8
|
const Button = /* @__PURE__ */ component("Button", function Button({ disabled, focusableWhenDisabled, nativeButton, ...rest }) {
|
|
6
9
|
const controller = useController(createButton, {
|
|
7
10
|
disabled,
|
package/src/button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.js","names":[],"sources":["../../../../packages/react/src/button.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createButton } from \"@kirana-ui/core/button\"\nimport type { ButtonProps as CoreProps } from \"@kirana-ui/core/button\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport type { ReactElement } from \"react\"\n\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type ButtonProps = PartComponentProps<\n \"button\",\n StateOf<Vocabulary[\"button\"][\"root\"]>,\n CoreProps\n>\n\n
|
|
1
|
+
{"version":3,"file":"button.js","names":[],"sources":["../../../../packages/react/src/button.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createButton } from \"@kirana-ui/core/button\"\nimport type { ButtonProps as CoreProps } from \"@kirana-ui/core/button\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport type { ReactElement } from \"react\"\n\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type ButtonProps = PartComponentProps<\n \"button\",\n StateOf<Vocabulary[\"button\"][\"root\"]>,\n CoreProps\n>\n\n/**\n * A `<button>`, or with `render` and `nativeButton={false}` another element that acts as one; a\n * link that navigates (`render={<a href=\"/x\" />}`) stays a link.\n */\nexport const Button = /* @__PURE__ */ component(\n \"Button\",\n function Button({\n disabled,\n focusableWhenDisabled,\n nativeButton,\n ...rest\n }: ButtonProps): ReactElement {\n const controller = useController(createButton, {\n disabled,\n focusableWhenDisabled,\n nativeButton,\n })\n return usePart(controller.root, \"button\", rest)\n }\n)\n"],"mappings":";;;;;;;AAmBA,MAAa,SAAyB,0BACpC,UACA,SAAS,OAAO,EACd,UACA,uBACA,cACA,GAAG,QACyB;CAC5B,MAAM,aAAa,cAAc,cAAc;EAC7C;EACA;EACA;CACF,CAAC;CACD,OAAO,QAAQ,WAAW,MAAM,UAAU,IAAI;AAChD,CACF"}
|
package/src/calendar.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
-
import { StateOf } from "@kirana-ui/core";
|
|
3
2
|
import { ReactElement, ReactNode } from "react";
|
|
4
|
-
import {
|
|
3
|
+
import { StateOf } from "@kirana-ui/core";
|
|
4
|
+
import { Calendar as Calendar$1, CalendarDay, CalendarMode, CalendarMonth, CalendarProps, CalendarWeekday } from "@kirana-ui/core/calendar";
|
|
5
5
|
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
6
|
type Parts = Vocabulary["calendar"];
|
|
7
7
|
/**
|
|
@@ -9,10 +9,11 @@ type Parts = Vocabulary["calendar"];
|
|
|
9
9
|
* provides its own to the calendar's parts).
|
|
10
10
|
*/
|
|
11
11
|
declare const Context: import("react").Context<Calendar$1 | null>;
|
|
12
|
-
|
|
12
|
+
/** `value` and `onValueChange` are typed by `mode`: a day, a range, or a list of days. */
|
|
13
|
+
export type RootProps<Mode extends CalendarMode = "single"> = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<CalendarProps<Mode>, "id"> & {
|
|
13
14
|
id?: string;
|
|
14
15
|
}>;
|
|
15
|
-
declare function Root({ value, defaultValue, onValueChange, mode,
|
|
16
|
+
declare function Root<Mode extends CalendarMode = "single">({ value, defaultValue, onValueChange, mode, required, minDays, maxDays, months, pagedNavigation, month, defaultMonth, onMonthChange, defaultFocusedValue, locale, calendarSystem, min, max, isDateUnavailable, disabled, readOnly, fixedWeeks, name, form, id, ...rest }: RootProps<Mode>): ReactElement;
|
|
16
17
|
export type HeadingProps = PartComponentProps<"div", StateOf<Parts["heading"]>>;
|
|
17
18
|
/** Names the month shown, unless it is given something else to say. */
|
|
18
19
|
declare function Heading({ children, ...props }: HeadingProps): ReactElement;
|
|
@@ -22,6 +23,15 @@ export type NextProps = PartComponentProps<"button", StateOf<Parts["next"]>>;
|
|
|
22
23
|
declare const Next: (props: NextProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
23
24
|
export type GridProps = PartComponentProps<"table", StateOf<Parts["grid"]>>;
|
|
24
25
|
declare const Grid: (props: GridProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
26
|
+
export interface MonthsProps {
|
|
27
|
+
/** Draws one month, once for each shown: its heading and its grid. */
|
|
28
|
+
children: (month: CalendarMonth) => ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Draws its child once for each month shown (`months` on the root), side by side: the parts
|
|
32
|
+
* inside each are that month's. Left out for one month.
|
|
33
|
+
*/
|
|
34
|
+
declare function Months({ children }: MonthsProps): import("react").JSX.Element;
|
|
25
35
|
export interface WeekdaysProps {
|
|
26
36
|
/** Draws one day of the week, once for each: its heading cell. */
|
|
27
37
|
children: (weekday: CalendarWeekday) => ReactNode;
|
|
@@ -40,26 +50,31 @@ export type HeadCellProps = PartComponentProps<"th", StateOf<Parts["headCell"]>,
|
|
|
40
50
|
}>;
|
|
41
51
|
declare function HeadCell({ weekday, ...props }: HeadCellProps): ReactElement;
|
|
42
52
|
export type CellProps = PartComponentProps<"td", StateOf<Parts["cell"]>, {
|
|
43
|
-
/** The day it holds, as `Calendar.Weeks` gave it: `day.date`. */
|
|
53
|
+
/** The day it holds, as `Calendar.Weeks` gave it: `day.date`. A `Day` inside takes it too. */
|
|
44
54
|
date: string;
|
|
45
55
|
}>;
|
|
46
56
|
declare function Cell({ date, ...props }: CellProps): ReactElement;
|
|
47
57
|
export type DayProps = PartComponentProps<"button", StateOf<Parts["day"]>, {
|
|
48
|
-
/** The day it is the button of,
|
|
49
|
-
date
|
|
58
|
+
/** The day it is the button of. Left out, the `Calendar.Cell`'s it is inside. */
|
|
59
|
+
date?: string;
|
|
50
60
|
}>;
|
|
51
|
-
declare function Day({ date, ...props }: DayProps): ReactElement;
|
|
61
|
+
declare function Day({ date: given, ...props }: DayProps): ReactElement;
|
|
62
|
+
export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>>;
|
|
63
|
+
/** The hidden input the value is submitted by, when the root has a `name`. */
|
|
64
|
+
declare const Input: (props: InputProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
52
65
|
export declare const Calendar: {
|
|
53
66
|
readonly Root: typeof Root;
|
|
54
67
|
readonly Heading: typeof Heading;
|
|
55
68
|
readonly Previous: typeof Previous;
|
|
56
69
|
readonly Next: typeof Next;
|
|
70
|
+
readonly Months: typeof Months;
|
|
57
71
|
readonly Grid: typeof Grid;
|
|
58
72
|
readonly Weekdays: typeof Weekdays;
|
|
59
73
|
readonly HeadCell: typeof HeadCell;
|
|
60
74
|
readonly Weeks: typeof Weeks;
|
|
61
75
|
readonly Cell: typeof Cell;
|
|
62
76
|
readonly Day: typeof Day;
|
|
77
|
+
readonly Input: typeof Input;
|
|
63
78
|
};
|
|
64
79
|
export { Context as CalendarContext };
|
|
65
80
|
//# sourceMappingURL=calendar.d.ts.map
|