@kirana-ui/react 0.0.0 → 0.1.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/LICENSE +1 -1
- package/package.json +121 -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/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/checkbox.d.ts +18 -0
- package/src/checkbox.js +50 -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/dialog.d.ts +46 -0
- package/src/dialog.js +53 -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/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 +21 -0
- package/src/hover-popup.js +49 -0
- package/src/hover-popup.js.map +1 -0
- package/src/index.d.ts +24 -0
- package/src/index.js +23 -0
- package/src/meter.d.ts +13 -0
- package/src/meter.js +7 -0
- package/src/meter.js.map +1 -0
- package/src/popover.d.ts +31 -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/radio-group.d.ts +24 -0
- package/src/radio-group.js +86 -0
- package/src/radio-group.js.map +1 -0
- package/src/runtime.d.ts +34 -0
- package/src/runtime.js +120 -0
- package/src/runtime.js.map +1 -0
- package/src/select.d.ts +46 -0
- package/src/select.js +91 -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 +82 -0
- package/src/slider.js.map +1 -0
- package/src/switch.d.ts +14 -0
- package/src/switch.js +45 -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/toggle.d.ts +6 -0
- package/src/toggle.js +15 -0
- package/src/toggle.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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
// src/direction-context.ts
|
|
3
|
+
/** The reading direction a provider states, if a component is inside one. */
|
|
4
|
+
const DirectionContext = createContext(null);
|
|
5
|
+
export { DirectionContext };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=direction-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction-context.js","names":[],"sources":["../../../../packages/react/src/direction-context.ts"],"sourcesContent":["import type { Direction, ReadonlySignal } from \"@kirana-ui/core\"\nimport { createContext } from \"react\"\n\n/** The reading direction a provider states, if a component is inside one. */\nexport const DirectionContext = createContext<ReadonlySignal<Direction> | null>(null)\n"],"mappings":";;;AAIA,MAAa,mBAAmB,cAAgD,IAAI"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Direction } from "@kirana-ui/core";
|
|
2
|
+
import { ReactElement, ReactNode } from "react";
|
|
3
|
+
export interface DirectionProviderProps {
|
|
4
|
+
/** The reading direction of what is inside. `ltr` when left out. */
|
|
5
|
+
direction?: Direction;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* States the reading direction for the components inside. It draws nothing: set the page's own
|
|
10
|
+
* `dir` attribute with it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function DirectionProvider({ direction, children }: DirectionProviderProps): ReactElement;
|
|
13
|
+
/** The direction the nearest provider states; `ltr` outside one. */
|
|
14
|
+
export declare function useDirection(): Direction;
|
|
15
|
+
//# sourceMappingURL=direction.d.ts.map
|
package/src/direction.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DirectionContext } from "./direction-context.js";
|
|
2
|
+
import { useController, useSignal } from "./runtime.js";
|
|
3
|
+
import { signal } from "@kirana-ui/core";
|
|
4
|
+
import { createDirection } from "@kirana-ui/core/direction";
|
|
5
|
+
import { useContext, useState } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/direction.tsx
|
|
8
|
+
/**
|
|
9
|
+
* States the reading direction for the components inside. It draws nothing: set the page's own
|
|
10
|
+
* `dir` attribute with it.
|
|
11
|
+
*/
|
|
12
|
+
function DirectionProvider({ direction, children }) {
|
|
13
|
+
const controller = useController(createDirection, { direction });
|
|
14
|
+
return /* @__PURE__ */ jsx(DirectionContext.Provider, {
|
|
15
|
+
value: controller.direction,
|
|
16
|
+
children
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
/** The direction the nearest provider states; `ltr` outside one. */
|
|
20
|
+
function useDirection() {
|
|
21
|
+
const given = useContext(DirectionContext);
|
|
22
|
+
const [fallback] = useState(() => signal("ltr"));
|
|
23
|
+
return useSignal(given ?? fallback);
|
|
24
|
+
}
|
|
25
|
+
export { DirectionProvider, useDirection };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=direction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direction.js","names":[],"sources":["../../../../packages/react/src/direction.tsx"],"sourcesContent":["import { signal } from \"@kirana-ui/core\"\nimport type { Direction } from \"@kirana-ui/core\"\nimport { createDirection } from \"@kirana-ui/core/direction\"\nimport { useContext, useState } from \"react\"\nimport type { ReactElement, ReactNode } from \"react\"\n\nimport { DirectionContext } from \"./direction-context.ts\"\nimport { useController, useSignal } from \"./runtime.tsx\"\n\nexport interface DirectionProviderProps {\n /** The reading direction of what is inside. `ltr` when left out. */\n direction?: Direction\n children?: ReactNode\n}\n\n/**\n * States the reading direction for the components inside. It draws nothing: set the page's own\n * `dir` attribute with it.\n */\nexport function DirectionProvider({ direction, children }: DirectionProviderProps): ReactElement {\n const controller = useController(createDirection, { direction })\n return (\n <DirectionContext.Provider value={controller.direction}>{children}</DirectionContext.Provider>\n )\n}\n\n/** The direction the nearest provider states; `ltr` outside one. */\nexport function useDirection(): Direction {\n const given = useContext(DirectionContext)\n const [fallback] = useState(() => signal<Direction>(\"ltr\"))\n return useSignal(given ?? fallback)\n}\n"],"mappings":";;;;;;;;;;;AAmBA,SAAgB,kBAAkB,EAAE,WAAW,YAAkD;CAC/F,MAAM,aAAa,cAAc,iBAAiB,EAAE,UAAU,CAAC;CAC/D,OACE,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO,WAAW;EAAY;CAAoC,CAAA;AAEjG;;AAGA,SAAgB,eAA0B;CACxC,MAAM,QAAQ,WAAW,gBAAgB;CACzC,MAAM,CAAC,YAAY,eAAe,OAAkB,KAAK,CAAC;CAC1D,OAAO,UAAU,SAAS,QAAQ;AACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-context.js","names":[],"sources":["../../../../packages/react/src/field-context.ts"],"sourcesContent":["import type { Field } from \"@kirana-ui/core/field\"\nimport { createContext } from \"react\"\n\n/** The field a part or a control is in, if it is in one. */\nexport const FieldContext = createContext<Field | null>(null)\n"],"mappings":";;;AAIA,MAAa,eAAe,cAA4B,IAAI"}
|
package/src/field.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { ReactElement, ReactNode } from "react";
|
|
3
|
+
import { FieldProps, FieldValidity, ValidityKey } from "@kirana-ui/core/field";
|
|
4
|
+
export type RootProps = Omit<FieldProps, "id"> & {
|
|
5
|
+
id?: string;
|
|
6
|
+
} & PartComponentProps;
|
|
7
|
+
declare function Root({ name, disabled, invalid, validate, validationMode, validationDebounceTime, id, ...rest }: RootProps): ReactElement;
|
|
8
|
+
declare const Label: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
9
|
+
/** An `<input>`; a `<textarea>` or a `<select>` through `render`. */
|
|
10
|
+
declare const Control: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
11
|
+
declare const Description: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
12
|
+
export interface ErrorProps extends PartComponentProps {
|
|
13
|
+
/** One of the browser's findings (`"valueMissing"`) to show for only that; `true` to show always. */
|
|
14
|
+
match?: ValidityKey | boolean;
|
|
15
|
+
}
|
|
16
|
+
/** What is wrong, or `children` in its place. In the page while it applies. */
|
|
17
|
+
declare function FieldError({ match, children, ...rest }: ErrorProps): ReactElement | null;
|
|
18
|
+
/** Draws nothing itself: `children` is given the field's validity. */
|
|
19
|
+
declare function Validity({ children }: {
|
|
20
|
+
children: (validity: FieldValidity) => ReactNode;
|
|
21
|
+
}): ReactNode;
|
|
22
|
+
export declare const Field: {
|
|
23
|
+
Root: typeof Root;
|
|
24
|
+
Label: typeof Label;
|
|
25
|
+
Control: typeof Control;
|
|
26
|
+
Description: typeof Description;
|
|
27
|
+
Error: typeof FieldError;
|
|
28
|
+
Validity: typeof Validity;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=field.d.ts.map
|
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, useOptions, usePart, useSignal } from "./runtime.js";
|
|
5
|
+
import { useContext, useEffect, 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
|
+
useEffect(() => error.mount(), [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, useEffect, 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, 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 useEffect(() => error.mount(), [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,gBAAgB,MAAM,MAAM,GAAG,CAAC,KAAK,CAAC;CACtC,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 } 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: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
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,21 @@
|
|
|
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
|
+
/** The parts of a popup the pointer opens: a tooltip's, a hover card's. */
|
|
11
|
+
export declare function hoverPopup(name: string, create: (props: ReadonlySignal<HoverPopupProps>) => HoverPopup, triggerTag: string): {
|
|
12
|
+
Root: ({ children, ...props }: RootProps) => ReactElement;
|
|
13
|
+
Trigger: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
14
|
+
Portal: ({ children }: {
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
}) => ReactElement | null;
|
|
17
|
+
Positioner: ({ side, align, sideOffset, alignOffset, collisionPadding, ...props }: PositionerProps) => ReactElement;
|
|
18
|
+
Popup: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
19
|
+
Arrow: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=hover-popup.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
const Trigger = (props) => usePart(use("Trigger").trigger, triggerTag, props);
|
|
36
|
+
const Popup = (props) => usePart(use("Popup").popup, "div", props);
|
|
37
|
+
const Arrow = (props) => usePart(use("Arrow").arrow, "div", props);
|
|
38
|
+
return {
|
|
39
|
+
Root,
|
|
40
|
+
Trigger,
|
|
41
|
+
Portal: Portal$1,
|
|
42
|
+
Positioner,
|
|
43
|
+
Popup,
|
|
44
|
+
Arrow
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export { hoverPopup };
|
|
48
|
+
|
|
49
|
+
//# 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>\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 const Trigger = (props: PartComponentProps) => usePart(use(\"Trigger\").trigger, triggerTag, props)\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":";;;;;;AAaA,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;CAEA,MAAM,WAAW,UAA8B,QAAQ,IAAI,SAAS,CAAC,CAAC,SAAS,YAAY,KAAK;CAChG,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,24 @@
|
|
|
1
|
+
import { Accordion } from "./accordion.js";
|
|
2
|
+
import { Checkbox } from "./checkbox.js";
|
|
3
|
+
import { Collapsible } from "./collapsible.js";
|
|
4
|
+
import { AlertDialog, Dialog } from "./dialog.js";
|
|
5
|
+
import { HoverCard } from "./hover-card.js";
|
|
6
|
+
import { Popover } from "./popover.js";
|
|
7
|
+
import { RadioGroup } from "./radio-group.js";
|
|
8
|
+
import { Select } from "./select.js";
|
|
9
|
+
import { Switch } from "./switch.js";
|
|
10
|
+
import { Tabs } from "./tabs.js";
|
|
11
|
+
import { Tooltip } from "./tooltip.js";
|
|
12
|
+
import { PartComponentProps, RenderProp } from "./runtime.js";
|
|
13
|
+
import { Avatar } from "./avatar.js";
|
|
14
|
+
import { Button } from "./button.js";
|
|
15
|
+
import { Meter } from "./meter.js";
|
|
16
|
+
import { Progress } from "./progress.js";
|
|
17
|
+
import { Separator } from "./separator.js";
|
|
18
|
+
import { Toggle } from "./toggle.js";
|
|
19
|
+
import { Slider } from "./slider.js";
|
|
20
|
+
import { Field } from "./field.js";
|
|
21
|
+
import { Fieldset } from "./fieldset.js";
|
|
22
|
+
import { Form } from "./form.js";
|
|
23
|
+
import { DirectionProvider, DirectionProviderProps, useDirection } from "./direction.js";
|
|
24
|
+
export { Accordion, AlertDialog, Avatar, Button, Checkbox, Collapsible, Dialog, DirectionProvider, type DirectionProviderProps, Field, Fieldset, Form, HoverCard, Meter, type PartComponentProps, Popover, Progress, RadioGroup, type RenderProp, Select, Separator, Slider, Switch, Tabs, Toggle, Tooltip, useDirection };
|
package/src/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Accordion } from "./accordion.js";
|
|
2
|
+
import { Checkbox } from "./checkbox.js";
|
|
3
|
+
import { Collapsible } from "./collapsible.js";
|
|
4
|
+
import { AlertDialog, Dialog } from "./dialog.js";
|
|
5
|
+
import { HoverCard } from "./hover-card.js";
|
|
6
|
+
import { Popover } from "./popover.js";
|
|
7
|
+
import { RadioGroup } from "./radio-group.js";
|
|
8
|
+
import { Select } from "./select.js";
|
|
9
|
+
import { Switch } from "./switch.js";
|
|
10
|
+
import { Tabs } from "./tabs.js";
|
|
11
|
+
import { Tooltip } from "./tooltip.js";
|
|
12
|
+
import { Avatar } from "./avatar.js";
|
|
13
|
+
import { Button } from "./button.js";
|
|
14
|
+
import { Meter } from "./meter.js";
|
|
15
|
+
import { Progress } from "./progress.js";
|
|
16
|
+
import { Separator } from "./separator.js";
|
|
17
|
+
import { Toggle } from "./toggle.js";
|
|
18
|
+
import { Slider } from "./slider.js";
|
|
19
|
+
import { Field } from "./field.js";
|
|
20
|
+
import { Fieldset } from "./fieldset.js";
|
|
21
|
+
import { Form } from "./form.js";
|
|
22
|
+
import { DirectionProvider, useDirection } from "./direction.js";
|
|
23
|
+
export { Accordion, AlertDialog, Avatar, Button, Checkbox, Collapsible, Dialog, DirectionProvider, Field, Fieldset, Form, HoverCard, Meter, Popover, Progress, RadioGroup, Select, Separator, Slider, Switch, Tabs, Toggle, Tooltip, useDirection };
|
package/src/meter.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
export declare const Meter: {
|
|
3
|
+
Root: ({ value, min, max, format, locale, getAriaValueText, id, ...rest }: Omit<import("@kirana-ui/core/meter").MeterProps, "id"> & {
|
|
4
|
+
id?: string;
|
|
5
|
+
} & PartComponentProps<undefined>) => import("react").ReactElement;
|
|
6
|
+
Track: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
+
Indicator: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
8
|
+
Value: ({ children, ...props }: Omit<PartComponentProps<undefined>, "children"> & {
|
|
9
|
+
children?: ((text: string | undefined) => import("react").ReactNode) | undefined;
|
|
10
|
+
}) => import("react").ReactElement;
|
|
11
|
+
Label: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=meter.d.ts.map
|
package/src/meter.js
ADDED
package/src/meter.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meter.js","names":[],"sources":["../../../../packages/react/src/meter.tsx"],"sourcesContent":["import { createMeter } from \"@kirana-ui/core/meter\"\n\nimport { valueBar } from \"./value-bar.tsx\"\n\nexport const Meter = valueBar(\"Meter\", createMeter)\n"],"mappings":";;;AAIA,MAAa,QAAQ,SAAS,SAAS,WAAW"}
|
package/src/popover.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
import { PositionOptions } from "@kirana-ui/core";
|
|
3
|
+
import { ReactElement, ReactNode } from "react";
|
|
4
|
+
import { PopoverProps } from "@kirana-ui/core/popover";
|
|
5
|
+
export type RootProps = Omit<PopoverProps, "id"> & {
|
|
6
|
+
id?: string;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
declare function Root({ children, ...props }: RootProps): ReactElement;
|
|
10
|
+
declare function Portal({ children }: {
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
}): ReactElement | null;
|
|
13
|
+
export type PositionerProps = PartComponentProps & Partial<PositionOptions>;
|
|
14
|
+
declare function Positioner({ side, align, sideOffset, alignOffset, collisionPadding, ...props }: PositionerProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
15
|
+
declare const Trigger: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
16
|
+
declare const Popup: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
17
|
+
declare const Title: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
18
|
+
declare const Description: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
19
|
+
declare const Close: (props: PartComponentProps) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
20
|
+
export declare const Popover: {
|
|
21
|
+
Root: typeof Root;
|
|
22
|
+
Trigger: typeof Trigger;
|
|
23
|
+
Portal: typeof Portal;
|
|
24
|
+
Positioner: typeof Positioner;
|
|
25
|
+
Popup: typeof Popup;
|
|
26
|
+
Title: typeof Title;
|
|
27
|
+
Description: typeof Description;
|
|
28
|
+
Close: typeof Close;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=popover.d.ts.map
|
package/src/popover.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Portal as Portal$1, 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
|
+
import { createPopover } from "@kirana-ui/core/popover";
|
|
6
|
+
// src/popover.tsx
|
|
7
|
+
const Context = createContext(null);
|
|
8
|
+
function usePopover(part) {
|
|
9
|
+
const controller = useContext(Context);
|
|
10
|
+
if (!controller) throw new Error(`<Popover.${part}> must be inside <Popover.Root>`);
|
|
11
|
+
return controller;
|
|
12
|
+
}
|
|
13
|
+
function Root({ children, ...props }) {
|
|
14
|
+
const controller = useController(createPopover, props);
|
|
15
|
+
return /* @__PURE__ */ jsx(Context.Provider, {
|
|
16
|
+
value: controller,
|
|
17
|
+
children
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function Portal({ children }) {
|
|
21
|
+
return useSignal(usePopover("Portal").mounted) ? /* @__PURE__ */ jsx(Portal$1, { children }) : null;
|
|
22
|
+
}
|
|
23
|
+
function Positioner({ side, align, sideOffset, alignOffset, collisionPadding, ...props }) {
|
|
24
|
+
const controller = usePopover("Positioner");
|
|
25
|
+
controller.positioning.set(defined({
|
|
26
|
+
side,
|
|
27
|
+
align,
|
|
28
|
+
sideOffset,
|
|
29
|
+
alignOffset,
|
|
30
|
+
collisionPadding
|
|
31
|
+
}));
|
|
32
|
+
return usePart(controller.positioner, "div", props);
|
|
33
|
+
}
|
|
34
|
+
const Trigger = (props) => usePart(usePopover("Trigger").trigger, "button", props);
|
|
35
|
+
const Popup = (props) => usePart(usePopover("Popup").popup, "div", props);
|
|
36
|
+
const Title = (props) => usePart(usePopover("Title").title, "h2", props);
|
|
37
|
+
const Description = (props) => usePart(usePopover("Description").description, "p", props);
|
|
38
|
+
const Close = (props) => usePart(usePopover("Close").close, "button", props);
|
|
39
|
+
const Popover = {
|
|
40
|
+
Root,
|
|
41
|
+
Trigger,
|
|
42
|
+
Portal,
|
|
43
|
+
Positioner,
|
|
44
|
+
Popup,
|
|
45
|
+
Title,
|
|
46
|
+
Description,
|
|
47
|
+
Close
|
|
48
|
+
};
|
|
49
|
+
export { Popover };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=popover.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover.js","names":["BodyPortal"],"sources":["../../../../packages/react/src/popover.tsx"],"sourcesContent":["import { defined } from \"@kirana-ui/core\"\nimport type { PositionOptions } from \"@kirana-ui/core\"\nimport { createPopover } from \"@kirana-ui/core/popover\"\nimport type { Popover as Controller, PopoverProps } from \"@kirana-ui/core/popover\"\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\nconst Context = createContext<Controller | null>(null)\n\nfunction usePopover(part: string): Controller {\n const controller = useContext(Context)\n if (!controller) throw new Error(`<Popover.${part}> must be inside <Popover.Root>`)\n return controller\n}\n\nexport type RootProps = Omit<PopoverProps, \"id\"> & { id?: string; children?: ReactNode }\n\nfunction Root({ children, ...props }: RootProps): ReactElement {\n const controller = useController(createPopover, props)\n return <Context.Provider value={controller}>{children}</Context.Provider>\n}\n\nfunction Portal({ children }: { children?: ReactNode }): ReactElement | null {\n const mounted = useSignal(usePopover(\"Portal\").mounted)\n return mounted ? <BodyPortal>{children}</BodyPortal> : null\n}\n\nexport type PositionerProps = PartComponentProps & Partial<PositionOptions>\n\nfunction Positioner({\n side,\n align,\n sideOffset,\n alignOffset,\n collisionPadding,\n ...props\n}: PositionerProps) {\n const controller = usePopover(\"Positioner\")\n // Written while rendering, so the first placement (made when the element attaches, before\n // this component's effects) reads them. Nothing re-renders for it: the core compares.\n controller.positioning.set(defined({ side, align, sideOffset, alignOffset, collisionPadding }))\n return usePart(controller.positioner, \"div\", props)\n}\n\nconst Trigger = (props: PartComponentProps) =>\n usePart(usePopover(\"Trigger\").trigger, \"button\", props)\nconst Popup = (props: PartComponentProps) => usePart(usePopover(\"Popup\").popup, \"div\", props)\nconst Title = (props: PartComponentProps) => usePart(usePopover(\"Title\").title, \"h2\", props)\nconst Description = (props: PartComponentProps) =>\n usePart(usePopover(\"Description\").description, \"p\", props)\nconst Close = (props: PartComponentProps) => usePart(usePopover(\"Close\").close, \"button\", props)\n\nexport const Popover = { Root, Trigger, Portal, Positioner, Popup, Title, Description, Close }\n"],"mappings":";;;;;;AAUA,MAAM,UAAU,cAAiC,IAAI;AAErD,SAAS,WAAW,MAA0B;CAC5C,MAAM,aAAa,WAAW,OAAO;CACrC,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,YAAY,KAAK,gCAAgC;CAClF,OAAO;AACT;AAIA,SAAS,KAAK,EAAE,UAAU,GAAG,SAAkC;CAC7D,MAAM,aAAa,cAAc,eAAe,KAAK;CACrD,OAAO,oBAAC,QAAQ,UAAT;EAAkB,OAAO;EAAa;CAA2B,CAAA;AAC1E;AAEA,SAAS,OAAO,EAAE,YAA2D;CAE3E,OADgB,UAAU,WAAW,QAAQ,CAAC,CAAC,OAClC,IAAI,oBAACA,UAAD,EAAa,SAAqB,CAAA,IAAI;AACzD;AAIA,SAAS,WAAW,EAClB,MACA,OACA,YACA,aACA,kBACA,GAAG,SACe;CAClB,MAAM,aAAa,WAAW,YAAY;CAG1C,WAAW,YAAY,IAAI,QAAQ;EAAE;EAAM;EAAO;EAAY;EAAa;CAAiB,CAAC,CAAC;CAC9F,OAAO,QAAQ,WAAW,YAAY,OAAO,KAAK;AACpD;AAEA,MAAM,WAAW,UACf,QAAQ,WAAW,SAAS,CAAC,CAAC,SAAS,UAAU,KAAK;AACxD,MAAM,SAAS,UAA8B,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,OAAO,KAAK;AAC5F,MAAM,SAAS,UAA8B,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,MAAM,KAAK;AAC3F,MAAM,eAAe,UACnB,QAAQ,WAAW,aAAa,CAAC,CAAC,aAAa,KAAK,KAAK;AAC3D,MAAM,SAAS,UAA8B,QAAQ,WAAW,OAAO,CAAC,CAAC,OAAO,UAAU,KAAK;AAE/F,MAAa,UAAU;CAAE;CAAM;CAAS;CAAQ;CAAY;CAAO;CAAO;CAAa;AAAM"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PartComponentProps } from "./runtime.js";
|
|
2
|
+
export declare const Progress: {
|
|
3
|
+
Root: ({ value, min, max, format, locale, getAriaValueText, id, ...rest }: Omit<import("@kirana-ui/core/meter").ValueBarProps, "id"> & {
|
|
4
|
+
id?: string;
|
|
5
|
+
} & PartComponentProps<undefined>) => import("react").ReactElement;
|
|
6
|
+
Track: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
+
Indicator: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
8
|
+
Value: ({ children, ...props }: Omit<PartComponentProps<undefined>, "children"> & {
|
|
9
|
+
children?: ((text: string | undefined) => import("react").ReactNode) | undefined;
|
|
10
|
+
}) => import("react").ReactElement;
|
|
11
|
+
Label: (props: PartComponentProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=progress.d.ts.map
|
package/src/progress.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress.js","names":[],"sources":["../../../../packages/react/src/progress.tsx"],"sourcesContent":["import { createProgress } from \"@kirana-ui/core/progress\"\n\nimport { valueBar } from \"./value-bar.tsx\"\n\nexport const Progress = valueBar(\"Progress\", createProgress)\n"],"mappings":";;;AAIA,MAAa,WAAW,SAAS,YAAY,cAAc"}
|