@pihanga2/shadcn 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/README.md +114 -0
- package/cards/badge/badge.component.d.ts +14 -0
- package/cards/badge/badge.component.js +18 -0
- package/cards/badge/badge.component.js.map +1 -0
- package/cards/badge/badge.types.d.ts +37 -0
- package/cards/badge/badge.types.js +7 -0
- package/cards/badge/badge.types.js.map +1 -0
- package/cards/badge/index.d.ts +1 -0
- package/cards/badge/index.js +12 -0
- package/cards/badge/index.js.map +1 -0
- package/cards/box/box.component.d.ts +4 -0
- package/cards/box/box.component.js +24 -0
- package/cards/box/box.component.js.map +1 -0
- package/cards/box/box.types.d.ts +71 -0
- package/cards/box/box.types.js +7 -0
- package/cards/box/box.types.js.map +1 -0
- package/cards/box/index.d.ts +1 -0
- package/cards/box/index.js +12 -0
- package/cards/box/index.js.map +1 -0
- package/cards/button/button.component.d.ts +4 -0
- package/cards/button/button.component.js +71 -0
- package/cards/button/button.component.js.map +1 -0
- package/cards/button/button.types.d.ts +106 -0
- package/cards/button/button.types.js +7 -0
- package/cards/button/button.types.js.map +1 -0
- package/cards/button/index.d.ts +1 -0
- package/cards/button/index.js +13 -0
- package/cards/button/index.js.map +1 -0
- package/cards/checkbox/checkbox.component.d.ts +4 -0
- package/cards/checkbox/checkbox.component.js +36 -0
- package/cards/checkbox/checkbox.component.js.map +1 -0
- package/cards/checkbox/checkbox.types.d.ts +37 -0
- package/cards/checkbox/checkbox.types.js +7 -0
- package/cards/checkbox/checkbox.types.js.map +1 -0
- package/cards/checkbox/index.d.ts +1 -0
- package/cards/checkbox/index.js +13 -0
- package/cards/checkbox/index.js.map +1 -0
- package/cards/conditional/conditional.component.d.ts +11 -0
- package/cards/conditional/conditional.component.js +15 -0
- package/cards/conditional/conditional.component.js.map +1 -0
- package/cards/conditional/conditional.types.d.ts +29 -0
- package/cards/conditional/conditional.types.js +7 -0
- package/cards/conditional/conditional.types.js.map +1 -0
- package/cards/conditional/index.d.ts +1 -0
- package/cards/conditional/index.js +12 -0
- package/cards/conditional/index.js.map +1 -0
- package/cards/core-index.d.ts +30 -0
- package/cards/core-index.js +61 -0
- package/cards/dataTable/dataTable.component.d.ts +4 -0
- package/cards/dataTable/dataTable.component.js +209 -0
- package/cards/dataTable/dataTable.component.js.map +1 -0
- package/cards/dataTable/dataTable.types.d.ts +196 -0
- package/cards/dataTable/dataTable.types.js +13 -0
- package/cards/dataTable/dataTable.types.js.map +1 -0
- package/cards/dataTable/dataTableRowDetail.component.d.ts +26 -0
- package/cards/dataTable/dataTableRowDetail.component.js +47 -0
- package/cards/dataTable/dataTableRowDetail.component.js.map +1 -0
- package/cards/dataTable/index.d.ts +1 -0
- package/cards/dataTable/index.js +16 -0
- package/cards/dataTable/index.js.map +1 -0
- package/cards/dialog/dialog.component.d.ts +4 -0
- package/cards/dialog/dialog.component.js +89 -0
- package/cards/dialog/dialog.component.js.map +1 -0
- package/cards/dialog/dialog.types.d.ts +115 -0
- package/cards/dialog/dialog.types.js +11 -0
- package/cards/dialog/dialog.types.js.map +1 -0
- package/cards/dialog/index.d.ts +1 -0
- package/cards/dialog/index.js +13 -0
- package/cards/dialog/index.js.map +1 -0
- package/cards/dropDownMenu/drop-down.component.d.ts +4 -0
- package/cards/dropDownMenu/drop-down.component.js +205 -0
- package/cards/dropDownMenu/drop-down.component.js.map +1 -0
- package/cards/dropDownMenu/drop-down.types.d.ts +131 -0
- package/cards/dropDownMenu/drop-down.types.js +7 -0
- package/cards/dropDownMenu/drop-down.types.js.map +1 -0
- package/cards/dropDownMenu/dropdown-context.d.ts +7 -0
- package/cards/dropDownMenu/dropdown-context.js +7 -0
- package/cards/dropDownMenu/dropdown-context.js.map +1 -0
- package/cards/dropDownMenu/dropdown-menu.ui.d.ts +42 -0
- package/cards/dropDownMenu/dropdown-menu.ui.js +111 -0
- package/cards/dropDownMenu/dropdown-menu.ui.js.map +1 -0
- package/cards/dropDownMenu/index.d.ts +1 -0
- package/cards/dropDownMenu/index.js +13 -0
- package/cards/dropDownMenu/index.js.map +1 -0
- package/cards/emptyCard.d.ts +7 -0
- package/cards/field/field.component.d.ts +4 -0
- package/cards/field/field.component.js +38 -0
- package/cards/field/field.component.js.map +1 -0
- package/cards/field/field.types.d.ts +30 -0
- package/cards/field/field.types.js +7 -0
- package/cards/field/field.types.js.map +1 -0
- package/cards/field/index.d.ts +1 -0
- package/cards/field/index.js +12 -0
- package/cards/field/index.js.map +1 -0
- package/cards/flexGrid/flexGrid.component.d.ts +4 -0
- package/cards/flexGrid/flexGrid.component.js +40 -0
- package/cards/flexGrid/flexGrid.component.js.map +1 -0
- package/cards/flexGrid/flexGrid.types.d.ts +23 -0
- package/cards/flexGrid/flexGrid.types.js +7 -0
- package/cards/flexGrid/flexGrid.types.js.map +1 -0
- package/cards/flexGrid/index.d.ts +1 -0
- package/cards/flexGrid/index.js +12 -0
- package/cards/flexGrid/index.js.map +1 -0
- package/cards/form/form.component.d.ts +4 -0
- package/cards/form/form.component.js +64 -0
- package/cards/form/form.component.js.map +1 -0
- package/cards/form/form.context.d.ts +23 -0
- package/cards/form/form.context.js +13 -0
- package/cards/form/form.context.js.map +1 -0
- package/cards/form/form.types.d.ts +43 -0
- package/cards/form/form.types.js +7 -0
- package/cards/form/form.types.js.map +1 -0
- package/cards/form/index.d.ts +2 -0
- package/cards/form/index.js +14 -0
- package/cards/form/index.js.map +1 -0
- package/cards/framework/framework.component.d.ts +3 -0
- package/cards/framework/framework.component.js +21 -0
- package/cards/framework/framework.component.js.map +1 -0
- package/cards/framework/index.d.ts +2 -0
- package/cards/framework/index.js +12 -0
- package/cards/framework/index.js.map +1 -0
- package/cards/graphin/graphin.component.d.ts +4 -0
- package/cards/graphin/graphin.types.d.ts +18 -0
- package/cards/graphin/index.d.ts +2 -0
- package/cards/graphin/tooltip.component.d.ts +10 -0
- package/cards/icons.d.ts +15 -0
- package/cards/icons.js +15 -0
- package/cards/icons.js.map +1 -0
- package/cards/input/index.d.ts +1 -0
- package/cards/input/index.js +13 -0
- package/cards/input/index.js.map +1 -0
- package/cards/input/input.component.d.ts +4 -0
- package/cards/input/input.component.js +69 -0
- package/cards/input/input.component.js.map +1 -0
- package/cards/input/input.types.d.ts +80 -0
- package/cards/input/input.types.js +7 -0
- package/cards/input/input.types.js.map +1 -0
- package/cards/jsonViewer/index.d.ts +1 -0
- package/cards/jsonViewer/jsonViewer.component.d.ts +4 -0
- package/cards/jsonViewer/jsonViewer.types.d.ts +76 -0
- package/cards/list/index.d.ts +1 -0
- package/cards/list/index.js +13 -0
- package/cards/list/index.js.map +1 -0
- package/cards/list/list.component.d.ts +4 -0
- package/cards/list/list.component.js +102 -0
- package/cards/list/list.component.js.map +1 -0
- package/cards/list/list.types.d.ts +65 -0
- package/cards/list/list.types.js +7 -0
- package/cards/list/list.types.js.map +1 -0
- package/cards/loadingOverlay/index.d.ts +1 -0
- package/cards/loadingOverlay/index.js +12 -0
- package/cards/loadingOverlay/index.js.map +1 -0
- package/cards/loadingOverlay/loadingOverlay.component.d.ts +4 -0
- package/cards/loadingOverlay/loadingOverlay.component.js +31 -0
- package/cards/loadingOverlay/loadingOverlay.component.js.map +1 -0
- package/cards/loadingOverlay/loadingOverlay.types.d.ts +13 -0
- package/cards/loadingOverlay/loadingOverlay.types.js +7 -0
- package/cards/loadingOverlay/loadingOverlay.types.js.map +1 -0
- package/cards/loadingSkeleton/index.d.ts +1 -0
- package/cards/loadingSkeleton/index.js +12 -0
- package/cards/loadingSkeleton/index.js.map +1 -0
- package/cards/loadingSkeleton/loading-skeleton.component.d.ts +19 -0
- package/cards/loadingSkeleton/loading-skeleton.component.js +33 -0
- package/cards/loadingSkeleton/loading-skeleton.component.js.map +1 -0
- package/cards/loadingSkeleton/loading-skeleton.types.d.ts +94 -0
- package/cards/loadingSkeleton/loading-skeleton.types.js +7 -0
- package/cards/loadingSkeleton/loading-skeleton.types.js.map +1 -0
- package/cards/markdownViewer/index.d.ts +1 -0
- package/cards/markdownViewer/markdownViewer.component.d.ts +4 -0
- package/cards/markdownViewer/markdownViewer.types.d.ts +28 -0
- package/cards/menu/index.d.ts +1 -0
- package/cards/menu/index.js +13 -0
- package/cards/menu/index.js.map +1 -0
- package/cards/menu/menu.component.d.ts +4 -0
- package/cards/menu/menu.component.js +23 -0
- package/cards/menu/menu.component.js.map +1 -0
- package/cards/menu/menu.types.d.ts +53 -0
- package/cards/menu/menu.types.js +7 -0
- package/cards/menu/menu.types.js.map +1 -0
- package/cards/modeToggle/index.d.ts +1 -0
- package/cards/modeToggle/index.js +13 -0
- package/cards/modeToggle/index.js.map +1 -0
- package/cards/modeToggle/mode-toggle.component.d.ts +4 -0
- package/cards/modeToggle/mode-toggle.component.js +32 -0
- package/cards/modeToggle/mode-toggle.component.js.map +1 -0
- package/cards/modeToggle/mode-toggle.types.d.ts +20 -0
- package/cards/modeToggle/mode-toggle.types.js +7 -0
- package/cards/modeToggle/mode-toggle.types.js.map +1 -0
- package/cards/navbarSearch/index.d.ts +1 -0
- package/cards/navbarSearch/index.js +13 -0
- package/cards/navbarSearch/index.js.map +1 -0
- package/cards/navbarSearch/navbarSearch.component.d.ts +3 -0
- package/cards/navbarSearch/navbarSearch.component.js +88 -0
- package/cards/navbarSearch/navbarSearch.component.js.map +1 -0
- package/cards/navbarSearch/navbarSearch.type.d.ts +32 -0
- package/cards/navbarSearch/navbarSearch.type.js +11 -0
- package/cards/navbarSearch/navbarSearch.type.js.map +1 -0
- package/cards/pageWithNavbar/index.d.ts +2 -0
- package/cards/pageWithNavbar/index.js +14 -0
- package/cards/pageWithNavbar/index.js.map +1 -0
- package/cards/pageWithNavbar/pageWithNavbar.component.d.ts +12 -0
- package/cards/pageWithNavbar/pageWithNavbar.component.js +153 -0
- package/cards/pageWithNavbar/pageWithNavbar.component.js.map +1 -0
- package/cards/pageWithNavbar/pageWithNavbar.type.d.ts +81 -0
- package/cards/pageWithNavbar/pageWithNavbar.type.js +7 -0
- package/cards/pageWithNavbar/pageWithNavbar.type.js.map +1 -0
- package/cards/pasteTarget/index.d.ts +1 -0
- package/cards/pasteTarget/index.js +13 -0
- package/cards/pasteTarget/index.js.map +1 -0
- package/cards/pasteTarget/pasteTarget.component.d.ts +4 -0
- package/cards/pasteTarget/pasteTarget.component.js +158 -0
- package/cards/pasteTarget/pasteTarget.component.js.map +1 -0
- package/cards/pasteTarget/pasteTarget.types.d.ts +46 -0
- package/cards/pasteTarget/pasteTarget.types.js +11 -0
- package/cards/pasteTarget/pasteTarget.types.js.map +1 -0
- package/cards/resizable/index.d.ts +1 -0
- package/cards/resizable/resizable.component.d.ts +4 -0
- package/cards/resizable/resizable.types.d.ts +49 -0
- package/cards/select/index.d.ts +1 -0
- package/cards/select/index.js +13 -0
- package/cards/select/index.js.map +1 -0
- package/cards/select/select.component.d.ts +4 -0
- package/cards/select/select.component.js +41 -0
- package/cards/select/select.component.js.map +1 -0
- package/cards/select/select.types.d.ts +73 -0
- package/cards/select/select.types.js +11 -0
- package/cards/select/select.types.js.map +1 -0
- package/cards/stack/index.d.ts +1 -0
- package/cards/stack/index.js +12 -0
- package/cards/stack/index.js.map +1 -0
- package/cards/stack/stack.component.d.ts +7 -0
- package/cards/stack/stack.component.js +83 -0
- package/cards/stack/stack.component.js.map +1 -0
- package/cards/stack/stack.types.d.ts +47 -0
- package/cards/stack/stack.types.js +7 -0
- package/cards/stack/stack.types.js.map +1 -0
- package/cards/stepper/index.d.ts +1 -0
- package/cards/stepper/index.js +13 -0
- package/cards/stepper/index.js.map +1 -0
- package/cards/stepper/stepper.component.d.ts +4 -0
- package/cards/stepper/stepper.component.js +48 -0
- package/cards/stepper/stepper.component.js.map +1 -0
- package/cards/stepper/stepper.types.d.ts +96 -0
- package/cards/stepper/stepper.types.js +7 -0
- package/cards/stepper/stepper.types.js.map +1 -0
- package/cards/switch/index.d.ts +1 -0
- package/cards/switch/index.js +13 -0
- package/cards/switch/index.js.map +1 -0
- package/cards/switch/switch.component.d.ts +4 -0
- package/cards/switch/switch.component.js +34 -0
- package/cards/switch/switch.component.js.map +1 -0
- package/cards/switch/switch.types.d.ts +39 -0
- package/cards/switch/switch.types.js +7 -0
- package/cards/switch/switch.types.js.map +1 -0
- package/cards/tabs/index.d.ts +1 -0
- package/cards/tabs/index.js +13 -0
- package/cards/tabs/index.js.map +1 -0
- package/cards/tabs/tabs.component.d.ts +4 -0
- package/cards/tabs/tabs.component.js +42 -0
- package/cards/tabs/tabs.component.js.map +1 -0
- package/cards/tabs/tabs.types.d.ts +72 -0
- package/cards/tabs/tabs.types.js +7 -0
- package/cards/tabs/tabs.types.js.map +1 -0
- package/cards/textField/index.d.ts +1 -0
- package/cards/textField/index.js +13 -0
- package/cards/textField/index.js.map +1 -0
- package/cards/textField/textField.component.d.ts +4 -0
- package/cards/textField/textField.component.js +29 -0
- package/cards/textField/textField.component.js.map +1 -0
- package/cards/textField/textField.types.d.ts +36 -0
- package/cards/textField/textField.types.js +7 -0
- package/cards/textField/textField.types.js.map +1 -0
- package/cards/toast/index.d.ts +1 -0
- package/cards/toast/index.js +13 -0
- package/cards/toast/index.js.map +1 -0
- package/cards/toast/toast.component.d.ts +4 -0
- package/cards/toast/toast.component.js +76 -0
- package/cards/toast/toast.component.js.map +1 -0
- package/cards/toast/toast.types.d.ts +100 -0
- package/cards/toast/toast.types.js +12 -0
- package/cards/toast/toast.types.js.map +1 -0
- package/cards/toggleGroup/index.d.ts +1 -0
- package/cards/toggleGroup/index.js +13 -0
- package/cards/toggleGroup/index.js.map +1 -0
- package/cards/toggleGroup/toggleGroup.component.d.ts +4 -0
- package/cards/toggleGroup/toggleGroup.component.js +55 -0
- package/cards/toggleGroup/toggleGroup.component.js.map +1 -0
- package/cards/toggleGroup/toggleGroup.types.d.ts +96 -0
- package/cards/toggleGroup/toggleGroup.types.js +7 -0
- package/cards/toggleGroup/toggleGroup.types.js.map +1 -0
- package/cards/types.d.ts +72 -0
- package/cards/types.js +22 -0
- package/cards/types.js.map +1 -0
- package/cards/typography/index.d.ts +1 -0
- package/cards/typography/index.js +12 -0
- package/cards/typography/index.js.map +1 -0
- package/cards/typography/typography.component.d.ts +4 -0
- package/cards/typography/typography.component.js +44 -0
- package/cards/typography/typography.component.js.map +1 -0
- package/cards/typography/typography.types.d.ts +23 -0
- package/cards/typography/typography.types.js +7 -0
- package/cards/typography/typography.types.js.map +1 -0
- package/components/hooks/use-is-touch-device.d.ts +1 -0
- package/components/lib/utils.js +10 -0
- package/components/lib/utils.js.map +1 -0
- package/components/theme-provider/index.d.ts +4 -0
- package/components/theme-provider/index.js +12 -0
- package/components/theme-provider/index.js.map +1 -0
- package/components/theme-provider/theme-provider.component.d.ts +2 -0
- package/components/theme-provider/theme-provider.component.js +31 -0
- package/components/theme-provider/theme-provider.component.js.map +1 -0
- package/components/theme-provider/theme-provider.types.d.ts +12 -0
- package/components/theme-provider/theme-provider.types.js +9 -0
- package/components/theme-provider/theme-provider.types.js.map +1 -0
- package/components/ui/avatar.js +30 -0
- package/components/ui/avatar.js.map +1 -0
- package/components/ui/badge.js +26 -0
- package/components/ui/badge.js.map +1 -0
- package/components/ui/button.js +98 -0
- package/components/ui/button.js.map +1 -0
- package/components/ui/dialog.js +109 -0
- package/components/ui/dialog.js.map +1 -0
- package/components/ui/field.js +68 -0
- package/components/ui/field.js.map +1 -0
- package/components/ui/input.js +16 -0
- package/components/ui/input.js.map +1 -0
- package/components/ui/label.js +16 -0
- package/components/ui/label.js.map +1 -0
- package/components/ui/menubar.js +62 -0
- package/components/ui/menubar.js.map +1 -0
- package/components/ui/select.js +84 -0
- package/components/ui/select.js.map +1 -0
- package/components/ui/separator.js +5 -0
- package/components/ui/sheet.js +49 -0
- package/components/ui/sheet.js.map +1 -0
- package/components/ui/spinner.js +35 -0
- package/components/ui/spinner.js.map +1 -0
- package/components/ui/stepper.js +145 -0
- package/components/ui/stepper.js.map +1 -0
- package/components/ui/switch.js +20 -0
- package/components/ui/switch.js.map +1 -0
- package/components/ui/table.js +61 -0
- package/components/ui/table.js.map +1 -0
- package/components/ui/tabs.js +38 -0
- package/components/ui/tabs.js.map +1 -0
- package/components/ui/toggle-group.js +50 -0
- package/components/ui/toggle-group.js.map +1 -0
- package/components/ui/toggle.js +27 -0
- package/components/ui/toggle.js.map +1 -0
- package/components/ui/tooltip.js +38 -0
- package/components/ui/tooltip.js.map +1 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.js +10 -0
- package/lib/utils.js.map +1 -0
- package/mountain-snow.svg +4 -0
- package/package.json +203 -0
- package/pihanga-shadcn.css +2 -0
- package/r/badge.json +35 -0
- package/r/box.json +26 -0
- package/r/button.json +39 -0
- package/r/checkbox.json +31 -0
- package/r/conditional.json +30 -0
- package/r/dataTable.json +43 -0
- package/r/dialog.json +36 -0
- package/r/dropDownMenu.json +47 -0
- package/r/field.json +35 -0
- package/r/flexGrid.json +32 -0
- package/r/form.json +37 -0
- package/r/framework.json +28 -0
- package/r/graphin.json +42 -0
- package/r/input.json +35 -0
- package/r/jsonViewer.json +40 -0
- package/r/list.json +39 -0
- package/r/loadingOverlay.json +39 -0
- package/r/loadingSkeleton.json +30 -0
- package/r/markdownViewer.json +51 -0
- package/r/menu.json +34 -0
- package/r/modeToggle.json +36 -0
- package/r/navbarSearch.json +31 -0
- package/r/pageWithNavbar.json +46 -0
- package/r/pasteTarget.json +41 -0
- package/r/pihanga-base.json +11 -0
- package/r/pihanga-cards-icons.json +16 -0
- package/r/pihanga-cards-types.json +16 -0
- package/r/pihanga-hook-use-is-touch-device.json +15 -0
- package/r/pihanga-lib-utils.json +18 -0
- package/r/pihanga-theme-provider.json +25 -0
- package/r/pihanga-ui-extras.json +68 -0
- package/r/registry.json +171 -0
- package/r/resizable.json +35 -0
- package/r/select.json +35 -0
- package/r/stack.json +27 -0
- package/r/stepper.json +39 -0
- package/r/switch.json +36 -0
- package/r/tabs.json +33 -0
- package/r/textField.json +32 -0
- package/r/toast.json +32 -0
- package/r/toggleGroup.json +35 -0
- package/r/typography.json +31 -0
|
@@ -0,0 +1,13 @@
|
|
|
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 a, registerCardComponent as o } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/switch/index.ts
|
|
5
|
+
o({
|
|
6
|
+
name: n,
|
|
7
|
+
component: e,
|
|
8
|
+
events: a(t)
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as PI_SWITCH_ACTION, n as PI_SWITCH_CARD, r as Switch, i as onPiSwitchChanged };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/switch/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {SwitchComponent} from \"./switch.component\";\nimport {PI_SWITCH_ACTION, PI_SWITCH_CARD} from \"./switch.types\";\n\nexport * from \"./switch.types\";\n\nregisterCardComponent({\n name: PI_SWITCH_CARD,\n component: SwitchComponent,\n events: actionTypesToEvents(PI_SWITCH_ACTION),\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAgB;AAC9C,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useFormContext as e } from "../form/form.context.js";
|
|
2
|
+
import { Label as t } from "../../components/ui/label.js";
|
|
3
|
+
import { Switch as n } from "../../components/ui/switch.js";
|
|
4
|
+
import "react";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
|
+
//#region src/cards/switch/switch.component.tsx
|
|
7
|
+
var a = (a) => {
|
|
8
|
+
let { name: o, checked: s = !1, disabled: c, label: l, className: u, cardName: d, onChanged: f } = a, p = a.id, m = e(), h = m.isInForm && !!o, g = h ? !!(m.formData[o] ?? !1) : s;
|
|
9
|
+
function _(e) {
|
|
10
|
+
h ? m.handleChange(o, e) : f({
|
|
11
|
+
name: o,
|
|
12
|
+
checked: e
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
let v = `${d}-${o ?? "switch"}`, y = p ?? v;
|
|
16
|
+
return /* @__PURE__ */ i("div", {
|
|
17
|
+
"data-pihanga": d,
|
|
18
|
+
className: `flex items-center gap-2 ${u ?? ""}`,
|
|
19
|
+
children: [/* @__PURE__ */ r(n, {
|
|
20
|
+
id: y,
|
|
21
|
+
checked: g,
|
|
22
|
+
onCheckedChange: _,
|
|
23
|
+
disabled: c
|
|
24
|
+
}), l && /* @__PURE__ */ r(t, {
|
|
25
|
+
htmlFor: y,
|
|
26
|
+
className: "cursor-pointer select-none",
|
|
27
|
+
children: l
|
|
28
|
+
})]
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { a as SwitchComponent };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=switch.component.js.map
|
|
@@ -0,0 +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":";;;;;;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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const PI_SWITCH_CARD = "pi/switch";
|
|
2
|
+
export declare const Switch: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<PiSwitchProps, S, PiSwitchEvents>) => import('@pihanga2/core').PiCardDef;
|
|
3
|
+
export declare const PI_SWITCH_ACTION: {
|
|
4
|
+
CHANGED: string;
|
|
5
|
+
};
|
|
6
|
+
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
|
+
cardID: string;
|
|
8
|
+
} & PiSwitchChangedEvent>) => void;
|
|
9
|
+
export type PiSwitchProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Field name used to bind to FormContext when inside a pi/form card.
|
|
12
|
+
* When provided the component reads its checked state from form data and
|
|
13
|
+
* writes back via form.handleChange.
|
|
14
|
+
*/
|
|
15
|
+
name?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Controlled checked state used in standalone mode (outside a Form).
|
|
18
|
+
* Ignored when `name` is set and the component is inside a pi/form.
|
|
19
|
+
*/
|
|
20
|
+
checked?: boolean;
|
|
21
|
+
/** When true, the switch is disabled and non-interactive. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Optional label text rendered beside the switch.
|
|
25
|
+
* The label is automatically associated with the switch via `htmlFor`.
|
|
26
|
+
*/
|
|
27
|
+
label?: string;
|
|
28
|
+
/** Extra Tailwind / CSS classes forwarded to the root wrapper element. */
|
|
29
|
+
className?: string;
|
|
30
|
+
};
|
|
31
|
+
export type PiSwitchChangedEvent = {
|
|
32
|
+
/** Field name, mirrors the `name` prop if provided. */
|
|
33
|
+
name?: string;
|
|
34
|
+
/** New checked state after the toggle. */
|
|
35
|
+
checked: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type PiSwitchEvents = {
|
|
38
|
+
onChanged: PiSwitchChangedEvent;
|
|
39
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/switch/switch.types.ts
|
|
3
|
+
var r = "pi/switch", i = e(r), a = n(r, ["changed"]), o = t(a.CHANGED);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { a as PI_SWITCH_ACTION, r as PI_SWITCH_CARD, i as Switch, o as onPiSwitchChanged };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=switch.types.js.map
|
|
@@ -0,0 +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 onPiSwitchChanged = createOnAction<PiSwitchChangedEvent>(\n PI_SWITCH_ACTION.CHANGED,\n);\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,IAAoB,EAC/B,EAAiB,OACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tabs.types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TabsComponent as e } from "./tabs.component.js";
|
|
2
|
+
import { SdTabs as t, TABS_ACTION as n, TABS_CARD as r, onTabsTabChanged as i } from "./tabs.types.js";
|
|
3
|
+
import { registerCardComponent as a } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/tabs/index.ts
|
|
5
|
+
a({
|
|
6
|
+
name: r,
|
|
7
|
+
component: e,
|
|
8
|
+
events: { onTabChanged: n.TABCHANGED }
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as SdTabs, n as TABS_ACTION, r as TABS_CARD, i as onTabsTabChanged };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/tabs/index.ts"],"sourcesContent":["import {registerCardComponent} from \"@pihanga2/core\";\n\nimport {TabsComponent} from \"./tabs.component\";\nimport {TABS_ACTION, TABS_CARD} from \"./tabs.types\";\n\nexport * from \"./tabs.types\";\n\nregisterCardComponent({\n name: TABS_CARD,\n component: TabsComponent,\n // Explicit mapping avoids CamelCase normalisation issues:\n // TABCHANGED → onTabChanged (lowercase 'c' would break with actionTypesToEvents)\n events: {\n onTabChanged: TABS_ACTION.TABCHANGED,\n },\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;CAGX,QAAQ,EACN,cAAc,EAAY,WAC5B;AACF,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Tabs as e, TabsContent as t, TabsList as n, TabsTrigger as r } from "../../components/ui/tabs.js";
|
|
2
|
+
import { Card as i } from "@pihanga2/core";
|
|
3
|
+
import { useState as a } from "react";
|
|
4
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
+
//#region src/cards/tabs/tabs.component.tsx
|
|
6
|
+
var c = (c) => {
|
|
7
|
+
let { tabs: l, value: u, defaultValue: d, selfManaged: f = !1, orientation: p = "horizontal", className: m, listClassName: h, contentClassName: g, cardName: _, onTabChanged: v } = c, [y, b] = a(u ?? d ?? l[0]?.id ?? ""), x = f ? y : u ?? d ?? l[0]?.id ?? "";
|
|
8
|
+
function S(e) {
|
|
9
|
+
f && b(e), typeof v == "function" && v({ tabId: e });
|
|
10
|
+
}
|
|
11
|
+
return /* @__PURE__ */ o("div", {
|
|
12
|
+
"data-pihanga": _,
|
|
13
|
+
children: /* @__PURE__ */ s(e, {
|
|
14
|
+
value: x,
|
|
15
|
+
onValueChange: S,
|
|
16
|
+
orientation: p,
|
|
17
|
+
className: m,
|
|
18
|
+
children: [/* @__PURE__ */ o(n, {
|
|
19
|
+
className: h,
|
|
20
|
+
children: l.map((e) => /* @__PURE__ */ o(r, {
|
|
21
|
+
value: e.id,
|
|
22
|
+
disabled: e.disabled,
|
|
23
|
+
children: typeof e.title == "string" ? e.title : /* @__PURE__ */ o(i, {
|
|
24
|
+
cardName: e.title,
|
|
25
|
+
parentCard: _
|
|
26
|
+
})
|
|
27
|
+
}, e.id))
|
|
28
|
+
}), l.map((e) => /* @__PURE__ */ o(t, {
|
|
29
|
+
value: e.id,
|
|
30
|
+
className: g,
|
|
31
|
+
children: /* @__PURE__ */ o(i, {
|
|
32
|
+
cardName: e.contentCard,
|
|
33
|
+
parentCard: _
|
|
34
|
+
})
|
|
35
|
+
}, e.id))]
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
export { c as TabsComponent };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=tabs.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.component.js","names":[],"sources":["../../../src/cards/tabs/tabs.component.tsx"],"sourcesContent":["import React, {useState} from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\nimport {Tabs, TabsContent, TabsList, TabsTrigger} from \"@/components/ui/tabs\";\nimport type {TabsEvents, TabsProps} from \"./tabs.types\";\n\nexport const TabsComponent = (\n props: PiCardProps<TabsProps, TabsEvents>,\n): React.ReactNode => {\n const {\n tabs,\n value: propValue,\n defaultValue,\n selfManaged = false,\n orientation = \"horizontal\",\n className,\n listClassName,\n contentClassName,\n cardName,\n onTabChanged,\n } = props;\n\n // Resolve the initial value for self-managed mode:\n // prefer propValue, then defaultValue, then first tab's id.\n const initialValue = propValue ?? defaultValue ?? tabs[0]?.id ?? \"\";\n\n // Internal state used only when selfManaged=true.\n const [managedValue, setManagedValue] = useState<string>(initialValue);\n\n // Effective active tab:\n // selfManaged → use internal state\n // controlled → use the prop (fall back to first tab if not set)\n const activeValue = selfManaged\n ? managedValue\n : (propValue ?? defaultValue ?? tabs[0]?.id ?? \"\");\n\n function handleValueChange(tabId: string) {\n if (selfManaged) {\n setManagedValue(tabId);\n }\n // Always dispatch the Pihanga event so reducers can observe the change\n // even in self-managed mode.\n if (typeof onTabChanged === \"function\") {\n onTabChanged({tabId});\n }\n }\n\n return (\n <div data-pihanga={cardName}>\n <Tabs\n value={activeValue}\n onValueChange={handleValueChange}\n orientation={orientation}\n className={className}\n >\n <TabsList className={listClassName}>\n {tabs.map((tab) => (\n <TabsTrigger key={tab.id} value={tab.id} disabled={tab.disabled}>\n {typeof tab.title !== \"string\" ? (\n <Card cardName={tab.title} parentCard={cardName} />\n ) : (\n tab.title\n )}\n </TabsTrigger>\n ))}\n </TabsList>\n\n {tabs.map((tab) => (\n <TabsContent key={tab.id} value={tab.id} className={contentClassName}>\n <Card cardName={tab.contentCard} parentCard={cardName} />\n </TabsContent>\n ))}\n </Tabs>\n </div>\n );\n};\n"],"mappings":";;;;;AAKA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,SACA,OAAO,GACP,iBACA,iBAAc,IACd,iBAAc,cACd,cACA,kBACA,qBACA,aACA,oBACE,GAOE,CAAC,GAAc,KAAmB,EAHnB,KAAa,KAAgB,EAAK,IAAI,MAAM,EAGI,GAK/D,IAAc,IAChB,IACC,KAAa,KAAgB,EAAK,IAAI,MAAM;CAEjD,SAAS,EAAkB,GAAe;EAMxC,AALI,KACF,EAAgB,CAAK,GAInB,OAAO,KAAiB,cAC1B,EAAa,EAAC,SAAK,CAAC;CAExB;CAEA,OACE,kBAAC,OAAD;EAAK,gBAAc;YACjB,kBAAC,GAAD;GACE,OAAO;GACP,eAAe;GACF;GACF;aAJb,CAME,kBAAC,GAAD;IAAU,WAAW;cAClB,EAAK,KAAK,MACT,kBAAC,GAAD;KAA0B,OAAO,EAAI;KAAI,UAAU,EAAI;eACpD,OAAO,EAAI,SAAU,WAGpB,EAAI,QAFJ,kBAAC,GAAD;MAAM,UAAU,EAAI;MAAO,YAAY;KAAW,CAAA;IAIzC,GANK,EAAI,EAMT,CACd;GACO,CAAA,GAET,EAAK,KAAK,MACT,kBAAC,GAAD;IAA0B,OAAO,EAAI;IAAI,WAAW;cAClD,kBAAC,GAAD;KAAM,UAAU,EAAI;KAAa,YAAY;IAAW,CAAA;GAC7C,GAFK,EAAI,EAET,CACd,CACG;;CACH,CAAA;AAET"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { PiCardRef } from '@pihanga2/core';
|
|
2
|
+
export declare const TABS_CARD = "shad/tabs";
|
|
3
|
+
export declare const SdTabs: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<TabsProps, S, TabsEvents>) => import('@pihanga2/core').PiCardDef;
|
|
4
|
+
export declare const TABS_ACTION: {
|
|
5
|
+
TABCHANGED: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const onTabsTabChanged: <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
|
+
} & TabsTabChangedEvent>) => void;
|
|
10
|
+
/**
|
|
11
|
+
* A single tab entry in the tabs component.
|
|
12
|
+
*/
|
|
13
|
+
export type TabItem = {
|
|
14
|
+
/** Unique identifier used for controlled value and events. */
|
|
15
|
+
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* The label displayed on the tab trigger.
|
|
18
|
+
* Can be a plain string or a PiCardRef for custom/rich tab labels.
|
|
19
|
+
*/
|
|
20
|
+
title: string | PiCardRef;
|
|
21
|
+
/**
|
|
22
|
+
* The Pihanga card rendered as the body of this tab when it is active.
|
|
23
|
+
*/
|
|
24
|
+
contentCard: PiCardRef;
|
|
25
|
+
/** When true the tab trigger is rendered as disabled. */
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type TabsProps = {
|
|
29
|
+
/** Ordered list of tab definitions. */
|
|
30
|
+
tabs: TabItem[];
|
|
31
|
+
/**
|
|
32
|
+
* Controlled: the currently active tab id.
|
|
33
|
+
* Must be provided (or supplied via a state mapper) when selfManaged is
|
|
34
|
+
* false (the default).
|
|
35
|
+
*/
|
|
36
|
+
value?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Uncontrolled initial active tab id.
|
|
39
|
+
* Used as the initial value in self-managed mode when value is not set;
|
|
40
|
+
* falls back to the first tab id if omitted.
|
|
41
|
+
*/
|
|
42
|
+
defaultValue?: string;
|
|
43
|
+
/**
|
|
44
|
+
* When true, the component manages its own active tab state internally.
|
|
45
|
+
* The onTabChanged event is still dispatched on every change so external
|
|
46
|
+
* reducers can observe the selection.
|
|
47
|
+
*
|
|
48
|
+
* When false (default), value fully controls the displayed tab.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
selfManaged?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Layout orientation of the tab list.
|
|
54
|
+
* Passed directly to the Radix Tabs primitive.
|
|
55
|
+
* @default "horizontal"
|
|
56
|
+
*/
|
|
57
|
+
orientation?: "horizontal" | "vertical";
|
|
58
|
+
/** Additional Tailwind/CSS classes applied to the root Tabs element. */
|
|
59
|
+
className?: string;
|
|
60
|
+
/** Additional classes applied to the TabsList element. */
|
|
61
|
+
listClassName?: string;
|
|
62
|
+
/** Additional classes applied to each TabsContent element. */
|
|
63
|
+
contentClassName?: string;
|
|
64
|
+
};
|
|
65
|
+
export type TabsTabChangedEvent = {
|
|
66
|
+
/** The id of the newly selected tab. */
|
|
67
|
+
tabId: string;
|
|
68
|
+
};
|
|
69
|
+
export type TabsEvents = {
|
|
70
|
+
/** Fired whenever the user selects a different tab. */
|
|
71
|
+
onTabChanged: TabsTabChangedEvent;
|
|
72
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/tabs/tabs.types.ts
|
|
3
|
+
var r = "shad/tabs", i = e(r), a = n(r, ["tabChanged"]), o = t(a.TABCHANGED);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { i as SdTabs, a as TABS_ACTION, r as TABS_CARD, o as onTabsTabChanged };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=tabs.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.types.js","names":[],"sources":["../../../src/cards/tabs/tabs.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n type PiCardRef,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const TABS_CARD = \"shad/tabs\";\n\nexport const SdTabs = createCardDeclaration<TabsProps, TabsEvents>(TABS_CARD);\n\nexport const TABS_ACTION = registerActions(TABS_CARD, [\"tabChanged\"]);\n\nexport const onTabsTabChanged = createOnAction<TabsTabChangedEvent>(\n TABS_ACTION.TABCHANGED,\n);\n\n// ─── Tab item definition ──────────────────────────────────────────────────────\n\n/**\n * A single tab entry in the tabs component.\n */\nexport type TabItem = {\n /** Unique identifier used for controlled value and events. */\n id: string;\n\n /**\n * The label displayed on the tab trigger.\n * Can be a plain string or a PiCardRef for custom/rich tab labels.\n */\n title: string | PiCardRef;\n\n /**\n * The Pihanga card rendered as the body of this tab when it is active.\n */\n contentCard: PiCardRef;\n\n /** When true the tab trigger is rendered as disabled. */\n disabled?: boolean;\n};\n\n// ─── Card props ───────────────────────────────────────────────────────────────\n\nexport type TabsProps = {\n /** Ordered list of tab definitions. */\n tabs: TabItem[];\n\n /**\n * Controlled: the currently active tab id.\n * Must be provided (or supplied via a state mapper) when selfManaged is\n * false (the default).\n */\n value?: string;\n\n /**\n * Uncontrolled initial active tab id.\n * Used as the initial value in self-managed mode when value is not set;\n * falls back to the first tab id if omitted.\n */\n defaultValue?: string;\n\n /**\n * When true, the component manages its own active tab state internally.\n * The onTabChanged event is still dispatched on every change so external\n * reducers can observe the selection.\n *\n * When false (default), value fully controls the displayed tab.\n * @default false\n */\n selfManaged?: boolean;\n\n /**\n * Layout orientation of the tab list.\n * Passed directly to the Radix Tabs primitive.\n * @default \"horizontal\"\n */\n orientation?: \"horizontal\" | \"vertical\";\n\n /** Additional Tailwind/CSS classes applied to the root Tabs element. */\n className?: string;\n\n /** Additional classes applied to the TabsList element. */\n listClassName?: string;\n\n /** Additional classes applied to each TabsContent element. */\n contentClassName?: string;\n};\n\n// ─── Events ───────────────────────────────────────────────────────────────────\n\nexport type TabsTabChangedEvent = {\n /** The id of the newly selected tab. */\n tabId: string;\n};\n\nexport type TabsEvents = {\n /** Fired whenever the user selects a different tab. */\n onTabChanged: TabsTabChangedEvent;\n};\n"],"mappings":";;AAOA,IAAa,IAAY,aAEZ,IAAS,EAA6C,CAAS,GAE/D,IAAc,EAAgB,GAAW,CAAC,YAAY,CAAC,GAEvD,IAAmB,EAC9B,EAAY,UACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './textField.types';
|
|
@@ -0,0 +1,13 @@
|
|
|
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 a, registerCardComponent as o } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/textField/index.ts
|
|
5
|
+
o({
|
|
6
|
+
name: n,
|
|
7
|
+
component: e,
|
|
8
|
+
events: a(t)
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as PI_TEXT_FIELD_ACTION, n as PI_TEXT_FIELD_CARD, r as TextField, i as onPiTextFieldChanged };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/textField/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {TextFieldComponent} from \"./textField.component\";\nimport {PI_TEXT_FIELD_ACTION, PI_TEXT_FIELD_CARD} from \"./textField.types\";\n\nexport * from \"./textField.types\";\n\nregisterCardComponent({\n name: PI_TEXT_FIELD_CARD,\n component: TextFieldComponent,\n events: actionTypesToEvents(PI_TEXT_FIELD_ACTION),\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAoB;AAClD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { PiCardProps } from '@pihanga2/core';
|
|
3
|
+
import { PiTextFieldEvents, PiTextFieldProps } from './textField.types';
|
|
4
|
+
export declare const TextFieldComponent: (props: PiCardProps<PiTextFieldProps, PiTextFieldEvents>) => React.ReactNode;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useFormContext as e } from "../form/form.context.js";
|
|
2
|
+
import { Input as t } from "../../components/ui/input.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
//#region src/cards/textField/textField.component.tsx
|
|
6
|
+
var r = (r) => {
|
|
7
|
+
let { name: i, value: a = "", type: o = "text", placeholder: s, disabled: c, cardName: l, onChanged: u } = r, d = r.id, f = !!r.invalid, p = e(), m = p.isInForm && !!i, h = m ? p.formData[i] ?? "" : a;
|
|
8
|
+
function g(e) {
|
|
9
|
+
let t = e.target.value;
|
|
10
|
+
m ? p.handleChange(i, t) : u({
|
|
11
|
+
name: i,
|
|
12
|
+
value: t
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
let _ = `${l}-${i ?? "field"}`;
|
|
16
|
+
return /* @__PURE__ */ n(t, {
|
|
17
|
+
id: d ?? _,
|
|
18
|
+
type: o,
|
|
19
|
+
value: h,
|
|
20
|
+
onChange: g,
|
|
21
|
+
placeholder: s,
|
|
22
|
+
disabled: c,
|
|
23
|
+
"aria-invalid": f || void 0
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { r as TextFieldComponent };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=textField.component.js.map
|
|
@@ -0,0 +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":";;;;;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"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare const PI_TEXT_FIELD_CARD = "pi/text-field";
|
|
2
|
+
export declare const TextField: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<PiTextFieldProps, S, PiTextFieldEvents>) => import('@pihanga2/core').PiCardDef;
|
|
3
|
+
export declare const PI_TEXT_FIELD_ACTION: {
|
|
4
|
+
CHANGED: string;
|
|
5
|
+
};
|
|
6
|
+
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
|
+
cardID: string;
|
|
8
|
+
} & PiTextFieldChangedEvent>) => void;
|
|
9
|
+
export type PiTextFieldProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Field name used to bind to FormContext when inside a pi/form card.
|
|
12
|
+
* When provided the component reads its value from form state and writes
|
|
13
|
+
* back via form.handleChange.
|
|
14
|
+
*/
|
|
15
|
+
name?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Controlled value used in standalone mode (outside a Form).
|
|
18
|
+
* Ignored when `name` is set and the component is inside a pi/form.
|
|
19
|
+
*/
|
|
20
|
+
value?: string;
|
|
21
|
+
/** HTML input type (e.g. "text", "email", "password", "number"). */
|
|
22
|
+
type?: string;
|
|
23
|
+
/** Placeholder text shown when the input is empty. */
|
|
24
|
+
placeholder?: string;
|
|
25
|
+
/** When true, the input is disabled and non-interactive. */
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
};
|
|
28
|
+
export type PiTextFieldChangedEvent = {
|
|
29
|
+
/** Field name, mirrors the `name` prop if provided. */
|
|
30
|
+
name?: string;
|
|
31
|
+
/** New value after the change. */
|
|
32
|
+
value: string;
|
|
33
|
+
};
|
|
34
|
+
export type PiTextFieldEvents = {
|
|
35
|
+
onChanged: PiTextFieldChangedEvent;
|
|
36
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
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);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { a as PI_TEXT_FIELD_ACTION, r as PI_TEXT_FIELD_CARD, i as TextField, o as onPiTextFieldChanged };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=textField.types.js.map
|
|
@@ -0,0 +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 onPiTextFieldChanged = createOnAction<PiTextFieldChangedEvent>(\n PI_TEXT_FIELD_ACTION.CHANGED,\n);\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,IAAuB,EAClC,EAAqB,OACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './toast.types';
|
|
@@ -0,0 +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 s } from "./toast.component.js";
|
|
3
|
+
import { actionTypesToEvents as c, registerCardComponent as l } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/toast/index.ts
|
|
5
|
+
l({
|
|
6
|
+
name: t,
|
|
7
|
+
component: s,
|
|
8
|
+
events: c(e)
|
|
9
|
+
});
|
|
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 };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/toast/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {ToastComponent} from \"./toast.component\";\nimport {PI_TOAST_ACTION, PI_TOAST_CARD} from \"./toast.types\";\n\nexport * from \"./toast.types\";\n\nregisterCardComponent({\n name: PI_TOAST_CARD,\n component: ToastComponent,\n events: actionTypesToEvents(PI_TOAST_ACTION),\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAe;AAC7C,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { TOAST_OP_ACTION as e } from "./toast.types.js";
|
|
2
|
+
import { Card as t, usePiReducer as n } from "@pihanga2/core";
|
|
3
|
+
import { useEffect as r, useRef as i, useState as a } from "react";
|
|
4
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
5
|
+
import { toast as s } from "sonner";
|
|
6
|
+
//#region src/cards/toast/toast.component.tsx
|
|
7
|
+
var c = (c) => {
|
|
8
|
+
let { variant: l = "default", duration: u = 4e3, dismissible: d = !0, className: f, onClosed: p, cardName: m } = c, [h, g] = a(null);
|
|
9
|
+
n(e.SHOW, (e, t) => {
|
|
10
|
+
t.cardName && t.cardName !== m || g({
|
|
11
|
+
message: t.message,
|
|
12
|
+
description: t.description,
|
|
13
|
+
contentCard: t.contentCard,
|
|
14
|
+
variant: t.variant ?? l,
|
|
15
|
+
position: t.position,
|
|
16
|
+
duration: t.duration ?? u
|
|
17
|
+
});
|
|
18
|
+
}, m);
|
|
19
|
+
let _ = i(void 0);
|
|
20
|
+
return r(() => {
|
|
21
|
+
if (!h) return;
|
|
22
|
+
let e = {
|
|
23
|
+
success: s.success,
|
|
24
|
+
error: s.error,
|
|
25
|
+
info: s.info,
|
|
26
|
+
warning: s.warning,
|
|
27
|
+
default: s
|
|
28
|
+
}[h.variant] || s, n = [f, `toast-${h.variant}`].filter(Boolean).join(" ");
|
|
29
|
+
if (h.contentCard) {
|
|
30
|
+
let r = h.contentCard;
|
|
31
|
+
_.current = e(() => /* @__PURE__ */ o(t, {
|
|
32
|
+
cardName: r,
|
|
33
|
+
parentCard: m
|
|
34
|
+
}), {
|
|
35
|
+
duration: h.duration,
|
|
36
|
+
position: h.position || "bottom-right",
|
|
37
|
+
dismissible: d,
|
|
38
|
+
className: n,
|
|
39
|
+
onDismiss: () => {
|
|
40
|
+
g(null), p({});
|
|
41
|
+
},
|
|
42
|
+
onAutoClose: () => {
|
|
43
|
+
g(null), p({});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
} else _.current = e(h.message, {
|
|
47
|
+
description: h.description,
|
|
48
|
+
duration: h.duration,
|
|
49
|
+
position: h.position || "bottom-right",
|
|
50
|
+
dismissible: d,
|
|
51
|
+
className: n,
|
|
52
|
+
onDismiss: () => {
|
|
53
|
+
g(null), p({});
|
|
54
|
+
},
|
|
55
|
+
onAutoClose: () => {
|
|
56
|
+
g(null), p({});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return () => {
|
|
60
|
+
_.current !== void 0 && s.dismiss(_.current);
|
|
61
|
+
};
|
|
62
|
+
}, [
|
|
63
|
+
h,
|
|
64
|
+
d,
|
|
65
|
+
f,
|
|
66
|
+
p,
|
|
67
|
+
m
|
|
68
|
+
]), /* @__PURE__ */ o("div", {
|
|
69
|
+
"data-pihanga": m,
|
|
70
|
+
style: { display: "none" }
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
export { c as ToastComponent };
|
|
75
|
+
|
|
76
|
+
//# sourceMappingURL=toast.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.component.js","names":[],"sources":["../../../src/cards/toast/toast.component.tsx"],"sourcesContent":["import React, {useEffect, useRef, useState} from \"react\";\nimport {\n Card,\n type PiCardProps,\n type PiCardRef,\n usePiReducer,\n type ReduxAction,\n type ReduxState,\n} from \"@pihanga2/core\";\nimport {toast} from \"sonner\";\n\nimport {\n ShowToastEvent,\n TOAST_OP_ACTION,\n ToastPosition,\n ToastType,\n type PiToastEvents,\n type PiToastProps,\n} from \"./toast.types\";\n\nexport const ToastComponent = (\n props: PiCardProps<PiToastProps, PiToastEvents>,\n): React.ReactNode => {\n const {\n variant: defaultVariant = \"default\",\n duration: defaultDuration = 4000,\n dismissible: defaultDismissible = true,\n className: defaultClassName,\n onClosed,\n cardName,\n } = props;\n\n // State for tracking Redux-triggered toast messages\n const [currentToast, setCurrentToast] = useState<{\n message?: string;\n description?: string;\n contentCard?: PiCardRef;\n variant: ToastType;\n position?: ToastPosition;\n duration: number;\n } | null>(null);\n\n // Listen for showToast Redux messages\n // This allows triggering toasts from anywhere via dispatchShowToast\n usePiReducer<ReduxState, ShowToastEvent & ReduxAction>(\n TOAST_OP_ACTION.SHOW,\n (_, action) => {\n // Only respond if message is for this card or no specific cardName is set\n if (action.cardName && action.cardName !== cardName) {\n return;\n }\n setCurrentToast({\n message: action.message,\n description: action.description,\n contentCard: action.contentCard,\n variant: action.variant ?? defaultVariant,\n position: action.position,\n duration: action.duration ?? defaultDuration,\n });\n },\n cardName,\n );\n\n // Setup hooks before conditional rendering\n const toastIdRef = useRef<string | number | undefined>(undefined);\n\n useEffect(() => {\n // Only show toast if Redux message was received\n if (!currentToast) {\n return;\n }\n\n // Map our toast types to Sonner's toast function\n const toastFn =\n {\n success: toast.success,\n error: toast.error,\n info: toast.info,\n warning: toast.warning,\n default: toast,\n }[currentToast.variant] || toast;\n\n // Build className: combine default + variant-based class\n const className = [defaultClassName, `toast-${currentToast.variant}`]\n .filter(Boolean)\n .join(\" \");\n\n // If contentCard is provided, render it as custom JSX content\n if (currentToast.contentCard) {\n const contentCard = currentToast.contentCard;\n const CustomToastContent = () => (\n <Card cardName={contentCard} parentCard={cardName} />\n );\n\n // Show the toast with custom card content\n toastIdRef.current = toastFn(CustomToastContent, {\n duration: currentToast.duration,\n position: currentToast.position || \"bottom-right\",\n dismissible: defaultDismissible,\n className,\n onDismiss: () => {\n setCurrentToast(null);\n onClosed({});\n },\n onAutoClose: () => {\n setCurrentToast(null);\n onClosed({});\n },\n });\n } else {\n // Show the toast with message and optional description\n toastIdRef.current = toastFn(currentToast.message, {\n description: currentToast.description,\n duration: currentToast.duration,\n position: currentToast.position || \"bottom-right\",\n dismissible: defaultDismissible,\n className,\n onDismiss: () => {\n setCurrentToast(null);\n onClosed({});\n },\n onAutoClose: () => {\n setCurrentToast(null);\n onClosed({});\n },\n });\n }\n\n // Cleanup on unmount\n return () => {\n if (toastIdRef.current !== undefined) {\n toast.dismiss(toastIdRef.current);\n }\n };\n }, [currentToast, defaultDismissible, defaultClassName, onClosed, cardName]);\n\n // This component doesn't render visible DOM itself\n // Sonner renders toasts in a portal via its Toaster component\n return <div data-pihanga={cardName} style={{display: \"none\"}} />;\n};\n"],"mappings":";;;;;;AAoBA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,SAAS,IAAiB,WAC1B,UAAU,IAAkB,KAC5B,aAAa,IAAqB,IAClC,WAAW,GACX,aACA,gBACE,GAGE,CAAC,GAAc,KAAmB,EAO9B,IAAI;CAId,EACE,EAAgB,OACf,GAAG,MAAW;EAET,EAAO,YAAY,EAAO,aAAa,KAG3C,EAAgB;GACd,SAAS,EAAO;GAChB,aAAa,EAAO;GACpB,aAAa,EAAO;GACpB,SAAS,EAAO,WAAW;GAC3B,UAAU,EAAO;GACjB,UAAU,EAAO,YAAY;EAC/B,CAAC;CACH,GACA,CACF;CAGA,IAAM,IAAa,EAAoC,KAAA,CAAS;CA0EhE,OAxEA,QAAgB;EAEd,IAAI,CAAC,GACH;EAIF,IAAM,IACJ;GACE,SAAS,EAAM;GACf,OAAO,EAAM;GACb,MAAM,EAAM;GACZ,SAAS,EAAM;GACf,SAAS;EACX,EAAE,EAAa,YAAY,GAGvB,IAAY,CAAC,GAAkB,SAAS,EAAa,SAAS,EACjE,OAAO,OAAO,EACd,KAAK,GAAG;EAGX,IAAI,EAAa,aAAa;GAC5B,IAAM,IAAc,EAAa;GAMjC,EAAW,UAAU,QAJnB,kBAAC,GAAD;IAAM,UAAU;IAAa,YAAY;GAAW,CAAA,GAIL;IAC/C,UAAU,EAAa;IACvB,UAAU,EAAa,YAAY;IACnC,aAAa;IACb;IACA,iBAAiB;KAEf,AADA,EAAgB,IAAI,GACpB,EAAS,CAAC,CAAC;IACb;IACA,mBAAmB;KAEjB,AADA,EAAgB,IAAI,GACpB,EAAS,CAAC,CAAC;IACb;GACF,CAAC;EACH,OAEE,EAAW,UAAU,EAAQ,EAAa,SAAS;GACjD,aAAa,EAAa;GAC1B,UAAU,EAAa;GACvB,UAAU,EAAa,YAAY;GACnC,aAAa;GACb;GACA,iBAAiB;IAEf,AADA,EAAgB,IAAI,GACpB,EAAS,CAAC,CAAC;GACb;GACA,mBAAmB;IAEjB,AADA,EAAgB,IAAI,GACpB,EAAS,CAAC,CAAC;GACb;EACF,CAAC;EAIH,aAAa;GACX,AAAI,EAAW,YAAY,KAAA,KACzB,EAAM,QAAQ,EAAW,OAAO;EAEpC;CACF,GAAG;EAAC;EAAc;EAAoB;EAAkB;EAAU;CAAQ,CAAC,GAIpE,kBAAC,OAAD;EAAK,gBAAc;EAAU,OAAO,EAAC,SAAS,OAAM;CAAI,CAAA;AACjE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { PiCardRef, DispatchF } from '@pihanga2/core';
|
|
2
|
+
export declare const PI_TOAST_CARD = "pi/toast";
|
|
3
|
+
export declare const Toast: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<PiToastProps, S, PiToastEvents>) => import('@pihanga2/core').PiCardDef;
|
|
4
|
+
export declare const TOAST_OP_ACTION: {
|
|
5
|
+
SHOW: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Dispatch helper to show a toast
|
|
9
|
+
*
|
|
10
|
+
* @param d - Dispatch function from Pihanga
|
|
11
|
+
* @param ev - Toast event data
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import {dispatchShowToast} from "@/cards/toast";
|
|
16
|
+
*
|
|
17
|
+
* dispatchShowToast(_dispatch, {
|
|
18
|
+
* message: "Success!",
|
|
19
|
+
* description: "Your changes were saved.",
|
|
20
|
+
* variant: "success",
|
|
21
|
+
* duration: 3000,
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare const dispatchShowToast: (d: DispatchF, ev: ShowToastEvent) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Action handler for when a toast is shown
|
|
28
|
+
*
|
|
29
|
+
* Use this in your reducers or effects to handle toast display events:
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import {onShowToast} from "@/cards/toast";
|
|
34
|
+
*
|
|
35
|
+
* export const handleShowToast = onShowToast((state, action) => {
|
|
36
|
+
* console.log("Toast shown:", action.payload.message);
|
|
37
|
+
* return state;
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const onShowToast: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
42
|
+
cardID: string;
|
|
43
|
+
} & ShowToastEvent>) => void;
|
|
44
|
+
export declare const PI_TOAST_ACTION: {
|
|
45
|
+
CLOSED: string;
|
|
46
|
+
};
|
|
47
|
+
export declare const onPiToastClosed: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
48
|
+
cardID: string;
|
|
49
|
+
} & PiToastClosedEvent>) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Toast notification type/variant.
|
|
52
|
+
*/
|
|
53
|
+
export type ToastType = "default" | "success" | "error" | "info" | "warning";
|
|
54
|
+
/**
|
|
55
|
+
* Position of the toast on the screen.
|
|
56
|
+
*/
|
|
57
|
+
export type ToastPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
58
|
+
export type PiToastProps = {
|
|
59
|
+
/**
|
|
60
|
+
* Default variant for toasts shown by this card instance.
|
|
61
|
+
* Can be overridden per individual toast via ShowToastEvent.variant.
|
|
62
|
+
* @default 'default'
|
|
63
|
+
*/
|
|
64
|
+
variant?: ToastType;
|
|
65
|
+
/**
|
|
66
|
+
* Default duration in milliseconds before the toast auto-closes.
|
|
67
|
+
* Can be overridden per individual toast via ShowToastEvent.duration.
|
|
68
|
+
* Set to `Infinity` to disable auto-close.
|
|
69
|
+
* @default 4000
|
|
70
|
+
*/
|
|
71
|
+
duration?: number;
|
|
72
|
+
/**
|
|
73
|
+
* Whether toasts from this card are dismissible by the user.
|
|
74
|
+
* This is a card-level setting only; it cannot be overridden per individual toast.
|
|
75
|
+
* @default true
|
|
76
|
+
*/
|
|
77
|
+
dismissible?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Custom CSS class to apply to all toasts from this card.
|
|
80
|
+
*/
|
|
81
|
+
className?: string;
|
|
82
|
+
};
|
|
83
|
+
export type PiToastClosedEvent = {
|
|
84
|
+
id?: string;
|
|
85
|
+
};
|
|
86
|
+
export type PiToastEvents = {
|
|
87
|
+
onClosed: PiToastClosedEvent;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Event payload for showing a toast
|
|
91
|
+
*/
|
|
92
|
+
export type ShowToastEvent = {
|
|
93
|
+
cardName?: string;
|
|
94
|
+
message: string;
|
|
95
|
+
description?: string;
|
|
96
|
+
contentCard?: PiCardRef;
|
|
97
|
+
variant?: ToastType;
|
|
98
|
+
position?: ToastPosition;
|
|
99
|
+
duration?: number;
|
|
100
|
+
};
|