@kirana-ui/react 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/llms.txt +1838 -0
- package/package.json +231 -6
- package/src/accordion.d.ts +28 -0
- package/src/accordion.js +81 -0
- package/src/accordion.js.map +1 -0
- package/src/alert-dialog.d.ts +2 -0
- package/src/alert-dialog.js +1 -0
- package/src/autocomplete.d.ts +2 -0
- package/src/autocomplete.js +1 -0
- package/src/autosize.d.ts +9 -0
- package/src/autosize.js +12 -0
- package/src/autosize.js.map +1 -0
- package/src/avatar.d.ts +16 -0
- package/src/avatar.js +42 -0
- package/src/avatar.js.map +1 -0
- package/src/button.d.ts +7 -0
- package/src/button.js +15 -0
- package/src/button.js.map +1 -0
- package/src/calendar.d.ts +44 -0
- package/src/calendar.js +85 -0
- package/src/calendar.js.map +1 -0
- package/src/carousel.d.ts +26 -0
- package/src/carousel.js +52 -0
- package/src/carousel.js.map +1 -0
- package/src/checkbox.d.ts +18 -0
- package/src/checkbox.js +51 -0
- package/src/checkbox.js.map +1 -0
- package/src/collapsible.d.ts +20 -0
- package/src/collapsible.js +43 -0
- package/src/collapsible.js.map +1 -0
- package/src/combobox.d.ts +91 -0
- package/src/combobox.js +164 -0
- package/src/combobox.js.map +1 -0
- package/src/command.d.ts +44 -0
- package/src/command.js +88 -0
- package/src/command.js.map +1 -0
- package/src/context-menu.d.ts +2 -0
- package/src/context-menu.js +1 -0
- package/src/date-field.d.ts +25 -0
- package/src/date-field.js +60 -0
- package/src/date-field.js.map +1 -0
- package/src/date-picker.d.ts +53 -0
- package/src/date-picker.js +62 -0
- package/src/date-picker.js.map +1 -0
- package/src/dialog.d.ts +63 -0
- package/src/dialog.js +66 -0
- package/src/dialog.js.map +1 -0
- package/src/direction-context.d.ts +4 -0
- package/src/direction-context.js +7 -0
- package/src/direction-context.js.map +1 -0
- package/src/direction.d.ts +15 -0
- package/src/direction.js +27 -0
- package/src/direction.js.map +1 -0
- package/src/drawer.d.ts +2 -0
- package/src/drawer.js +1 -0
- package/src/field-context.d.ts +4 -0
- package/src/field-context.js +7 -0
- package/src/field-context.js.map +1 -0
- package/src/field.d.ts +31 -0
- package/src/field.js +71 -0
- package/src/field.js.map +1 -0
- package/src/fieldset.d.ts +15 -0
- package/src/fieldset.js +31 -0
- package/src/fieldset.js.map +1 -0
- package/src/form.d.ts +8 -0
- package/src/form.js +27 -0
- package/src/form.js.map +1 -0
- package/src/hover-card.d.ts +13 -0
- package/src/hover-card.js +7 -0
- package/src/hover-card.js.map +1 -0
- package/src/hover-popup.d.ts +25 -0
- package/src/hover-popup.js +57 -0
- package/src/hover-popup.js.map +1 -0
- package/src/index.d.ts +48 -0
- package/src/index.js +47 -0
- package/src/input.d.ts +10 -0
- package/src/input.js +21 -0
- package/src/input.js.map +1 -0
- package/src/label.d.ts +5 -0
- package/src/label.js +14 -0
- package/src/label.js.map +1 -0
- package/src/listbox.d.ts +28 -0
- package/src/listbox.js +89 -0
- package/src/listbox.js.map +1 -0
- package/src/menu.d.ts +89 -0
- package/src/menu.js +214 -0
- package/src/menu.js.map +1 -0
- package/src/menubar-context.d.ts +4 -0
- package/src/menubar-context.js +7 -0
- package/src/menubar-context.js.map +1 -0
- package/src/menubar.d.ts +9 -0
- package/src/menubar.js +25 -0
- package/src/menubar.js.map +1 -0
- package/src/message-scroller.d.ts +18 -0
- package/src/message-scroller.js +35 -0
- package/src/message-scroller.js.map +1 -0
- package/src/meter.d.ts +13 -0
- package/src/meter.js +7 -0
- package/src/meter.js.map +1 -0
- package/src/navigation-menu.d.ts +48 -0
- package/src/navigation-menu.js +115 -0
- package/src/navigation-menu.js.map +1 -0
- package/src/number-field.d.ts +21 -0
- package/src/number-field.js +62 -0
- package/src/number-field.js.map +1 -0
- package/src/otp.d.ts +26 -0
- package/src/otp.js +70 -0
- package/src/otp.js.map +1 -0
- package/src/pagination.d.ts +27 -0
- package/src/pagination.js +50 -0
- package/src/pagination.js.map +1 -0
- package/src/popover.d.ts +32 -0
- package/src/popover.js +51 -0
- package/src/popover.js.map +1 -0
- package/src/progress.d.ts +13 -0
- package/src/progress.js +7 -0
- package/src/progress.js.map +1 -0
- package/src/qr-code.d.ts +16 -0
- package/src/qr-code.js +32 -0
- package/src/qr-code.js.map +1 -0
- package/src/radio-group.d.ts +24 -0
- package/src/radio-group.js +87 -0
- package/src/radio-group.js.map +1 -0
- package/src/resizable.d.ts +19 -0
- package/src/resizable.js +51 -0
- package/src/resizable.js.map +1 -0
- package/src/runtime.d.ts +61 -0
- package/src/runtime.js +208 -0
- package/src/runtime.js.map +1 -0
- package/src/scroll-area.d.ts +25 -0
- package/src/scroll-area.js +61 -0
- package/src/scroll-area.js.map +1 -0
- package/src/select.d.ts +74 -0
- package/src/select.js +149 -0
- package/src/select.js.map +1 -0
- package/src/separator.d.ts +6 -0
- package/src/separator.js +10 -0
- package/src/separator.js.map +1 -0
- package/src/slider.d.ts +29 -0
- package/src/slider.js +84 -0
- package/src/slider.js.map +1 -0
- package/src/switch.d.ts +14 -0
- package/src/switch.js +46 -0
- package/src/switch.js.map +1 -0
- package/src/tabs.d.ts +30 -0
- package/src/tabs.js +73 -0
- package/src/tabs.js.map +1 -0
- package/src/toast.d.ts +32 -0
- package/src/toast.js +61 -0
- package/src/toast.js.map +1 -0
- package/src/toggle-group.d.ts +7 -0
- package/src/toggle-group.js +32 -0
- package/src/toggle-group.js.map +1 -0
- package/src/toggle.d.ts +7 -0
- package/src/toggle.js +25 -0
- package/src/toggle.js.map +1 -0
- package/src/toolbar-context.d.ts +7 -0
- package/src/toolbar-context.js +9 -0
- package/src/toolbar-context.js.map +1 -0
- package/src/toolbar.d.ts +20 -0
- package/src/toolbar.js +53 -0
- package/src/toolbar.js.map +1 -0
- package/src/tooltip.d.ts +13 -0
- package/src/tooltip.js +7 -0
- package/src/tooltip.js.map +1 -0
- package/src/value-bar.d.ts +17 -0
- package/src/value-bar.js +51 -0
- package/src/value-bar.js.map +1 -0
- package/README.md +0 -7
- package/index.js +0 -5
package/src/field.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { FieldContext } from "./field-context.js";
|
|
2
|
+
import { FieldsetContext } from "./fieldset.js";
|
|
3
|
+
import { FormContext } from "./form.js";
|
|
4
|
+
import { useController, useMount, useOptions, usePart, useSignal } from "./runtime.js";
|
|
5
|
+
import { useContext, useMemo } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { createField } from "@kirana-ui/core/field";
|
|
8
|
+
// src/field.tsx
|
|
9
|
+
function useField(part) {
|
|
10
|
+
const controller = useContext(FieldContext);
|
|
11
|
+
if (!controller) throw new Error(`<Field.${part}> must be inside <Field.Root>`);
|
|
12
|
+
return controller;
|
|
13
|
+
}
|
|
14
|
+
function Root({ name, disabled, invalid, validate, validationMode, validationDebounceTime, id, ...rest }) {
|
|
15
|
+
const form = useContext(FormContext) ?? void 0;
|
|
16
|
+
const fieldset = useContext(FieldsetContext) ?? void 0;
|
|
17
|
+
const create = useMemo(() => (props) => createField(props, {
|
|
18
|
+
form,
|
|
19
|
+
fieldset
|
|
20
|
+
}), [form, fieldset]);
|
|
21
|
+
const controller = useController(create, {
|
|
22
|
+
name,
|
|
23
|
+
disabled,
|
|
24
|
+
invalid,
|
|
25
|
+
validate,
|
|
26
|
+
validationMode,
|
|
27
|
+
validationDebounceTime,
|
|
28
|
+
id
|
|
29
|
+
});
|
|
30
|
+
return /* @__PURE__ */ jsx(FieldContext.Provider, {
|
|
31
|
+
value: controller,
|
|
32
|
+
children: /* @__PURE__ */ jsx(RootElement, { ...rest })
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const RootElement = (props) => usePart(useField("Root").root, "div", props);
|
|
36
|
+
const Label = (props) => usePart(useField("Label").label, "label", props);
|
|
37
|
+
/** An `<input>`; a `<textarea>` or a `<select>` through `render`. */
|
|
38
|
+
const Control = (props) => usePart(useField("Control").control, "input", props);
|
|
39
|
+
const Description = (props) => usePart(useField("Description").description, "p", props);
|
|
40
|
+
const PartElement = ({ part, tag, ...props }) => usePart(part, tag, props);
|
|
41
|
+
/** What is wrong, or `children` in its place. In the page while it applies. */
|
|
42
|
+
function FieldError({ match, children, ...rest }) {
|
|
43
|
+
const controller = useField("Error");
|
|
44
|
+
const options = useOptions({ match });
|
|
45
|
+
const error = useMemo(() => controller.error(() => options.get().match), [controller, options]);
|
|
46
|
+
useMount(error);
|
|
47
|
+
const mounted = useSignal(error.mounted);
|
|
48
|
+
const text = useSignal(error.text);
|
|
49
|
+
if (!mounted) return null;
|
|
50
|
+
return /* @__PURE__ */ jsx(PartElement, {
|
|
51
|
+
part: error.part,
|
|
52
|
+
tag: "div",
|
|
53
|
+
...rest,
|
|
54
|
+
children: children ?? text
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Draws nothing itself: `children` is given the field's validity. */
|
|
58
|
+
function Validity({ children }) {
|
|
59
|
+
return children(useSignal(useField("Validity").validity));
|
|
60
|
+
}
|
|
61
|
+
const Field = {
|
|
62
|
+
Root,
|
|
63
|
+
Label,
|
|
64
|
+
Control,
|
|
65
|
+
Description,
|
|
66
|
+
Error: FieldError,
|
|
67
|
+
Validity
|
|
68
|
+
};
|
|
69
|
+
export { Field };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=field.js.map
|
package/src/field.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.js","names":[],"sources":["../../../../packages/react/src/field.tsx"],"sourcesContent":["import type { Part, ReadonlySignal } from \"@kirana-ui/core\"\nimport { createField } from \"@kirana-ui/core/field\"\nimport type {\n Field as Controller,\n FieldProps,\n FieldValidity,\n ValidityKey,\n} from \"@kirana-ui/core/field\"\nimport { useContext, useMemo } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { FieldsetContext } from \"./fieldset.tsx\"\nimport { FormContext } from \"./form.tsx\"\nimport { useController, useMount, useOptions, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nfunction useField(part: string): Controller {\n const controller = useContext(FieldContext)\n if (!controller) throw new Error(`<Field.${part}> must be inside <Field.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<FieldProps, \"id\"> & { id?: string } & PartComponentProps\n\nfunction Root({\n name,\n disabled,\n invalid,\n validate,\n validationMode,\n validationDebounceTime,\n id,\n ...rest\n}: RootProps): ReactElement {\n const form = useContext(FormContext) ?? undefined\n const fieldset = useContext(FieldsetContext) ?? undefined\n const create = useMemo(\n () => (props: ReadonlySignal<FieldProps>) => createField(props, { form, fieldset }),\n [form, fieldset]\n )\n const controller = useController(create, {\n name,\n disabled,\n invalid,\n validate,\n validationMode,\n validationDebounceTime,\n id,\n })\n return (\n <FieldContext.Provider value={controller}>\n <RootElement {...rest} />\n </FieldContext.Provider>\n )\n}\n\nconst RootElement = (props: PartComponentProps) => usePart(useField(\"Root\").root, \"div\", props)\nconst Label = (props: PartComponentProps) => usePart(useField(\"Label\").label, \"label\", props)\n/** An `<input>`; a `<textarea>` or a `<select>` through `render`. */\nconst Control = (props: PartComponentProps) => usePart(useField(\"Control\").control, \"input\", props)\nconst Description = (props: PartComponentProps) =>\n usePart(useField(\"Description\").description, \"p\", props)\n\nconst PartElement = ({ part, tag, ...props }: PartComponentProps & { part: Part; tag: string }) =>\n usePart(part, tag, props)\n\nexport interface ErrorProps extends PartComponentProps {\n /** One of the browser's findings (`\"valueMissing\"`) to show for only that; `true` to show always. */\n match?: ValidityKey | boolean\n}\n\n/** What is wrong, or `children` in its place. In the page while it applies. */\nfunction FieldError({ match, children, ...rest }: ErrorProps): ReactElement | null {\n const controller = useField(\"Error\")\n const options = useOptions({ match })\n const error = useMemo(() => controller.error(() => options.get().match), [controller, options])\n useMount(error)\n const mounted = useSignal(error.mounted)\n const text = useSignal(error.text)\n if (!mounted) return null\n return (\n <PartElement part={error.part} tag=\"div\" {...rest}>\n {children ?? text}\n </PartElement>\n )\n}\n\n/** Draws nothing itself: `children` is given the field's validity. */\nfunction Validity({ children }: { children: (validity: FieldValidity) => ReactNode }): ReactNode {\n return children(useSignal(useField(\"Validity\").validity))\n}\n\nexport const Field = { Root, Label, Control, Description, Error: FieldError, Validity }\n"],"mappings":";;;;;;;;AAiBA,SAAS,SAAS,MAA0B;CAC1C,MAAM,aAAa,WAAW,YAAY;CAC1C,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,UAAU,KAAK,8BAA8B;CAC9E,OAAO;AACT;AAIA,SAAS,KAAK,EACZ,MACA,UACA,SACA,UACA,gBACA,wBACA,IACA,GAAG,QACuB;CAC1B,MAAM,OAAO,WAAW,WAAW,KAAK,KAAA;CACxC,MAAM,WAAW,WAAW,eAAe,KAAK,KAAA;CAChD,MAAM,SAAS,eACN,UAAsC,YAAY,OAAO;EAAE;EAAM;CAAS,CAAC,GAClF,CAAC,MAAM,QAAQ,CACjB;CACA,MAAM,aAAa,cAAc,QAAQ;EACvC;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,aAAa,UAAd;EAAuB,OAAO;EAC5B,UAAA,oBAAC,aAAD,EAAa,GAAI,KAAO,CAAA;CACH,CAAA;AAE3B;AAEA,MAAM,eAAe,UAA8B,QAAQ,SAAS,MAAM,CAAC,CAAC,MAAM,OAAO,KAAK;AAC9F,MAAM,SAAS,UAA8B,QAAQ,SAAS,OAAO,CAAC,CAAC,OAAO,SAAS,KAAK;;AAE5F,MAAM,WAAW,UAA8B,QAAQ,SAAS,SAAS,CAAC,CAAC,SAAS,SAAS,KAAK;AAClG,MAAM,eAAe,UACnB,QAAQ,SAAS,aAAa,CAAC,CAAC,aAAa,KAAK,KAAK;AAEzD,MAAM,eAAe,EAAE,MAAM,KAAK,GAAG,YACnC,QAAQ,MAAM,KAAK,KAAK;;AAQ1B,SAAS,WAAW,EAAE,OAAO,UAAU,GAAG,QAAyC;CACjF,MAAM,aAAa,SAAS,OAAO;CACnC,MAAM,UAAU,WAAW,EAAE,MAAM,CAAC;CACpC,MAAM,QAAQ,cAAc,WAAW,YAAY,QAAQ,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,YAAY,OAAO,CAAC;CAC9F,SAAS,KAAK;CACd,MAAM,UAAU,UAAU,MAAM,OAAO;CACvC,MAAM,OAAO,UAAU,MAAM,IAAI;CACjC,IAAI,CAAC,SAAS,OAAO;CACrB,OACE,oBAAC,aAAD;EAAa,MAAM,MAAM;EAAM,KAAI;EAAM,GAAI;EAC1C,UAAA,YAAY;CACF,CAAA;AAEjB;;AAGA,SAAS,SAAS,EAAE,YAA6E;CAC/F,OAAO,SAAS,UAAU,SAAS,UAAU,CAAC,CAAC,QAAQ,CAAC;AAC1D;AAEA,MAAa,QAAQ;CAAE;CAAM;CAAO;CAAS;CAAa,OAAO;CAAY;AAAS"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { Fieldset as Fieldset$1, FieldsetProps } from "@kirana-ui/core/fieldset";
|
|
4
|
+
/** The fieldset a field is in, if it is in one. */
|
|
5
|
+
export declare const FieldsetContext: import("react").Context<Fieldset$1 | null>;
|
|
6
|
+
declare function Root({ disabled, id, ...rest }: Omit<FieldsetProps, "id"> & {
|
|
7
|
+
id?: string;
|
|
8
|
+
} & PartComponentProps): ReactElement;
|
|
9
|
+
declare const Legend: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
10
|
+
export declare const Fieldset: {
|
|
11
|
+
Root: typeof Root;
|
|
12
|
+
Legend: typeof Legend;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=fieldset.d.ts.map
|
package/src/fieldset.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useController, usePart } from "./runtime.js";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createFieldset } from "@kirana-ui/core/fieldset";
|
|
5
|
+
// src/fieldset.tsx
|
|
6
|
+
/** The fieldset a field is in, if it is in one. */
|
|
7
|
+
const FieldsetContext = createContext(null);
|
|
8
|
+
function useFieldset(part) {
|
|
9
|
+
const controller = useContext(FieldsetContext);
|
|
10
|
+
if (!controller) throw new Error(`<Fieldset.${part}> must be inside <Fieldset.Root>`);
|
|
11
|
+
return controller;
|
|
12
|
+
}
|
|
13
|
+
function Root({ disabled, id, ...rest }) {
|
|
14
|
+
const controller = useController(createFieldset, {
|
|
15
|
+
disabled,
|
|
16
|
+
id
|
|
17
|
+
});
|
|
18
|
+
return /* @__PURE__ */ jsx(FieldsetContext.Provider, {
|
|
19
|
+
value: controller,
|
|
20
|
+
children: /* @__PURE__ */ jsx(RootElement, { ...rest })
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const RootElement = (props) => usePart(useFieldset("Root").root, "fieldset", props);
|
|
24
|
+
const Legend = (props) => usePart(useFieldset("Legend").legend, "div", props);
|
|
25
|
+
const Fieldset = {
|
|
26
|
+
Root,
|
|
27
|
+
Legend
|
|
28
|
+
};
|
|
29
|
+
export { Fieldset, FieldsetContext };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=fieldset.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldset.js","names":[],"sources":["../../../../packages/react/src/fieldset.tsx"],"sourcesContent":["import { createFieldset } from \"@kirana-ui/core/fieldset\"\nimport type { Fieldset as Controller, FieldsetProps } from \"@kirana-ui/core/fieldset\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\n/** The fieldset a field is in, if it is in one. */\nexport const FieldsetContext = createContext<Controller | null>(null)\n\nfunction useFieldset(part: string): Controller {\n const controller = useContext(FieldsetContext)\n if (!controller) throw new Error(`<Fieldset.${part}> must be inside <Fieldset.Root>`)\n return controller\n}\n\nfunction Root({\n disabled,\n id,\n ...rest\n}: Omit<FieldsetProps, \"id\"> & { id?: string } & PartComponentProps): ReactElement {\n const controller = useController(createFieldset, { disabled, id })\n return (\n <FieldsetContext.Provider value={controller}>\n <RootElement {...rest} />\n </FieldsetContext.Provider>\n )\n}\n\nconst RootElement = (props: PartComponentProps) =>\n usePart(useFieldset(\"Root\").root, \"fieldset\", props)\nconst Legend = (props: PartComponentProps) => usePart(useFieldset(\"Legend\").legend, \"div\", props)\n\nexport const Fieldset = { Root, Legend }\n"],"mappings":";;;;;;AASA,MAAa,kBAAkB,cAAiC,IAAI;AAEpE,SAAS,YAAY,MAA0B;CAC7C,MAAM,aAAa,WAAW,eAAe;CAC7C,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,aAAa,KAAK,iCAAiC;CACpF,OAAO;AACT;AAEA,SAAS,KAAK,EACZ,UACA,IACA,GAAG,QAC8E;CACjF,MAAM,aAAa,cAAc,gBAAgB;EAAE;EAAU;CAAG,CAAC;CACjE,OACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;EAC/B,UAAA,oBAAC,aAAD,EAAa,GAAI,KAAO,CAAA;CACA,CAAA;AAE9B;AAEA,MAAM,eAAe,UACnB,QAAQ,YAAY,MAAM,CAAC,CAAC,MAAM,YAAY,KAAK;AACrD,MAAM,UAAU,UAA8B,QAAQ,YAAY,QAAQ,CAAC,CAAC,QAAQ,OAAO,KAAK;AAEhG,MAAa,WAAW;CAAE;CAAM;AAAO"}
|
package/src/form.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { Form as Form$1, FormProps } from "@kirana-ui/core/form";
|
|
4
|
+
/** The form a field is in, if it is in one. */
|
|
5
|
+
export declare const FormContext: import("react").Context<Form$1 | null>;
|
|
6
|
+
/** A `<form>` whose fields say what is wrong; `onFormSubmit` takes the values once all are valid. */
|
|
7
|
+
export declare function Form({ errors, onClearErrors, onFormSubmit, validationMode, ...rest }: FormProps & PartComponentProps): ReactElement;
|
|
8
|
+
//# sourceMappingURL=form.d.ts.map
|
package/src/form.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useController, usePart } from "./runtime.js";
|
|
2
|
+
import { createContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createForm } from "@kirana-ui/core/form";
|
|
5
|
+
// src/form.tsx
|
|
6
|
+
/** The form a field is in, if it is in one. */
|
|
7
|
+
const FormContext = createContext(null);
|
|
8
|
+
/** A `<form>` whose fields say what is wrong; `onFormSubmit` takes the values once all are valid. */
|
|
9
|
+
function Form({ errors, onClearErrors, onFormSubmit, validationMode, ...rest }) {
|
|
10
|
+
const controller = useController(createForm, {
|
|
11
|
+
errors,
|
|
12
|
+
onClearErrors,
|
|
13
|
+
onFormSubmit,
|
|
14
|
+
validationMode
|
|
15
|
+
});
|
|
16
|
+
return /* @__PURE__ */ jsx(FormContext.Provider, {
|
|
17
|
+
value: controller,
|
|
18
|
+
children: /* @__PURE__ */ jsx(Element, {
|
|
19
|
+
part: controller,
|
|
20
|
+
...rest
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
const Element = ({ part, ...props }) => usePart(part.root, "form", props);
|
|
25
|
+
export { Form, FormContext };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=form.js.map
|
package/src/form.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.js","names":[],"sources":["../../../../packages/react/src/form.tsx"],"sourcesContent":["import { createForm } from \"@kirana-ui/core/form\"\nimport type { Form as Controller, FormProps } from \"@kirana-ui/core/form\"\nimport { createContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\n/** The form a field is in, if it is in one. */\nexport const FormContext = createContext<Controller | null>(null)\n\n/** A `<form>` whose fields say what is wrong; `onFormSubmit` takes the values once all are valid. */\nexport function Form({\n errors,\n onClearErrors,\n onFormSubmit,\n validationMode,\n ...rest\n}: FormProps & PartComponentProps): ReactElement {\n const controller = useController(createForm, {\n errors,\n onClearErrors,\n onFormSubmit,\n validationMode,\n })\n return (\n <FormContext.Provider value={controller}>\n <Element part={controller} {...rest} />\n </FormContext.Provider>\n )\n}\n\nconst Element = ({ part, ...props }: PartComponentProps & { part: Controller }) =>\n usePart(part.root, \"form\", props)\n"],"mappings":";;;;;;AASA,MAAa,cAAc,cAAiC,IAAI;;AAGhE,SAAgB,KAAK,EACnB,QACA,eACA,cACA,gBACA,GAAG,QAC4C;CAC/C,MAAM,aAAa,cAAc,YAAY;EAC3C;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,SAAD;GAAS,MAAM;GAAY,GAAI;EAAO,CAAA;CAClB,CAAA;AAE1B;AAEA,MAAM,WAAW,EAAE,MAAM,GAAG,YAC1B,QAAQ,KAAK,MAAM,QAAQ,KAAK"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PositionerProps, RootProps, TriggerProps } from "./hover-popup.js";
|
|
2
|
+
import { PartComponentProps } from "./runtime.js";
|
|
3
|
+
export declare const HoverCard: {
|
|
4
|
+
Root: ({ children, ...props }: RootProps) => import("react").ReactElement;
|
|
5
|
+
Trigger: ({ delay, closeDelay, ...props }: TriggerProps) => import("react").ReactElement;
|
|
6
|
+
Portal: ({ children }: {
|
|
7
|
+
children?: import("react").ReactNode;
|
|
8
|
+
}) => import("react").ReactElement | null;
|
|
9
|
+
Positioner: ({ side, align, sideOffset, alignOffset, collisionPadding, ...props }: PositionerProps) => import("react").ReactElement;
|
|
10
|
+
Popup: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
11
|
+
Arrow: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=hover-card.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { hoverPopup } from "./hover-popup.js";
|
|
2
|
+
import { createHoverCard } from "@kirana-ui/core/hover-card";
|
|
3
|
+
// src/hover-card.tsx
|
|
4
|
+
const HoverCard = hoverPopup("HoverCard", createHoverCard, "a");
|
|
5
|
+
export { HoverCard };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=hover-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hover-card.js","names":[],"sources":["../../../../packages/react/src/hover-card.tsx"],"sourcesContent":["import { createHoverCard } from \"@kirana-ui/core/hover-card\"\n\nimport { hoverPopup } from \"./hover-popup.tsx\"\n\nexport const HoverCard = hoverPopup(\"HoverCard\", createHoverCard, \"a\")\n"],"mappings":";;;AAIA,MAAa,YAAY,WAAW,aAAa,iBAAiB,GAAG"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { PositionOptions, ReadonlySignal } from "@kirana-ui/core";
|
|
3
|
+
import { ReactElement, ReactNode } from "react";
|
|
4
|
+
import { HoverPopup, HoverPopupProps } from "@kirana-ui/core/tooltip";
|
|
5
|
+
export type RootProps = Omit<HoverPopupProps, "id"> & {
|
|
6
|
+
id?: string;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export type PositionerProps = PartComponentProps & Partial<PositionOptions>;
|
|
10
|
+
export type TriggerProps = PartComponentProps & {
|
|
11
|
+
delay?: number;
|
|
12
|
+
closeDelay?: number;
|
|
13
|
+
};
|
|
14
|
+
/** The parts of a popup the pointer opens: a tooltip's, a hover card's. */
|
|
15
|
+
export declare function hoverPopup(name: string, create: (props: ReadonlySignal<HoverPopupProps>) => HoverPopup, triggerTag: string): {
|
|
16
|
+
Root: ({ children, ...props }: RootProps) => ReactElement;
|
|
17
|
+
Trigger: ({ delay, closeDelay, ...props }: TriggerProps) => ReactElement;
|
|
18
|
+
Portal: ({ children }: {
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}) => ReactElement | null;
|
|
21
|
+
Positioner: ({ side, align, sideOffset, alignOffset, collisionPadding, ...props }: PositionerProps) => ReactElement;
|
|
22
|
+
Popup: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
23
|
+
Arrow: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=hover-popup.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Portal, useController, usePart, useSignal } from "./runtime.js";
|
|
2
|
+
import { defined } from "@kirana-ui/core";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/hover-popup.tsx
|
|
6
|
+
/** The parts of a popup the pointer opens: a tooltip's, a hover card's. */
|
|
7
|
+
function hoverPopup(name, create, triggerTag) {
|
|
8
|
+
const Context = createContext(null);
|
|
9
|
+
function use(part) {
|
|
10
|
+
const controller = useContext(Context);
|
|
11
|
+
if (!controller) throw new Error(`<${name}.${part}> must be inside <${name}.Root>`);
|
|
12
|
+
return controller;
|
|
13
|
+
}
|
|
14
|
+
function Root({ children, ...props }) {
|
|
15
|
+
const controller = useController(create, props);
|
|
16
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
17
|
+
value: controller,
|
|
18
|
+
children
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function Portal$1({ children }) {
|
|
22
|
+
return useSignal(use("Portal").mounted) ? /* @__PURE__ */ jsx(Portal, { children }) : null;
|
|
23
|
+
}
|
|
24
|
+
function Positioner({ side, align, sideOffset, alignOffset, collisionPadding, ...props }) {
|
|
25
|
+
const controller = use("Positioner");
|
|
26
|
+
controller.positioning.set(defined({
|
|
27
|
+
side,
|
|
28
|
+
align,
|
|
29
|
+
sideOffset,
|
|
30
|
+
alignOffset,
|
|
31
|
+
collisionPadding
|
|
32
|
+
}));
|
|
33
|
+
return usePart(controller.positioner, "div", props);
|
|
34
|
+
}
|
|
35
|
+
/** `delay` and `closeDelay` here come before the root's. */
|
|
36
|
+
function Trigger({ delay, closeDelay, ...props }) {
|
|
37
|
+
const controller = use("Trigger");
|
|
38
|
+
controller.timing.set(defined({
|
|
39
|
+
delay,
|
|
40
|
+
closeDelay
|
|
41
|
+
}));
|
|
42
|
+
return usePart(controller.trigger, triggerTag, props);
|
|
43
|
+
}
|
|
44
|
+
const Popup = (props) => usePart(use("Popup").popup, "div", props);
|
|
45
|
+
const Arrow = (props) => usePart(use("Arrow").arrow, "div", props);
|
|
46
|
+
return {
|
|
47
|
+
Root,
|
|
48
|
+
Trigger,
|
|
49
|
+
Portal: Portal$1,
|
|
50
|
+
Positioner,
|
|
51
|
+
Popup,
|
|
52
|
+
Arrow
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export { hoverPopup };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=hover-popup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hover-popup.js","names":["Portal","BodyPortal"],"sources":["../../../../packages/react/src/hover-popup.tsx"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { PositionOptions, ReadonlySignal } from \"@kirana-ui/core\"\nimport type { HoverPopup, HoverPopupProps } from \"@kirana-ui/core/tooltip\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { Portal as BodyPortal, useController, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type RootProps = Omit<HoverPopupProps, \"id\"> & { id?: string; children?: ReactNode }\nexport type PositionerProps = PartComponentProps & Partial<PositionOptions>\nexport type TriggerProps = PartComponentProps & { delay?: number; closeDelay?: number }\n\n/** The parts of a popup the pointer opens: a tooltip's, a hover card's. */\nexport function hoverPopup(\n name: string,\n create: (props: ReadonlySignal<HoverPopupProps>) => HoverPopup,\n triggerTag: string\n) {\n const Context = createContext<HoverPopup | null>(null)\n\n function use(part: string): HoverPopup {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<${name}.${part}> must be inside <${name}.Root>`)\n return controller\n }\n\n function Root({ children, ...props }: RootProps): ReactElement {\n const controller = useController(create, props)\n return <Context.Provider value={controller}>{children}</Context.Provider>\n }\n\n function Portal({ children }: { children?: ReactNode }): ReactElement | null {\n const mounted = useSignal(use(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n }\n\n function Positioner({\n side,\n align,\n sideOffset,\n alignOffset,\n collisionPadding,\n ...props\n }: PositionerProps): ReactElement {\n const controller = use(\"Positioner\")\n // Written while rendering, so the first placement reads them. Nothing re-renders for it.\n controller.positioning.set(defined({ side, align, sideOffset, alignOffset, collisionPadding }))\n return usePart(controller.positioner, \"div\", props)\n }\n\n /** `delay` and `closeDelay` here come before the root's. */\n function Trigger({ delay, closeDelay, ...props }: TriggerProps): ReactElement {\n const controller = use(\"Trigger\")\n controller.timing.set(defined({ delay, closeDelay }))\n return usePart(controller.trigger, triggerTag, props)\n }\n const Popup = (props: PartComponentProps) => usePart(use(\"Popup\").popup, \"div\", props)\n const Arrow = (props: PartComponentProps) => usePart(use(\"Arrow\").arrow, \"div\", props)\n\n return { Root, Trigger, Portal, Positioner, Popup, Arrow }\n}\n"],"mappings":";;;;;;AAcA,SAAgB,WACd,MACA,QACA,YACA;CACA,MAAM,UAAU,cAAiC,IAAI;CAErD,SAAS,IAAI,MAA0B;EACrC,MAAM,aAAa,WAAW,OAAO;EACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,IAAI,KAAK,GAAG,KAAK,oBAAoB,KAAK,OAAO;EAClF,OAAO;CACT;CAEA,SAAS,KAAK,EAAE,UAAU,GAAG,SAAkC;EAC7D,MAAM,aAAa,cAAc,QAAQ,KAAK;EAC9C,OAAO,oBAAC,QAAQ,UAAT;GAAkB,OAAO;GAAa;EAA2B,CAAA;CAC1E;CAEA,SAASA,SAAO,EAAE,YAA2D;EAE3E,OADgB,UAAU,IAAI,QAAQ,CAAC,CAAC,OAC3B,IAAI,oBAACC,QAAD,EAAa,SAAqB,CAAA,IAAI;CACzD;CAEA,SAAS,WAAW,EAClB,MACA,OACA,YACA,aACA,kBACA,GAAG,SAC6B;EAChC,MAAM,aAAa,IAAI,YAAY;EAEnC,WAAW,YAAY,IAAI,QAAQ;GAAE;GAAM;GAAO;GAAY;GAAa;EAAiB,CAAC,CAAC;EAC9F,OAAO,QAAQ,WAAW,YAAY,OAAO,KAAK;CACpD;;CAGA,SAAS,QAAQ,EAAE,OAAO,YAAY,GAAG,SAAqC;EAC5E,MAAM,aAAa,IAAI,SAAS;EAChC,WAAW,OAAO,IAAI,QAAQ;GAAE;GAAO;EAAW,CAAC,CAAC;EACpD,OAAO,QAAQ,WAAW,SAAS,YAAY,KAAK;CACtD;CACA,MAAM,SAAS,UAA8B,QAAQ,IAAI,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;CACrF,MAAM,SAAS,UAA8B,QAAQ,IAAI,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;CAErF,OAAO;EAAE;EAAM;EAAS,QAAA;EAAQ;EAAY;EAAO;CAAM;AAC3D"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Accordion } from "./accordion.js";
|
|
2
|
+
import { Checkbox } from "./checkbox.js";
|
|
3
|
+
import { Collapsible } from "./collapsible.js";
|
|
4
|
+
import { AlertDialog, Dialog, Drawer } from "./dialog.js";
|
|
5
|
+
import { MessageScroller } from "./message-scroller.js";
|
|
6
|
+
import { HoverCard } from "./hover-card.js";
|
|
7
|
+
import { Autocomplete, Combobox } from "./combobox.js";
|
|
8
|
+
import { Listbox } from "./listbox.js";
|
|
9
|
+
import { ContextMenu, Menu } from "./menu.js";
|
|
10
|
+
import { Menubar } from "./menubar.js";
|
|
11
|
+
import { NavigationMenu } from "./navigation-menu.js";
|
|
12
|
+
import { Otp } from "./otp.js";
|
|
13
|
+
import { DateField } from "./date-field.js";
|
|
14
|
+
import { Input } from "./input.js";
|
|
15
|
+
import { Label } from "./label.js";
|
|
16
|
+
import { Command } from "./command.js";
|
|
17
|
+
import { NumberField } from "./number-field.js";
|
|
18
|
+
import "./autocomplete.js";
|
|
19
|
+
import { Pagination } from "./pagination.js";
|
|
20
|
+
import { DatePicker } from "./date-picker.js";
|
|
21
|
+
import { Calendar } from "./calendar.js";
|
|
22
|
+
import { QrCode } from "./qr-code.js";
|
|
23
|
+
import { Autosize } from "./autosize.js";
|
|
24
|
+
import { Carousel } from "./carousel.js";
|
|
25
|
+
import { Toast, createToaster } from "./toast.js";
|
|
26
|
+
import { Resizable } from "./resizable.js";
|
|
27
|
+
import { Popover } from "./popover.js";
|
|
28
|
+
import { RadioGroup } from "./radio-group.js";
|
|
29
|
+
import { Select } from "./select.js";
|
|
30
|
+
import { Switch } from "./switch.js";
|
|
31
|
+
import { Tabs } from "./tabs.js";
|
|
32
|
+
import { Tooltip } from "./tooltip.js";
|
|
33
|
+
import { PartComponentProps, PortalProvider, PortalProviderProps, RenderProp } from "./runtime.js";
|
|
34
|
+
import { Avatar } from "./avatar.js";
|
|
35
|
+
import { Button } from "./button.js";
|
|
36
|
+
import { Meter } from "./meter.js";
|
|
37
|
+
import { Progress } from "./progress.js";
|
|
38
|
+
import { Separator } from "./separator.js";
|
|
39
|
+
import { Toggle } from "./toggle.js";
|
|
40
|
+
import { ToggleGroup } from "./toggle-group.js";
|
|
41
|
+
import { Toolbar } from "./toolbar.js";
|
|
42
|
+
import { ScrollArea } from "./scroll-area.js";
|
|
43
|
+
import { Slider } from "./slider.js";
|
|
44
|
+
import { Field } from "./field.js";
|
|
45
|
+
import { Fieldset } from "./fieldset.js";
|
|
46
|
+
import { Form } from "./form.js";
|
|
47
|
+
import { DirectionProvider, DirectionProviderProps, useDirection } from "./direction.js";
|
|
48
|
+
export { Accordion, AlertDialog, Autocomplete, Autosize, Avatar, Button, Calendar, Carousel, Checkbox, Collapsible, Combobox, Command, ContextMenu, DateField, DatePicker, Dialog, DirectionProvider, type DirectionProviderProps, Drawer, Field, Fieldset, Form, HoverCard, Input, Label, Listbox, Menu, Menubar, MessageScroller, Meter, NavigationMenu, NumberField, Otp, Pagination, type PartComponentProps, Popover, PortalProvider, type PortalProviderProps, Progress, QrCode, RadioGroup, type RenderProp, Resizable, ScrollArea, Select, Separator, Slider, Switch, Tabs, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, createToaster, useDirection };
|
package/src/index.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Accordion } from "./accordion.js";
|
|
2
|
+
import { Checkbox } from "./checkbox.js";
|
|
3
|
+
import { Collapsible } from "./collapsible.js";
|
|
4
|
+
import { AlertDialog, Dialog, Drawer } from "./dialog.js";
|
|
5
|
+
import { MessageScroller } from "./message-scroller.js";
|
|
6
|
+
import { HoverCard } from "./hover-card.js";
|
|
7
|
+
import { Autocomplete, Combobox } from "./combobox.js";
|
|
8
|
+
import { Listbox } from "./listbox.js";
|
|
9
|
+
import { ContextMenu, Menu } from "./menu.js";
|
|
10
|
+
import { Menubar } from "./menubar.js";
|
|
11
|
+
import { NavigationMenu } from "./navigation-menu.js";
|
|
12
|
+
import { Otp } from "./otp.js";
|
|
13
|
+
import { DateField } from "./date-field.js";
|
|
14
|
+
import { Input } from "./input.js";
|
|
15
|
+
import { Label } from "./label.js";
|
|
16
|
+
import { Command } from "./command.js";
|
|
17
|
+
import { NumberField } from "./number-field.js";
|
|
18
|
+
import { Pagination } from "./pagination.js";
|
|
19
|
+
import { DatePicker } from "./date-picker.js";
|
|
20
|
+
import { Calendar } from "./calendar.js";
|
|
21
|
+
import { QrCode } from "./qr-code.js";
|
|
22
|
+
import { Autosize } from "./autosize.js";
|
|
23
|
+
import { Carousel } from "./carousel.js";
|
|
24
|
+
import { Toast, createToaster } from "./toast.js";
|
|
25
|
+
import { Resizable } from "./resizable.js";
|
|
26
|
+
import { Popover } from "./popover.js";
|
|
27
|
+
import { RadioGroup } from "./radio-group.js";
|
|
28
|
+
import { Select } from "./select.js";
|
|
29
|
+
import { Switch } from "./switch.js";
|
|
30
|
+
import { Tabs } from "./tabs.js";
|
|
31
|
+
import { Tooltip } from "./tooltip.js";
|
|
32
|
+
import { Avatar } from "./avatar.js";
|
|
33
|
+
import { Button } from "./button.js";
|
|
34
|
+
import { Meter } from "./meter.js";
|
|
35
|
+
import { Progress } from "./progress.js";
|
|
36
|
+
import { Separator } from "./separator.js";
|
|
37
|
+
import { Toggle } from "./toggle.js";
|
|
38
|
+
import { ToggleGroup } from "./toggle-group.js";
|
|
39
|
+
import { Toolbar } from "./toolbar.js";
|
|
40
|
+
import { ScrollArea } from "./scroll-area.js";
|
|
41
|
+
import { Slider } from "./slider.js";
|
|
42
|
+
import { Field } from "./field.js";
|
|
43
|
+
import { Fieldset } from "./fieldset.js";
|
|
44
|
+
import { Form } from "./form.js";
|
|
45
|
+
import { DirectionProvider, useDirection } from "./direction.js";
|
|
46
|
+
import { PortalProvider } from "./runtime.js";
|
|
47
|
+
export { Accordion, AlertDialog, Autocomplete, Autosize, Avatar, Button, Calendar, Carousel, Checkbox, Collapsible, Combobox, Command, ContextMenu, DateField, DatePicker, Dialog, DirectionProvider, Drawer, Field, Fieldset, Form, HoverCard, Input, Label, Listbox, Menu, Menubar, MessageScroller, Meter, NavigationMenu, NumberField, Otp, Pagination, Popover, PortalProvider, Progress, QrCode, RadioGroup, Resizable, ScrollArea, Select, Separator, Slider, Switch, Tabs, Toast, Toggle, ToggleGroup, Toolbar, Tooltip, createToaster, useDirection };
|
package/src/input.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { InputProps as InputProps$1 } from "@kirana-ui/core/input";
|
|
4
|
+
export type InputProps = InputProps$1 & PartComponentProps;
|
|
5
|
+
/**
|
|
6
|
+
* An `<input>`; a `<textarea>` through `render`. It takes what an `<input>` takes (`value`,
|
|
7
|
+
* `defaultValue`), and inside a `<Field.Root>` it is the field's control.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Input({ disabled, onValueChange, ...rest }: InputProps): ReactElement;
|
|
10
|
+
//# sourceMappingURL=input.d.ts.map
|
package/src/input.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FieldContext } from "./field-context.js";
|
|
2
|
+
import { useController, usePart } from "./runtime.js";
|
|
3
|
+
import { within } from "@kirana-ui/core";
|
|
4
|
+
import { useContext } from "react";
|
|
5
|
+
import { createInput } from "@kirana-ui/core/input";
|
|
6
|
+
// src/input.tsx
|
|
7
|
+
/**
|
|
8
|
+
* An `<input>`; a `<textarea>` through `render`. It takes what an `<input>` takes (`value`,
|
|
9
|
+
* `defaultValue`), and inside a `<Field.Root>` it is the field's control.
|
|
10
|
+
*/
|
|
11
|
+
function Input({ disabled, onValueChange, ...rest }) {
|
|
12
|
+
const field = useContext(FieldContext) ?? void 0;
|
|
13
|
+
const controller = useController(within(createInput, { field }), {
|
|
14
|
+
disabled,
|
|
15
|
+
onValueChange
|
|
16
|
+
});
|
|
17
|
+
return usePart(controller.input, "input", rest);
|
|
18
|
+
}
|
|
19
|
+
export { Input };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=input.js.map
|
package/src/input.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../../../../packages/react/src/input.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport { createInput } from \"@kirana-ui/core/input\"\nimport type { Input as Controller, InputProps as CoreProps } from \"@kirana-ui/core/input\"\nimport { useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type InputProps = CoreProps & PartComponentProps\n\n/**\n * An `<input>`; a `<textarea>` through `render`. It takes what an `<input>` takes (`value`,\n * `defaultValue`), and inside a `<Field.Root>` it is the field's control.\n */\nexport function Input({ disabled, onValueChange, ...rest }: InputProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const controller = useController<CoreProps, Controller>(within(createInput, { field }), {\n disabled,\n onValueChange,\n })\n return usePart(controller.input, \"input\", rest)\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAgB,MAAM,EAAE,UAAU,eAAe,GAAG,QAAkC;CACpF,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,aAAa,cAAqC,OAAO,aAAa,EAAE,MAAM,CAAC,GAAG;EACtF;EACA;CACF,CAAC;CACD,OAAO,QAAQ,WAAW,OAAO,SAAS,IAAI;AAChD"}
|
package/src/label.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
/** A `<label>`. Inside a `<Field.Root>` it is the field's label. */
|
|
4
|
+
export declare function Label(props: PartComponentProps): ReactElement;
|
|
5
|
+
//# sourceMappingURL=label.d.ts.map
|
package/src/label.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldContext } from "./field-context.js";
|
|
2
|
+
import { usePart } from "./runtime.js";
|
|
3
|
+
import { useContext, useMemo } from "react";
|
|
4
|
+
import { createLabel } from "@kirana-ui/core/label";
|
|
5
|
+
// src/label.tsx
|
|
6
|
+
/** A `<label>`. Inside a `<Field.Root>` it is the field's label. */
|
|
7
|
+
function Label(props) {
|
|
8
|
+
const field = useContext(FieldContext) ?? void 0;
|
|
9
|
+
const made = useMemo(() => createLabel({ field }), [field]);
|
|
10
|
+
return usePart(made.label, "label", props);
|
|
11
|
+
}
|
|
12
|
+
export { Label };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=label.js.map
|
package/src/label.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"label.js","names":[],"sources":["../../../../packages/react/src/label.tsx"],"sourcesContent":["import { createLabel } from \"@kirana-ui/core/label\"\nimport { useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\n/** A `<label>`. Inside a `<Field.Root>` it is the field's label. */\nexport function Label(props: PartComponentProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const made = useMemo(() => createLabel({ field }), [field])\n return usePart(made.label, \"label\", props)\n}\n"],"mappings":";;;;;;AASA,SAAgB,MAAM,OAAyC;CAC7D,MAAM,QAAQ,WAAW,YAAY,KAAK,KAAA;CAC1C,MAAM,OAAO,cAAc,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;CAC1D,OAAO,QAAQ,KAAK,OAAO,SAAS,KAAK;AAC3C"}
|
package/src/listbox.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
import { ListboxItemOptions, ListboxProps } from "@kirana-ui/core/listbox";
|
|
4
|
+
export type RootProps<Value> = Omit<ListboxProps<Value>, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
declare function Root<Value>({ value, defaultValue, onValueChange, multiple, disabled, loop, name, form, virtualized, id, ...rest }: RootProps<Value>): ReactElement;
|
|
8
|
+
export type ItemProps = PartComponentProps & ListboxItemOptions & {
|
|
9
|
+
value: unknown;
|
|
10
|
+
};
|
|
11
|
+
declare function Item({ value, disabled, label, index, ...props }: ItemProps): ReactElement;
|
|
12
|
+
export interface ItemIndicatorProps extends PartComponentProps {
|
|
13
|
+
keepMounted?: boolean;
|
|
14
|
+
}
|
|
15
|
+
declare function ItemIndicator({ keepMounted, ...props }: ItemIndicatorProps): ReactElement | null;
|
|
16
|
+
declare function Group({ id, ...props }: PartComponentProps & {
|
|
17
|
+
id?: string;
|
|
18
|
+
}): ReactElement;
|
|
19
|
+
declare function GroupLabel(props: PartComponentProps): ReactElement;
|
|
20
|
+
export declare const Listbox: {
|
|
21
|
+
Root: typeof Root;
|
|
22
|
+
Item: typeof Item;
|
|
23
|
+
ItemIndicator: typeof ItemIndicator;
|
|
24
|
+
Group: typeof Group;
|
|
25
|
+
GroupLabel: typeof GroupLabel;
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=listbox.d.ts.map
|
package/src/listbox.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useController, useOptions, usePart, useSignal } from "./runtime.js";
|
|
2
|
+
import { defined } from "@kirana-ui/core";
|
|
3
|
+
import { createContext, useContext, useId, useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { createListbox } from "@kirana-ui/core/listbox";
|
|
6
|
+
// src/listbox.tsx
|
|
7
|
+
const Context = createContext(null);
|
|
8
|
+
const ItemContext = createContext(void 0);
|
|
9
|
+
const GroupContext = createContext(null);
|
|
10
|
+
function useListbox(part) {
|
|
11
|
+
const controller = useContext(Context);
|
|
12
|
+
if (!controller) throw new Error(`<Listbox.${part}> must be inside <Listbox.Root>`);
|
|
13
|
+
return controller;
|
|
14
|
+
}
|
|
15
|
+
function Root({ value, defaultValue, onValueChange, multiple, disabled, loop, name, form, virtualized, id, ...rest }) {
|
|
16
|
+
const controller = useController(createListbox, {
|
|
17
|
+
value,
|
|
18
|
+
defaultValue,
|
|
19
|
+
onValueChange,
|
|
20
|
+
multiple,
|
|
21
|
+
disabled,
|
|
22
|
+
loop,
|
|
23
|
+
name,
|
|
24
|
+
form,
|
|
25
|
+
virtualized,
|
|
26
|
+
id
|
|
27
|
+
});
|
|
28
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
29
|
+
value: controller,
|
|
30
|
+
children: usePart(controller.root, "div", rest)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function Item({ value, disabled, label, index, ...props }) {
|
|
34
|
+
const controller = useListbox("Item");
|
|
35
|
+
const options = useOptions({
|
|
36
|
+
disabled,
|
|
37
|
+
label,
|
|
38
|
+
index
|
|
39
|
+
});
|
|
40
|
+
const part = useMemo(() => controller.item(value, () => defined(options.get())), [
|
|
41
|
+
controller,
|
|
42
|
+
value,
|
|
43
|
+
options
|
|
44
|
+
]);
|
|
45
|
+
return /* @__PURE__ */ jsx(ItemContext.Provider, {
|
|
46
|
+
value,
|
|
47
|
+
children: usePart(part, "div", props)
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const PartElement = ({ part, tag, ...props }) => usePart(part, tag, props);
|
|
51
|
+
function ItemIndicator({ keepMounted, ...props }) {
|
|
52
|
+
const controller = useListbox("ItemIndicator");
|
|
53
|
+
const value = useContext(ItemContext);
|
|
54
|
+
const selected = useSignal(controller.selected(value));
|
|
55
|
+
const part = useMemo(() => controller.indicator(value), [controller, value]);
|
|
56
|
+
return selected || keepMounted ? /* @__PURE__ */ jsx(PartElement, {
|
|
57
|
+
part,
|
|
58
|
+
tag: "span",
|
|
59
|
+
...props
|
|
60
|
+
}) : null;
|
|
61
|
+
}
|
|
62
|
+
function Group({ id, ...props }) {
|
|
63
|
+
const controller = useListbox("Group");
|
|
64
|
+
const generated = useId();
|
|
65
|
+
const group = useMemo(() => controller.group(id ?? generated), [
|
|
66
|
+
controller,
|
|
67
|
+
id,
|
|
68
|
+
generated
|
|
69
|
+
]);
|
|
70
|
+
return /* @__PURE__ */ jsx(GroupContext.Provider, {
|
|
71
|
+
value: group,
|
|
72
|
+
children: usePart(group.root, "div", props)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function GroupLabel(props) {
|
|
76
|
+
const group = useContext(GroupContext);
|
|
77
|
+
if (!group) throw new Error("<Listbox.GroupLabel> must be inside <Listbox.Group>");
|
|
78
|
+
return usePart(group.label, "div", props);
|
|
79
|
+
}
|
|
80
|
+
const Listbox = {
|
|
81
|
+
Root,
|
|
82
|
+
Item,
|
|
83
|
+
ItemIndicator,
|
|
84
|
+
Group,
|
|
85
|
+
GroupLabel
|
|
86
|
+
};
|
|
87
|
+
export { Listbox };
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=listbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listbox.js","names":[],"sources":["../../../../packages/react/src/listbox.tsx"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { Part } from \"@kirana-ui/core\"\nimport { createListbox } from \"@kirana-ui/core/listbox\"\nimport type {\n Listbox as Controller,\n ListboxGroup,\n ListboxItemOptions,\n ListboxProps,\n} from \"@kirana-ui/core/listbox\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { useController, useOptions, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nconst Context = createContext<Controller | null>(null)\nconst ItemContext = createContext<unknown>(undefined)\nconst GroupContext = createContext<ListboxGroup | null>(null)\n\nfunction useListbox(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Listbox.${part}> must be inside <Listbox.Root>`)\n return controller\n}\n\nexport type RootProps<Value> = Omit<ListboxProps<Value>, \"id\"> & {\n id?: string\n} & PartComponentProps\n\nfunction Root<Value>({\n value,\n defaultValue,\n onValueChange,\n multiple,\n disabled,\n loop,\n name,\n form,\n virtualized,\n id,\n ...rest\n}: RootProps<Value>): ReactElement {\n const controller = useController<ListboxProps<Value>, Controller<Value>>(createListbox, {\n value: value as readonly Value[] | undefined,\n defaultValue: defaultValue as readonly Value[] | undefined,\n onValueChange,\n multiple,\n disabled,\n loop,\n name,\n form,\n virtualized,\n id,\n }) as unknown as Controller\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type ItemProps = PartComponentProps & ListboxItemOptions & { value: unknown }\n\nfunction Item({ value, disabled, label, index, ...props }: ItemProps): ReactElement {\n const controller = useListbox(\"Item\")\n const options = useOptions({ disabled, label, index })\n const part = useMemo(\n () => controller.item(value, () => defined(options.get())),\n [controller, value, options]\n )\n return <ItemContext.Provider value={value}>{usePart(part, \"div\", props)}</ItemContext.Provider>\n}\n\nconst PartElement = ({ part, tag, ...props }: PartComponentProps & { part: Part; tag: string }) =>\n usePart(part, tag, props)\n\nexport interface ItemIndicatorProps extends PartComponentProps {\n keepMounted?: boolean\n}\n\nfunction ItemIndicator({ keepMounted, ...props }: ItemIndicatorProps): ReactElement | null {\n const controller = useListbox(\"ItemIndicator\")\n const value = useContext(ItemContext)\n const selected = useSignal(controller.selected(value))\n const part = useMemo(() => controller.indicator(value), [controller, value])\n return selected || keepMounted ? <PartElement part={part} tag=\"span\" {...props} /> : null\n}\n\nfunction Group({ id, ...props }: PartComponentProps & { id?: string }): ReactElement {\n const controller = useListbox(\"Group\")\n const generated = useId()\n const group = useMemo(() => controller.group(id ?? generated), [controller, id, generated])\n return (\n <GroupContext.Provider value={group}>{usePart(group.root, \"div\", props)}</GroupContext.Provider>\n )\n}\n\nfunction GroupLabel(props: PartComponentProps): ReactElement {\n const group = useContext(GroupContext)\n if (!group) throw new Error(\"<Listbox.GroupLabel> must be inside <Listbox.Group>\")\n return usePart(group.label, \"div\", props)\n}\n\nexport const Listbox = { Root, Item, ItemIndicator, Group, GroupLabel }\n"],"mappings":";;;;;;AAeA,MAAM,UAAU,cAAiC,IAAI;AACrD,MAAM,cAAc,cAAuB,KAAA,CAAS;AACpD,MAAM,eAAe,cAAmC,IAAI;AAE5D,SAAS,WAAW,MAA0B;CAC5C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,gCAAgC;CAClF,OAAO;AACT;AAMA,SAAS,KAAY,EACnB,OACA,cACA,eACA,UACA,UACA,MACA,MACA,MACA,aACA,IACA,GAAG,QAC8B;CACjC,MAAM,aAAa,cAAsD,eAAe;EAC/E;EACO;EACd;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,SAAS,KAAK,EAAE,OAAO,UAAU,OAAO,OAAO,GAAG,SAAkC;CAClF,MAAM,aAAa,WAAW,MAAM;CACpC,MAAM,UAAU,WAAW;EAAE;EAAU;EAAO;CAAM,CAAC;CACrD,MAAM,OAAO,cACL,WAAW,KAAK,aAAa,QAAQ,QAAQ,IAAI,CAAC,CAAC,GACzD;EAAC;EAAY;EAAO;CAAO,CAC7B;CACA,OAAO,oBAAC,YAAY,UAAb;EAA6B;EAAQ,UAAA,QAAQ,MAAM,OAAO,KAAK;CAAwB,CAAA;AAChG;AAEA,MAAM,eAAe,EAAE,MAAM,KAAK,GAAG,YACnC,QAAQ,MAAM,KAAK,KAAK;AAM1B,SAAS,cAAc,EAAE,aAAa,GAAG,SAAkD;CACzF,MAAM,aAAa,WAAW,eAAe;CAC7C,MAAM,QAAQ,WAAW,WAAW;CACpC,MAAM,WAAW,UAAU,WAAW,SAAS,KAAK,CAAC;CACrD,MAAM,OAAO,cAAc,WAAW,UAAU,KAAK,GAAG,CAAC,YAAY,KAAK,CAAC;CAC3E,OAAO,YAAY,cAAc,oBAAC,aAAD;EAAmB;EAAM,KAAI;EAAO,GAAI;CAAQ,CAAA,IAAI;AACvF;AAEA,SAAS,MAAM,EAAE,IAAI,GAAG,SAA6D;CACnF,MAAM,aAAa,WAAW,OAAO;CACrC,MAAM,YAAY,MAAM;CACxB,MAAM,QAAQ,cAAc,WAAW,MAAM,MAAM,SAAS,GAAG;EAAC;EAAY;EAAI;CAAS,CAAC;CAC1F,OACE,oBAAC,aAAa,UAAd;EAAuB,OAAO;EAAQ,UAAA,QAAQ,MAAM,MAAM,OAAO,KAAK;CAAyB,CAAA;AAEnG;AAEA,SAAS,WAAW,OAAyC;CAC3D,MAAM,QAAQ,WAAW,YAAY;CACrC,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,qDAAqD;CACjF,OAAO,QAAQ,MAAM,OAAO,OAAO,KAAK;AAC1C;AAEA,MAAa,UAAU;CAAE;CAAM;CAAM;CAAe;CAAO;AAAW"}
|