@pihanga2/shadcn 0.2.1 → 0.2.2
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/AGENT.building-cards.md +208 -3
- package/AGENT.md +58 -3
- package/AGENT.using-cards.md +142 -4
- package/README.md +4 -1
- package/cards/badge/badge.component.js +1 -0
- package/cards/badge/badge.component.js.map +1 -1
- package/cards/box/box.component.js +1 -1
- package/cards/box/box.component.js.map +1 -1
- package/cards/box/box.types.d.ts +0 -8
- package/cards/box/box.types.js.map +1 -1
- package/cards/button/button.types.d.ts +1 -0
- package/cards/button/button.types.js.map +1 -1
- package/cards/{chartGraph/chartGraph.component.d.ts → chart/chart.component.d.ts} +1 -1
- package/cards/chart/chart.types.d.ts +223 -0
- package/cards/chart/index.d.ts +1 -0
- package/cards/checkbox/checkbox.component.js +1 -0
- package/cards/checkbox/checkbox.component.js.map +1 -1
- package/cards/checkbox/checkbox.types.d.ts +4 -0
- package/cards/checkbox/checkbox.types.js +2 -2
- package/cards/checkbox/checkbox.types.js.map +1 -1
- package/cards/checkbox/index.js +5 -5
- package/cards/conditional/conditional.types.d.ts +20 -5
- package/cards/conditional/conditional.types.js.map +1 -1
- package/cards/core-index.d.ts +3 -0
- package/cards/core-index.js +36 -29
- package/cards/dataTable/dataTable.types.js.map +1 -1
- package/cards/dataTable/dataTableRowDetail.component.js +1 -0
- package/cards/dataTable/dataTableRowDetail.component.js.map +1 -1
- package/cards/field/field.types.js.map +1 -1
- package/cards/fileDrop/fileDrop.component.js +90 -0
- package/cards/fileDrop/fileDrop.component.js.map +1 -0
- package/cards/fileDrop/fileDrop.types.js +11 -0
- package/cards/fileDrop/fileDrop.types.js.map +1 -0
- package/cards/fileDrop/index.js +13 -0
- package/cards/fileDrop/index.js.map +1 -0
- package/cards/flexGrid/flexGrid.types.js.map +1 -1
- package/cards/form/form.types.d.ts +4 -0
- package/cards/form/form.types.js +2 -2
- package/cards/form/form.types.js.map +1 -1
- package/cards/form/index.js +5 -5
- package/cards/graphin/graphin.types.d.ts +37 -4
- package/cards/input/index.js +5 -5
- package/cards/input/input.component.js +1 -0
- package/cards/input/input.component.js.map +1 -1
- package/cards/input/input.types.d.ts +10 -2
- package/cards/input/input.types.js +2 -2
- package/cards/input/input.types.js.map +1 -1
- package/cards/list/list.types.js +1 -0
- package/cards/list/list.types.js.map +1 -1
- package/cards/pageWithNavbar/pageWithNavbar.component.d.ts +5 -7
- package/cards/pageWithNavbar/pageWithNavbar.component.js +1 -1
- package/cards/pageWithNavbar/pageWithNavbar.component.js.map +1 -1
- package/cards/pasteTarget/pasteTarget.component.js.map +1 -1
- package/cards/select/index.js +5 -5
- package/cards/select/select.component.js +1 -0
- package/cards/select/select.component.js.map +1 -1
- package/cards/select/select.types.d.ts +12 -0
- package/cards/select/select.types.js +2 -2
- package/cards/select/select.types.js.map +1 -1
- package/cards/slider/index.js +13 -0
- package/cards/slider/index.js.map +1 -0
- package/cards/slider/slider.component.js +64 -0
- package/cards/slider/slider.component.js.map +1 -0
- package/cards/slider/slider.types.d.ts +12 -4
- package/cards/slider/slider.types.js +7 -0
- package/cards/slider/slider.types.js.map +1 -0
- package/cards/sliderValue/index.js +12 -0
- package/cards/sliderValue/index.js.map +1 -0
- package/cards/sliderValue/sliderValue.component.js +33 -0
- package/cards/sliderValue/sliderValue.component.js.map +1 -0
- package/cards/sliderValue/sliderValue.types.js +7 -0
- package/cards/sliderValue/sliderValue.types.js.map +1 -0
- package/cards/stack/stack.component.js +1 -1
- package/cards/stack/stack.component.js.map +1 -1
- package/cards/stack/stack.types.js.map +1 -1
- package/cards/switch/index.js +5 -5
- package/cards/switch/switch.component.js +1 -0
- package/cards/switch/switch.component.js.map +1 -1
- package/cards/switch/switch.types.d.ts +4 -0
- package/cards/switch/switch.types.js +2 -2
- package/cards/switch/switch.types.js.map +1 -1
- package/cards/textField/index.js +5 -5
- package/cards/textField/textField.component.js +1 -0
- package/cards/textField/textField.component.js.map +1 -1
- package/cards/textField/textField.types.d.ts +4 -0
- package/cards/textField/textField.types.js +2 -2
- package/cards/textField/textField.types.js.map +1 -1
- package/cards/toast/index.js +7 -7
- package/cards/toast/toast.component.js.map +1 -1
- package/cards/toast/toast.types.d.ts +4 -0
- package/cards/toast/toast.types.js +2 -2
- package/cards/toast/toast.types.js.map +1 -1
- package/cards/toggleGroup/index.js +5 -5
- package/cards/toggleGroup/toggleGroup.component.js +1 -0
- package/cards/toggleGroup/toggleGroup.component.js.map +1 -1
- package/cards/toggleGroup/toggleGroup.types.d.ts +4 -0
- package/cards/toggleGroup/toggleGroup.types.js +2 -2
- package/cards/toggleGroup/toggleGroup.types.js.map +1 -1
- package/cards/typography/typography.types.js +1 -0
- package/cards/typography/typography.types.js.map +1 -1
- package/components/ui/slider.js +36 -0
- package/components/ui/slider.js.map +1 -0
- package/components/ui/toggle-group.js +1 -0
- package/components/ui/toggle-group.js.map +1 -1
- package/package.json +19 -2
- package/pihanga-shadcn.css +1 -1
- package/cards/chartGraph/chartGraph.types.d.ts +0 -102
- package/cards/chartGraph/index.d.ts +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useFormContext as e } from "../form/form.context.js";
|
|
2
2
|
import { Select as t, SelectContent as n, SelectGroup as r, SelectItem as i, SelectTrigger as a, SelectValue as o } from "../../components/ui/select.js";
|
|
3
|
+
import "@pihanga2/core";
|
|
3
4
|
import { useState as s } from "react";
|
|
4
5
|
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
5
6
|
//#region src/cards/select/select.component.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.component.js","names":[],"sources":["../../../src/cards/select/select.component.tsx"],"sourcesContent":["import React, {useState} from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {\n Select as RadixSelect,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@/components/ui/select\";\nimport {useFormContext} from \"@/cards/form/form.context\";\nimport type {PiSelectEvents, PiSelectProps} from \"./select.types\";\n\nexport const SelectComponent = (\n props: PiCardProps<PiSelectProps, PiSelectEvents>,\n): React.ReactNode => {\n const {\n name,\n value: propValue = \"\",\n defaultValue,\n selfManaged = false,\n options,\n placeholder,\n required,\n disabled,\n ariaLabel,\n cardName,\n onChanged,\n onOpened,\n onClosed,\n } = props;\n\n // `id` and `invalid` may be injected by a parent pi/field card via\n // Pihanga's extra-prop forwarding. They are not in the official type so\n // we read them through an escape hatch.\n const injectedId = (props as {id?: string}).id;\n const invalid = Boolean((props as {invalid?: boolean}).invalid);\n\n // Detect if we are inside a pi/form card via React context.\n const form = useFormContext();\n const useFormData = form.isInForm && Boolean(name);\n\n // Internal state used only when selfManaged=true and not bound to a form.\n const [managedValue, setManagedValue] = useState<string>(\n defaultValue ?? propValue,\n );\n\n const value = useFormData\n ? ((form.formData[name!] as string | undefined) ?? \"\")\n : selfManaged\n ? managedValue\n : propValue;\n\n function handleChange(newValue: string) {\n if (useFormData) {\n form.handleChange(name!, newValue);\n } else {\n if (selfManaged) {\n setManagedValue(newValue);\n }\n onChanged({name, value: newValue});\n }\n }\n\n function handleOpenChange(open: boolean) {\n if (open) {\n onOpened({});\n } else {\n onClosed({});\n }\n }\n\n // Use the id injected by pi/field; fall back to a local id when standalone.\n const selfId = `${cardName}-${name ?? \"select\"}`;\n const fieldId = injectedId ?? selfId;\n\n return (\n <RadixSelect\n value={value}\n defaultValue={defaultValue}\n onValueChange={handleChange}\n onOpenChange={handleOpenChange}\n disabled={disabled}\n required={required}\n aria-label={ariaLabel}\n >\n <SelectTrigger\n id={fieldId}\n aria-invalid={invalid || undefined}\n data-pihanga={cardName}\n >\n <SelectValue placeholder={placeholder ?? \"Select…\"} />\n </SelectTrigger>\n <SelectContent>\n <SelectGroup>\n {options.map((opt) => (\n <SelectItem\n key={opt.value}\n value={opt.value}\n disabled={opt.disabled}\n >\n {opt.label}\n </SelectItem>\n ))}\n </SelectGroup>\n </SelectContent>\n </RadixSelect>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"select.component.js","names":[],"sources":["../../../src/cards/select/select.component.tsx"],"sourcesContent":["import React, {useState} from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {\n Select as RadixSelect,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"@/components/ui/select\";\nimport {useFormContext} from \"@/cards/form/form.context\";\nimport type {PiSelectEvents, PiSelectProps} from \"./select.types\";\n\nexport const SelectComponent = (\n props: PiCardProps<PiSelectProps, PiSelectEvents>,\n): React.ReactNode => {\n const {\n name,\n value: propValue = \"\",\n defaultValue,\n selfManaged = false,\n options,\n placeholder,\n required,\n disabled,\n ariaLabel,\n cardName,\n onChanged,\n onOpened,\n onClosed,\n } = props;\n\n // `id` and `invalid` may be injected by a parent pi/field card via\n // Pihanga's extra-prop forwarding. They are not in the official type so\n // we read them through an escape hatch.\n const injectedId = (props as {id?: string}).id;\n const invalid = Boolean((props as {invalid?: boolean}).invalid);\n\n // Detect if we are inside a pi/form card via React context.\n const form = useFormContext();\n const useFormData = form.isInForm && Boolean(name);\n\n // Internal state used only when selfManaged=true and not bound to a form.\n const [managedValue, setManagedValue] = useState<string>(\n defaultValue ?? propValue,\n );\n\n const value = useFormData\n ? ((form.formData[name!] as string | undefined) ?? \"\")\n : selfManaged\n ? managedValue\n : propValue;\n\n function handleChange(newValue: string) {\n if (useFormData) {\n form.handleChange(name!, newValue);\n } else {\n if (selfManaged) {\n setManagedValue(newValue);\n }\n onChanged({name, value: newValue});\n }\n }\n\n function handleOpenChange(open: boolean) {\n if (open) {\n onOpened({});\n } else {\n onClosed({});\n }\n }\n\n // Use the id injected by pi/field; fall back to a local id when standalone.\n const selfId = `${cardName}-${name ?? \"select\"}`;\n const fieldId = injectedId ?? selfId;\n\n return (\n <RadixSelect\n value={value}\n defaultValue={defaultValue}\n onValueChange={handleChange}\n onOpenChange={handleOpenChange}\n disabled={disabled}\n required={required}\n aria-label={ariaLabel}\n >\n <SelectTrigger\n id={fieldId}\n aria-invalid={invalid || undefined}\n data-pihanga={cardName}\n >\n <SelectValue placeholder={placeholder ?? \"Select…\"} />\n </SelectTrigger>\n <SelectContent>\n <SelectGroup>\n {options.map((opt) => (\n <SelectItem\n key={opt.value}\n value={opt.value}\n disabled={opt.disabled}\n >\n {opt.label}\n </SelectItem>\n ))}\n </SelectGroup>\n </SelectContent>\n </RadixSelect>\n );\n};\n"],"mappings":";;;;;;AAaA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,SACA,OAAO,IAAY,IACnB,iBACA,iBAAc,IACd,YACA,gBACA,aACA,aACA,cACA,aACA,cACA,aACA,gBACE,GAKE,IAAc,EAAwB,IACtC,IAAU,EAAS,EAA8B,SAGjD,IAAO,EAAe,GACtB,IAAc,EAAK,YAAY,EAAQ,GAGvC,CAAC,GAAc,KAAmB,EACtC,KAAgB,CAClB,GAEM,IAAQ,IACR,EAAK,SAAS,MAAiC,KACjD,IACE,IACA;CAEN,SAAS,EAAa,GAAkB;EACtC,AAAI,IACF,EAAK,aAAa,GAAO,CAAQ,KAE7B,KACF,EAAgB,CAAQ,GAE1B,EAAU;GAAC;GAAM,OAAO;EAAQ,CAAC;CAErC;CAEA,SAAS,EAAiB,GAAe;EACvC,AAAI,IACF,EAAS,CAAC,CAAC,IAEX,EAAS,CAAC,CAAC;CAEf;CAGA,IAAM,IAAS,GAAG,EAAS,GAAG,KAAQ;CAGtC,OACE,kBAAC,GAAD;EACS;EACO;EACd,eAAe;EACf,cAAc;EACJ;EACA;EACV,cAAY;YAPd,CASE,kBAAC,GAAD;GACE,IAbU,KAAc;GAcxB,gBAAc,KAAW,KAAA;GACzB,gBAAc;aAEd,kBAAC,GAAD,EAAa,aAAa,KAAe,UAAY,CAAA;EACxC,CAAA,GACf,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UACG,EAAQ,KAAK,MACZ,kBAAC,GAAD;GAEE,OAAO,EAAI;GACX,UAAU,EAAI;aAEb,EAAI;EACK,GALL,EAAI,KAKC,CACb,EACU,CAAA,EACA,CAAA,CACJ;;AAEjB"}
|
|
@@ -5,12 +5,24 @@ export declare const PI_SELECT_ACTION: {
|
|
|
5
5
|
CLOSED: string;
|
|
6
6
|
OPENED: string;
|
|
7
7
|
};
|
|
8
|
+
export declare const onSelectChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
9
|
+
cardID: string;
|
|
10
|
+
} & PiSelectChangedEvent>) => void;
|
|
11
|
+
/** @deprecated Use `onSelectChanged` instead. */
|
|
8
12
|
export declare const onPiSelectChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
9
13
|
cardID: string;
|
|
10
14
|
} & PiSelectChangedEvent>) => void;
|
|
15
|
+
export declare const onSelectOpened: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
16
|
+
cardID: string;
|
|
17
|
+
} & PiSelectOpenedEvent>) => void;
|
|
18
|
+
/** @deprecated Use `onSelectOpened` instead. */
|
|
11
19
|
export declare const onPiSelectOpened: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
12
20
|
cardID: string;
|
|
13
21
|
} & PiSelectOpenedEvent>) => void;
|
|
22
|
+
export declare const onSelectClosed: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
23
|
+
cardID: string;
|
|
24
|
+
} & PiSelectClosedEvent>) => void;
|
|
25
|
+
/** @deprecated Use `onSelectClosed` instead. */
|
|
14
26
|
export declare const onPiSelectClosed: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
15
27
|
cardID: string;
|
|
16
28
|
} & PiSelectClosedEvent>) => void;
|
|
@@ -4,8 +4,8 @@ var r = "pi/select", i = e(r), a = n(r, [
|
|
|
4
4
|
"changed",
|
|
5
5
|
"opened",
|
|
6
6
|
"closed"
|
|
7
|
-
]), o = t(a.CHANGED), s = t(a.OPENED), c = t(a.CLOSED);
|
|
7
|
+
]), o = t(a.CHANGED), s = o, c = t(a.OPENED), l = c, u = t(a.CLOSED), d = u;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { a as PI_SELECT_ACTION, r as PI_SELECT_CARD, i as Select,
|
|
9
|
+
export { a as PI_SELECT_ACTION, r as PI_SELECT_CARD, i as Select, s as onPiSelectChanged, d as onPiSelectClosed, l as onPiSelectOpened, o as onSelectChanged, u as onSelectClosed, c as onSelectOpened };
|
|
10
10
|
|
|
11
11
|
//# sourceMappingURL=select.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.types.js","names":[],"sources":["../../../src/cards/select/select.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_SELECT_CARD = \"pi/select\";\n\nexport const Select = createCardDeclaration<PiSelectProps, PiSelectEvents>(\n PI_SELECT_CARD,\n);\n\nexport const PI_SELECT_ACTION = registerActions(PI_SELECT_CARD, [\n \"changed\",\n \"opened\",\n \"closed\",\n]);\n\nexport const
|
|
1
|
+
{"version":3,"file":"select.types.js","names":[],"sources":["../../../src/cards/select/select.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_SELECT_CARD = \"pi/select\";\n\nexport const Select = createCardDeclaration<PiSelectProps, PiSelectEvents>(\n PI_SELECT_CARD,\n);\n\nexport const PI_SELECT_ACTION = registerActions(PI_SELECT_CARD, [\n \"changed\",\n \"opened\",\n \"closed\",\n]);\n\nexport const onSelectChanged = createOnAction<PiSelectChangedEvent>(\n PI_SELECT_ACTION.CHANGED,\n);\n\n/** @deprecated Use `onSelectChanged` instead. */\nexport const onPiSelectChanged = onSelectChanged;\n\nexport const onSelectOpened = createOnAction<PiSelectOpenedEvent>(\n PI_SELECT_ACTION.OPENED,\n);\n\n/** @deprecated Use `onSelectOpened` instead. */\nexport const onPiSelectOpened = onSelectOpened;\n\nexport const onSelectClosed = createOnAction<PiSelectClosedEvent>(\n PI_SELECT_ACTION.CLOSED,\n);\n\n/** @deprecated Use `onSelectClosed` instead. */\nexport const onPiSelectClosed = onSelectClosed;\n\nexport type PiSelectOption = {\n /** The value stored in form state / dispatched in events. */\n value: string;\n /** Human-readable label shown in the dropdown. */\n label: string;\n /** When true, the option is shown but cannot be selected. */\n disabled?: boolean;\n};\n\nexport type PiSelectProps = {\n /**\n * Field name used to bind to FormContext when inside a pi/form card.\n * When provided the component reads its selected value from form data and\n * writes back via form.handleChange.\n */\n name?: string;\n\n /**\n * Controlled value used in standalone mode (outside a Form).\n * Ignored when `name` is set and the component is inside a pi/form.\n */\n value?: string;\n\n /**\n * When true the component manages its own selected-value state internally.\n * Selecting an item will still dispatch the normal `onChanged` action, but\n * the UI will immediately reflect the new selection without waiting for the\n * host application to update `value` via a reducer.\n *\n * Has no effect when the component is bound to a pi/form via `name`.\n */\n selfManaged?: boolean;\n\n /**\n * Default (uncontrolled) value. Mirrors Radix `defaultValue`.\n */\n defaultValue?: string;\n\n /** Available options to display in the dropdown. */\n options: PiSelectOption[];\n\n /** Placeholder text shown when no option is selected. */\n placeholder?: string;\n\n /** When true, the select is required (HTML form attribute). */\n required?: boolean;\n\n /** When true, the select is disabled and non-interactive. */\n disabled?: boolean;\n\n /** Accessible label for screen readers. */\n ariaLabel?: string;\n};\n\nexport type PiSelectChangedEvent = {\n /** Field name, mirrors the `name` prop if provided. */\n name?: string;\n /** The value of the newly selected option. */\n value: string;\n};\n\nexport type PiSelectOpenedEvent = Record<string, never>;\n\nexport type PiSelectClosedEvent = Record<string, never>;\n\nexport type PiSelectEvents = {\n onChanged: PiSelectChangedEvent;\n onOpened: PiSelectOpenedEvent;\n onClosed: PiSelectClosedEvent;\n};\n"],"mappings":";;AAMA,IAAa,IAAiB,aAEjB,IAAS,EACpB,CACF,GAEa,IAAmB,EAAgB,GAAgB;CAC9D;CACA;CACA;AACF,CAAC,GAEY,IAAkB,EAC7B,EAAiB,OACnB,GAGa,IAAoB,GAEpB,IAAiB,EAC5B,EAAiB,MACnB,GAGa,IAAmB,GAEnB,IAAiB,EAC5B,EAAiB,MACnB,GAGa,IAAmB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SliderComponent as e } from "./slider.component.js";
|
|
2
|
+
import { PI_SLIDER_ACTION as t, PI_SLIDER_CARD as n, Slider as r, onPiSliderChanged as i, onPiSliderCommitted as a, onSliderChanged as o, onSliderCommitted as s } from "./slider.types.js";
|
|
3
|
+
import { actionTypesToEvents as c, registerCardComponent as l } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/slider/index.ts
|
|
5
|
+
l({
|
|
6
|
+
name: n,
|
|
7
|
+
component: e,
|
|
8
|
+
events: c(t)
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as PI_SLIDER_ACTION, n as PI_SLIDER_CARD, r as Slider, i as onPiSliderChanged, a as onPiSliderCommitted, o as onSliderChanged, s as onSliderCommitted };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/slider/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {SliderComponent} from \"./slider.component\";\nimport {PI_SLIDER_ACTION, PI_SLIDER_CARD} from \"./slider.types\";\n\nexport * from \"./slider.types\";\n\nregisterCardComponent({\n name: PI_SLIDER_CARD,\n component: SliderComponent,\n events: actionTypesToEvents(PI_SLIDER_ACTION),\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAgB;AAC9C,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useFormContext as e } from "../form/form.context.js";
|
|
2
|
+
import { Slider as t } from "../../components/ui/slider.js";
|
|
3
|
+
import "@pihanga2/core";
|
|
4
|
+
import { useEffect as n, useRef as r, useState as i } from "react";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
//#region src/cards/slider/slider.component.tsx
|
|
7
|
+
var s = (s) => {
|
|
8
|
+
let { name: c, value: l, defaultValue: u, selfManaged: d = !1, min: f = 0, max: p = 100, step: m = 1, disabled: h, debounceMs: g = 0, suppressChangedEvents: _ = !1, label: v, className: y, cardName: b, onChanged: x, onCommitted: S } = s, C = e(), w = C.isInForm && !!c, [T, E] = i(u ?? l ?? f), D = w ? C.formData[c] ?? f : d ? T : l ?? f, O = r(D);
|
|
9
|
+
O.current = D;
|
|
10
|
+
let k = r(!1), [A, j] = i(D), M = k.current ? A : D, N = r(null), P = r(D);
|
|
11
|
+
n(() => () => {
|
|
12
|
+
N.current != null && clearTimeout(N.current);
|
|
13
|
+
}, []);
|
|
14
|
+
function F(e) {
|
|
15
|
+
_ || (w ? C.handleChange(c, e) : x({
|
|
16
|
+
name: c,
|
|
17
|
+
value: e
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
function I() {
|
|
21
|
+
k.current = !0, j(O.current);
|
|
22
|
+
}
|
|
23
|
+
function L(e) {
|
|
24
|
+
let t = e[0] ?? f;
|
|
25
|
+
k.current && (j(t), d && !w && E(t), g > 0 ? (P.current = t, N.current != null && clearTimeout(N.current), N.current = setTimeout(() => {
|
|
26
|
+
N.current = null, F(P.current);
|
|
27
|
+
}, g)) : F(t));
|
|
28
|
+
}
|
|
29
|
+
function R(e) {
|
|
30
|
+
let t = e[0] ?? f;
|
|
31
|
+
k.current = !1, j(O.current), N.current != null && (clearTimeout(N.current), N.current = null), g > 0 && !_ && F(t), S({
|
|
32
|
+
name: c,
|
|
33
|
+
value: t
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return /* @__PURE__ */ o("div", {
|
|
37
|
+
"data-pihanga": b,
|
|
38
|
+
className: `flex flex-col gap-2 ${y ?? ""}`,
|
|
39
|
+
children: [v && /* @__PURE__ */ o("div", {
|
|
40
|
+
className: "flex items-center justify-between",
|
|
41
|
+
children: [/* @__PURE__ */ a("span", {
|
|
42
|
+
className: "text-sm font-medium leading-none",
|
|
43
|
+
children: v
|
|
44
|
+
}), /* @__PURE__ */ a("span", {
|
|
45
|
+
className: "text-sm text-muted-foreground tabular-nums",
|
|
46
|
+
children: M
|
|
47
|
+
})]
|
|
48
|
+
}), /* @__PURE__ */ a(t, {
|
|
49
|
+
value: [M],
|
|
50
|
+
min: f,
|
|
51
|
+
max: p,
|
|
52
|
+
step: m,
|
|
53
|
+
disabled: h,
|
|
54
|
+
onPointerDown: I,
|
|
55
|
+
onValueChange: L,
|
|
56
|
+
onValueCommit: R,
|
|
57
|
+
className: "w-full"
|
|
58
|
+
})]
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { s as SliderComponent };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=slider.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.component.js","names":[],"sources":["../../../src/cards/slider/slider.component.tsx"],"sourcesContent":["import React, {useEffect, useRef, useState} from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {Slider as SliderUI} from \"@/components/ui/slider\";\nimport {useFormContext} from \"@/cards/form/form.context\";\nimport type {PiSliderEvents, PiSliderProps} from \"./slider.types\";\n\nexport const SliderComponent = (\n props: PiCardProps<PiSliderProps, PiSliderEvents>,\n): React.ReactNode => {\n const {\n name,\n value: propValue,\n defaultValue,\n selfManaged = false,\n min = 0,\n max = 100,\n step = 1,\n disabled,\n debounceMs = 0,\n suppressChangedEvents = false,\n label,\n className,\n cardName,\n onChanged,\n onCommitted,\n } = props;\n\n // Detect if we are inside a pi/form card via React context.\n const form = useFormContext();\n const useFormData = form.isInForm && Boolean(name);\n\n // Internal state used only when selfManaged=true and not bound to a form.\n const [managedValue, setManagedValue] = useState<number>(\n defaultValue ?? propValue ?? min,\n );\n\n // The \"canonical\" value from props / form / self-managed state.\n const canonicalValue = useFormData\n ? ((form.formData[name!] as number | undefined) ?? min)\n : selfManaged\n ? managedValue\n : (propValue ?? min);\n\n // Keep a ref to the latest canonical value so event handlers always see\n // the most up-to-date external value even if it changed during a drag.\n const canonicalValueRef = useRef(canonicalValue);\n canonicalValueRef.current = canonicalValue;\n\n // \"Interactive\" drag state — tracks knob position independently while the\n // user is actively dragging so we don't need an external value round-trip.\n const isDragging = useRef(false);\n const [interactiveValue, setInteractiveValue] =\n useState<number>(canonicalValue);\n\n // While dragging the knob follows pointer; otherwise it reflects the canonical value.\n const displayValue = isDragging.current ? interactiveValue : canonicalValue;\n\n // Refs for debounce: timer handle + latest pending value.\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n const pendingValue = useRef<number>(canonicalValue);\n\n // Clean up any pending debounce timer on unmount.\n useEffect(() => {\n return () => {\n if (debounceTimer.current != null) clearTimeout(debounceTimer.current);\n };\n }, []);\n\n function dispatchChanged(newValue: number) {\n // Silently skip if the caller has opted out of continuous change events.\n if (suppressChangedEvents) return;\n\n if (useFormData) {\n form.handleChange(name!, newValue);\n } else {\n onChanged({name, value: newValue});\n }\n }\n\n // Called on pointer/touch down — enter interactive mode so the knob can\n // move freely without waiting for an external state update.\n function handlePointerDown() {\n isDragging.current = true;\n setInteractiveValue(canonicalValueRef.current);\n }\n\n function handleValueChange(newValues: number[]) {\n const newValue = newValues[0] ?? min;\n\n // Guard: only update interactive display when actively dragging.\n if (!isDragging.current) return;\n\n setInteractiveValue(newValue);\n\n // Update internal state immediately so the thumb moves without lag.\n if (selfManaged && !useFormData) {\n setManagedValue(newValue);\n }\n\n if (debounceMs > 0) {\n // Record the latest value and (re)start the quiet-window timer.\n pendingValue.current = newValue;\n if (debounceTimer.current != null) clearTimeout(debounceTimer.current);\n debounceTimer.current = setTimeout(() => {\n debounceTimer.current = null;\n dispatchChanged(pendingValue.current);\n }, debounceMs);\n } else {\n dispatchChanged(newValue);\n }\n }\n\n function handleValueCommit(newValues: number[]) {\n const newValue = newValues[0] ?? min;\n\n // Leave interactive mode — on next render displayValue reverts to canonicalValue,\n // snapping the knob back to whatever the external state currently says.\n isDragging.current = false;\n setInteractiveValue(canonicalValueRef.current);\n\n // Cancel any pending debounced onChanged — the committed event supersedes it.\n if (debounceTimer.current != null) {\n clearTimeout(debounceTimer.current);\n debounceTimer.current = null;\n }\n\n // When debounce is active (and not suppressed), flush the final value via\n // onChanged before the committed event so listeners always see both.\n if (debounceMs > 0 && !suppressChangedEvents) {\n dispatchChanged(newValue);\n }\n\n onCommitted({name, value: newValue});\n }\n\n return (\n <div\n data-pihanga={cardName}\n className={`flex flex-col gap-2 ${className ?? \"\"}`}\n >\n {label && (\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm font-medium leading-none\">{label}</span>\n <span className=\"text-sm text-muted-foreground tabular-nums\">\n {displayValue}\n </span>\n </div>\n )}\n <SliderUI\n value={[displayValue]}\n min={min}\n max={max}\n step={step}\n disabled={disabled}\n onPointerDown={handlePointerDown}\n onValueChange={handleValueChange}\n onValueCommit={handleValueCommit}\n className=\"w-full\"\n />\n </div>\n );\n};\n"],"mappings":";;;;;;AAMA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,SACA,OAAO,GACP,iBACA,iBAAc,IACd,SAAM,GACN,SAAM,KACN,UAAO,GACP,aACA,gBAAa,GACb,2BAAwB,IACxB,UACA,cACA,aACA,cACA,mBACE,GAGE,IAAO,EAAe,GACtB,IAAc,EAAK,YAAY,EAAQ,GAGvC,CAAC,GAAc,KAAmB,EACtC,KAAgB,KAAa,CAC/B,GAGM,IAAiB,IACjB,EAAK,SAAS,MAAiC,IACjD,IACE,IACC,KAAa,GAId,IAAoB,EAAO,CAAc;CAC/C,EAAkB,UAAU;CAI5B,IAAM,IAAa,EAAO,EAAK,GACzB,CAAC,GAAkB,KACvB,EAAiB,CAAc,GAG3B,IAAe,EAAW,UAAU,IAAmB,GAGvD,IAAgB,EAA6C,IAAI,GACjE,IAAe,EAAe,CAAc;CAGlD,cACe;EACX,AAAI,EAAc,WAAW,QAAM,aAAa,EAAc,OAAO;CACvE,GACC,CAAC,CAAC;CAEL,SAAS,EAAgB,GAAkB;EAErC,MAEA,IACF,EAAK,aAAa,GAAO,CAAQ,IAEjC,EAAU;GAAC;GAAM,OAAO;EAAQ,CAAC;CAErC;CAIA,SAAS,IAAoB;EAE3B,AADA,EAAW,UAAU,IACrB,EAAoB,EAAkB,OAAO;CAC/C;CAEA,SAAS,EAAkB,GAAqB;EAC9C,IAAM,IAAW,EAAU,MAAM;EAG5B,EAAW,YAEhB,EAAoB,CAAQ,GAGxB,KAAe,CAAC,KAClB,EAAgB,CAAQ,GAGtB,IAAa,KAEf,EAAa,UAAU,GACnB,EAAc,WAAW,QAAM,aAAa,EAAc,OAAO,GACrE,EAAc,UAAU,iBAAiB;GAEvC,AADA,EAAc,UAAU,MACxB,EAAgB,EAAa,OAAO;EACtC,GAAG,CAAU,KAEb,EAAgB,CAAQ;CAE5B;CAEA,SAAS,EAAkB,GAAqB;EAC9C,IAAM,IAAW,EAAU,MAAM;EAmBjC,AAfA,EAAW,UAAU,IACrB,EAAoB,EAAkB,OAAO,GAGzC,EAAc,WAAW,SAC3B,aAAa,EAAc,OAAO,GAClC,EAAc,UAAU,OAKtB,IAAa,KAAK,CAAC,KACrB,EAAgB,CAAQ,GAG1B,EAAY;GAAC;GAAM,OAAO;EAAQ,CAAC;CACrC;CAEA,OACE,kBAAC,OAAD;EACE,gBAAc;EACd,WAAW,uBAAuB,KAAa;YAFjD,CAIG,KACC,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,QAAD;IAAM,WAAU;cAAoC;GAAY,CAAA,GAChE,kBAAC,QAAD;IAAM,WAAU;cACb;GACG,CAAA,CACH;MAEP,kBAAC,GAAD;GACE,OAAO,CAAC,CAAY;GACf;GACA;GACC;GACI;GACV,eAAe;GACf,eAAe;GACf,eAAe;GACf,WAAU;EACX,CAAA,CACE;;AAET"}
|
|
@@ -4,15 +4,23 @@ export declare const PI_SLIDER_ACTION: {
|
|
|
4
4
|
CHANGED: string;
|
|
5
5
|
COMMITTED: string;
|
|
6
6
|
};
|
|
7
|
+
export declare const onSliderChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
8
|
+
cardID: string;
|
|
9
|
+
} & PiSliderChangedEvent>) => void;
|
|
10
|
+
/** @deprecated Use `onSliderChanged` instead. */
|
|
7
11
|
export declare const onPiSliderChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
8
12
|
cardID: string;
|
|
9
13
|
} & PiSliderChangedEvent>) => void;
|
|
10
14
|
/**
|
|
11
15
|
* Fired once when the user **finishes** dragging (mouse-up / touch-end).
|
|
12
16
|
*
|
|
13
|
-
* Use this instead of `
|
|
17
|
+
* Use this instead of `onSliderChanged` when you only care about the final
|
|
14
18
|
* settled value and do not want to process every intermediate drag position.
|
|
15
19
|
*/
|
|
20
|
+
export declare const onSliderCommitted: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
21
|
+
cardID: string;
|
|
22
|
+
} & PiSliderCommittedEvent>) => void;
|
|
23
|
+
/** @deprecated Use `onSliderCommitted` instead. */
|
|
16
24
|
export declare const onPiSliderCommitted: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
17
25
|
cardID: string;
|
|
18
26
|
} & PiSliderCommittedEvent>) => void;
|
|
@@ -66,13 +74,13 @@ export type PiSliderProps = {
|
|
|
66
74
|
*/
|
|
67
75
|
debounceMs?: number;
|
|
68
76
|
/**
|
|
69
|
-
* When true, `
|
|
77
|
+
* When true, `onSliderChanged` is **never** dispatched during drag.
|
|
70
78
|
*
|
|
71
|
-
* Use this together with `
|
|
79
|
+
* Use this together with `onSliderCommitted` when you only care about
|
|
72
80
|
* the final settled value and want to eliminate all intermediate Redux
|
|
73
81
|
* actions entirely (stricter than `debounceMs`).
|
|
74
82
|
*
|
|
75
|
-
* `
|
|
83
|
+
* `onSliderCommitted` is unaffected and always fires on release.
|
|
76
84
|
* `selfManaged` visual updates are also unaffected.
|
|
77
85
|
*/
|
|
78
86
|
suppressChangedEvents?: boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/slider/slider.types.ts
|
|
3
|
+
var r = "shad/slider", i = e(r), a = n(r, ["changed", "committed"]), o = t(a.CHANGED), s = o, c = t(a.COMMITTED), l = c;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { a as PI_SLIDER_ACTION, r as PI_SLIDER_CARD, i as Slider, s as onPiSliderChanged, l as onPiSliderCommitted, o as onSliderChanged, c as onSliderCommitted };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=slider.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slider.types.js","names":[],"sources":["../../../src/cards/slider/slider.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_SLIDER_CARD = \"shad/slider\";\n\nexport const Slider = createCardDeclaration<PiSliderProps, PiSliderEvents>(\n PI_SLIDER_CARD,\n);\n\nexport const PI_SLIDER_ACTION = registerActions(PI_SLIDER_CARD, [\n \"changed\",\n \"committed\",\n]);\n\nexport const onSliderChanged = createOnAction<PiSliderChangedEvent>(\n PI_SLIDER_ACTION.CHANGED,\n);\n\n/** @deprecated Use `onSliderChanged` instead. */\nexport const onPiSliderChanged = onSliderChanged;\n\n/**\n * Fired once when the user **finishes** dragging (mouse-up / touch-end).\n *\n * Use this instead of `onSliderChanged` when you only care about the final\n * settled value and do not want to process every intermediate drag position.\n */\nexport const onSliderCommitted = createOnAction<PiSliderCommittedEvent>(\n PI_SLIDER_ACTION.COMMITTED,\n);\n\n/** @deprecated Use `onSliderCommitted` instead. */\nexport const onPiSliderCommitted = onSliderCommitted;\n\n// ---------------------------------------------------------------------------\n// Props & Events\n// ---------------------------------------------------------------------------\n\nexport type PiSliderProps = {\n /**\n * Field name used to bind to FormContext when inside a pi/form card.\n * When provided the component reads its value from form data and writes\n * back via form.handleChange.\n */\n name?: string;\n\n /**\n * Controlled numeric value (single thumb).\n * Ignored when `name` is set and the component is inside a pi/form,\n * and also ignored when `selfManaged` is true (use `defaultValue` instead).\n */\n value?: number;\n\n /**\n * Initial value used when `selfManaged` is true.\n * Falls back to `value` → `min` → 0 if not provided.\n */\n defaultValue?: number;\n\n /**\n * When true the slider keeps its own internal value state.\n * Dragging updates the displayed value immediately without needing an\n * external state update. `onChanged` is still fired on every change so\n * the app can react (or log) without being responsible for feeding the\n * value back as a prop.\n *\n * Ignored when inside a pi/form (form state takes precedence).\n */\n selfManaged?: boolean;\n\n /** Minimum value of the slider range. Defaults to 0. */\n min?: number;\n\n /** Maximum value of the slider range. Defaults to 100. */\n max?: number;\n\n /** Stepping interval between selectable values. Defaults to 1. */\n step?: number;\n\n /** When true, the slider is disabled and non-interactive. */\n disabled?: boolean;\n\n /**\n * Debounce delay in milliseconds applied to `onChanged` during continuous\n * drag. Only the last value within each quiet window is dispatched.\n *\n * Useful when the `onChanged` handler is expensive (e.g. triggers an API\n * call) — set e.g. `debounceMs: 200` to cap the event rate.\n *\n * Has no effect on `onCommitted`, which always fires exactly once at\n * drag-end regardless of this setting.\n *\n * Omit (or set to 0) to dispatch on every drag position (default behaviour).\n */\n debounceMs?: number;\n\n /**\n * When true, `onSliderChanged` is **never** dispatched during drag.\n *\n * Use this together with `onSliderCommitted` when you only care about\n * the final settled value and want to eliminate all intermediate Redux\n * actions entirely (stricter than `debounceMs`).\n *\n * `onSliderCommitted` is unaffected and always fires on release.\n * `selfManaged` visual updates are also unaffected.\n */\n suppressChangedEvents?: boolean;\n\n /**\n * Optional label text rendered above the slider.\n * When provided, the current numeric value is shown to the right of the label.\n */\n label?: string;\n\n /** Extra Tailwind / CSS classes forwarded to the root wrapper element. */\n className?: string;\n};\n\nexport type PiSliderChangedEvent = {\n /** Field name, mirrors the `name` prop if provided. */\n name?: string;\n /** New numeric value after the change. */\n value: number;\n};\n\nexport type PiSliderCommittedEvent = {\n /** Field name, mirrors the `name` prop if provided. */\n name?: string;\n /** Final settled value when the user released the thumb. */\n value: number;\n};\n\nexport type PiSliderEvents = {\n onChanged: PiSliderChangedEvent;\n onCommitted: PiSliderCommittedEvent;\n};\n"],"mappings":";;AAMA,IAAa,IAAiB,eAEjB,IAAS,EACpB,CACF,GAEa,IAAmB,EAAgB,GAAgB,CAC9D,WACA,WACF,CAAC,GAEY,IAAkB,EAC7B,EAAiB,OACnB,GAGa,IAAoB,GAQpB,IAAoB,EAC/B,EAAiB,SACnB,GAGa,IAAsB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SliderValueComponent as e } from "./sliderValue.component.js";
|
|
2
|
+
import { PI_SLIDER_VALUE_CARD as t, SliderValue as n } from "./sliderValue.types.js";
|
|
3
|
+
import { registerCardComponent as r } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/sliderValue/index.ts
|
|
5
|
+
r({
|
|
6
|
+
name: t,
|
|
7
|
+
component: e
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as PI_SLIDER_VALUE_CARD, n as SliderValue };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/sliderValue/index.ts"],"sourcesContent":["import {registerCardComponent} from \"@pihanga2/core\";\n\nimport {SliderValueComponent} from \"./sliderValue.component\";\nimport {PI_SLIDER_VALUE_CARD} from \"./sliderValue.types\";\n\nexport * from \"./sliderValue.types\";\n\nregisterCardComponent({\n name: PI_SLIDER_VALUE_CARD,\n component: SliderValueComponent,\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;AACb,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { cn as e } from "../../components/lib/utils.js";
|
|
2
|
+
import "@pihanga2/core";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
5
|
+
//#region src/cards/sliderValue/sliderValue.component.tsx
|
|
6
|
+
var r = (r) => {
|
|
7
|
+
let { value: i, min: a = 0, max: o = 100, label: s, className: c, cardName: l } = r, u = Math.min(Math.max(i, a), o), d = o - a, f = d > 0 ? (u - a) / d * 100 : 0;
|
|
8
|
+
return /* @__PURE__ */ n("div", {
|
|
9
|
+
"data-pihanga": l,
|
|
10
|
+
className: e("flex flex-col gap-2", c),
|
|
11
|
+
children: [s && /* @__PURE__ */ n("div", {
|
|
12
|
+
className: "flex items-center justify-between",
|
|
13
|
+
children: [/* @__PURE__ */ t("span", {
|
|
14
|
+
className: "text-sm font-medium leading-none",
|
|
15
|
+
children: s
|
|
16
|
+
}), /* @__PURE__ */ t("span", {
|
|
17
|
+
className: "text-sm text-muted-foreground tabular-nums",
|
|
18
|
+
children: u
|
|
19
|
+
})]
|
|
20
|
+
}), /* @__PURE__ */ t("div", {
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
className: e("bg-muted relative h-1.5 w-full grow overflow-hidden rounded-full"),
|
|
23
|
+
children: /* @__PURE__ */ t("div", {
|
|
24
|
+
className: "bg-primary absolute h-full transition-[width]",
|
|
25
|
+
style: { width: `${f}%` }
|
|
26
|
+
})
|
|
27
|
+
})]
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { r as SliderValueComponent };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=sliderValue.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sliderValue.component.js","names":[],"sources":["../../../src/cards/sliderValue/sliderValue.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {cn} from \"@/components/lib/utils\";\nimport type {PiSliderValueProps} from \"./sliderValue.types\";\n\n/**\n * Display-only companion to `shad/slider`.\n *\n * Renders the same track + filled-range visual as the interactive slider but\n * with no thumb and no user interaction. Use this card to show a read-only\n * numeric value in contexts where editing is not permitted (e.g. a summary\n * panel, a table cell, or a loading state).\n *\n * The component uses the same Tailwind classes as `src/components/ui/slider.tsx`\n * so the two cards look identical.\n */\nexport const SliderValueComponent = (\n props: PiCardProps<PiSliderValueProps>,\n): React.ReactNode => {\n const {value, min = 0, max = 100, label, className, cardName} = props;\n\n // Clamp value inside [min, max] and compute fill percentage.\n const clamped = Math.min(Math.max(value, min), max);\n const range = max - min;\n const pct = range > 0 ? ((clamped - min) / range) * 100 : 0;\n\n return (\n <div\n data-pihanga={cardName}\n className={cn(\"flex flex-col gap-2\", className)}\n >\n {label && (\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm font-medium leading-none\">{label}</span>\n <span className=\"text-sm text-muted-foreground tabular-nums\">\n {clamped}\n </span>\n </div>\n )}\n {/* Track — mirrors the SliderPrimitive.Track CSS from slider.tsx */}\n <div\n aria-hidden=\"true\"\n className={cn(\n \"bg-muted relative h-1.5 w-full grow overflow-hidden rounded-full\",\n )}\n >\n {/* Range fill — mirrors SliderPrimitive.Range */}\n <div\n className=\"bg-primary absolute h-full transition-[width]\"\n style={{width: `${pct}%`}}\n />\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;AAgBA,IAAa,KACX,MACoB;CACpB,IAAM,EAAC,UAAO,SAAM,GAAG,SAAM,KAAK,UAAO,cAAW,gBAAY,GAG1D,IAAU,KAAK,IAAI,KAAK,IAAI,GAAO,CAAG,GAAG,CAAG,GAC5C,IAAQ,IAAM,GACd,IAAM,IAAQ,KAAM,IAAU,KAAO,IAAS,MAAM;CAE1D,OACE,kBAAC,OAAD;EACE,gBAAc;EACd,WAAW,EAAG,uBAAuB,CAAS;YAFhD,CAIG,KACC,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,QAAD;IAAM,WAAU;cAAoC;GAAY,CAAA,GAChE,kBAAC,QAAD;IAAM,WAAU;cACb;GACG,CAAA,CACH;MAGP,kBAAC,OAAD;GACE,eAAY;GACZ,WAAW,EACT,kEACF;aAGA,kBAAC,OAAD;IACE,WAAU;IACV,OAAO,EAAC,OAAO,GAAG,EAAI,GAAE;GACzB,CAAA;EACE,CAAA,CACF;;AAET"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/sliderValue/sliderValue.types.ts
|
|
3
|
+
var t = "shad/slider-value", n = e(t);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { t as PI_SLIDER_VALUE_CARD, n as SliderValue };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=sliderValue.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sliderValue.types.js","names":[],"sources":["../../../src/cards/sliderValue/sliderValue.types.ts"],"sourcesContent":["import {createCardDeclaration} from \"@pihanga2/core\";\n\nexport const PI_SLIDER_VALUE_CARD = \"shad/slider-value\";\n\nexport const SliderValue =\n createCardDeclaration<PiSliderValueProps>(PI_SLIDER_VALUE_CARD);\n\n// ---------------------------------------------------------------------------\n// Props (no events — display-only)\n// ---------------------------------------------------------------------------\n\nexport type PiSliderValueProps = {\n /**\n * The numeric value to display on the track.\n * Clamped between `min` and `max`.\n */\n value: number;\n\n /** Minimum value of the range. Defaults to 0. */\n min?: number;\n\n /** Maximum value of the range. Defaults to 100. */\n max?: number;\n\n /**\n * Optional label text rendered above the track.\n * When provided, the numeric value is shown to the right of the label,\n * matching the interactive `shad/slider` layout exactly.\n */\n label?: string;\n\n /** Extra Tailwind / CSS classes forwarded to the root wrapper element. */\n className?: string;\n};\n"],"mappings":";;AAEA,IAAa,IAAuB,qBAEvB,IACX,EAA0C,CAAoB"}
|
|
@@ -6,7 +6,7 @@ import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
|
6
6
|
var a = (a) => {
|
|
7
7
|
let { content: o, direction: s, divider: c, spacing: l, justifyContent: u, alignItems: d, className: f, style: p, cardName: m } = a, h = [
|
|
8
8
|
f,
|
|
9
|
-
(p
|
|
9
|
+
(p ?? {}).root,
|
|
10
10
|
"flex"
|
|
11
11
|
];
|
|
12
12
|
if (s) switch (s) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.component.js","names":[],"sources":["../../../src/cards/stack/stack.component.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type {StackProps} from \"./stack.types\";\n\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\nimport clsx from \"clsx\";\nimport {Fragment} from \"react\";\n\nexport type SelectSD = {\n root?: string;\n};\n\nexport const Component = (props: PiCardProps<StackProps>): React.ReactNode => {\n const {\n content,\n direction,\n divider,\n spacing,\n justifyContent,\n alignItems,\n className,\n style,\n cardName,\n } = props;\n const sd: SelectSD = (style as
|
|
1
|
+
{"version":3,"file":"stack.component.js","names":[],"sources":["../../../src/cards/stack/stack.component.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type {StackProps} from \"./stack.types\";\n\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\nimport clsx from \"clsx\";\nimport {Fragment} from \"react\";\n\nexport type SelectSD = {\n root?: string;\n};\n\nexport const Component = (props: PiCardProps<StackProps>): React.ReactNode => {\n const {\n content,\n direction,\n divider,\n spacing,\n justifyContent,\n alignItems,\n className,\n style,\n cardName,\n } = props;\n const sd: SelectSD = (style as SelectSD | undefined) ?? {};\n\n const cn = [className, sd.root, \"flex\"];\n if (direction) {\n switch (direction) {\n // \"column-reverse\" | \"column\" | \"row-reverse\" | \"row\"\n case \"row\":\n cn.push(\"flex-row\");\n break;\n case \"row-reverse\":\n cn.push(\"flex-row-reverse\");\n break;\n case \"column\":\n cn.push(\"flex-col\");\n break;\n case \"column-reverse\":\n cn.push(\"flex-col-reverse\");\n break;\n }\n }\n if (justifyContent) {\n switch (justifyContent) {\n // \"flex-start\" | \"center\" | \"flex-end\" | \"space-between\" | \"space-around\" | \"space-evenly\"\n case \"flex-start\":\n cn.push(\"justify-start\");\n break;\n case \"center\":\n cn.push(\"justify-center\");\n break;\n case \"flex-end\":\n cn.push(\"justify-end\");\n break;\n case \"space-between\":\n cn.push(\"justify-between\");\n break;\n case \"space-around\":\n cn.push(\"justify-around\");\n break;\n case \"space-evenly\":\n cn.push(\"justify-evenly\");\n break;\n }\n }\n if (alignItems) {\n switch (alignItems) {\n // \"flex-start\" | \"center\" | \"flex-end\" | \"normal\" | \"stretch\" | \"start\" | \"end\" | \"baseline\" | \"initial\" | \"inherit\"\n case \"flex-start\":\n cn.push(\"items-start\");\n break;\n case \"center\":\n cn.push(\"items-center\");\n break;\n case \"stretch\":\n cn.push(\"items-stretch\");\n break;\n case \"flex-end\":\n cn.push(\"items-end\");\n break;\n case \"baseline\":\n cn.push(\"items-baseline\");\n break;\n default:\n console.warn(\"stack: unsupported 'alignItems' property\", alignItems);\n }\n }\n if (spacing && spacing > 0) {\n if (\n direction === undefined ||\n direction === \"row\" ||\n direction === \"row-reverse\"\n ) {\n cn.push(`gap-${spacing}`);\n } else {\n cn.push(`gap-${spacing}`);\n }\n }\n\n function renderContent() {\n if (!content) return null;\n\n return content.map((cn, i) => (\n <Fragment key={i}>\n <Card cardName={cn} parentCard={cardName} key={`item-${i}`} />\n {divider && i < content.length - 1 && (\n <Card cardName={divider} parentCard={cardName} key={`divider-${i}`} />\n )}\n </Fragment>\n ));\n }\n\n return (\n <div className={clsx(cn)} data-pihanga={cardName}>\n {renderContent()}\n {props.children}\n </div>\n );\n};\n"],"mappings":";;;;;AAWA,IAAa,KAAa,MAAoD;CAC5E,IAAM,EACJ,YACA,cACA,YACA,YACA,mBACA,eACA,cACA,UACA,gBACE,GAGE,IAAK;EAAC;GAFU,KAAkC,CAAC,GAE/B;EAAM;CAAM;CACtC,IAAI,GACF,QAAQ,GAAR;EAEE,KAAK;GACH,EAAG,KAAK,UAAU;GAClB;EACF,KAAK;GACH,EAAG,KAAK,kBAAkB;GAC1B;EACF,KAAK;GACH,EAAG,KAAK,UAAU;GAClB;EACF,KAAK;GACH,EAAG,KAAK,kBAAkB;GAC1B;CACJ;CAEF,IAAI,GACF,QAAQ,GAAR;EAEE,KAAK;GACH,EAAG,KAAK,eAAe;GACvB;EACF,KAAK;GACH,EAAG,KAAK,gBAAgB;GACxB;EACF,KAAK;GACH,EAAG,KAAK,aAAa;GACrB;EACF,KAAK;GACH,EAAG,KAAK,iBAAiB;GACzB;EACF,KAAK;GACH,EAAG,KAAK,gBAAgB;GACxB;EACF,KAAK;GACH,EAAG,KAAK,gBAAgB;GACxB;CACJ;CAEF,IAAI,GACF,QAAQ,GAAR;EAEE,KAAK;GACH,EAAG,KAAK,aAAa;GACrB;EACF,KAAK;GACH,EAAG,KAAK,cAAc;GACtB;EACF,KAAK;GACH,EAAG,KAAK,eAAe;GACvB;EACF,KAAK;GACH,EAAG,KAAK,WAAW;GACnB;EACF,KAAK;GACH,EAAG,KAAK,gBAAgB;GACxB;EACF,SACE,QAAQ,KAAK,4CAA4C,CAAU;CACvE;CAEF,AAAI,KAAW,IAAU,KAMrB,EAAG,KAAK,OAAO,GAAS;CAM5B,SAAS,IAAgB;EAGvB,OAFK,IAEE,EAAQ,KAAK,GAAI,MACtB,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;GAAM,UAAU;GAAI,YAAY;EAA6B,GAAd,QAAQ,GAAM,GAC5D,KAAW,IAAI,EAAQ,SAAS,KAC/B,kBAAC,GAAD;GAAM,UAAU;GAAS,YAAY;EAAgC,GAAjB,WAAW,GAAM,CAE/D,EAAA,GALK,CAKL,CACX,IAToB;CAUvB;CAEA,OACE,kBAAC,OAAD;EAAK,WAAW,EAAK,CAAE;EAAG,gBAAc;YAAxC,CACG,EAAc,GACd,EAAM,QACJ;;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.types.js","names":[],"sources":["../../../src/cards/stack/stack.types.ts"],"sourcesContent":["import {type PiCardRef, createCardDeclaration} from \"@pihanga2/core\";\nimport {AlignItemsT} from \"../types\";\n\nexport const STACK_CARD = \"pi/stack\";\n\n/**\n * Factory function for declaring a `stack` card instance.\n *\n * ```ts\n * import {registerCard} from \"@pihanga2/core\";\n * import {Stack} from \"@/cards/stack\";\n *\n * registerCard(\"myApp/toolbar\", Stack({\n * direction: \"row\",\n * spacing: 2,\n * alignItems: \"center\",\n * justifyContent: \"space-between\",\n * content: [\"myApp/logo\", \"myApp/navLinks\", \"myApp/userMenu\"],\n * }));\n * ```\n */\nexport const Stack = createCardDeclaration<StackProps>(STACK_CARD);\n\n/**\n * CSS `flex-direction` values supported by the Stack card.\n */\nexport type DirectionT = \"column-reverse\" | \"column\" | \"row-reverse\" | \"row\";\n\n/**\n * CSS `justify-content` values supported by the Stack card.\n */\nexport type JustifyContentT =\n | \"flex-start\"\n | \"center\"\n | \"flex-end\"\n | \"space-between\"\n | \"space-around\"\n | \"space-evenly\";\n\nexport type StackProps<S = object> = {\n /** Ordered list of child card refs to render */\n content: PiCardRef[];\n\n /** Flex direction — defaults to `\"column\"` */\n direction?: DirectionT;\n /** Optional card ref rendered as a separator between children */\n divider?: PiCardRef;\n /** Tailwind gap spacing units between children */\n spacing?: number;\n\n justifyContent?: JustifyContentT;\n alignItems?: AlignItemsT;\n\n /** Additional Tailwind utility classes */\n className?: string;\n /** Card style object (use the `shad` key for Tailwind-compatible overrides) */\n style?: S;\n};\n"],"mappings":";;AAGA,IAAa,IAAa,YAkBb,IAAQ,EAAkC,CAAU"}
|
|
1
|
+
{"version":3,"file":"stack.types.js","names":[],"sources":["../../../src/cards/stack/stack.types.ts"],"sourcesContent":["import {type PiCardRef, createCardDeclaration} from \"@pihanga2/core\";\nimport type {AlignItemsT} from \"../types\";\n\nexport const STACK_CARD = \"pi/stack\";\n\n/**\n * Factory function for declaring a `stack` card instance.\n *\n * ```ts\n * import {registerCard} from \"@pihanga2/core\";\n * import {Stack} from \"@/cards/stack\";\n *\n * registerCard(\"myApp/toolbar\", Stack({\n * direction: \"row\",\n * spacing: 2,\n * alignItems: \"center\",\n * justifyContent: \"space-between\",\n * content: [\"myApp/logo\", \"myApp/navLinks\", \"myApp/userMenu\"],\n * }));\n * ```\n */\nexport const Stack = createCardDeclaration<StackProps>(STACK_CARD);\n\n/**\n * CSS `flex-direction` values supported by the Stack card.\n */\nexport type DirectionT = \"column-reverse\" | \"column\" | \"row-reverse\" | \"row\";\n\n/**\n * CSS `justify-content` values supported by the Stack card.\n */\nexport type JustifyContentT =\n | \"flex-start\"\n | \"center\"\n | \"flex-end\"\n | \"space-between\"\n | \"space-around\"\n | \"space-evenly\";\n\nexport type StackProps<S = object> = {\n /** Ordered list of child card refs to render */\n content: PiCardRef[];\n\n /** Flex direction — defaults to `\"column\"` */\n direction?: DirectionT;\n /** Optional card ref rendered as a separator between children */\n divider?: PiCardRef;\n /** Tailwind gap spacing units between children */\n spacing?: number;\n\n justifyContent?: JustifyContentT;\n alignItems?: AlignItemsT;\n\n /** Additional Tailwind utility classes */\n className?: string;\n /** Card style object (use the `shad` key for Tailwind-compatible overrides) */\n style?: S;\n};\n"],"mappings":";;AAGA,IAAa,IAAa,YAkBb,IAAQ,EAAkC,CAAU"}
|
package/cards/switch/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { SwitchComponent as e } from "./switch.component.js";
|
|
2
|
-
import { PI_SWITCH_ACTION as t, PI_SWITCH_CARD as n, Switch as r, onPiSwitchChanged as i } from "./switch.types.js";
|
|
3
|
-
import { actionTypesToEvents as
|
|
2
|
+
import { PI_SWITCH_ACTION as t, PI_SWITCH_CARD as n, Switch as r, onPiSwitchChanged as i, onSwitchChanged as a } from "./switch.types.js";
|
|
3
|
+
import { actionTypesToEvents as o, registerCardComponent as s } from "@pihanga2/core";
|
|
4
4
|
//#region src/cards/switch/index.ts
|
|
5
|
-
|
|
5
|
+
s({
|
|
6
6
|
name: n,
|
|
7
7
|
component: e,
|
|
8
|
-
events:
|
|
8
|
+
events: o(t)
|
|
9
9
|
});
|
|
10
10
|
//#endregion
|
|
11
|
-
export { t as PI_SWITCH_ACTION, n as PI_SWITCH_CARD, r as Switch, i as onPiSwitchChanged };
|
|
11
|
+
export { t as PI_SWITCH_ACTION, n as PI_SWITCH_CARD, r as Switch, i as onPiSwitchChanged, a as onSwitchChanged };
|
|
12
12
|
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useFormContext as e } from "../form/form.context.js";
|
|
2
2
|
import { Label as t } from "../../components/ui/label.js";
|
|
3
3
|
import { Switch as n } from "../../components/ui/switch.js";
|
|
4
|
+
import "@pihanga2/core";
|
|
4
5
|
import "react";
|
|
5
6
|
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
7
|
//#region src/cards/switch/switch.component.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.component.js","names":[],"sources":["../../../src/cards/switch/switch.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {Switch as SwitchUI} from \"@/components/ui/switch\";\nimport {Label} from \"@/components/ui/label\";\nimport {useFormContext} from \"@/cards/form/form.context\";\nimport type {PiSwitchEvents, PiSwitchProps} from \"./switch.types\";\n\nexport const SwitchComponent = (\n props: PiCardProps<PiSwitchProps, PiSwitchEvents>,\n): React.ReactNode => {\n const {\n name,\n checked: propChecked = false,\n disabled,\n label,\n className,\n cardName,\n onChanged,\n } = props;\n\n // `id` and `invalid` may be injected by a parent pi/field card via\n // Pihanga's extra-prop forwarding. They are not in the official type so\n // we read them through an escape hatch.\n const injectedId = (props as {id?: string}).id;\n\n // Detect if we are inside a pi/form card via React context.\n const form = useFormContext();\n const useFormData = form.isInForm && Boolean(name);\n\n const checked = useFormData\n ? Boolean(form.formData[name!] ?? false)\n : propChecked;\n\n function handleCheckedChange(newChecked: boolean) {\n if (useFormData) {\n form.handleChange(name!, newChecked);\n } else {\n onChanged({name, checked: newChecked});\n }\n }\n\n // Use the id injected by pi/field; fall back to a local id when standalone.\n const selfId = `${cardName}-${name ?? \"switch\"}`;\n const fieldId = injectedId ?? selfId;\n\n return (\n <div\n data-pihanga={cardName}\n className={`flex items-center gap-2 ${className ?? \"\"}`}\n >\n <SwitchUI\n id={fieldId}\n checked={checked}\n onCheckedChange={handleCheckedChange}\n disabled={disabled}\n />\n {label && (\n <Label htmlFor={fieldId} className=\"cursor-pointer select-none\">\n {label}\n </Label>\n )}\n </div>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"switch.component.js","names":[],"sources":["../../../src/cards/switch/switch.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {Switch as SwitchUI} from \"@/components/ui/switch\";\nimport {Label} from \"@/components/ui/label\";\nimport {useFormContext} from \"@/cards/form/form.context\";\nimport type {PiSwitchEvents, PiSwitchProps} from \"./switch.types\";\n\nexport const SwitchComponent = (\n props: PiCardProps<PiSwitchProps, PiSwitchEvents>,\n): React.ReactNode => {\n const {\n name,\n checked: propChecked = false,\n disabled,\n label,\n className,\n cardName,\n onChanged,\n } = props;\n\n // `id` and `invalid` may be injected by a parent pi/field card via\n // Pihanga's extra-prop forwarding. They are not in the official type so\n // we read them through an escape hatch.\n const injectedId = (props as {id?: string}).id;\n\n // Detect if we are inside a pi/form card via React context.\n const form = useFormContext();\n const useFormData = form.isInForm && Boolean(name);\n\n const checked = useFormData\n ? Boolean(form.formData[name!] ?? false)\n : propChecked;\n\n function handleCheckedChange(newChecked: boolean) {\n if (useFormData) {\n form.handleChange(name!, newChecked);\n } else {\n onChanged({name, checked: newChecked});\n }\n }\n\n // Use the id injected by pi/field; fall back to a local id when standalone.\n const selfId = `${cardName}-${name ?? \"switch\"}`;\n const fieldId = injectedId ?? selfId;\n\n return (\n <div\n data-pihanga={cardName}\n className={`flex items-center gap-2 ${className ?? \"\"}`}\n >\n <SwitchUI\n id={fieldId}\n checked={checked}\n onCheckedChange={handleCheckedChange}\n disabled={disabled}\n />\n {label && (\n <Label htmlFor={fieldId} className=\"cursor-pointer select-none\">\n {label}\n </Label>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;AAOA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,SACA,SAAS,IAAc,IACvB,aACA,UACA,cACA,aACA,iBACE,GAKE,IAAc,EAAwB,IAGtC,IAAO,EAAe,GACtB,IAAc,EAAK,YAAY,EAAQ,GAEvC,IAAU,IACZ,GAAQ,EAAK,SAAS,MAAU,MAChC;CAEJ,SAAS,EAAoB,GAAqB;EAChD,AAAI,IACF,EAAK,aAAa,GAAO,CAAU,IAEnC,EAAU;GAAC;GAAM,SAAS;EAAU,CAAC;CAEzC;CAGA,IAAM,IAAS,GAAG,EAAS,GAAG,KAAQ,YAChC,IAAU,KAAc;CAE9B,OACE,kBAAC,OAAD;EACE,gBAAc;EACd,WAAW,2BAA2B,KAAa;YAFrD,CAIE,kBAAC,GAAD;GACE,IAAI;GACK;GACT,iBAAiB;GACP;EACX,CAAA,GACA,KACC,kBAAC,GAAD;GAAO,SAAS;GAAS,WAAU;aAChC;EACI,CAAA,CAEN;;AAET"}
|
|
@@ -3,6 +3,10 @@ export declare const Switch: <S extends import('@pihanga2/core').ReduxState>(p:
|
|
|
3
3
|
export declare const PI_SWITCH_ACTION: {
|
|
4
4
|
CHANGED: string;
|
|
5
5
|
};
|
|
6
|
+
export declare const onSwitchChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
7
|
+
cardID: string;
|
|
8
|
+
} & PiSwitchChangedEvent>) => void;
|
|
9
|
+
/** @deprecated Use `onSwitchChanged` instead. */
|
|
6
10
|
export declare const onPiSwitchChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
7
11
|
cardID: string;
|
|
8
12
|
} & PiSwitchChangedEvent>) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
2
|
//#region src/cards/switch/switch.types.ts
|
|
3
|
-
var r = "pi/switch", i = e(r), a = n(r, ["changed"]), o = t(a.CHANGED);
|
|
3
|
+
var r = "pi/switch", i = e(r), a = n(r, ["changed"]), o = t(a.CHANGED), s = o;
|
|
4
4
|
//#endregion
|
|
5
|
-
export { a as PI_SWITCH_ACTION, r as PI_SWITCH_CARD, i as Switch,
|
|
5
|
+
export { a as PI_SWITCH_ACTION, r as PI_SWITCH_CARD, i as Switch, s as onPiSwitchChanged, o as onSwitchChanged };
|
|
6
6
|
|
|
7
7
|
//# sourceMappingURL=switch.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.types.js","names":[],"sources":["../../../src/cards/switch/switch.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_SWITCH_CARD = \"pi/switch\";\n\nexport const Switch = createCardDeclaration<PiSwitchProps, PiSwitchEvents>(\n PI_SWITCH_CARD,\n);\n\nexport const PI_SWITCH_ACTION = registerActions(PI_SWITCH_CARD, [\"changed\"]);\n\nexport const
|
|
1
|
+
{"version":3,"file":"switch.types.js","names":[],"sources":["../../../src/cards/switch/switch.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_SWITCH_CARD = \"pi/switch\";\n\nexport const Switch = createCardDeclaration<PiSwitchProps, PiSwitchEvents>(\n PI_SWITCH_CARD,\n);\n\nexport const PI_SWITCH_ACTION = registerActions(PI_SWITCH_CARD, [\"changed\"]);\n\nexport const onSwitchChanged = createOnAction<PiSwitchChangedEvent>(\n PI_SWITCH_ACTION.CHANGED,\n);\n\n/** @deprecated Use `onSwitchChanged` instead. */\nexport const onPiSwitchChanged = onSwitchChanged;\n\n// ---------------------------------------------------------------------------\n// Props & Events\n// ---------------------------------------------------------------------------\n\nexport type PiSwitchProps = {\n /**\n * Field name used to bind to FormContext when inside a pi/form card.\n * When provided the component reads its checked state from form data and\n * writes back via form.handleChange.\n */\n name?: string;\n\n /**\n * Controlled checked state used in standalone mode (outside a Form).\n * Ignored when `name` is set and the component is inside a pi/form.\n */\n checked?: boolean;\n\n /** When true, the switch is disabled and non-interactive. */\n disabled?: boolean;\n\n /**\n * Optional label text rendered beside the switch.\n * The label is automatically associated with the switch via `htmlFor`.\n */\n label?: string;\n\n /** Extra Tailwind / CSS classes forwarded to the root wrapper element. */\n className?: string;\n};\n\nexport type PiSwitchChangedEvent = {\n /** Field name, mirrors the `name` prop if provided. */\n name?: string;\n /** New checked state after the toggle. */\n checked: boolean;\n};\n\nexport type PiSwitchEvents = {\n onChanged: PiSwitchChangedEvent;\n};\n"],"mappings":";;AAMA,IAAa,IAAiB,aAEjB,IAAS,EACpB,CACF,GAEa,IAAmB,EAAgB,GAAgB,CAAC,SAAS,CAAC,GAE9D,IAAkB,EAC7B,EAAiB,OACnB,GAGa,IAAoB"}
|
package/cards/textField/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { TextFieldComponent as e } from "./textField.component.js";
|
|
2
|
-
import { PI_TEXT_FIELD_ACTION as t, PI_TEXT_FIELD_CARD as n, TextField as r, onPiTextFieldChanged as i } from "./textField.types.js";
|
|
3
|
-
import { actionTypesToEvents as
|
|
2
|
+
import { PI_TEXT_FIELD_ACTION as t, PI_TEXT_FIELD_CARD as n, TextField as r, onPiTextFieldChanged as i, onTextFieldChanged as a } from "./textField.types.js";
|
|
3
|
+
import { actionTypesToEvents as o, registerCardComponent as s } from "@pihanga2/core";
|
|
4
4
|
//#region src/cards/textField/index.ts
|
|
5
|
-
|
|
5
|
+
s({
|
|
6
6
|
name: n,
|
|
7
7
|
component: e,
|
|
8
|
-
events:
|
|
8
|
+
events: o(t)
|
|
9
9
|
});
|
|
10
10
|
//#endregion
|
|
11
|
-
export { t as PI_TEXT_FIELD_ACTION, n as PI_TEXT_FIELD_CARD, r as TextField, i as onPiTextFieldChanged };
|
|
11
|
+
export { t as PI_TEXT_FIELD_ACTION, n as PI_TEXT_FIELD_CARD, r as TextField, i as onPiTextFieldChanged, a as onTextFieldChanged };
|
|
12
12
|
|
|
13
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useFormContext as e } from "../form/form.context.js";
|
|
2
2
|
import { Input as t } from "../../components/ui/input.js";
|
|
3
|
+
import "@pihanga2/core";
|
|
3
4
|
import "react";
|
|
4
5
|
import { jsx as n } from "react/jsx-runtime";
|
|
5
6
|
//#region src/cards/textField/textField.component.tsx
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textField.component.js","names":[],"sources":["../../../src/cards/textField/textField.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {Input} from \"@/components/ui/input\";\nimport {useFormContext} from \"@/cards/form/form.context\";\nimport type {PiTextFieldEvents, PiTextFieldProps} from \"./textField.types\";\n\nexport const TextFieldComponent = (\n props: PiCardProps<PiTextFieldProps, PiTextFieldEvents>,\n): React.ReactNode => {\n const {\n name,\n value: propValue = \"\",\n type = \"text\",\n placeholder,\n disabled,\n cardName,\n onChanged,\n } = props;\n\n // `id` and `invalid` may be injected by a parent pi/field card via\n // Pihanga's extra-prop forwarding. They are not in the official type so\n // we read them through an escape hatch.\n const injectedId = (props as {id?: string}).id;\n const invalid = Boolean((props as {invalid?: boolean}).invalid);\n\n // Detect if we are inside a pi/form card via React context.\n const form = useFormContext();\n const useFormData = form.isInForm && Boolean(name);\n\n const value = useFormData\n ? ((form.formData[name!] as string | undefined) ?? \"\")\n : propValue;\n\n function handleChange(e: React.ChangeEvent<HTMLInputElement>) {\n const newValue = e.target.value;\n if (useFormData) {\n form.handleChange(name!, newValue);\n } else {\n onChanged({name, value: newValue});\n }\n }\n\n // Use the id injected by pi/field (for label↔control linking); fall back\n // to a locally-generated id when used standalone.\n const selfId = `${cardName}-${name ?? \"field\"}`;\n const fieldId = injectedId ?? selfId;\n\n return (\n <Input\n id={fieldId}\n type={type}\n value={value}\n onChange={handleChange}\n placeholder={placeholder}\n disabled={disabled}\n aria-invalid={invalid || undefined}\n />\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"textField.component.js","names":[],"sources":["../../../src/cards/textField/textField.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {Input} from \"@/components/ui/input\";\nimport {useFormContext} from \"@/cards/form/form.context\";\nimport type {PiTextFieldEvents, PiTextFieldProps} from \"./textField.types\";\n\nexport const TextFieldComponent = (\n props: PiCardProps<PiTextFieldProps, PiTextFieldEvents>,\n): React.ReactNode => {\n const {\n name,\n value: propValue = \"\",\n type = \"text\",\n placeholder,\n disabled,\n cardName,\n onChanged,\n } = props;\n\n // `id` and `invalid` may be injected by a parent pi/field card via\n // Pihanga's extra-prop forwarding. They are not in the official type so\n // we read them through an escape hatch.\n const injectedId = (props as {id?: string}).id;\n const invalid = Boolean((props as {invalid?: boolean}).invalid);\n\n // Detect if we are inside a pi/form card via React context.\n const form = useFormContext();\n const useFormData = form.isInForm && Boolean(name);\n\n const value = useFormData\n ? ((form.formData[name!] as string | undefined) ?? \"\")\n : propValue;\n\n function handleChange(e: React.ChangeEvent<HTMLInputElement>) {\n const newValue = e.target.value;\n if (useFormData) {\n form.handleChange(name!, newValue);\n } else {\n onChanged({name, value: newValue});\n }\n }\n\n // Use the id injected by pi/field (for label↔control linking); fall back\n // to a locally-generated id when used standalone.\n const selfId = `${cardName}-${name ?? \"field\"}`;\n const fieldId = injectedId ?? selfId;\n\n return (\n <Input\n id={fieldId}\n type={type}\n value={value}\n onChange={handleChange}\n placeholder={placeholder}\n disabled={disabled}\n aria-invalid={invalid || undefined}\n />\n );\n};\n"],"mappings":";;;;;;AAMA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,SACA,OAAO,IAAY,IACnB,UAAO,QACP,gBACA,aACA,aACA,iBACE,GAKE,IAAc,EAAwB,IACtC,IAAU,EAAS,EAA8B,SAGjD,IAAO,EAAe,GACtB,IAAc,EAAK,YAAY,EAAQ,GAEvC,IAAQ,IACR,EAAK,SAAS,MAAiC,KACjD;CAEJ,SAAS,EAAa,GAAwC;EAC5D,IAAM,IAAW,EAAE,OAAO;EAC1B,AAAI,IACF,EAAK,aAAa,GAAO,CAAQ,IAEjC,EAAU;GAAC;GAAM,OAAO;EAAQ,CAAC;CAErC;CAIA,IAAM,IAAS,GAAG,EAAS,GAAG,KAAQ;CAGtC,OACE,kBAAC,GAAD;EACE,IAJY,KAAc;EAKpB;EACC;EACP,UAAU;EACG;EACH;EACV,gBAAc,KAAW,KAAA;CAC1B,CAAA;AAEL"}
|
|
@@ -3,6 +3,10 @@ export declare const TextField: <S extends import('@pihanga2/core').ReduxState>(
|
|
|
3
3
|
export declare const PI_TEXT_FIELD_ACTION: {
|
|
4
4
|
CHANGED: string;
|
|
5
5
|
};
|
|
6
|
+
export declare const onTextFieldChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
7
|
+
cardID: string;
|
|
8
|
+
} & PiTextFieldChangedEvent>) => void;
|
|
9
|
+
/** @deprecated Use `onTextFieldChanged` instead. */
|
|
6
10
|
export declare const onPiTextFieldChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
7
11
|
cardID: string;
|
|
8
12
|
} & PiTextFieldChangedEvent>) => void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
2
|
//#region src/cards/textField/textField.types.ts
|
|
3
|
-
var r = "pi/text-field", i = e(r), a = n(r, ["changed"]), o = t(a.CHANGED);
|
|
3
|
+
var r = "pi/text-field", i = e(r), a = n(r, ["changed"]), o = t(a.CHANGED), s = o;
|
|
4
4
|
//#endregion
|
|
5
|
-
export { a as PI_TEXT_FIELD_ACTION, r as PI_TEXT_FIELD_CARD, i as TextField,
|
|
5
|
+
export { a as PI_TEXT_FIELD_ACTION, r as PI_TEXT_FIELD_CARD, i as TextField, s as onPiTextFieldChanged, o as onTextFieldChanged };
|
|
6
6
|
|
|
7
7
|
//# sourceMappingURL=textField.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textField.types.js","names":[],"sources":["../../../src/cards/textField/textField.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_TEXT_FIELD_CARD = \"pi/text-field\";\n\nexport const TextField = createCardDeclaration<\n PiTextFieldProps,\n PiTextFieldEvents\n>(PI_TEXT_FIELD_CARD);\n\nexport const PI_TEXT_FIELD_ACTION = registerActions(PI_TEXT_FIELD_CARD, [\n \"changed\",\n]);\n\nexport const
|
|
1
|
+
{"version":3,"file":"textField.types.js","names":[],"sources":["../../../src/cards/textField/textField.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_TEXT_FIELD_CARD = \"pi/text-field\";\n\nexport const TextField = createCardDeclaration<\n PiTextFieldProps,\n PiTextFieldEvents\n>(PI_TEXT_FIELD_CARD);\n\nexport const PI_TEXT_FIELD_ACTION = registerActions(PI_TEXT_FIELD_CARD, [\n \"changed\",\n]);\n\nexport const onTextFieldChanged = createOnAction<PiTextFieldChangedEvent>(\n PI_TEXT_FIELD_ACTION.CHANGED,\n);\n\n/** @deprecated Use `onTextFieldChanged` instead. */\nexport const onPiTextFieldChanged = onTextFieldChanged;\n\nexport type PiTextFieldProps = {\n /**\n * Field name used to bind to FormContext when inside a pi/form card.\n * When provided the component reads its value from form state and writes\n * back via form.handleChange.\n */\n name?: string;\n\n /**\n * Controlled value used in standalone mode (outside a Form).\n * Ignored when `name` is set and the component is inside a pi/form.\n */\n value?: string;\n\n /** HTML input type (e.g. \"text\", \"email\", \"password\", \"number\"). */\n type?: string;\n\n /** Placeholder text shown when the input is empty. */\n placeholder?: string;\n\n /** When true, the input is disabled and non-interactive. */\n disabled?: boolean;\n};\n\nexport type PiTextFieldChangedEvent = {\n /** Field name, mirrors the `name` prop if provided. */\n name?: string;\n /** New value after the change. */\n value: string;\n};\n\nexport type PiTextFieldEvents = {\n onChanged: PiTextFieldChangedEvent;\n};\n"],"mappings":";;AAMA,IAAa,IAAqB,iBAErB,IAAY,EAGvB,CAAkB,GAEP,IAAuB,EAAgB,GAAoB,CACtE,SACF,CAAC,GAEY,IAAqB,EAChC,EAAqB,OACvB,GAGa,IAAuB"}
|
package/cards/toast/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { PI_TOAST_ACTION as e, PI_TOAST_CARD as t, TOAST_OP_ACTION as n, Toast as r, dispatchShowToast as i, onPiToastClosed as a, onShowToast as o } from "./toast.types.js";
|
|
2
|
-
import { ToastComponent as
|
|
3
|
-
import { actionTypesToEvents as
|
|
1
|
+
import { PI_TOAST_ACTION as e, PI_TOAST_CARD as t, TOAST_OP_ACTION as n, Toast as r, dispatchShowToast as i, onPiToastClosed as a, onShowToast as o, onToastClosed as s } from "./toast.types.js";
|
|
2
|
+
import { ToastComponent as c } from "./toast.component.js";
|
|
3
|
+
import { actionTypesToEvents as l, registerCardComponent as u } from "@pihanga2/core";
|
|
4
4
|
//#region src/cards/toast/index.ts
|
|
5
|
-
|
|
5
|
+
u({
|
|
6
6
|
name: t,
|
|
7
|
-
component:
|
|
8
|
-
events:
|
|
7
|
+
component: c,
|
|
8
|
+
events: l(e)
|
|
9
9
|
});
|
|
10
10
|
//#endregion
|
|
11
|
-
export { e as PI_TOAST_ACTION, t as PI_TOAST_CARD, n as TOAST_OP_ACTION, r as Toast, i as dispatchShowToast, a as onPiToastClosed, o as onShowToast };
|
|
11
|
+
export { e as PI_TOAST_ACTION, t as PI_TOAST_CARD, n as TOAST_OP_ACTION, r as Toast, i as dispatchShowToast, a as onPiToastClosed, o as onShowToast, s as onToastClosed };
|
|
12
12
|
|
|
13
13
|
//# sourceMappingURL=index.js.map
|