@kirana-ui/react 0.1.1 → 0.2.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/llms.txt +1601 -223
- package/package.json +14 -2
- package/skills/kirana-ui-primitives/SKILL.md +142 -0
- package/src/accordion.d.ts +26 -15
- package/src/accordion.js +11 -10
- package/src/accordion.js.map +1 -1
- package/src/agent.d.ts +1 -0
- package/src/agent.js +1 -0
- package/src/alert-dialog.d.ts +3 -2
- package/src/autocomplete.d.ts +3 -2
- package/src/autosize.d.ts +5 -2
- package/src/autosize.js +2 -2
- package/src/autosize.js.map +1 -1
- package/src/avatar.d.ts +12 -8
- package/src/avatar.js +18 -9
- package/src/avatar.js.map +1 -1
- package/src/button.d.ts +4 -2
- package/src/button.js +3 -3
- package/src/button.js.map +1 -1
- package/src/calendar.d.ts +49 -28
- package/src/calendar.js +7 -3
- package/src/calendar.js.map +1 -1
- package/src/carousel.d.ts +25 -15
- package/src/carousel.js +3 -3
- package/src/carousel.js.map +1 -1
- package/src/checkbox.d.ts +10 -7
- package/src/checkbox.js +18 -12
- package/src/checkbox.js.map +1 -1
- package/src/collapsible.d.ts +12 -8
- package/src/collapsible.js +8 -7
- package/src/collapsible.js.map +1 -1
- package/src/combobox.d.ts +88 -60
- package/src/combobox.js +44 -31
- package/src/combobox.js.map +1 -1
- package/src/command.d.ts +30 -21
- package/src/command.js +14 -7
- package/src/command.js.map +1 -1
- package/src/context-menu.d.ts +3 -2
- package/src/date-field.d.ts +25 -13
- package/src/date-field.js +7 -3
- package/src/date-field.js.map +1 -1
- package/src/date-picker.d.ts +31 -40
- package/src/date-picker.js +3 -3
- package/src/date-picker.js.map +1 -1
- package/src/dialog.d.ts +45 -35
- package/src/dialog.js +12 -8
- package/src/dialog.js.map +1 -1
- package/src/direction.d.ts +1 -0
- package/src/direction.js.map +1 -1
- package/src/drawer.d.ts +3 -2
- package/src/element.d.ts +12 -0
- package/src/element.js +20 -0
- package/src/element.js.map +1 -0
- package/src/field.d.ts +24 -16
- package/src/field.js +9 -7
- package/src/field.js.map +1 -1
- package/src/fieldset.d.ts +10 -5
- package/src/fieldset.js +4 -5
- package/src/fieldset.js.map +1 -1
- package/src/form.d.ts +5 -2
- package/src/form.js +6 -6
- package/src/form.js.map +1 -1
- package/src/hover-card.d.ts +16 -10
- package/src/hover-card.js +1 -1
- package/src/hover-card.js.map +1 -1
- package/src/hover-popup.d.ts +24 -14
- package/src/hover-popup.js +5 -13
- package/src/hover-popup.js.map +1 -1
- package/src/index.d.ts +13 -3
- package/src/input.d.ts +4 -2
- package/src/input.js +3 -3
- package/src/input.js.map +1 -1
- package/src/label.d.ts +4 -1
- package/src/label.js +3 -3
- package/src/label.js.map +1 -1
- package/src/listbox.d.ts +23 -15
- package/src/listbox.js +4 -5
- package/src/listbox.js.map +1 -1
- package/src/menu.d.ts +83 -65
- package/src/menu.js +10 -18
- package/src/menu.js.map +1 -1
- package/src/menubar.d.ts +5 -3
- package/src/menubar.js +3 -3
- package/src/menubar.js.map +1 -1
- package/src/message-scroller.d.ts +15 -9
- package/src/message-scroller.js +3 -3
- package/src/message-scroller.js.map +1 -1
- package/src/meter.d.ts +18 -9
- package/src/meter.js +1 -1
- package/src/meter.js.map +1 -1
- package/src/navigation-menu.d.ts +50 -40
- package/src/navigation-menu.js +15 -24
- package/src/navigation-menu.js.map +1 -1
- package/src/number-field.d.ts +19 -12
- package/src/number-field.js +6 -10
- package/src/number-field.js.map +1 -1
- package/src/otp.d.ts +24 -15
- package/src/otp.js +7 -13
- package/src/otp.js.map +1 -1
- package/src/pagination.d.ts +26 -16
- package/src/pagination.js +3 -3
- package/src/pagination.js.map +1 -1
- package/src/popover.d.ts +30 -21
- package/src/popover.js +9 -13
- package/src/popover.js.map +1 -1
- package/src/progress.d.ts +18 -9
- package/src/progress.js +1 -1
- package/src/progress.js.map +1 -1
- package/src/qr-code.d.ts +12 -7
- package/src/qr-code.js +3 -3
- package/src/qr-code.js.map +1 -1
- package/src/radio-group.d.ts +17 -11
- package/src/radio-group.js +16 -19
- package/src/radio-group.js.map +1 -1
- package/src/resizable.d.ts +13 -8
- package/src/resizable.js +3 -3
- package/src/resizable.js.map +1 -1
- package/src/runtime.d.ts +89 -15
- package/src/runtime.js +112 -19
- package/src/runtime.js.map +1 -1
- package/src/scroll-area.d.ts +26 -15
- package/src/scroll-area.js +9 -6
- package/src/scroll-area.js.map +1 -1
- package/src/select.d.ts +65 -45
- package/src/select.js +40 -35
- package/src/select.js.map +1 -1
- package/src/separator.d.ts +4 -2
- package/src/separator.js +3 -3
- package/src/separator.js.map +1 -1
- package/src/slider.d.ts +35 -20
- package/src/slider.js +17 -18
- package/src/slider.js.map +1 -1
- package/src/switch.d.ts +10 -6
- package/src/switch.js +11 -9
- package/src/switch.js.map +1 -1
- package/src/tabs.d.ts +22 -14
- package/src/tabs.js +5 -6
- package/src/tabs.js.map +1 -1
- package/src/testing.d.ts +1 -0
- package/src/testing.js +1 -0
- package/src/toast.d.ts +59 -23
- package/src/toast.js +59 -13
- package/src/toast.js.map +1 -1
- package/src/toggle-group.d.ts +5 -2
- package/src/toggle-group.js +3 -3
- package/src/toggle-group.js.map +1 -1
- package/src/toggle.d.ts +4 -2
- package/src/toggle.js +3 -3
- package/src/toggle.js.map +1 -1
- package/src/toolbar.d.ts +26 -11
- package/src/toolbar.js +23 -13
- package/src/toolbar.js.map +1 -1
- package/src/tooltip.d.ts +16 -10
- package/src/tooltip.js +1 -1
- package/src/tooltip.js.map +1 -1
- package/src/use-render.d.ts +38 -0
- package/src/use-render.js +50 -0
- package/src/use-render.js.map +1 -0
- package/src/value-bar.d.ts +19 -11
- package/src/value-bar.js +8 -5
- package/src/value-bar.js.map +1 -1
package/src/fieldset.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { Fieldset as Fieldset$1, FieldsetProps } from "@kirana-ui/core/fieldset";
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["fieldset"];
|
|
4
7
|
/** The fieldset a field is in, if it is in one. */
|
|
5
8
|
export declare const FieldsetContext: import("react").Context<Fieldset$1 | null>;
|
|
6
|
-
|
|
9
|
+
export type RootProps = PartComponentProps<"fieldset", StateOf<Parts["root"]>, Omit<FieldsetProps, "id"> & {
|
|
7
10
|
id?: string;
|
|
8
|
-
}
|
|
9
|
-
declare
|
|
11
|
+
}>;
|
|
12
|
+
declare function Root({ disabled, id, ...rest }: RootProps): ReactElement;
|
|
13
|
+
export type LegendProps = PartComponentProps<"div", StateOf<Parts["legend"]>>;
|
|
14
|
+
declare const Legend: (props: LegendProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
10
15
|
export declare const Fieldset: {
|
|
11
|
-
Root: typeof Root;
|
|
12
|
-
Legend: typeof Legend;
|
|
16
|
+
readonly Root: typeof Root;
|
|
17
|
+
readonly Legend: typeof Legend;
|
|
13
18
|
};
|
|
14
19
|
export {};
|
|
15
20
|
//# sourceMappingURL=fieldset.d.ts.map
|
package/src/fieldset.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useController, usePart } from "./runtime.js";
|
|
1
|
+
import { parts, useController, usePart } from "./runtime.js";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { createFieldset } from "@kirana-ui/core/fieldset";
|
|
@@ -17,15 +17,14 @@ function Root({ disabled, id, ...rest }) {
|
|
|
17
17
|
});
|
|
18
18
|
return /* @__PURE__ */ jsx(FieldsetContext.Provider, {
|
|
19
19
|
value: controller,
|
|
20
|
-
children:
|
|
20
|
+
children: usePart(controller.root, "fieldset", rest)
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
const RootElement = (props) => usePart(useFieldset("Root").root, "fieldset", props);
|
|
24
23
|
const Legend = (props) => usePart(useFieldset("Legend").legend, "div", props);
|
|
25
|
-
const Fieldset = {
|
|
24
|
+
const Fieldset = /* @__PURE__ */ parts("Fieldset", {
|
|
26
25
|
Root,
|
|
27
26
|
Legend
|
|
28
|
-
};
|
|
27
|
+
});
|
|
29
28
|
export { Fieldset, FieldsetContext };
|
|
30
29
|
|
|
31
30
|
//# sourceMappingURL=fieldset.js.map
|
package/src/fieldset.js.map
CHANGED
|
@@ -1 +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\
|
|
1
|
+
{"version":3,"file":"fieldset.js","names":[],"sources":["../../../../packages/react/src/fieldset.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createFieldset } from \"@kirana-ui/core/fieldset\"\nimport type { Fieldset as Controller, FieldsetProps } from \"@kirana-ui/core/fieldset\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { parts, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"fieldset\"]\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\nexport type RootProps = PartComponentProps<\n \"fieldset\",\n StateOf<Parts[\"root\"]>,\n Omit<FieldsetProps, \"id\"> & { id?: string }\n>\n\nfunction Root({ disabled, id, ...rest }: RootProps): ReactElement {\n const controller = useController(createFieldset, { disabled, id })\n return (\n <FieldsetContext.Provider value={controller}>\n {usePart(controller.root, \"fieldset\", rest)}\n </FieldsetContext.Provider>\n )\n}\n\nexport type LegendProps = PartComponentProps<\"div\", StateOf<Parts[\"legend\"]>>\n\nconst Legend = (props: LegendProps) => usePart(useFieldset(\"Legend\").legend, \"div\", props)\n\nexport const Fieldset = /* @__PURE__ */ parts(\"Fieldset\", { Root, Legend })\n"],"mappings":";;;;;;AAaA,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;AAQA,SAAS,KAAK,EAAE,UAAU,IAAI,GAAG,QAAiC;CAChE,MAAM,aAAa,cAAc,gBAAgB;EAAE;EAAU;CAAG,CAAC;CACjE,OACE,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;EAC9B,UAAA,QAAQ,WAAW,MAAM,YAAY,IAAI;CAClB,CAAA;AAE9B;AAIA,MAAM,UAAU,UAAuB,QAAQ,YAAY,QAAQ,CAAC,CAAC,QAAQ,OAAO,KAAK;AAEzF,MAAa,WAA2B,sBAAM,YAAY;CAAE;CAAM;AAAO,CAAC"}
|
package/src/form.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
|
-
import { Form as Form$1, FormProps } from "@kirana-ui/core/form";
|
|
4
|
+
import { Form as Form$1, FormProps as FormProps$1 } from "@kirana-ui/core/form";
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
4
6
|
/** The form a field is in, if it is in one. */
|
|
5
7
|
export declare const FormContext: import("react").Context<Form$1 | null>;
|
|
8
|
+
export type FormProps = PartComponentProps<"form", StateOf<Vocabulary["form"]["root"]>, FormProps$1>;
|
|
6
9
|
/** A `<form>` whose fields say what is wrong; `onFormSubmit` takes the values once all are valid. */
|
|
7
|
-
export declare
|
|
10
|
+
export declare const Form: ({ errors, onClearErrors, onFormSubmit, validationMode, ...rest }: FormProps) => ReactElement;
|
|
8
11
|
//# sourceMappingURL=form.d.ts.map
|
package/src/form.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PartElement, component, useController } from "./runtime.js";
|
|
2
2
|
import { createContext } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { createForm } from "@kirana-ui/core/form";
|
|
@@ -6,7 +6,7 @@ import { createForm } from "@kirana-ui/core/form";
|
|
|
6
6
|
/** The form a field is in, if it is in one. */
|
|
7
7
|
const FormContext = createContext(null);
|
|
8
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 }) {
|
|
9
|
+
const Form = /* @__PURE__ */ component("Form", function Form({ errors, onClearErrors, onFormSubmit, validationMode, ...rest }) {
|
|
10
10
|
const controller = useController(createForm, {
|
|
11
11
|
errors,
|
|
12
12
|
onClearErrors,
|
|
@@ -15,13 +15,13 @@ function Form({ errors, onClearErrors, onFormSubmit, validationMode, ...rest })
|
|
|
15
15
|
});
|
|
16
16
|
return /* @__PURE__ */ jsx(FormContext.Provider, {
|
|
17
17
|
value: controller,
|
|
18
|
-
children: /* @__PURE__ */ jsx(
|
|
19
|
-
|
|
18
|
+
children: /* @__PURE__ */ jsx(PartElement, {
|
|
19
|
+
of: controller.root,
|
|
20
|
+
tag: "form",
|
|
20
21
|
...rest
|
|
21
22
|
})
|
|
22
23
|
});
|
|
23
|
-
}
|
|
24
|
-
const Element = ({ part, ...props }) => usePart(part.root, "form", props);
|
|
24
|
+
});
|
|
25
25
|
export { Form, FormContext };
|
|
26
26
|
|
|
27
27
|
//# sourceMappingURL=form.js.map
|
package/src/form.js.map
CHANGED
|
@@ -1 +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 {
|
|
1
|
+
{"version":3,"file":"form.js","names":[],"sources":["../../../../packages/react/src/form.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createForm } from \"@kirana-ui/core/form\"\nimport type { Form as Controller, FormProps as CoreProps } from \"@kirana-ui/core/form\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { PartElement, component, useController } 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\nexport type FormProps = PartComponentProps<\"form\", StateOf<Vocabulary[\"form\"][\"root\"]>, CoreProps>\n\n/** A `<form>` whose fields say what is wrong; `onFormSubmit` takes the values once all are valid. */\nexport const Form = /* @__PURE__ */ component(\n \"Form\",\n function Form({\n errors,\n onClearErrors,\n onFormSubmit,\n validationMode,\n ...rest\n }: FormProps): ReactElement {\n const controller = useController(createForm, {\n errors,\n onClearErrors,\n onFormSubmit,\n validationMode,\n })\n return (\n <FormContext.Provider value={controller}>\n <PartElement of={controller.root} tag=\"form\" {...rest} />\n </FormContext.Provider>\n )\n }\n)\n"],"mappings":";;;;;;AAWA,MAAa,cAAc,cAAiC,IAAI;;AAKhE,MAAa,OAAuB,0BAClC,QACA,SAAS,KAAK,EACZ,QACA,eACA,cACA,gBACA,GAAG,QACuB;CAC1B,MAAM,aAAa,cAAc,YAAY;EAC3C;EACA;EACA;EACA;CACF,CAAC;CACD,OACE,oBAAC,YAAY,UAAb;EAAsB,OAAO;EAC3B,UAAA,oBAAC,aAAD;GAAa,IAAI,WAAW;GAAM,KAAI;GAAO,GAAI;EAAO,CAAA;CACpC,CAAA;AAE1B,CACF"}
|
package/src/hover-card.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PartComponentProps } from "./runtime.js";
|
|
1
|
+
import { RootProps, TriggerOptions } from "./hover-popup.js";
|
|
2
|
+
import { PartComponentProps, PortalProps, PositionerOptions } from "./runtime.js";
|
|
3
|
+
import { StateOf } from "@kirana-ui/core";
|
|
4
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
5
|
+
type Parts = Vocabulary["hoverCard"];
|
|
6
|
+
export type TriggerProps = PartComponentProps<"a", StateOf<Parts["trigger"]>, TriggerOptions>;
|
|
7
|
+
export type PositionerProps = PartComponentProps<"div", StateOf<Parts["positioner"]>, PositionerOptions>;
|
|
8
|
+
export type PopupProps = PartComponentProps<"div", StateOf<Parts["popup"]>>;
|
|
9
|
+
export type ArrowProps = PartComponentProps<"div", StateOf<Parts["arrow"]>>;
|
|
3
10
|
export declare const HoverCard: {
|
|
4
|
-
Root: (
|
|
5
|
-
Trigger: (
|
|
6
|
-
Portal: (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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>>;
|
|
11
|
+
Root: (props: RootProps) => import("react").ReactElement;
|
|
12
|
+
Trigger: (props: TriggerProps) => import("react").ReactElement;
|
|
13
|
+
Portal: (props: PortalProps) => import("react").ReactElement | null;
|
|
14
|
+
Positioner: (props: PositionerProps) => import("react").ReactElement;
|
|
15
|
+
Popup: (props: PopupProps) => import("react").ReactElement;
|
|
16
|
+
Arrow: (props: ArrowProps) => import("react").ReactElement;
|
|
12
17
|
};
|
|
18
|
+
export type { PortalProps, RootProps };
|
|
13
19
|
//# sourceMappingURL=hover-card.d.ts.map
|
package/src/hover-card.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hoverPopup } from "./hover-popup.js";
|
|
2
2
|
import { createHoverCard } from "@kirana-ui/core/hover-card";
|
|
3
3
|
// src/hover-card.tsx
|
|
4
|
-
const HoverCard = hoverPopup("HoverCard", createHoverCard, "a");
|
|
4
|
+
const HoverCard = /* @__PURE__ */ hoverPopup("HoverCard", createHoverCard, "a");
|
|
5
5
|
export { HoverCard };
|
|
6
6
|
|
|
7
7
|
//# sourceMappingURL=hover-card.js.map
|
package/src/hover-card.js.map
CHANGED
|
@@ -1 +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":";;;
|
|
1
|
+
{"version":3,"file":"hover-card.js","names":[],"sources":["../../../../packages/react/src/hover-card.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createHoverCard } from \"@kirana-ui/core/hover-card\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\n\nimport { hoverPopup } from \"./hover-popup.tsx\"\nimport type { TriggerOptions } from \"./hover-popup.tsx\"\nimport type { PartComponentProps, PositionerOptions } from \"./runtime.tsx\"\n\nexport type { PortalProps, RootProps } from \"./hover-popup.tsx\"\n\ntype Parts = Vocabulary[\"hoverCard\"]\n\nexport type TriggerProps = PartComponentProps<\"a\", StateOf<Parts[\"trigger\"]>, TriggerOptions>\nexport type PositionerProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"positioner\"]>,\n PositionerOptions\n>\nexport type PopupProps = PartComponentProps<\"div\", StateOf<Parts[\"popup\"]>>\nexport type ArrowProps = PartComponentProps<\"div\", StateOf<Parts[\"arrow\"]>>\n\nexport const HoverCard = /* @__PURE__ */ hoverPopup<{\n Trigger: TriggerProps\n Positioner: PositionerProps\n Popup: PopupProps\n Arrow: ArrowProps\n}>(\"HoverCard\", createHoverCard, \"a\")\n"],"mappings":";;;AAqBA,MAAa,YAA4B,2BAKtC,aAAa,iBAAiB,GAAG"}
|
package/src/hover-popup.d.ts
CHANGED
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
import { PartComponentProps } from "./runtime.js";
|
|
2
|
-
import {
|
|
1
|
+
import { PartComponentProps, PartTag, PortalProps, PositionerOptions, PositionerProps } from "./runtime.js";
|
|
2
|
+
import { PartState, ReadonlySignal } from "@kirana-ui/core";
|
|
3
3
|
import { ReactElement, ReactNode } from "react";
|
|
4
4
|
import { HoverPopup, HoverPopupProps } from "@kirana-ui/core/tooltip";
|
|
5
5
|
export type RootProps = Omit<HoverPopupProps, "id"> & {
|
|
6
6
|
id?: string;
|
|
7
7
|
children?: ReactNode;
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
export
|
|
9
|
+
/** What a trigger takes of its own: `delay` and `closeDelay` here come before the root's. */
|
|
10
|
+
export interface TriggerOptions {
|
|
11
|
+
/** How long the pointer rests on this trigger before the popup opens, in milliseconds. */
|
|
11
12
|
delay?: number;
|
|
13
|
+
/** How long after the pointer leaves this trigger's popup closes, in milliseconds. */
|
|
12
14
|
closeDelay?: number;
|
|
13
|
-
}
|
|
15
|
+
}
|
|
16
|
+
/** A trigger's props. Its element is its component's: a tooltip's `button`, a hover card's `a`. */
|
|
17
|
+
export type TriggerProps<Tag extends PartTag = "button", State = PartState> = PartComponentProps<Tag, State, TriggerOptions>;
|
|
18
|
+
/** The props of the parts that draw an element, as their component's entry types them. */
|
|
19
|
+
export interface HoverPartProps {
|
|
20
|
+
Trigger: TriggerOptions;
|
|
21
|
+
Positioner: PositionerOptions;
|
|
22
|
+
Popup: object;
|
|
23
|
+
Arrow: object;
|
|
24
|
+
}
|
|
14
25
|
/** 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:
|
|
16
|
-
Root: (
|
|
17
|
-
Trigger: (
|
|
18
|
-
Portal: (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Popup: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
23
|
-
Arrow: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
26
|
+
export declare function hoverPopup<Props extends HoverPartProps>(name: string, create: (props: ReadonlySignal<HoverPopupProps>) => HoverPopup, triggerTag: PartTag): {
|
|
27
|
+
Root: (props: RootProps) => ReactElement;
|
|
28
|
+
Trigger: (props: Props["Trigger"]) => ReactElement;
|
|
29
|
+
Portal: (props: PortalProps) => ReactElement | null;
|
|
30
|
+
Positioner: (props: Props["Positioner"]) => ReactElement;
|
|
31
|
+
Popup: (props: Props["Popup"]) => ReactElement;
|
|
32
|
+
Arrow: (props: Props["Arrow"]) => ReactElement;
|
|
24
33
|
};
|
|
34
|
+
export type { PortalProps, PositionerProps };
|
|
25
35
|
//# sourceMappingURL=hover-popup.d.ts.map
|
package/src/hover-popup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Portal, useController, usePart, useSignal } from "./runtime.js";
|
|
1
|
+
import { Portal, parts, useController, usePart, usePositioning, useSignal } from "./runtime.js";
|
|
2
2
|
import { defined } from "@kirana-ui/core";
|
|
3
3
|
import { createContext, useContext } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -21,18 +21,10 @@ function hoverPopup(name, create, triggerTag) {
|
|
|
21
21
|
function Portal$1({ children }) {
|
|
22
22
|
return useSignal(use("Portal").mounted) ? /* @__PURE__ */ jsx(Portal, { children }) : null;
|
|
23
23
|
}
|
|
24
|
-
function Positioner(
|
|
24
|
+
function Positioner(props) {
|
|
25
25
|
const controller = use("Positioner");
|
|
26
|
-
controller.positioning
|
|
27
|
-
side,
|
|
28
|
-
align,
|
|
29
|
-
sideOffset,
|
|
30
|
-
alignOffset,
|
|
31
|
-
collisionPadding
|
|
32
|
-
}));
|
|
33
|
-
return usePart(controller.positioner, "div", props);
|
|
26
|
+
return usePart(controller.positioner, "div", usePositioning(controller.positioning, props));
|
|
34
27
|
}
|
|
35
|
-
/** `delay` and `closeDelay` here come before the root's. */
|
|
36
28
|
function Trigger({ delay, closeDelay, ...props }) {
|
|
37
29
|
const controller = use("Trigger");
|
|
38
30
|
controller.timing.set(defined({
|
|
@@ -43,14 +35,14 @@ function hoverPopup(name, create, triggerTag) {
|
|
|
43
35
|
}
|
|
44
36
|
const Popup = (props) => usePart(use("Popup").popup, "div", props);
|
|
45
37
|
const Arrow = (props) => usePart(use("Arrow").arrow, "div", props);
|
|
46
|
-
return {
|
|
38
|
+
return parts(name, {
|
|
47
39
|
Root,
|
|
48
40
|
Trigger,
|
|
49
41
|
Portal: Portal$1,
|
|
50
42
|
Positioner,
|
|
51
43
|
Popup,
|
|
52
44
|
Arrow
|
|
53
|
-
};
|
|
45
|
+
});
|
|
54
46
|
}
|
|
55
47
|
export { hoverPopup };
|
|
56
48
|
|
package/src/hover-popup.js.map
CHANGED
|
@@ -1 +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 {
|
|
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 { PartState, 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 {\n Portal as BodyPortal,\n parts,\n useController,\n usePart,\n usePositioning,\n useSignal,\n} from \"./runtime.tsx\"\nimport type {\n PartComponentProps,\n PartTag,\n PortalProps,\n PositionerOptions,\n PositionerProps,\n} from \"./runtime.tsx\"\n\nexport type { PortalProps, PositionerProps }\n\nexport type RootProps = Omit<HoverPopupProps, \"id\"> & { id?: string; children?: ReactNode }\n\n/** What a trigger takes of its own: `delay` and `closeDelay` here come before the root's. */\nexport interface TriggerOptions {\n /** How long the pointer rests on this trigger before the popup opens, in milliseconds. */\n delay?: number\n /** How long after the pointer leaves this trigger's popup closes, in milliseconds. */\n closeDelay?: number\n}\n\n/** A trigger's props. Its element is its component's: a tooltip's `button`, a hover card's `a`. */\nexport type TriggerProps<Tag extends PartTag = \"button\", State = PartState> = PartComponentProps<\n Tag,\n State,\n TriggerOptions\n>\n\n/** The props of the parts that draw an element, as their component's entry types them. */\nexport interface HoverPartProps {\n Trigger: TriggerOptions\n Positioner: PositionerOptions\n Popup: object\n Arrow: object\n}\n\n/** The parts of a popup the pointer opens: a tooltip's, a hover card's. */\nexport function hoverPopup<Props extends HoverPartProps>(\n name: string,\n create: (props: ReadonlySignal<HoverPopupProps>) => HoverPopup,\n triggerTag: PartTag\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 }: PortalProps): ReactElement | null {\n const mounted = useSignal(use(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n }\n\n function Positioner(props: PositionerProps): ReactElement {\n const controller = use(\"Positioner\")\n return usePart(controller.positioner, \"div\", usePositioning(controller.positioning, props))\n }\n\n function Trigger({ delay, closeDelay, ...props }: TriggerProps<\"div\">): ReactElement {\n const controller = use(\"Trigger\")\n controller.timing.set(defined({ delay, closeDelay }))\n // Typed here as any part's: the entry says which element it is.\n return usePart(controller.trigger, triggerTag as \"div\", 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 parts(name, { Root, Trigger, Portal, Positioner, Popup, Arrow }) as unknown as {\n Root: (props: RootProps) => ReactElement\n Trigger: (props: Props[\"Trigger\"]) => ReactElement\n Portal: (props: PortalProps) => ReactElement | null\n Positioner: (props: Props[\"Positioner\"]) => ReactElement\n Popup: (props: Props[\"Popup\"]) => ReactElement\n Arrow: (props: Props[\"Arrow\"]) => ReactElement\n }\n}\n"],"mappings":";;;;;;AAkDA,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,YAA8C;EAE9D,OADgB,UAAU,IAAI,QAAQ,CAAC,CAAC,OAC3B,IAAI,oBAACC,QAAD,EAAa,SAAqB,CAAA,IAAI;CACzD;CAEA,SAAS,WAAW,OAAsC;EACxD,MAAM,aAAa,IAAI,YAAY;EACnC,OAAO,QAAQ,WAAW,YAAY,OAAO,eAAe,WAAW,aAAa,KAAK,CAAC;CAC5F;CAEA,SAAS,QAAQ,EAAE,OAAO,YAAY,GAAG,SAA4C;EACnF,MAAM,aAAa,IAAI,SAAS;EAChC,WAAW,OAAO,IAAI,QAAQ;GAAE;GAAO;EAAW,CAAC,CAAC;EAEpD,OAAO,QAAQ,WAAW,SAAS,YAAqB,KAAK;CAC/D;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,MAAM,MAAM;EAAE;EAAM;EAAS,QAAA;EAAQ;EAAY;EAAO;CAAM,CAAC;AAQxE"}
|
package/src/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ import { Calendar } from "./calendar.js";
|
|
|
22
22
|
import { QrCode } from "./qr-code.js";
|
|
23
23
|
import { Autosize } from "./autosize.js";
|
|
24
24
|
import { Carousel } from "./carousel.js";
|
|
25
|
-
import { Toast, createToaster } from "./toast.js";
|
|
25
|
+
import { Toast, ToastActionOptions, ToastContent, ToastOptions, ToastRecord, ToastState, Toaster, ToasterOptions, createToaster } from "./toast.js";
|
|
26
26
|
import { Resizable } from "./resizable.js";
|
|
27
27
|
import { Popover } from "./popover.js";
|
|
28
28
|
import { RadioGroup } from "./radio-group.js";
|
|
@@ -30,7 +30,7 @@ import { Select } from "./select.js";
|
|
|
30
30
|
import { Switch } from "./switch.js";
|
|
31
31
|
import { Tabs } from "./tabs.js";
|
|
32
32
|
import { Tooltip } from "./tooltip.js";
|
|
33
|
-
import { PartComponentProps, PortalProvider, PortalProviderProps, RenderProp } from "./runtime.js";
|
|
33
|
+
import { PartComponentProps, PartEvent, PortalProvider, PortalProviderProps, RenderProp } from "./runtime.js";
|
|
34
34
|
import { Avatar } from "./avatar.js";
|
|
35
35
|
import { Button } from "./button.js";
|
|
36
36
|
import { Meter } from "./meter.js";
|
|
@@ -45,4 +45,14 @@ import { Field } from "./field.js";
|
|
|
45
45
|
import { Fieldset } from "./fieldset.js";
|
|
46
46
|
import { Form } from "./form.js";
|
|
47
47
|
import { DirectionProvider, DirectionProviderProps, useDirection } from "./direction.js";
|
|
48
|
-
|
|
48
|
+
import { Align, Anchor, AnchorOption, Bindable, ChangeDetails, ChangeSource, ComponentDefinition, Direction, ItemLabels, ListCollection, Orientation, Part, PartDefinition, PartProps, PartState, PartStyle, PhysicalSide, PositionOptions, ReadonlySignal, Side, Signal, StateDefinition, StateOf } from "@kirana-ui/core";
|
|
49
|
+
import { CalendarDay, CalendarValue, CalendarWeekday, DateRange, IsoDate } from "@kirana-ui/core/calendar";
|
|
50
|
+
import { DateFieldSegment, DateUnit } from "@kirana-ui/core/date-field";
|
|
51
|
+
import { DrawerSide, DrawerSnapPoint } from "@kirana-ui/core/drawer";
|
|
52
|
+
import { QrCorrection } from "@kirana-ui/core/qr-code";
|
|
53
|
+
import { SelectShown } from "@kirana-ui/core/select";
|
|
54
|
+
import { FieldValidity, ValidityKey } from "@kirana-ui/core/field";
|
|
55
|
+
import { FormErrors, FormValues, ValidationMode } from "@kirana-ui/core/form";
|
|
56
|
+
import { PaginationEntry } from "@kirana-ui/core/pagination";
|
|
57
|
+
import { SliderChangeDetails, SliderTold } from "@kirana-ui/core/slider";
|
|
58
|
+
export { Accordion, AlertDialog, type Align, type Anchor, type AnchorOption, Autocomplete, Autosize, Avatar, type Bindable, Button, Calendar, type CalendarDay, type CalendarValue, type CalendarWeekday, Carousel, type ChangeDetails, type ChangeSource, Checkbox, Collapsible, Combobox, Command, type ComponentDefinition, ContextMenu, DateField, type DateFieldSegment, DatePicker, type DateRange, type DateUnit, Dialog, type Direction, DirectionProvider, type DirectionProviderProps, Drawer, type DrawerSide, type DrawerSnapPoint, Field, type FieldValidity, Fieldset, Form, type FormErrors, type FormValues, HoverCard, Input, type IsoDate, type ItemLabels, Label, type ListCollection, Listbox, Menu, Menubar, MessageScroller, Meter, NavigationMenu, NumberField, type Orientation, Otp, Pagination, type PaginationEntry, type Part, type PartComponentProps, type PartDefinition, type PartEvent, type PartProps, type PartState, type PartStyle, type PhysicalSide, Popover, PortalProvider, type PortalProviderProps, type PositionOptions, Progress, QrCode, type QrCorrection, RadioGroup, type ReadonlySignal, type RenderProp, Resizable, ScrollArea, Select, type SelectShown, Separator, type Side, type Signal, Slider, type SliderChangeDetails, type SliderTold, type StateDefinition, type StateOf, Switch, Tabs, Toast, type ToastActionOptions, type ToastContent, type ToastOptions, type ToastRecord, type ToastState, type Toaster, type ToasterOptions, Toggle, ToggleGroup, Toolbar, Tooltip, type ValidationMode, type ValidityKey, createToaster, useDirection };
|
package/src/input.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { InputProps as InputProps$1 } from "@kirana-ui/core/input";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
export type InputProps = PartComponentProps<"input", StateOf<Vocabulary["input"]["input"]>, InputProps$1>;
|
|
5
7
|
/**
|
|
6
8
|
* An `<input>`; a `<textarea>` through `render`. It takes what an `<input>` takes (`value`,
|
|
7
9
|
* `defaultValue`), and inside a `<Field.Root>` it is the field's control.
|
|
8
10
|
*/
|
|
9
|
-
export declare
|
|
11
|
+
export declare const Input: ({ disabled, onValueChange, ...rest }: InputProps) => ReactElement;
|
|
10
12
|
//# sourceMappingURL=input.d.ts.map
|
package/src/input.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FieldContext } from "./field-context.js";
|
|
2
|
-
import { useController, usePart } from "./runtime.js";
|
|
2
|
+
import { component, useController, usePart } from "./runtime.js";
|
|
3
3
|
import { within } from "@kirana-ui/core";
|
|
4
4
|
import { useContext } from "react";
|
|
5
5
|
import { createInput } from "@kirana-ui/core/input";
|
|
@@ -8,14 +8,14 @@ import { createInput } from "@kirana-ui/core/input";
|
|
|
8
8
|
* An `<input>`; a `<textarea>` through `render`. It takes what an `<input>` takes (`value`,
|
|
9
9
|
* `defaultValue`), and inside a `<Field.Root>` it is the field's control.
|
|
10
10
|
*/
|
|
11
|
-
function Input({ disabled, onValueChange, ...rest }) {
|
|
11
|
+
const Input = /* @__PURE__ */ component("Input", function Input({ disabled, onValueChange, ...rest }) {
|
|
12
12
|
const field = useContext(FieldContext) ?? void 0;
|
|
13
13
|
const controller = useController(within(createInput, { field }), {
|
|
14
14
|
disabled,
|
|
15
15
|
onValueChange
|
|
16
16
|
});
|
|
17
17
|
return usePart(controller.input, "input", rest);
|
|
18
|
-
}
|
|
18
|
+
});
|
|
19
19
|
export { Input };
|
|
20
20
|
|
|
21
21
|
//# sourceMappingURL=input.js.map
|
package/src/input.js.map
CHANGED
|
@@ -1 +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 =
|
|
1
|
+
{"version":3,"file":"input.js","names":[],"sources":["../../../../packages/react/src/input.tsx"],"sourcesContent":["import { within } from \"@kirana-ui/core\"\nimport type { StateOf } 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 type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { component, useController, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type InputProps = PartComponentProps<\n \"input\",\n StateOf<Vocabulary[\"input\"][\"input\"]>,\n CoreProps\n>\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 const Input = /* @__PURE__ */ component(\n \"Input\",\n 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)\n"],"mappings":";;;;;;;;;;AAsBA,MAAa,QAAwB,0BACnC,SACA,SAAS,MAAM,EAAE,UAAU,eAAe,GAAG,QAAkC;CAC7E,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,CACF"}
|
package/src/label.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
4
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
5
|
+
export type LabelProps = PartComponentProps<"label", StateOf<Vocabulary["label"]["label"]>>;
|
|
3
6
|
/** A `<label>`. Inside a `<Field.Root>` it is the field's label. */
|
|
4
|
-
export declare
|
|
7
|
+
export declare const Label: (props: LabelProps) => ReactElement;
|
|
5
8
|
//# sourceMappingURL=label.d.ts.map
|
package/src/label.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { FieldContext } from "./field-context.js";
|
|
2
|
-
import { usePart } from "./runtime.js";
|
|
2
|
+
import { component, usePart } from "./runtime.js";
|
|
3
3
|
import { useContext, useMemo } from "react";
|
|
4
4
|
import { createLabel } from "@kirana-ui/core/label";
|
|
5
5
|
// src/label.tsx
|
|
6
6
|
/** A `<label>`. Inside a `<Field.Root>` it is the field's label. */
|
|
7
|
-
function Label(props) {
|
|
7
|
+
const Label = /* @__PURE__ */ component("Label", function Label(props) {
|
|
8
8
|
const field = useContext(FieldContext) ?? void 0;
|
|
9
9
|
const made = useMemo(() => createLabel({ field }), [field]);
|
|
10
10
|
return usePart(made.label, "label", props);
|
|
11
|
-
}
|
|
11
|
+
});
|
|
12
12
|
export { Label };
|
|
13
13
|
|
|
14
14
|
//# sourceMappingURL=label.js.map
|
package/src/label.js.map
CHANGED
|
@@ -1 +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:
|
|
1
|
+
{"version":3,"file":"label.js","names":[],"sources":["../../../../packages/react/src/label.tsx"],"sourcesContent":["import type { StateOf } from \"@kirana-ui/core\"\nimport { createLabel } from \"@kirana-ui/core/label\"\nimport type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { useContext, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { FieldContext } from \"./field-context.ts\"\nimport { component, usePart } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\nexport type LabelProps = PartComponentProps<\"label\", StateOf<Vocabulary[\"label\"][\"label\"]>>\n\n/** A `<label>`. Inside a `<Field.Root>` it is the field's label. */\nexport const Label = /* @__PURE__ */ component(\n \"Label\",\n function Label(props: LabelProps): ReactElement {\n const field = useContext(FieldContext) ?? undefined\n const made = useMemo(() => createLabel({ field }), [field])\n return usePart(made.label, \"label\", props)\n }\n)\n"],"mappings":";;;;;;AAaA,MAAa,QAAwB,0BACnC,SACA,SAAS,MAAM,OAAiC;CAC9C,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,CACF"}
|
package/src/listbox.d.ts
CHANGED
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { StateOf } from "@kirana-ui/core";
|
|
2
3
|
import { ReactElement } from "react";
|
|
3
4
|
import { ListboxItemOptions, ListboxProps } from "@kirana-ui/core/listbox";
|
|
4
|
-
|
|
5
|
+
import { Vocabulary } from "@kirana-ui/core/vocabulary";
|
|
6
|
+
type Parts = Vocabulary["listbox"];
|
|
7
|
+
/** `Value` is what tells an item from the others: the type of `value`'s entries. */
|
|
8
|
+
export type RootProps<Value = unknown> = PartComponentProps<"div", StateOf<Parts["root"]>, Omit<ListboxProps<Value>, "id"> & {
|
|
5
9
|
id?: string;
|
|
6
|
-
}
|
|
7
|
-
declare function Root<Value>({ value, defaultValue, onValueChange, multiple, disabled, loop, name, form, virtualized, id, ...rest }: RootProps<Value>): ReactElement;
|
|
8
|
-
export type ItemProps = PartComponentProps
|
|
10
|
+
}>;
|
|
11
|
+
declare function Root<Value = unknown>({ value, defaultValue, onValueChange, multiple, disabled, loop, name, form, virtualized, id, ...rest }: RootProps<Value>): ReactElement;
|
|
12
|
+
export type ItemProps = PartComponentProps<"div", StateOf<Parts["item"]>, ListboxItemOptions & {
|
|
13
|
+
/** What is in the listbox's value while this item is chosen. */
|
|
9
14
|
value: unknown;
|
|
10
|
-
}
|
|
15
|
+
}>;
|
|
11
16
|
declare function Item({ value, disabled, label, index, ...props }: ItemProps): ReactElement;
|
|
12
|
-
export
|
|
17
|
+
export type ItemIndicatorProps = PartComponentProps<"span", StateOf<Parts["itemIndicator"]>, {
|
|
18
|
+
/** Keeps the mark in the page while its item is not chosen. */
|
|
13
19
|
keepMounted?: boolean;
|
|
14
|
-
}
|
|
20
|
+
}>;
|
|
15
21
|
declare function ItemIndicator({ keepMounted, ...props }: ItemIndicatorProps): ReactElement | null;
|
|
16
|
-
|
|
22
|
+
export type GroupProps = PartComponentProps<"div", StateOf<Parts["group"]>, {
|
|
17
23
|
id?: string;
|
|
18
|
-
}
|
|
19
|
-
declare function
|
|
24
|
+
}>;
|
|
25
|
+
declare function Group({ id, ...props }: GroupProps): ReactElement;
|
|
26
|
+
export type GroupLabelProps = PartComponentProps<"div", StateOf<Parts["groupLabel"]>>;
|
|
27
|
+
declare function GroupLabel(props: GroupLabelProps): ReactElement;
|
|
20
28
|
export declare const Listbox: {
|
|
21
|
-
Root: typeof Root;
|
|
22
|
-
Item: typeof Item;
|
|
23
|
-
ItemIndicator: typeof ItemIndicator;
|
|
24
|
-
Group: typeof Group;
|
|
25
|
-
GroupLabel: typeof GroupLabel;
|
|
29
|
+
readonly Root: typeof Root;
|
|
30
|
+
readonly Item: typeof Item;
|
|
31
|
+
readonly ItemIndicator: typeof ItemIndicator;
|
|
32
|
+
readonly Group: typeof Group;
|
|
33
|
+
readonly GroupLabel: typeof GroupLabel;
|
|
26
34
|
};
|
|
27
35
|
export {};
|
|
28
36
|
//# sourceMappingURL=listbox.d.ts.map
|
package/src/listbox.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useController, useOptions, usePart, useSignal } from "./runtime.js";
|
|
1
|
+
import { PartElement, parts, useController, useOptions, usePart, useSignal } from "./runtime.js";
|
|
2
2
|
import { defined } from "@kirana-ui/core";
|
|
3
3
|
import { createContext, useContext, useId, useMemo } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -47,14 +47,13 @@ function Item({ value, disabled, label, index, ...props }) {
|
|
|
47
47
|
children: usePart(part, "div", props)
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
|
-
const PartElement = ({ part, tag, ...props }) => usePart(part, tag, props);
|
|
51
50
|
function ItemIndicator({ keepMounted, ...props }) {
|
|
52
51
|
const controller = useListbox("ItemIndicator");
|
|
53
52
|
const value = useContext(ItemContext);
|
|
54
53
|
const selected = useSignal(controller.selected(value));
|
|
55
54
|
const part = useMemo(() => controller.indicator(value), [controller, value]);
|
|
56
55
|
return selected || keepMounted ? /* @__PURE__ */ jsx(PartElement, {
|
|
57
|
-
part,
|
|
56
|
+
of: part,
|
|
58
57
|
tag: "span",
|
|
59
58
|
...props
|
|
60
59
|
}) : null;
|
|
@@ -77,13 +76,13 @@ function GroupLabel(props) {
|
|
|
77
76
|
if (!group) throw new Error("<Listbox.GroupLabel> must be inside <Listbox.Group>");
|
|
78
77
|
return usePart(group.label, "div", props);
|
|
79
78
|
}
|
|
80
|
-
const Listbox = {
|
|
79
|
+
const Listbox = /* @__PURE__ */ parts("Listbox", {
|
|
81
80
|
Root,
|
|
82
81
|
Item,
|
|
83
82
|
ItemIndicator,
|
|
84
83
|
Group,
|
|
85
84
|
GroupLabel
|
|
86
|
-
};
|
|
85
|
+
});
|
|
87
86
|
export { Listbox };
|
|
88
87
|
|
|
89
88
|
//# sourceMappingURL=listbox.js.map
|
package/src/listbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listbox.js","names":[],"sources":["../../../../packages/react/src/listbox.tsx"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type {
|
|
1
|
+
{"version":3,"file":"listbox.js","names":[],"sources":["../../../../packages/react/src/listbox.tsx"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { StateOf } 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 type { Vocabulary } from \"@kirana-ui/core/vocabulary\"\nimport { createContext, useContext, useId, useMemo } from \"react\"\nimport type { ReactElement } from \"react\"\n\nimport { PartElement, parts, useController, useOptions, usePart, useSignal } from \"./runtime.tsx\"\nimport type { PartComponentProps } from \"./runtime.tsx\"\n\ntype Parts = Vocabulary[\"listbox\"]\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\n/** `Value` is what tells an item from the others: the type of `value`'s entries. */\nexport type RootProps<Value = unknown> = PartComponentProps<\n \"div\",\n StateOf<Parts[\"root\"]>,\n Omit<ListboxProps<Value>, \"id\"> & { id?: string }\n>\n\nfunction Root<Value = unknown>({\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: Controller = useController<ListboxProps<Value>, Controller<Value>>(\n createListbox,\n { value, defaultValue, onValueChange, multiple, disabled, loop, name, form, virtualized, id }\n )\n return (\n <Context.Provider value={controller}>{usePart(controller.root, \"div\", rest)}</Context.Provider>\n )\n}\n\nexport type ItemProps = PartComponentProps<\n \"div\",\n StateOf<Parts[\"item\"]>,\n ListboxItemOptions & {\n /** What is in the listbox's value while this item is chosen. */\n value: unknown\n }\n>\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\nexport type ItemIndicatorProps = PartComponentProps<\n \"span\",\n StateOf<Parts[\"itemIndicator\"]>,\n {\n /** Keeps the mark in the page while its item is not chosen. */\n keepMounted?: boolean\n }\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 of={part} tag=\"span\" {...props} /> : null\n}\n\nexport type GroupProps = PartComponentProps<\"div\", StateOf<Parts[\"group\"]>, { id?: string }>\n\nfunction Group({ id, ...props }: GroupProps): 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\nexport type GroupLabelProps = PartComponentProps<\"div\", StateOf<Parts[\"groupLabel\"]>>\n\nfunction GroupLabel(props: GroupLabelProps): 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 = /* @__PURE__ */ parts(\"Listbox\", {\n Root,\n Item,\n ItemIndicator,\n Group,\n GroupLabel,\n})\n"],"mappings":";;;;;;AAkBA,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;AASA,SAAS,KAAsB,EAC7B,OACA,cACA,eACA,UACA,UACA,MACA,MACA,MACA,aACA,IACA,GAAG,QAC8B;CACjC,MAAM,aAAyB,cAC7B,eACA;EAAE;EAAO;EAAc;EAAe;EAAU;EAAU;EAAM;EAAM;EAAM;EAAa;CAAG,CAC9F;CACA,OACE,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa,UAAA,QAAQ,WAAW,MAAM,OAAO,IAAI;CAAoB,CAAA;AAElG;AAWA,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;AAWA,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;EAAa,IAAI;EAAM,KAAI;EAAO,GAAI;CAAQ,CAAA,IAAI;AACrF;AAIA,SAAS,MAAM,EAAE,IAAI,GAAG,SAAmC;CACzD,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;AAIA,SAAS,WAAW,OAAsC;CACxD,MAAM,QAAQ,WAAW,YAAY;CACrC,IAAI,CAAC,OAAO,MAAM,IAAI,MAAM,qDAAqD;CACjF,OAAO,QAAQ,MAAM,OAAO,OAAO,KAAK;AAC1C;AAEA,MAAa,UAA0B,sBAAM,WAAW;CACtD;CACA;CACA;CACA;CACA;AACF,CAAC"}
|