@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/src/otp.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { FieldContext } from "./field-context.js";
|
|
1
2
|
import { PartElement, parts, useController, usePart, useSignal } from "./runtime.js";
|
|
2
3
|
import { createContext, useContext } from "react";
|
|
4
|
+
import { within } from "@kirana-ui/core";
|
|
3
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
4
6
|
import { createOtp } from "@kirana-ui/core/otp";
|
|
5
7
|
// src/otp.tsx
|
|
@@ -10,15 +12,21 @@ function useOtp(part) {
|
|
|
10
12
|
if (!controller) throw new Error(`<Otp.${part}> must be inside <Otp.Root>`);
|
|
11
13
|
return controller;
|
|
12
14
|
}
|
|
13
|
-
function Root({ length, value, defaultValue, onValueChange, onComplete, mode, disabled, name, form, id, ...rest }) {
|
|
14
|
-
const
|
|
15
|
+
function Root({ length, value, defaultValue, onValueChange, onValueComplete, onComplete, validationType, mode, pattern, disabled, readOnly, required, name, form, id, ...rest }) {
|
|
16
|
+
const field = useContext(FieldContext) ?? void 0;
|
|
17
|
+
const controller = useController(within(createOtp, { field }), {
|
|
15
18
|
length,
|
|
16
19
|
value,
|
|
17
20
|
defaultValue,
|
|
18
21
|
onValueChange,
|
|
22
|
+
onValueComplete,
|
|
19
23
|
onComplete,
|
|
24
|
+
validationType,
|
|
20
25
|
mode,
|
|
26
|
+
pattern,
|
|
21
27
|
disabled,
|
|
28
|
+
readOnly,
|
|
29
|
+
required,
|
|
22
30
|
name,
|
|
23
31
|
form,
|
|
24
32
|
id
|
package/src/otp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/react/src/otp.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp as Controller, OtpProps, OtpSlot } from \"@kirana-ui/core/otp\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { PartElement, parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"otp\"]\n\nconst Context = createContext<Controller | null>(null)\nconst SlotContext = createContext<OtpSlot | null>(null)\n\nfunction useOtp(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Otp.${part}> must be inside <Otp.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<OtpProps, \"id\"> & { id?: string
|
|
1
|
+
{"version":3,"file":"otp.js","names":[],"sources":["../../../../packages/react/src/otp.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createOtp } from \"@kirana-ui/core/otp\"\nimport type { Otp as Controller, OtpProps, OtpSlot } from \"@kirana-ui/core/otp\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { PartElement, parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"otp\"]\n\nconst Context = createContext<Controller | null>(null)\nconst SlotContext = createContext<OtpSlot | null>(null)\n\nfunction useOtp(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Otp.${part}> must be inside <Otp.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<OtpProps, \"id\"> & {\n /** The id of its input, not of the root: a `<label for>` names it. */\n id?: string\n }\n>\n\nfunction Root({\n length,\n value,\n defaultValue,\n onValueChange,\n onValueComplete,\n onComplete,\n validationType,\n mode,\n pattern,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n ...rest\n}: RootProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const controller = useController<OtpProps, Controller>(within(createOtp, { field }), {\n length,\n value,\n defaultValue,\n onValueChange,\n onValueComplete,\n onComplete,\n validationType,\n mode,\n pattern,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n })\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>>\n\nconst Input = (props: InputProps) => usePart(useOtp(\"Input\").input, \"input\", props)\nexport type GroupProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>>\n\nconst Group = (props: GroupProps) => usePart(useOtp(\"Group\").group, \"div\", props)\nexport type SeparatorProps = PartComponentProps<\"div\", StateOf<Parts[\"separator\"]>>\n\nconst Separator = (props: SeparatorProps) => usePart(useOtp(\"Separator\").separator, \"div\", props)\n\nexport type SlotProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"slot\"]>,\n {\n /** Which character of the code it shows, from 0. */\n index: number\n }\n>\n\n/** One cell: it shows its character, then whatever it is given (a caret). */\nfunction Slot({ index, ...props }: SlotProps): ReactElement {\n const slot = useOtp(\"Slot\").slot(index)\n const char = useSignal(slot.char)\n return (\n <SlotContext.Provider value={slot}>\n {usePart(slot.part, \"div\", props, undefined, (content) => (\n // Its character comes first, whatever element the caller asked for.\n <>\n {char}\n {content}\n </>\n ))}\n </SlotContext.Provider>\n )\n}\n\nexport type CaretProps = PartComponentProps<\"div\", StateOf<Parts[\"caret\"]>>\n\n/** Drawn in its cell while the cell is the active one and empty. */\nfunction Caret(props: CaretProps): ReactElement | null {\n const controller = useOtp(\"Caret\")\n const slot = useContext(SlotContext)\n if (!slot) throw new Error(\"<Otp.Caret> must be inside <Otp.Slot>\")\n const shown = useSignal(slot.caret)\n return shown ? <PartElement of={controller.caretPart} tag=\"div\" {...props} /> : null\n}\n\nexport const Otp = /* @__PURE__ */ parts(\"Otp\", { Root, Input, Group, Slot, Separator, Caret })\n"],"mappings":";;;;;;;AAcA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAA8B,IAAI;AAEtD,SAAS,OAAO,MAA0B;CACxC,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,QAAQ,KAAK,4BAA4B;CAC1E,OAAO;AACT;AAWA,SAAS,KAAK,EACZ,QACA,OACA,cACA,eACA,iBACA,YACA,gBACA,MACA,SACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,aAAa,cAAoC,OAAO,WAAW,EAAE,MAAM,CAAC,GAAG;EACnF;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAIA,MAAM,SAAS,UAAsB,QAAQ,OAAO,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK;AAGlF,MAAM,SAAS,UAAsB,QAAQ,OAAO,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AAGhF,MAAM,aAAa,UAA0B,QAAQ,OAAO,WAAW,CAAC,CAAC,WAAW,OAAO,KAAK;;AAYhG,SAAS,KAAK,EAAE,OAAO,GAAG,SAAkC;CAC1D,MAAM,OAAO,OAAO,MAAM,CAAC,CAAC,KAAK,KAAK;CACtC,MAAM,OAAO,UAAU,KAAK,IAAI;CAChC,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC1B,UAAA,QAAQ,KAAK,MAAM,OAAO,OAAO,KAAA,IAAY,YAE5C,qBAAA,YAAA,EAAA,UAAA,CACG,MACA,OACD,EAAA,CAAA,CACH;CACmB,CAAA;AAE1B;;AAKA,SAAS,MAAM,OAAwC;CACrD,MAAM,aAAa,OAAO,OAAO;CACjC,MAAM,OAAO,WAAW,WAAW;CACnC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,uCAAuC;CAElE,OADc,UAAU,KAAK,KAClB,IAAI,oBAAC,aAAD;EAAa,IAAI,WAAW;EAAW,KAAI;EAAM,GAAI;CAAQ,CAAA,IAAI;AAClF;AAEA,MAAa,MAAsB,sBAAM,OAAO;CAAE;CAAM;CAAO;CAAO;CAAM;CAAW;AAAM,CAAC"}
|
package/src/pagination.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, ReactNode } from "react";
|
|
3
|
+
import { StateOf } from "@kirana-ui/core";
|
|
4
4
|
import { PaginationEntry, PaginationProps } from "@kirana-ui/core/pagination";
|
|
5
5
|
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
6
|
type Parts = Vocabulary["pagination"];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { StateOf } from "@kirana-ui/core";
|
|
4
|
+
import { PasswordInputProps } from "@kirana-ui/core/password-input";
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["passwordInput"];
|
|
7
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, PasswordInputProps>;
|
|
8
|
+
declare function Root({ visible, defaultVisible, onVisibleChange, disabled, onValueChange, ...rest }: RootProps): ReactElement;
|
|
9
|
+
export type InputProps = PartComponentProps<"input", StateOf<Parts["input"]>>;
|
|
10
|
+
/** It takes what an `<input>` takes (`value`, `defaultValue`, `autoComplete`). */
|
|
11
|
+
declare const Input: (props: InputProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
12
|
+
export type ToggleProps = PartComponentProps<"button", StateOf<Parts["toggle"]>>;
|
|
13
|
+
declare const Toggle: (props: ToggleProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
14
|
+
export type IndicatorProps = PartComponentProps<"span", StateOf<Parts["indicator"]>>;
|
|
15
|
+
declare const Indicator: (props: IndicatorProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
16
|
+
export declare const PasswordInput: {
|
|
17
|
+
readonly Root: typeof Root;
|
|
18
|
+
readonly Input: typeof Input;
|
|
19
|
+
readonly Toggle: typeof Toggle;
|
|
20
|
+
readonly Indicator: typeof Indicator;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=password-input.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FieldContext } from "./field-context.js";
|
|
2
|
+
import { parts, useController, usePart } from "./runtime.js";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import { within } from "@kirana-ui/core";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { createPasswordInput } from "@kirana-ui/core/password-input";
|
|
7
|
+
// src/password-input.tsx
|
|
8
|
+
const Context = createContext(null);
|
|
9
|
+
function usePasswordInput(part) {
|
|
10
|
+
const controller = useContext(Context);
|
|
11
|
+
if (!controller) throw new Error(`<PasswordInput.${part}> must be inside <PasswordInput.Root>`);
|
|
12
|
+
return controller;
|
|
13
|
+
}
|
|
14
|
+
function Root({ visible, defaultVisible, onVisibleChange, disabled, onValueChange, ...rest }) {
|
|
15
|
+
const field = useContext(FieldContext) ?? void 0;
|
|
16
|
+
const controller = useController(within(createPasswordInput, { field }), {
|
|
17
|
+
visible,
|
|
18
|
+
defaultVisible,
|
|
19
|
+
onVisibleChange,
|
|
20
|
+
disabled,
|
|
21
|
+
onValueChange
|
|
22
|
+
});
|
|
23
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
24
|
+
value: controller,
|
|
25
|
+
children: usePart(controller.root, "div", rest)
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/** It takes what an `<input>` takes (`value`, `defaultValue`, `autoComplete`). */
|
|
29
|
+
const Input = (props) => usePart(usePasswordInput("Input").input, "input", props);
|
|
30
|
+
const Toggle = (props) => usePart(usePasswordInput("Toggle").toggle, "button", props);
|
|
31
|
+
const Indicator = (props) => usePart(usePasswordInput("Indicator").indicator, "span", props);
|
|
32
|
+
const PasswordInput = /* @__PURE__ */ parts("PasswordInput", {
|
|
33
|
+
Root,
|
|
34
|
+
Input,
|
|
35
|
+
Toggle,
|
|
36
|
+
Indicator
|
|
37
|
+
});
|
|
38
|
+
export { PasswordInput };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=password-input.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-input.js","names":[],"sources":["../../../../packages/react/src/password-input.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createPasswordInput } from \"@kirana-ui/core/password-input\"\nimport type {\n PasswordInput as Controller,\n PasswordInputProps,\n} from \"@kirana-ui/core/password-input\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { parts, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"passwordInput\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction usePasswordInput(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<PasswordInput.${part}> must be inside <PasswordInput.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\"div\", StateOf<Parts[\"root\"]>, PasswordInputProps>\n\nfunction Root({\n visible,\n defaultVisible,\n onVisibleChange,\n disabled,\n onValueChange,\n ...rest\n}: RootProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const controller = useController<PasswordInputProps, Controller>(\n within(createPasswordInput, { field }),\n { visible, defaultVisible, onVisibleChange, disabled, onValueChange }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type InputProps = PartComponentProps<\"input\", StateOf<Parts[\"input\"]>>\n\n/** It takes what an `<input>` takes (`value`, `defaultValue`, `autoComplete`). */\nconst Input = (props: InputProps) => usePart(usePasswordInput(\"Input\").input, \"input\", props)\n\nexport type ToggleProps = PartComponentProps<\"button\", StateOf<Parts[\"toggle\"]>>\n\nconst Toggle = (props: ToggleProps) => usePart(usePasswordInput(\"Toggle\").toggle, \"button\", props)\n\nexport type IndicatorProps = PartComponentProps<\"span\", StateOf<Parts[\"indicator\"]>>\n\nconst Indicator = (props: IndicatorProps) =>\n usePart(usePasswordInput(\"Indicator\").indicator, \"span\", props)\n\nexport const PasswordInput = /* @__PURE__ */ parts(\"PasswordInput\", {\n Root,\n Input,\n Toggle,\n Indicator,\n})\n"],"mappings":";;;;;;;AAiBA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,iBAAiB,MAA0B;CAClD,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,kBAAkB,KAAK,sCAAsC;CAC9F,OAAO;AACT;AAIA,SAAS,KAAK,EACZ,SACA,gBACA,iBACA,UACA,eACA,GAAG,QACuB;CAC1B,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,aAAa,cACjB,OAAO,qBAAqB,EAAE,MAAM,CAAC,GACrC;EAAE;EAAS;EAAgB;EAAiB;EAAU;CAAc,CACtE;CACA,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;;AAKA,MAAM,SAAS,UAAsB,QAAQ,iBAAiB,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK;AAI5F,MAAM,UAAU,UAAuB,QAAQ,iBAAiB,QAAQ,CAAC,CAAC,QAAQ,UAAU,KAAK;AAIjG,MAAM,aAAa,UACjB,QAAQ,iBAAiB,WAAW,CAAC,CAAC,WAAW,QAAQ,KAAK;AAEhE,MAAa,gBAAgC,sBAAM,iBAAiB;CAClE;CACA;CACA;CACA;AACF,CAAC"}
|
package/src/popover.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PartComponentProps, PortalProps, PositionerOptions } 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 { Popover as Popover$1, PopoverProps, PopoverTriggerOptions } from "@kirana-ui/core/popover";
|
|
5
5
|
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
6
|
type Parts = Vocabulary["popover"];
|
|
7
7
|
/**
|
|
@@ -17,12 +17,18 @@ declare function Root({ children, ...props }: RootProps): ReactElement;
|
|
|
17
17
|
declare function Portal({ children }: PortalProps): ReactElement | null;
|
|
18
18
|
export type PositionerProps = PartComponentProps<"div", StateOf<Parts["positioner"]>, PositionerOptions>;
|
|
19
19
|
declare function Positioner(props: PositionerProps): ReactElement;
|
|
20
|
-
|
|
20
|
+
/** What a trigger takes of its own: whether the pointer opens the popover too, and its waits. */
|
|
21
|
+
export type TriggerOptions = PopoverTriggerOptions;
|
|
22
|
+
export type TriggerProps = PartComponentProps<"button", StateOf<Parts["trigger"]>, TriggerOptions>;
|
|
23
|
+
export type BackdropProps = PartComponentProps<"div", StateOf<Parts["backdrop"]>>;
|
|
24
|
+
export type ArrowProps = PartComponentProps<"div", StateOf<Parts["arrow"]>>;
|
|
21
25
|
export type PopupProps = PartComponentProps<"div", StateOf<Parts["popup"]>>;
|
|
22
26
|
export type TitleProps = PartComponentProps<"h2", StateOf<Parts["title"]>>;
|
|
23
27
|
export type DescriptionProps = PartComponentProps<"p", StateOf<Parts["description"]>>;
|
|
24
28
|
export type CloseProps = PartComponentProps<"button", StateOf<Parts["close"]>>;
|
|
25
|
-
declare
|
|
29
|
+
declare function Trigger({ openOnHover, delay, closeDelay, ...props }: TriggerProps): ReactElement;
|
|
30
|
+
declare const Backdrop: (props: BackdropProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
31
|
+
declare const Arrow: (props: ArrowProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
26
32
|
declare const Popup: (props: PopupProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
27
33
|
declare const Title: (props: TitleProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
28
34
|
declare const Description: (props: DescriptionProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -31,8 +37,10 @@ export declare const Popover: {
|
|
|
31
37
|
readonly Root: typeof Root;
|
|
32
38
|
readonly Trigger: typeof Trigger;
|
|
33
39
|
readonly Portal: typeof Portal;
|
|
40
|
+
readonly Backdrop: typeof Backdrop;
|
|
34
41
|
readonly Positioner: typeof Positioner;
|
|
35
42
|
readonly Popup: typeof Popup;
|
|
43
|
+
readonly Arrow: typeof Arrow;
|
|
36
44
|
readonly Title: typeof Title;
|
|
37
45
|
readonly Description: typeof Description;
|
|
38
46
|
readonly Close: typeof Close;
|
package/src/popover.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Portal as Portal$1, parts, useController, usePart, usePositioning, useSignal } from "./runtime.js";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
|
+
import { defined } from "@kirana-ui/core";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
5
|
import { createPopover } from "@kirana-ui/core/popover";
|
|
5
6
|
// src/popover.tsx
|
|
@@ -27,7 +28,17 @@ function Positioner(props) {
|
|
|
27
28
|
const controller = usePopover("Positioner");
|
|
28
29
|
return usePart(controller.positioner, "div", usePositioning(controller.positioning, props));
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
function Trigger({ openOnHover, delay, closeDelay, ...props }) {
|
|
32
|
+
const controller = usePopover("Trigger");
|
|
33
|
+
controller.hovering.set(defined({
|
|
34
|
+
openOnHover,
|
|
35
|
+
delay,
|
|
36
|
+
closeDelay
|
|
37
|
+
}));
|
|
38
|
+
return usePart(controller.trigger, "button", props);
|
|
39
|
+
}
|
|
40
|
+
const Backdrop = (props) => usePart(usePopover("Backdrop").backdrop, "div", props);
|
|
41
|
+
const Arrow = (props) => usePart(usePopover("Arrow").arrow, "div", props);
|
|
31
42
|
const Popup = (props) => usePart(usePopover("Popup").popup, "div", props);
|
|
32
43
|
const Title = (props) => usePart(usePopover("Title").title, "h2", props);
|
|
33
44
|
const Description = (props) => usePart(usePopover("Description").description, "p", props);
|
|
@@ -36,8 +47,10 @@ const Popover = /* @__PURE__ */ parts("Popover", {
|
|
|
36
47
|
Root,
|
|
37
48
|
Trigger,
|
|
38
49
|
Portal,
|
|
50
|
+
Backdrop,
|
|
39
51
|
Positioner,
|
|
40
52
|
Popup,
|
|
53
|
+
Arrow,
|
|
41
54
|
Title,
|
|
42
55
|
Description,
|
|
43
56
|
Close
|
package/src/popover.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/popover.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type {
|
|
1
|
+
{"version":3,"file":"popover.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/popover.tsx"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type {\n Popover as Controller,\n PopoverProps,\n PopoverTriggerOptions,\n} from \"@kirana-ui/core/popover\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport {\n Portal as BodyPortal,\n parts,\n useController,\n usePart,\n usePositioning,\n useSignal,\n} from \"./runtime.tsx\"\nimport type { PartComponentProps, PortalProps, PositionerOptions } from \"./runtime.tsx\"\n\nexport type { PortalProps }\n\ntype Parts = Vocabulary[\"popover\"]\n\n/**\n * The popover its parts are inside. Exported for a component that is made of one (a date picker\n * provides its own to the popover's parts).\n */\nconst Context = createContext<Controller | null>(null)\n/** For a component made of this one's parts: a date picker. */\nexport { Context as PopoverContext }\n\nfunction usePopover(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Popover.${part}> must be inside <Popover.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<PopoverProps, \"id\"> & { id?: string; children?: ReactNode }\n\nfunction Root({ children, ...props }: RootProps): ReactElement {\n const controller = useController(createPopover, props)\n return <Context.Provider value={controller}>{children}</Context.Provider>\n}\n\nfunction Portal({ children }: PortalProps): ReactElement | null {\n const mounted = useSignal(usePopover(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n}\n\nexport type PositionerProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"positioner\"]>,\n PositionerOptions\n>\n\nfunction Positioner(props: PositionerProps): ReactElement {\n const controller = usePopover(\"Positioner\")\n return usePart(controller.positioner, \"div\", usePositioning(controller.positioning, props))\n}\n\n/** What a trigger takes of its own: whether the pointer opens the popover too, and its waits. */\nexport type TriggerOptions = PopoverTriggerOptions\n\nexport type TriggerProps = PartComponentProps<\"button\", StateOf<Parts[\"trigger\"]>, TriggerOptions>\nexport type BackdropProps = PartComponentProps<\"div\", StateOf<Parts[\"backdrop\"]>>\nexport type ArrowProps = PartComponentProps<\"div\", StateOf<Parts[\"arrow\"]>>\nexport type PopupProps = PartComponentProps<\"div\", StateOf<Parts[\"popup\"]>>\nexport type TitleProps = PartComponentProps<\"h2\", StateOf<Parts[\"title\"]>>\nexport type DescriptionProps = PartComponentProps<\"p\", StateOf<Parts[\"description\"]>>\nexport type CloseProps = PartComponentProps<\"button\", StateOf<Parts[\"close\"]>>\n\nfunction Trigger({ openOnHover, delay, closeDelay, ...props }: TriggerProps): ReactElement {\n const controller = usePopover(\"Trigger\")\n // Written while rendering, as a positioner's are: nothing re-renders for it.\n controller.hovering.set(defined({ openOnHover, delay, closeDelay }))\n return usePart(controller.trigger, \"button\", props)\n}\nconst Backdrop = (props: BackdropProps) => usePart(usePopover(\"Backdrop\").backdrop, \"div\", props)\nconst Arrow = (props: ArrowProps) => usePart(usePopover(\"Arrow\").arrow, \"div\", props)\nconst Popup = (props: PopupProps) => usePart(usePopover(\"Popup\").popup, \"div\", props)\nconst Title = (props: TitleProps) => usePart(usePopover(\"Title\").title, \"h2\", props)\nconst Description = (props: DescriptionProps) =>\n usePart(usePopover(\"Description\").description, \"p\", props)\nconst Close = (props: CloseProps) => usePart(usePopover(\"Close\").close, \"button\", props)\n\nexport const Popover = /* @__PURE__ */ parts(\"Popover\", {\n Root,\n Trigger,\n Portal,\n Backdrop,\n Positioner,\n Popup,\n Arrow,\n Title,\n Description,\n Close,\n})\n"],"mappings":";;;;;;;;;;AA8BA,MAAM,UAAU,cAAiC,IAAI;AAIrD,SAAS,WAAW,MAA0B;CAC5C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,gCAAgC;CAClF,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,UAAU,GAAG,SAAkC;CAC7D,MAAM,aAAa,cAAc,eAAe,KAAK;CACrD,OAAO,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa;CAA2B,CAAA;AAC1E;AAEA,SAAS,OAAO,EAAE,YAA8C;CAE9D,OADgB,UAAU,WAAW,QAAQ,CAAC,CAAC,OAClC,IAAI,oBAACA,UAAD,EAAa,SAAqB,CAAA,IAAI;AACzD;AAQA,SAAS,WAAW,OAAsC;CACxD,MAAM,aAAa,WAAW,YAAY;CAC1C,OAAO,QAAQ,WAAW,YAAY,OAAO,eAAe,WAAW,aAAa,KAAK,CAAC;AAC5F;AAaA,SAAS,QAAQ,EAAE,aAAa,OAAO,YAAY,GAAG,SAAqC;CACzF,MAAM,aAAa,WAAW,SAAS;CAEvC,WAAW,SAAS,IAAI,QAAQ;EAAE;EAAa;EAAO;CAAW,CAAC,CAAC;CACnE,OAAO,QAAQ,WAAW,SAAS,UAAU,KAAK;AACpD;AACA,MAAM,YAAY,UAAyB,QAAQ,WAAW,UAAU,CAAC,CAAC,UAAU,OAAO,KAAK;AAChG,MAAM,SAAS,UAAsB,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AACpF,MAAM,SAAS,UAAsB,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AACpF,MAAM,SAAS,UAAsB,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,MAAM,KAAK;AACnF,MAAM,eAAe,UACnB,QAAQ,WAAW,aAAa,CAAC,CAAC,aAAa,KAAK,KAAK;AAC3D,MAAM,SAAS,UAAsB,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,UAAU,KAAK;AAEvF,MAAa,UAA0B,sBAAM,WAAW;CACtD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
|
package/src/qr-code.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 { QrCodeProps } from "@kirana-ui/core/qr-code";
|
|
5
5
|
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
6
|
type Parts = Vocabulary["qrCode"];
|
package/src/radio-group.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 { RadioGroupProps } from "@kirana-ui/core/radio-group";
|
|
5
5
|
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
6
|
type Parts = Vocabulary["radioGroup"];
|
|
@@ -14,8 +14,10 @@ export type ItemProps = PartComponentProps<"span", StateOf<Parts["item"]>, {
|
|
|
14
14
|
value: unknown;
|
|
15
15
|
/** Disables this item: it cannot be chosen. */
|
|
16
16
|
disabled?: boolean;
|
|
17
|
+
/** The id of the item's native radio, unique in the page: a `<label htmlFor>` names it. */
|
|
18
|
+
id?: string;
|
|
17
19
|
}>;
|
|
18
|
-
declare function Item({ value, disabled, ...rest }: ItemProps): ReactElement;
|
|
20
|
+
declare function Item({ value, disabled, id, ...rest }: ItemProps): ReactElement;
|
|
19
21
|
export type IndicatorProps = PartComponentProps<"span", StateOf<Parts["indicator"]>, {
|
|
20
22
|
/** Keeps the mark in the page while its item is not the chosen one. */
|
|
21
23
|
keepMounted?: boolean;
|
package/src/radio-group.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DirectionContext } from "./direction-context.js";
|
|
2
2
|
import { FieldContext } from "./field-context.js";
|
|
3
3
|
import { PartElement, parts, useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
|
|
4
|
-
import { defined, within } from "@kirana-ui/core";
|
|
5
4
|
import { createContext, useContext, useMemo } from "react";
|
|
5
|
+
import { defined, within } from "@kirana-ui/core";
|
|
6
6
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import { createRadioGroup } from "@kirana-ui/core/radio-group";
|
|
8
8
|
// src/radio-group.tsx
|
|
@@ -40,9 +40,12 @@ function Root({ value, defaultValue, onValueChange, disabled, readOnly, required
|
|
|
40
40
|
})
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
function Item({ value, disabled, ...rest }) {
|
|
43
|
+
function Item({ value, disabled, id, ...rest }) {
|
|
44
44
|
const controller = useRadioGroup("Item");
|
|
45
|
-
const options = useOptions({
|
|
45
|
+
const options = useOptions({
|
|
46
|
+
disabled,
|
|
47
|
+
id
|
|
48
|
+
});
|
|
46
49
|
const made = useMemo(() => {
|
|
47
50
|
const read = () => defined(options.get());
|
|
48
51
|
return {
|
package/src/radio-group.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/react/src/radio-group.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createRadioGroup } from \"@kirana-ui/core/radio-group\"\nimport type { RadioGroup as Controller, RadioGroupProps } from \"@kirana-ui/core/radio-group\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { FieldContext } from \"./field-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[\"radioGroup\"]\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<unknown>(undefined)\n\nfunction useRadioGroup(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<RadioGroup.${part}> must be inside <RadioGroup.Root>`)\n return controller\n}\n\n/** `Value` is what tells an item from the others: the type of `value`. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<RadioGroupProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createRadioGroup<Value>, { field, direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n disabled,\n readOnly,\n required,\n name,\n form,\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 \"span\",\n StateOf<Parts[\"item\"]>,\n {\n /** What the group's value is while this item is the chosen one. */\n value: unknown\n /** Disables this item: it cannot be chosen. */\n disabled?: boolean\n }\n>\n\nfunction Item({ value, disabled, ...rest }: ItemProps): ReactElement {\n const controller = useRadioGroup(\"Item\")\n const options = useOptions({ disabled })\n const made = useMemo(() => {\n const read = () => defined(options.get())\n return { item: controller.item(value, read), input: controller.itemInput(value, read) }\n }, [controller, value, options])\n return (\n <ItemContext.Provider value={value}>\n {usePart(made.item, \"span\", rest, undefined, (content) => (\n // Its native input is the element's last child, whatever element the caller asked for.\n <>\n {content}\n <PartElement of={made.input} tag=\"input\" />\n </>\n ))}\n </ItemContext.Provider>\n )\n}\n\nexport type IndicatorProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"indicator\"]>,\n {\n /** Keeps the mark in the page while its item is not the chosen one. */\n keepMounted?: boolean\n }\n>\n\nfunction Indicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null {\n const controller = useRadioGroup(\"Indicator\")\n const value = useContext(ItemContext)\n const indicator = useMemo(() => controller.indicator(value), [controller, value])\n useMount(indicator)\n const mounted = useSignal(indicator.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={indicator.part} tag=\"span\" {...props} />\n}\n\nexport const RadioGroup = /* @__PURE__ */ parts(\"RadioGroup\", { Root, Item, Indicator })\n"],"mappings":";;;;;;;;AAuBA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAAuB,KAAA,CAAS;AAEpD,SAAS,cAAc,MAA0B;CAC/C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,eAAe,KAAK,mCAAmC;CACxF,OAAO;AACT;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QAC8B;CACjC,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,kBAAyB;EAAE;EAAO;CAAU,CAAC;CACnE,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;
|
|
1
|
+
{"version":3,"file":"radio-group.js","names":[],"sources":["../../../../packages/react/src/radio-group.tsx"],"sourcesContent":["import { defined, within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createRadioGroup } from \"@kirana-ui/core/radio-group\"\nimport type { RadioGroup as Controller, RadioGroupProps } from \"@kirana-ui/core/radio-group\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { FieldContext } from \"./field-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[\"radioGroup\"]\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<unknown>(undefined)\n\nfunction useRadioGroup(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<RadioGroup.${part}> must be inside <RadioGroup.Root>`)\n return controller\n}\n\n/** `Value` is what tells an item from the others: the type of `value`. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<RadioGroupProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\n value,\n defaultValue,\n onValueChange,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createRadioGroup<Value>, { field, direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n disabled,\n readOnly,\n required,\n name,\n form,\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 \"span\",\n StateOf<Parts[\"item\"]>,\n {\n /** What the group's value is while this item is the chosen one. */\n value: unknown\n /** Disables this item: it cannot be chosen. */\n disabled?: boolean\n /** The id of the item's native radio, unique in the page: a `<label htmlFor>` names it. */\n id?: string\n }\n>\n\nfunction Item({ value, disabled, id, ...rest }: ItemProps): ReactElement {\n const controller = useRadioGroup(\"Item\")\n const options = useOptions({ disabled, id })\n const made = useMemo(() => {\n const read = () => defined(options.get())\n return { item: controller.item(value, read), input: controller.itemInput(value, read) }\n }, [controller, value, options])\n return (\n <ItemContext.Provider value={value}>\n {usePart(made.item, \"span\", rest, undefined, (content) => (\n // Its native input is the element's last child, whatever element the caller asked for.\n <>\n {content}\n <PartElement of={made.input} tag=\"input\" />\n </>\n ))}\n </ItemContext.Provider>\n )\n}\n\nexport type IndicatorProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"indicator\"]>,\n {\n /** Keeps the mark in the page while its item is not the chosen one. */\n keepMounted?: boolean\n }\n>\n\nfunction Indicator({ keepMounted, ...props }: IndicatorProps): ReactElement | null {\n const controller = useRadioGroup(\"Indicator\")\n const value = useContext(ItemContext)\n const indicator = useMemo(() => controller.indicator(value), [controller, value])\n useMount(indicator)\n const mounted = useSignal(indicator.mounted)\n if (!mounted && !keepMounted) return null\n return <PartElement of={indicator.part} tag=\"span\" {...props} />\n}\n\nexport const RadioGroup = /* @__PURE__ */ parts(\"RadioGroup\", { Root, Item, Indicator })\n"],"mappings":";;;;;;;;AAuBA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAAuB,KAAA,CAAS;AAEpD,SAAS,cAAc,MAA0B;CAC/C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,eAAe,KAAK,mCAAmC;CACxF,OAAO;AACT;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QAC8B;CACjC,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,kBAAyB;EAAE;EAAO;CAAU,CAAC;CACnE,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;AAeA,SAAS,KAAK,EAAE,OAAO,UAAU,IAAI,GAAG,QAAiC;CACvE,MAAM,aAAa,cAAc,MAAM;CACvC,MAAM,UAAU,WAAW;EAAE;EAAU;CAAG,CAAC;CAC3C,MAAM,OAAO,cAAc;EACzB,MAAM,aAAa,QAAQ,QAAQ,IAAI,CAAC;EACxC,OAAO;GAAE,MAAM,WAAW,KAAK,OAAO,IAAI;GAAG,OAAO,WAAW,UAAU,OAAO,IAAI;EAAE;CACxF,GAAG;EAAC;EAAY;EAAO;CAAO,CAAC;CAC/B,OACE,oBAAC,YAAY,UAAb;EAA6B;EAC1B,UAAA,QAAQ,KAAK,MAAM,QAAQ,MAAM,KAAA,IAAY,YAE5C,qBAAA,YAAA,EAAA,UAAA,CACG,SACD,oBAAC,aAAD;GAAa,IAAI,KAAK;GAAO,KAAI;EAAS,CAAA,CAC1C,EAAA,CAAA,CACH;CACmB,CAAA;AAE1B;AAWA,SAAS,UAAU,EAAE,aAAa,GAAG,SAA8C;CACjF,MAAM,aAAa,cAAc,WAAW;CAC5C,MAAM,QAAQ,WAAW,WAAW;CACpC,MAAM,YAAY,cAAc,WAAW,UAAU,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CAChF,SAAS,SAAS;CAElB,IAAI,CADY,UAAU,UAAU,OACzB,KAAK,CAAC,aAAa,OAAO;CACrC,OAAO,oBAAC,aAAD;EAAa,IAAI,UAAU;EAAM,KAAI;EAAO,GAAI;CAAQ,CAAA;AACjE;AAEA,MAAa,aAA6B,sBAAM,cAAc;CAAE;CAAM;CAAM;AAAU,CAAC"}
|
package/src/rating.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement, ReactNode } from "react";
|
|
3
|
+
import { StateOf } from "@kirana-ui/core";
|
|
4
|
+
import { RatingProps } from "@kirana-ui/core/rating";
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["rating"];
|
|
7
|
+
export type RootProps = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<RatingProps, "id"> & {
|
|
8
|
+
id?: string;
|
|
9
|
+
}>;
|
|
10
|
+
declare function Root({ value, defaultValue, onValueChange, onHoverChange, count, allowHalf, disabled, readOnly, required, name, form, id, ...rest }: RootProps): ReactElement;
|
|
11
|
+
export interface ItemsProps {
|
|
12
|
+
/** Draws one item, once for each place, from 1. */
|
|
13
|
+
children: (place: number) => ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/** Draws its child once for each item, from 1 to `count`. */
|
|
16
|
+
declare function Items({ children }: ItemsProps): ReactElement;
|
|
17
|
+
export type ItemProps = PartComponentProps<"span", StateOf<Parts["item"]>, {
|
|
18
|
+
/** Its place among the items, from 1. */
|
|
19
|
+
place: number;
|
|
20
|
+
}>;
|
|
21
|
+
declare function Item({ place, ...props }: ItemProps): ReactElement;
|
|
22
|
+
export declare const Rating: {
|
|
23
|
+
readonly Root: typeof Root;
|
|
24
|
+
readonly Items: typeof Items;
|
|
25
|
+
readonly Item: typeof Item;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=rating.d.ts.map
|
package/src/rating.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DirectionContext } from "./direction-context.js";
|
|
2
|
+
import { FieldContext } from "./field-context.js";
|
|
3
|
+
import { PartElement, parts, useController, usePart, useSignal } from "./runtime.js";
|
|
4
|
+
import { Fragment, createContext, useContext } from "react";
|
|
5
|
+
import { within } from "@kirana-ui/core";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { createRating } from "@kirana-ui/core/rating";
|
|
8
|
+
// src/rating.tsx
|
|
9
|
+
const Context = createContext(null);
|
|
10
|
+
function useRating(part) {
|
|
11
|
+
const controller = useContext(Context);
|
|
12
|
+
if (!controller) throw new Error(`<Rating.${part}> must be inside <Rating.Root>`);
|
|
13
|
+
return controller;
|
|
14
|
+
}
|
|
15
|
+
function Root({ value, defaultValue, onValueChange, onHoverChange, count, allowHalf, disabled, readOnly, required, name, form, id, ...rest }) {
|
|
16
|
+
const field = useContext(FieldContext) ?? void 0;
|
|
17
|
+
const direction = useContext(DirectionContext) ?? void 0;
|
|
18
|
+
const create = within(createRating, {
|
|
19
|
+
field,
|
|
20
|
+
direction
|
|
21
|
+
});
|
|
22
|
+
const controller = useController(create, {
|
|
23
|
+
value,
|
|
24
|
+
defaultValue,
|
|
25
|
+
onValueChange,
|
|
26
|
+
onHoverChange,
|
|
27
|
+
count,
|
|
28
|
+
allowHalf,
|
|
29
|
+
disabled,
|
|
30
|
+
readOnly,
|
|
31
|
+
required,
|
|
32
|
+
name,
|
|
33
|
+
form,
|
|
34
|
+
id
|
|
35
|
+
});
|
|
36
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
37
|
+
value: controller,
|
|
38
|
+
children: usePart(controller.root, "div", rest, void 0, (content) => /* @__PURE__ */ jsxs(Fragment$1, { children: [content, /* @__PURE__ */ jsx(PartElement, {
|
|
39
|
+
of: controller.input,
|
|
40
|
+
tag: "input"
|
|
41
|
+
})] }))
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** Draws its child once for each item, from 1 to `count`. */
|
|
45
|
+
function Items({ children }) {
|
|
46
|
+
const places = useSignal(useRating("Items").places);
|
|
47
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: places.map((place) => /* @__PURE__ */ jsx(Fragment, { children: children(place) }, place)) });
|
|
48
|
+
}
|
|
49
|
+
function Item({ place, ...props }) {
|
|
50
|
+
return usePart(useRating("Item").item(place), "span", props);
|
|
51
|
+
}
|
|
52
|
+
const Rating = /* @__PURE__ */ parts("Rating", {
|
|
53
|
+
Root,
|
|
54
|
+
Items,
|
|
55
|
+
Item
|
|
56
|
+
});
|
|
57
|
+
export { Rating };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=rating.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rating.js","names":[],"sources":["../../../../packages/react/src/rating.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } from \"@kirana-ui/core\"\nimport { createRating } from \"@kirana-ui/core/rating\"\nimport type { Rating as Controller, RatingProps } from \"@kirana-ui/core/rating\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { Fragment, createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { FieldContext } from \"./field-context.ts\"\nimport { PartElement, parts, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"rating\"]\n\nconst Context = createContext<Controller | null>(null)\n\nfunction useRating(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Rating.${part}> must be inside <Rating.Root>`)\n return controller\n}\n\nexport type RootProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<RatingProps, \"id\"> & { id?: string }\n>\n\nfunction Root({\n value,\n defaultValue,\n onValueChange,\n onHoverChange,\n count,\n allowHalf,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n ...rest\n}: RootProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const direction = useContext(DirectionContext) ?? undefined\n const create = within(createRating, { field, direction })\n const controller: Controller = useController(create, {\n value,\n defaultValue,\n onValueChange,\n onHoverChange,\n count,\n allowHalf,\n disabled,\n readOnly,\n required,\n name,\n form,\n id,\n })\n return (\n <Context.Provider value={controller}>\n {usePart(controller.root, \"div\", rest, undefined, (content) => (\n // The input a form reads is the element's last child, whatever element was asked for.\n <>\n {content}\n <PartElement of={controller.input} tag=\"input\" />\n </>\n ))}\n </Context.Provider>\n )\n}\n\nexport interface ItemsProps {\n /** Draws one item, once for each place, from 1. */\n children: (place: number) => ReactNode\n}\n\n/** Draws its child once for each item, from 1 to `count`. */\nfunction Items({ children }: ItemsProps): ReactElement {\n const places = useSignal(useRating(\"Items\").places)\n return (\n <>\n {places.map((place) => (\n <Fragment key={place}>{children(place)}</Fragment>\n ))}\n </>\n )\n}\n\nexport type ItemProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"item\"]>,\n {\n /** Its place among the items, from 1. */\n place: number\n }\n>\n\nfunction Item({ place, ...props }: ItemProps): ReactElement {\n return usePart(useRating(\"Item\").item(place), \"span\", props)\n}\n\nexport const Rating = /* @__PURE__ */ parts(\"Rating\", { Root, Items, Item })\n"],"mappings":";;;;;;;;AAeA,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;AAQA,SAAS,KAAK,EACZ,OACA,cACA,eACA,eACA,OACA,WACA,UACA,UACA,UACA,MACA,MACA,IACA,GAAG,QACuB;CAC1B,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,YAAY,WAAW,gBAAgB,KAAK,KAAA;CAClD,MAAM,SAAS,OAAO,cAAc;EAAE;EAAO;CAAU,CAAC;CACxD,MAAM,aAAyB,cAAc,QAAQ;EACnD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EACtB,UAAA,QAAQ,WAAW,MAAM,OAAO,MAAM,KAAA,IAAY,YAEjD,qBAAA,YAAA,EAAA,UAAA,CACG,SACD,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAO,KAAI;EAAS,CAAA,CAChD,EAAA,CAAA,CACH;CACe,CAAA;AAEtB;;AAQA,SAAS,MAAM,EAAE,YAAsC;CACrD,MAAM,SAAS,UAAU,UAAU,OAAO,CAAC,CAAC,MAAM;CAClD,OACE,oBAAA,YAAA,EAAA,UACG,OAAO,KAAK,UACX,oBAAC,UAAD,EAAA,UAAuB,SAAS,KAAK,EAAY,GAAlC,KAAkC,CAClD,EACD,CAAA;AAEN;AAWA,SAAS,KAAK,EAAE,OAAO,GAAG,SAAkC;CAC1D,OAAO,QAAQ,UAAU,MAAM,CAAC,CAAC,KAAK,KAAK,GAAG,QAAQ,KAAK;AAC7D;AAEA,MAAa,SAAyB,sBAAM,UAAU;CAAE;CAAM;CAAO;AAAK,CAAC"}
|
package/src/resizable.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 { ResizablePanelOptions, ResizableProps } from "@kirana-ui/core/resizable";
|
|
5
5
|
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
6
|
type Parts = Vocabulary["resizable"];
|
package/src/resizable.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DirectionContext } from "./direction-context.js";
|
|
2
2
|
import { parts, useController, useOptions, usePart } from "./runtime.js";
|
|
3
|
-
import { defined, within } from "@kirana-ui/core";
|
|
4
3
|
import { createContext, useContext, useMemo } from "react";
|
|
4
|
+
import { defined, within } from "@kirana-ui/core";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { createResizable } from "@kirana-ui/core/resizable";
|
|
7
7
|
// src/resizable.tsx
|
package/src/runtime.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Anchor, Part, PartEvent, PartState, PositionOptions, ReadonlySignal, Signal } from "@kirana-ui/core";
|
|
2
1
|
import { ClassAttributes, ComponentPropsWithoutRef, HTMLAttributes, JSX, ReactElement, ReactNode, Ref, RefCallback, RefObject, SyntheticEvent, useLayoutEffect } from "react";
|
|
2
|
+
import { Anchor, Direction, Part, PartEvent, PartState, PositionOptions, ReadonlySignal, Signal } from "@kirana-ui/core";
|
|
3
3
|
/** A layout effect in the browser, an effect (which never runs) on a server. */
|
|
4
4
|
export declare const useIsomorphicLayoutEffect: typeof useLayoutEffect;
|
|
5
5
|
/** A core signal's value, re-rendering when it changes. */
|
|
@@ -11,9 +11,9 @@ export declare function useSignal<T>(source: ReadonlySignal<T>): T;
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function useController<P extends object, C extends {
|
|
13
13
|
mount(): () => void;
|
|
14
|
-
}>(create: (props: ReadonlySignal<P>) => C, props: Omit<P, "id"> & {
|
|
14
|
+
}>(create: (props: ReadonlySignal<P>) => C, props: NoInfer<Omit<P, "id"> & {
|
|
15
15
|
id?: string | undefined;
|
|
16
|
-
}): C;
|
|
16
|
+
}>): C;
|
|
17
17
|
/**
|
|
18
18
|
* Starts what a controller (or an item of one) runs while it is in the page. StrictMode runs an
|
|
19
19
|
* effect, undoes it and runs it again in one commit, to find effects that cannot be run twice:
|
|
@@ -40,15 +40,18 @@ export type RenderedProps = HTMLAttributes<HTMLElement> & {
|
|
|
40
40
|
} & Record<string, unknown>;
|
|
41
41
|
/**
|
|
42
42
|
* What `render` takes: an element, drawn with the part's props merged over its own, or a
|
|
43
|
-
* function given the part's props and its state.
|
|
43
|
+
* function given the part's props and its state. Unnamed, a state is any entries a `data-*`
|
|
44
|
+
* attribute is written from: a part's own entry names its exactly.
|
|
44
45
|
*/
|
|
45
|
-
export type RenderProp<State =
|
|
46
|
+
export type RenderProp<State = Record<string, string | boolean | null | undefined>> = ReactElement<Record<string, unknown>> | ((props: RenderedProps, state: State) => ReactElement);
|
|
46
47
|
/**
|
|
47
48
|
* A part's props: its element's own (`Tag`'s attributes and handlers, a `ref` to that
|
|
48
49
|
* element), `render`, and the part's own props (`Own`) in place of the element's of the same
|
|
49
|
-
* name. `State` is what a `render` function is told of the part.
|
|
50
|
+
* name. `State` is what a `render` function is told of the part. A plain element of one's own
|
|
51
|
+
* drawn through `useRender` names its state here (`PartComponentProps<"span", { variant:
|
|
52
|
+
* string | null }>`); unnamed, it is any entries of `string | boolean | null | undefined`.
|
|
50
53
|
*/
|
|
51
|
-
export type PartComponentProps<Tag extends PartTag = "div", State =
|
|
54
|
+
export type PartComponentProps<Tag extends PartTag = "div", State = Record<string, string | boolean | null | undefined>, Own = unknown> = { [Name in keyof ComponentPropsWithoutRef<Tag> as Name extends keyof Own ? never : Name]: Hearing<ComponentPropsWithoutRef<Tag>[Name]>; } & Own & {
|
|
52
55
|
/**
|
|
53
56
|
* Renders the part as another element or component. An element's own props lie over the
|
|
54
57
|
* props handed to the part, and the part's own (its role, its state, its handlers) over
|
|
@@ -107,7 +110,7 @@ export type PositionerProps<State = PartState> = PartComponentProps<"div", State
|
|
|
107
110
|
* A positioner's own props, written where its placement reads them: the one place they are
|
|
108
111
|
* named. Gives back what is left, for the part's element.
|
|
109
112
|
*/
|
|
110
|
-
export declare function usePositioning<Props extends PositionerOptions>(positioning: Signal<Partial<PositionOptions>>, { side, align, sideOffset, alignOffset, collisionPadding, anchor, ...rest }: Props): Omit<Props, keyof PositionerOptions>;
|
|
113
|
+
export declare function usePositioning<Props extends PositionerOptions>(positioning: Signal<Partial<PositionOptions>>, { side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, sticky, arrowPadding, positionMethod, anchor, ...rest }: Props): Omit<Props, keyof PositionerOptions>;
|
|
111
114
|
/**
|
|
112
115
|
* A text input whose text is the core's own (a combobox's, a number field's): its `value` is
|
|
113
116
|
* given to React as the input's default. To React a `value` with no `onChange` is an input
|
|
@@ -131,5 +134,12 @@ export interface PortalProps {
|
|
|
131
134
|
}
|
|
132
135
|
/** Its children in a container at the end of the page, once the page has hydrated. */
|
|
133
136
|
export declare function Portal({ children }: PortalProps): ReactElement | null;
|
|
137
|
+
/**
|
|
138
|
+
* The reading direction a `DirectionProvider` around this component states, as the signal a
|
|
139
|
+
* controller takes (`within(createX, { direction })`); `undefined` outside one, where the
|
|
140
|
+
* controller reads the direction its element is laid out in. For a component of your own: the
|
|
141
|
+
* library's parts read the same.
|
|
142
|
+
*/
|
|
143
|
+
export declare function useDirectionAround(): ReadonlySignal<Direction> | undefined;
|
|
134
144
|
export type { PartEvent };
|
|
135
145
|
//# sourceMappingURL=runtime.d.ts.map
|
package/src/runtime.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { DirectionContext } from "./direction-context.js";
|
|
1
2
|
import { REF_IS_A_PROP, give, refOf } from "./element.js";
|
|
2
|
-
import { composeProps, computed, defined, mergeProps, sameProps, signal, stateOf } from "@kirana-ui/core";
|
|
3
3
|
import { cloneElement, createContext, createElement, forwardRef, isValidElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
4
|
+
import { composeProps, computed, defined, forElement, mergeProps, sameProps, signal, stateOf, untype } from "@kirana-ui/core";
|
|
4
5
|
import { createPortal } from "react-dom";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
6
7
|
// src/runtime.tsx
|
|
@@ -110,8 +111,9 @@ function reactStyle(style) {
|
|
|
110
111
|
}
|
|
111
112
|
return out;
|
|
112
113
|
}
|
|
113
|
-
function toReact(props) {
|
|
114
|
+
function toReact(props, own) {
|
|
114
115
|
const out = {};
|
|
116
|
+
for (const key in own) if (BOOLEAN.has(key) && !(key in props) && (key !== "inert" || REF_IS_A_PROP)) out[RENAMED[key] ?? key] = false;
|
|
115
117
|
for (const key in props) {
|
|
116
118
|
const value = props[key];
|
|
117
119
|
if (BOOLEAN.has(key)) {
|
|
@@ -160,6 +162,7 @@ function usePart(part, tag, props, state, hold) {
|
|
|
160
162
|
now.leaving = false;
|
|
161
163
|
now.detach();
|
|
162
164
|
}
|
|
165
|
+
untype(element);
|
|
163
166
|
held.current = {
|
|
164
167
|
element,
|
|
165
168
|
part,
|
|
@@ -179,8 +182,10 @@ function usePart(part, tag, props, state, hold) {
|
|
|
179
182
|
const { ref: _ref, ...element } = REF_IS_A_PROP ? asked.props : { ...asked.props };
|
|
180
183
|
under = composeProps(caller, element);
|
|
181
184
|
}
|
|
185
|
+
const drawnAs = asked ? typeof asked.type === "string" ? asked.type : void 0 : typeof render === "function" ? void 0 : tag;
|
|
186
|
+
const placed = forElement(own, under, drawnAs);
|
|
182
187
|
const drawn = {
|
|
183
|
-
...toReact(mergeProps(under,
|
|
188
|
+
...toReact(mergeProps(under, placed), placed),
|
|
184
189
|
ref: attach
|
|
185
190
|
};
|
|
186
191
|
if (hold) drawn.children = hold(drawn.children);
|
|
@@ -246,13 +251,18 @@ function anchorOf(anchor) {
|
|
|
246
251
|
* A positioner's own props, written where its placement reads them: the one place they are
|
|
247
252
|
* named. Gives back what is left, for the part's element.
|
|
248
253
|
*/
|
|
249
|
-
function usePositioning(positioning, { side, align, sideOffset, alignOffset, collisionPadding, anchor, ...rest }) {
|
|
254
|
+
function usePositioning(positioning, { side, align, sideOffset, alignOffset, collisionPadding, collisionBoundary, collisionAvoidance, sticky, arrowPadding, positionMethod, anchor, ...rest }) {
|
|
250
255
|
positioning.set(defined({
|
|
251
256
|
side,
|
|
252
257
|
align,
|
|
253
258
|
sideOffset,
|
|
254
259
|
alignOffset,
|
|
255
260
|
collisionPadding,
|
|
261
|
+
collisionBoundary,
|
|
262
|
+
collisionAvoidance,
|
|
263
|
+
sticky,
|
|
264
|
+
arrowPadding,
|
|
265
|
+
positionMethod,
|
|
256
266
|
anchor: anchorOf(anchor)
|
|
257
267
|
}));
|
|
258
268
|
return rest;
|
|
@@ -296,6 +306,15 @@ function Portal({ children }) {
|
|
|
296
306
|
children
|
|
297
307
|
}), container ?? document.body);
|
|
298
308
|
}
|
|
299
|
-
|
|
309
|
+
/**
|
|
310
|
+
* The reading direction a `DirectionProvider` around this component states, as the signal a
|
|
311
|
+
* controller takes (`within(createX, { direction })`); `undefined` outside one, where the
|
|
312
|
+
* controller reads the direction its element is laid out in. For a component of your own: the
|
|
313
|
+
* library's parts read the same.
|
|
314
|
+
*/
|
|
315
|
+
function useDirectionAround() {
|
|
316
|
+
return useContext(DirectionContext) ?? void 0;
|
|
317
|
+
}
|
|
318
|
+
export { PartElement, Portal, PortalProvider, component, parts, useController, useDirectionAround, useIsomorphicLayoutEffect, useMount, useOptions, useOwnText, usePart, usePositioning, useSignal };
|
|
300
319
|
|
|
301
320
|
//# sourceMappingURL=runtime.js.map
|