@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,12 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/toast/toast.types.ts
|
|
3
|
+
var r = "pi/toast", i = e(r), a = n("toast/op", ["show"]), o = (e, t) => {
|
|
4
|
+
e({
|
|
5
|
+
...t,
|
|
6
|
+
type: a.SHOW
|
|
7
|
+
});
|
|
8
|
+
}, s = t(a.SHOW), c = n(r, ["closed"]), l = t(c.CLOSED);
|
|
9
|
+
//#endregion
|
|
10
|
+
export { c as PI_TOAST_ACTION, r as PI_TOAST_CARD, a as TOAST_OP_ACTION, i as Toast, o as dispatchShowToast, l as onPiToastClosed, s as onShowToast };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=toast.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toast.types.js","names":[],"sources":["../../../src/cards/toast/toast.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n PiCardRef,\n registerActions,\n type DispatchF,\n} from \"@pihanga2/core\";\n\nexport const PI_TOAST_CARD = \"pi/toast\";\n\nexport const Toast = createCardDeclaration<PiToastProps, PiToastEvents>(\n PI_TOAST_CARD,\n);\n\nexport const TOAST_OP_ACTION = registerActions(\"toast/op\", [\"show\"]);\n\n/**\n * Dispatch helper to show a toast\n *\n * @param d - Dispatch function from Pihanga\n * @param ev - Toast event data\n *\n * @example\n * ```typescript\n * import {dispatchShowToast} from \"@/cards/toast\";\n *\n * dispatchShowToast(_dispatch, {\n * message: \"Success!\",\n * description: \"Your changes were saved.\",\n * variant: \"success\",\n * duration: 3000,\n * });\n * ```\n */\nexport const dispatchShowToast = (d: DispatchF, ev: ShowToastEvent) => {\n d({...ev, type: TOAST_OP_ACTION.SHOW});\n};\n\n/**\n * Action handler for when a toast is shown\n *\n * Use this in your reducers or effects to handle toast display events:\n *\n * @example\n * ```typescript\n * import {onShowToast} from \"@/cards/toast\";\n *\n * export const handleShowToast = onShowToast((state, action) => {\n * console.log(\"Toast shown:\", action.payload.message);\n * return state;\n * });\n * ```\n */\nexport const onShowToast = createOnAction<ShowToastEvent>(TOAST_OP_ACTION.SHOW);\n\nexport const PI_TOAST_ACTION = registerActions(PI_TOAST_CARD, [\"closed\"]);\n\nexport const onPiToastClosed = createOnAction<PiToastClosedEvent>(\n PI_TOAST_ACTION.CLOSED,\n);\n\n/**\n * Toast notification type/variant.\n */\nexport type ToastType = \"default\" | \"success\" | \"error\" | \"info\" | \"warning\";\n\n/**\n * Position of the toast on the screen.\n */\nexport type ToastPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\";\n\nexport type PiToastProps = {\n /**\n * Default variant for toasts shown by this card instance.\n * Can be overridden per individual toast via ShowToastEvent.variant.\n * @default 'default'\n */\n variant?: ToastType;\n\n /**\n * Default duration in milliseconds before the toast auto-closes.\n * Can be overridden per individual toast via ShowToastEvent.duration.\n * Set to `Infinity` to disable auto-close.\n * @default 4000\n */\n duration?: number;\n\n /**\n * Whether toasts from this card are dismissible by the user.\n * This is a card-level setting only; it cannot be overridden per individual toast.\n * @default true\n */\n dismissible?: boolean;\n\n /**\n * Custom CSS class to apply to all toasts from this card.\n */\n className?: string;\n};\n\nexport type PiToastClosedEvent = {\n id?: string;\n};\n\nexport type PiToastEvents = {\n onClosed: PiToastClosedEvent;\n};\n\n/**\n * Event payload for showing a toast\n */\nexport type ShowToastEvent = {\n cardName?: string;\n message: string;\n description?: string;\n contentCard?: PiCardRef; // Alternative: custom card for richer content\n variant?: ToastType;\n position?: ToastPosition; // Toast position on screen\n duration?: number;\n};\n"],"mappings":";;AAQA,IAAa,IAAgB,YAEhB,IAAQ,EACnB,CACF,GAEa,IAAkB,EAAgB,YAAY,CAAC,MAAM,CAAC,GAoBtD,KAAqB,GAAc,MAAuB;CACrE,EAAE;EAAC,GAAG;EAAI,MAAM,EAAgB;CAAI,CAAC;AACvC,GAiBa,IAAc,EAA+B,EAAgB,IAAI,GAEjE,IAAkB,EAAgB,GAAe,CAAC,QAAQ,CAAC,GAE3D,IAAkB,EAC7B,EAAgB,MAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './toggleGroup.types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ToggleGroupComponent as e } from "./toggleGroup.component.js";
|
|
2
|
+
import { PI_TOGGLE_GROUP_ACTION as t, PI_TOGGLE_GROUP_CARD as n, ToggleGroup as r, onPiToggleGroupChanged as i } from "./toggleGroup.types.js";
|
|
3
|
+
import { actionTypesToEvents as a, registerCardComponent as o } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/toggleGroup/index.ts
|
|
5
|
+
o({
|
|
6
|
+
name: n,
|
|
7
|
+
component: e,
|
|
8
|
+
events: a(t)
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as PI_TOGGLE_GROUP_ACTION, n as PI_TOGGLE_GROUP_CARD, r as ToggleGroup, i as onPiToggleGroupChanged };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/toggleGroup/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {ToggleGroupComponent} from \"./toggleGroup.component\";\nimport {\n PI_TOGGLE_GROUP_ACTION,\n PI_TOGGLE_GROUP_CARD,\n} from \"./toggleGroup.types\";\n\nexport * from \"./toggleGroup.types\";\n\nregisterCardComponent({\n name: PI_TOGGLE_GROUP_CARD,\n component: ToggleGroupComponent,\n events: actionTypesToEvents(PI_TOGGLE_GROUP_ACTION),\n});\n"],"mappings":";;;;AAUA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAsB;AACpD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { PiCardProps } from '@pihanga2/core';
|
|
3
|
+
import { PiToggleGroupEvents, PiToggleGroupProps } from './toggleGroup.types';
|
|
4
|
+
export declare const ToggleGroupComponent: (props: PiCardProps<PiToggleGroupProps, PiToggleGroupEvents>) => React.ReactNode;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useFormContext as e } from "../form/form.context.js";
|
|
2
|
+
import { ToggleGroup as t, ToggleGroupItem as n } from "../../components/ui/toggle-group.js";
|
|
3
|
+
import r from "react";
|
|
4
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
5
|
+
//#region src/cards/toggleGroup/toggleGroup.component.tsx
|
|
6
|
+
var a = (a) => {
|
|
7
|
+
let { name: o, items: s, type: c = "single", value: l, selfManaged: u = !1, variant: d = "default", size: f = "default", spacing: p = 0, disabled: m, className: h, cardName: g, onChanged: _ } = a, v = e(), y = v.isInForm && !!o, b = c === "multiple" ? Array.isArray(l) ? l : l == null ? [] : [String(l)] : typeof l == "string" ? l : "", [x, S] = r.useState(b), C = y ? v.formData[o] : void 0, w = y ? c === "multiple" ? Array.isArray(C) ? C : C == null ? [] : [String(C)] : C == null ? "" : String(C) : u ? x : l ?? (c === "multiple" ? [] : "");
|
|
8
|
+
function T(e) {
|
|
9
|
+
y ? v.handleChange(o, e) : (u && S(e), _({
|
|
10
|
+
name: o ?? g,
|
|
11
|
+
value: e
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
function E(e) {
|
|
15
|
+
y ? v.handleChange(o, e) : (u && S(e), _({
|
|
16
|
+
name: o ?? g,
|
|
17
|
+
value: e
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
return c === "single" ? /* @__PURE__ */ i(t, {
|
|
21
|
+
"data-pihanga": g,
|
|
22
|
+
type: "single",
|
|
23
|
+
value: typeof w == "string" ? w : "",
|
|
24
|
+
onValueChange: T,
|
|
25
|
+
variant: d,
|
|
26
|
+
size: f,
|
|
27
|
+
spacing: p,
|
|
28
|
+
disabled: m,
|
|
29
|
+
className: h,
|
|
30
|
+
children: s.map((e) => /* @__PURE__ */ i(n, {
|
|
31
|
+
value: e.value,
|
|
32
|
+
disabled: e.disabled,
|
|
33
|
+
children: e.label
|
|
34
|
+
}, e.value))
|
|
35
|
+
}) : /* @__PURE__ */ i(t, {
|
|
36
|
+
"data-pihanga": g,
|
|
37
|
+
type: "multiple",
|
|
38
|
+
value: Array.isArray(w) ? w : w ? [w] : [],
|
|
39
|
+
onValueChange: E,
|
|
40
|
+
variant: d,
|
|
41
|
+
size: f,
|
|
42
|
+
spacing: p,
|
|
43
|
+
disabled: m,
|
|
44
|
+
className: h,
|
|
45
|
+
children: s.map((e) => /* @__PURE__ */ i(n, {
|
|
46
|
+
value: e.value,
|
|
47
|
+
disabled: e.disabled,
|
|
48
|
+
children: e.label
|
|
49
|
+
}, e.value))
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
export { a as ToggleGroupComponent };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=toggleGroup.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggleGroup.component.js","names":[],"sources":["../../../src/cards/toggleGroup/toggleGroup.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {\n ToggleGroup as ToggleGroupUI,\n ToggleGroupItem,\n} from \"@/components/ui/toggle-group\";\nimport {useFormContext} from \"@/cards/form/form.context\";\nimport type {\n PiToggleGroupEvents,\n PiToggleGroupProps,\n} from \"./toggleGroup.types\";\n\nexport const ToggleGroupComponent = (\n props: PiCardProps<PiToggleGroupProps, PiToggleGroupEvents>,\n): React.ReactNode => {\n const {\n name,\n items,\n type = \"single\",\n value: propValue,\n selfManaged = false,\n variant = \"default\",\n size = \"default\",\n spacing = 0,\n disabled,\n className,\n cardName,\n onChanged,\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 // ---------------------------------------------------------------------------\n // Self-managed (internal) state — only active when selfManaged=true and we\n // are NOT inside a pi/form card.\n // ---------------------------------------------------------------------------\n const initialSelfValue: string | string[] =\n type === \"multiple\"\n ? Array.isArray(propValue)\n ? propValue\n : propValue != null\n ? [String(propValue)]\n : []\n : typeof propValue === \"string\"\n ? propValue\n : \"\";\n\n const [internalValue, setInternalValue] = React.useState<string | string[]>(\n initialSelfValue,\n );\n\n // ---------------------------------------------------------------------------\n // Derive the effective value from the appropriate source.\n // 1. Form context (highest priority)\n // 2. Self-managed internal state\n // 3. Externally controlled prop value\n // ---------------------------------------------------------------------------\n const formRawValue = useFormData ? form.formData[name!] : undefined;\n const value: string | string[] = useFormData\n ? type === \"multiple\"\n ? Array.isArray(formRawValue)\n ? (formRawValue as string[])\n : formRawValue != null\n ? [String(formRawValue)]\n : []\n : formRawValue != null\n ? String(formRawValue)\n : \"\"\n : selfManaged\n ? internalValue\n : (propValue ?? (type === \"multiple\" ? [] : \"\"));\n\n function handleSingleChange(newValue: string) {\n if (useFormData) {\n form.handleChange(name!, newValue);\n } else {\n if (selfManaged) {\n setInternalValue(newValue);\n }\n onChanged({name: name ?? cardName, value: newValue});\n }\n }\n\n function handleMultipleChange(newValue: string[]) {\n if (useFormData) {\n form.handleChange(name!, newValue);\n } else {\n if (selfManaged) {\n setInternalValue(newValue);\n }\n onChanged({name: name ?? cardName, value: newValue});\n }\n }\n\n // Render single-selection group\n if (type === \"single\") {\n return (\n <ToggleGroupUI\n data-pihanga={cardName}\n type=\"single\"\n value={typeof value === \"string\" ? value : \"\"}\n onValueChange={handleSingleChange}\n variant={variant}\n size={size}\n spacing={spacing}\n disabled={disabled}\n className={className}\n >\n {items.map((item) => (\n <ToggleGroupItem\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n >\n {item.label}\n </ToggleGroupItem>\n ))}\n </ToggleGroupUI>\n );\n }\n\n // Render multiple-selection group\n return (\n <ToggleGroupUI\n data-pihanga={cardName}\n type=\"multiple\"\n value={Array.isArray(value) ? value : value ? [value] : []}\n onValueChange={handleMultipleChange}\n variant={variant}\n size={size}\n spacing={spacing}\n disabled={disabled}\n className={className}\n >\n {items.map((item) => (\n <ToggleGroupItem\n key={item.value}\n value={item.value}\n disabled={item.disabled}\n >\n {item.label}\n </ToggleGroupItem>\n ))}\n </ToggleGroupUI>\n );\n};\n"],"mappings":";;;;;AAYA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,SACA,UACA,UAAO,UACP,OAAO,GACP,iBAAc,IACd,aAAU,WACV,UAAO,WACP,aAAU,GACV,aACA,cACA,aACA,iBACE,GAGE,IAAO,EAAe,GACtB,IAAc,EAAK,YAAY,EAAQ,GAMvC,IACJ,MAAS,aACL,MAAM,QAAQ,CAAS,IACrB,IACA,KAAa,OAEX,CAAC,IADD,CAAC,OAAO,CAAS,CAAC,IAEtB,OAAO,KAAc,WACnB,IACA,IAEF,CAAC,GAAe,KAAoB,EAAM,SAC9C,CACF,GAQM,IAAe,IAAc,EAAK,SAAS,KAAS,KAAA,GACpD,IAA2B,IAC7B,MAAS,aACP,MAAM,QAAQ,CAAY,IACvB,IACD,KAAgB,OAEd,CAAC,IADD,CAAC,OAAO,CAAY,CAAC,IAEzB,KAAgB,OAEd,KADA,OAAO,CAAY,IAEvB,IACE,IACC,MAAc,MAAS,aAAa,CAAC,IAAI;CAEhD,SAAS,EAAmB,GAAkB;EAC5C,AAAI,IACF,EAAK,aAAa,GAAO,CAAQ,KAE7B,KACF,EAAiB,CAAQ,GAE3B,EAAU;GAAC,MAAM,KAAQ;GAAU,OAAO;EAAQ,CAAC;CAEvD;CAEA,SAAS,EAAqB,GAAoB;EAChD,AAAI,IACF,EAAK,aAAa,GAAO,CAAQ,KAE7B,KACF,EAAiB,CAAQ,GAE3B,EAAU;GAAC,MAAM,KAAQ;GAAU,OAAO;EAAQ,CAAC;CAEvD;CA8BA,OA3BI,MAAS,WAET,kBAAC,GAAD;EACE,gBAAc;EACd,MAAK;EACL,OAAO,OAAO,KAAU,WAAW,IAAQ;EAC3C,eAAe;EACN;EACH;EACG;EACC;EACC;YAEV,EAAM,KAAK,MACV,kBAAC,GAAD;GAEE,OAAO,EAAK;GACZ,UAAU,EAAK;aAEd,EAAK;EACS,GALV,EAAK,KAKK,CAClB;CACY,CAAA,IAMjB,kBAAC,GAAD;EACE,gBAAc;EACd,MAAK;EACL,OAAO,MAAM,QAAQ,CAAK,IAAI,IAAQ,IAAQ,CAAC,CAAK,IAAI,CAAC;EACzD,eAAe;EACN;EACH;EACG;EACC;EACC;YAEV,EAAM,KAAK,MACV,kBAAC,GAAD;GAEE,OAAO,EAAK;GACZ,UAAU,EAAK;aAEd,EAAK;EACS,GALV,EAAK,KAKK,CAClB;CACY,CAAA;AAEnB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export declare const PI_TOGGLE_GROUP_CARD = "pi/toggle-group";
|
|
2
|
+
export declare const ToggleGroup: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<PiToggleGroupProps, S, PiToggleGroupEvents>) => import('@pihanga2/core').PiCardDef;
|
|
3
|
+
export declare const PI_TOGGLE_GROUP_ACTION: {
|
|
4
|
+
CHANGED: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const onPiToggleGroupChanged: <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
|
+
} & PiToggleGroupChangedEvent>) => void;
|
|
9
|
+
export type PiToggleGroupItem = {
|
|
10
|
+
/** The value associated with this toggle item. */
|
|
11
|
+
value: string;
|
|
12
|
+
/** Human-readable label rendered inside the toggle button. */
|
|
13
|
+
label: string;
|
|
14
|
+
/** When true, this individual item is disabled. */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type PiToggleGroupProps = {
|
|
18
|
+
/**
|
|
19
|
+
* Field name used to bind to FormContext when inside a pi/form card.
|
|
20
|
+
* When provided the component reads its selected value from form data and
|
|
21
|
+
* writes back via form.handleChange.
|
|
22
|
+
*/
|
|
23
|
+
name?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The list of toggle items to display.
|
|
26
|
+
*/
|
|
27
|
+
items: PiToggleGroupItem[];
|
|
28
|
+
/**
|
|
29
|
+
* Selection mode.
|
|
30
|
+
* - `"single"` — at most one item can be active at a time.
|
|
31
|
+
* - `"multiple"` — any number of items can be active simultaneously.
|
|
32
|
+
*
|
|
33
|
+
* @default "single"
|
|
34
|
+
*/
|
|
35
|
+
type?: "single" | "multiple";
|
|
36
|
+
/**
|
|
37
|
+
* Controlled selected value(s).
|
|
38
|
+
* - In `"single"` mode: a `string` (or `undefined` for nothing selected).
|
|
39
|
+
* - In `"multiple"` mode: an array of `string`.
|
|
40
|
+
*
|
|
41
|
+
* Ignored when `name` is set and the component is inside a pi/form.
|
|
42
|
+
* Also ignored when `selfManaged` is `true`.
|
|
43
|
+
*/
|
|
44
|
+
value?: string | string[];
|
|
45
|
+
/**
|
|
46
|
+
* When `true`, the component manages its own selection state internally
|
|
47
|
+
* using `React.useState`. The `value` prop is used only as the initial
|
|
48
|
+
* value (i.e. `defaultValue`) and subsequent changes do not require an
|
|
49
|
+
* external state update. `onChanged` is still fired so callers can
|
|
50
|
+
* observe changes without owning the state.
|
|
51
|
+
*
|
|
52
|
+
* Has no effect when inside a pi/form (form context always takes
|
|
53
|
+
* precedence).
|
|
54
|
+
*
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
selfManaged?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Visual style variant of the toggle buttons.
|
|
60
|
+
* - `"default"` — transparent background, highlights on active.
|
|
61
|
+
* - `"outline"` — bordered buttons, grouped or spaced.
|
|
62
|
+
*
|
|
63
|
+
* @default "default"
|
|
64
|
+
*/
|
|
65
|
+
variant?: "default" | "outline";
|
|
66
|
+
/**
|
|
67
|
+
* Size of each toggle button.
|
|
68
|
+
* @default "default"
|
|
69
|
+
*/
|
|
70
|
+
size?: "default" | "sm" | "lg";
|
|
71
|
+
/**
|
|
72
|
+
* Gap between toggle buttons (in Tailwind spacing units).
|
|
73
|
+
* `0` = buttons are joined (no gap, rounded ends only).
|
|
74
|
+
* Positive values add space between each button.
|
|
75
|
+
*
|
|
76
|
+
* @default 0
|
|
77
|
+
*/
|
|
78
|
+
spacing?: number;
|
|
79
|
+
/** When true, the entire group is disabled and non-interactive. */
|
|
80
|
+
disabled?: boolean;
|
|
81
|
+
/** Extra Tailwind / CSS classes forwarded to the root element. */
|
|
82
|
+
className?: string;
|
|
83
|
+
};
|
|
84
|
+
export type PiToggleGroupChangedEvent = {
|
|
85
|
+
/** Field name, mirrors the `name` prop if provided. */
|
|
86
|
+
name?: string;
|
|
87
|
+
/**
|
|
88
|
+
* New selected value(s).
|
|
89
|
+
* - In `"single"` mode: a `string` (empty string when nothing selected).
|
|
90
|
+
* - In `"multiple"` mode: an array of `string`.
|
|
91
|
+
*/
|
|
92
|
+
value: string | string[];
|
|
93
|
+
};
|
|
94
|
+
export type PiToggleGroupEvents = {
|
|
95
|
+
onChanged: PiToggleGroupChangedEvent;
|
|
96
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/toggleGroup/toggleGroup.types.ts
|
|
3
|
+
var r = "pi/toggle-group", i = e(r), a = n(r, ["changed"]), o = t(a.CHANGED);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { a as PI_TOGGLE_GROUP_ACTION, r as PI_TOGGLE_GROUP_CARD, i as ToggleGroup, o as onPiToggleGroupChanged };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=toggleGroup.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toggleGroup.types.js","names":[],"sources":["../../../src/cards/toggleGroup/toggleGroup.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_TOGGLE_GROUP_CARD = \"pi/toggle-group\";\n\nexport const ToggleGroup = createCardDeclaration<\n PiToggleGroupProps,\n PiToggleGroupEvents\n>(PI_TOGGLE_GROUP_CARD);\n\nexport const PI_TOGGLE_GROUP_ACTION = registerActions(PI_TOGGLE_GROUP_CARD, [\n \"changed\",\n]);\n\nexport const onPiToggleGroupChanged = createOnAction<PiToggleGroupChangedEvent>(\n PI_TOGGLE_GROUP_ACTION.CHANGED,\n);\n\n// ---------------------------------------------------------------------------\n// Item type\n// ---------------------------------------------------------------------------\n\nexport type PiToggleGroupItem = {\n /** The value associated with this toggle item. */\n value: string;\n /** Human-readable label rendered inside the toggle button. */\n label: string;\n /** When true, this individual item is disabled. */\n disabled?: boolean;\n};\n\n// ---------------------------------------------------------------------------\n// Props & Events\n// ---------------------------------------------------------------------------\n\nexport type PiToggleGroupProps = {\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 * The list of toggle items to display.\n */\n items: PiToggleGroupItem[];\n\n /**\n * Selection mode.\n * - `\"single\"` — at most one item can be active at a time.\n * - `\"multiple\"` — any number of items can be active simultaneously.\n *\n * @default \"single\"\n */\n type?: \"single\" | \"multiple\";\n\n /**\n * Controlled selected value(s).\n * - In `\"single\"` mode: a `string` (or `undefined` for nothing selected).\n * - In `\"multiple\"` mode: an array of `string`.\n *\n * Ignored when `name` is set and the component is inside a pi/form.\n * Also ignored when `selfManaged` is `true`.\n */\n value?: string | string[];\n\n /**\n * When `true`, the component manages its own selection state internally\n * using `React.useState`. The `value` prop is used only as the initial\n * value (i.e. `defaultValue`) and subsequent changes do not require an\n * external state update. `onChanged` is still fired so callers can\n * observe changes without owning the state.\n *\n * Has no effect when inside a pi/form (form context always takes\n * precedence).\n *\n * @default false\n */\n selfManaged?: boolean;\n\n /**\n * Visual style variant of the toggle buttons.\n * - `\"default\"` — transparent background, highlights on active.\n * - `\"outline\"` — bordered buttons, grouped or spaced.\n *\n * @default \"default\"\n */\n variant?: \"default\" | \"outline\";\n\n /**\n * Size of each toggle button.\n * @default \"default\"\n */\n size?: \"default\" | \"sm\" | \"lg\";\n\n /**\n * Gap between toggle buttons (in Tailwind spacing units).\n * `0` = buttons are joined (no gap, rounded ends only).\n * Positive values add space between each button.\n *\n * @default 0\n */\n spacing?: number;\n\n /** When true, the entire group is disabled and non-interactive. */\n disabled?: boolean;\n\n /** Extra Tailwind / CSS classes forwarded to the root element. */\n className?: string;\n};\n\nexport type PiToggleGroupChangedEvent = {\n /** Field name, mirrors the `name` prop if provided. */\n name?: string;\n /**\n * New selected value(s).\n * - In `\"single\"` mode: a `string` (empty string when nothing selected).\n * - In `\"multiple\"` mode: an array of `string`.\n */\n value: string | string[];\n};\n\nexport type PiToggleGroupEvents = {\n onChanged: PiToggleGroupChangedEvent;\n};\n"],"mappings":";;AAMA,IAAa,IAAuB,mBAEvB,IAAc,EAGzB,CAAoB,GAET,IAAyB,EAAgB,GAAsB,CAC1E,SACF,CAAC,GAEY,IAAyB,EACpC,EAAuB,OACzB"}
|
package/cards/types.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Screen size breakpoints matching Tailwind CSS defaults.
|
|
3
|
+
*
|
|
4
|
+
* Used with {@link SizeMap} to render different cards (or none at all)
|
|
5
|
+
* depending on the viewport width.
|
|
6
|
+
*/
|
|
7
|
+
export declare enum ScreenSize {
|
|
8
|
+
XS = "xs",// default / < 640px
|
|
9
|
+
SM = "sm",// ≥ 640px
|
|
10
|
+
MD = "md",// ≥ 768px
|
|
11
|
+
LG = "lg",// ≥ 1024px
|
|
12
|
+
XL = "xl",// ≥ 1280px
|
|
13
|
+
XXL = "2xl"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Ascending order of breakpoints — used for cascade resolution.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare const SCREEN_SIZE_ORDER: ScreenSize[];
|
|
20
|
+
/**
|
|
21
|
+
* Minimum viewport widths (px) for each breakpoint.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export declare const SCREEN_SIZE_WIDTHS: Record<ScreenSize, number>;
|
|
25
|
+
/**
|
|
26
|
+
* Map a value {@link T} to specific screen-size breakpoints.
|
|
27
|
+
*
|
|
28
|
+
* Resolution follows a **mobile-first cascade**: the entry with the
|
|
29
|
+
* largest breakpoint that is ≤ the current viewport size wins.
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* // Show "desktopCard" on md and above, nothing on xs/sm:
|
|
33
|
+
* { [ScreenSize.MD]: "desktopCard" }
|
|
34
|
+
*
|
|
35
|
+
* // Show a different card per breakpoint:
|
|
36
|
+
* { [ScreenSize.XS]: "mobileCard", [ScreenSize.MD]: "desktopCard" }
|
|
37
|
+
*
|
|
38
|
+
* // Explicitly hide on md and above:
|
|
39
|
+
* { [ScreenSize.XS]: "card", [ScreenSize.MD]: null }
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* Set `default` as a final fallback when no breakpoint entry matches.
|
|
43
|
+
*/
|
|
44
|
+
export type SizeMap<T> = Partial<Record<ScreenSize, T | null>> & {
|
|
45
|
+
default?: T | null;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Shadcn button / badge visual variant.
|
|
49
|
+
*
|
|
50
|
+
* Maps directly to the `variant` prop accepted by `@/components/ui/button`
|
|
51
|
+
* and `@/components/ui/badge`.
|
|
52
|
+
*/
|
|
53
|
+
export type VariantT = "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
|
|
54
|
+
/**
|
|
55
|
+
* Shadcn component size token.
|
|
56
|
+
*
|
|
57
|
+
* Maps directly to the `size` prop accepted by `@/components/ui/button`.
|
|
58
|
+
*/
|
|
59
|
+
export type SizeT = "default" | "sm" | "lg" | "icon";
|
|
60
|
+
/**
|
|
61
|
+
* Tailwind colour token (e.g. `"red"`, `"emerald"`, `"sky"`) or an arbitrary
|
|
62
|
+
* CSS colour string. Kept as `string` so consumers can pass any Tailwind
|
|
63
|
+
* palette key without being locked to a finite union.
|
|
64
|
+
*/
|
|
65
|
+
export type ColorT = string;
|
|
66
|
+
/**
|
|
67
|
+
* A decorator displayed before or after a button / menu-item label.
|
|
68
|
+
*
|
|
69
|
+
* Expressed as a registered icon name (resolved at render time via the icon
|
|
70
|
+
* registry) or an arbitrary Tailwind-class string for inline SVG icons.
|
|
71
|
+
*/
|
|
72
|
+
export type DecoratorT = string;
|
package/cards/types.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/cards/types.ts
|
|
2
|
+
var e = /* @__PURE__ */ function(e) {
|
|
3
|
+
return e.XS = "xs", e.SM = "sm", e.MD = "md", e.LG = "lg", e.XL = "xl", e.XXL = "2xl", e;
|
|
4
|
+
}({}), t = [
|
|
5
|
+
"xs",
|
|
6
|
+
"sm",
|
|
7
|
+
"md",
|
|
8
|
+
"lg",
|
|
9
|
+
"xl",
|
|
10
|
+
"2xl"
|
|
11
|
+
], n = {
|
|
12
|
+
xs: 0,
|
|
13
|
+
sm: 640,
|
|
14
|
+
md: 768,
|
|
15
|
+
lg: 1024,
|
|
16
|
+
xl: 1280,
|
|
17
|
+
"2xl": 1536
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { t as SCREEN_SIZE_ORDER, n as SCREEN_SIZE_WIDTHS, e as ScreenSize };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/cards/types.ts"],"sourcesContent":["/**\n * Screen size breakpoints matching Tailwind CSS defaults.\n *\n * Used with {@link SizeMap} to render different cards (or none at all)\n * depending on the viewport width.\n */\nexport enum ScreenSize {\n XS = \"xs\", // default / < 640px\n SM = \"sm\", // ≥ 640px\n MD = \"md\", // ≥ 768px\n LG = \"lg\", // ≥ 1024px\n XL = \"xl\", // ≥ 1280px\n XXL = \"2xl\", // ≥ 1536px\n}\n\n/**\n * Ascending order of breakpoints — used for cascade resolution.\n * @internal\n */\nexport const SCREEN_SIZE_ORDER: ScreenSize[] = [\n ScreenSize.XS,\n ScreenSize.SM,\n ScreenSize.MD,\n ScreenSize.LG,\n ScreenSize.XL,\n ScreenSize.XXL,\n];\n\n/**\n * Minimum viewport widths (px) for each breakpoint.\n * @internal\n */\nexport const SCREEN_SIZE_WIDTHS: Record<ScreenSize, number> = {\n [ScreenSize.XS]: 0,\n [ScreenSize.SM]: 640,\n [ScreenSize.MD]: 768,\n [ScreenSize.LG]: 1024,\n [ScreenSize.XL]: 1280,\n [ScreenSize.XXL]: 1536,\n};\n\n/**\n * Map a value {@link T} to specific screen-size breakpoints.\n *\n * Resolution follows a **mobile-first cascade**: the entry with the\n * largest breakpoint that is ≤ the current viewport size wins.\n *\n * ```ts\n * // Show \"desktopCard\" on md and above, nothing on xs/sm:\n * { [ScreenSize.MD]: \"desktopCard\" }\n *\n * // Show a different card per breakpoint:\n * { [ScreenSize.XS]: \"mobileCard\", [ScreenSize.MD]: \"desktopCard\" }\n *\n * // Explicitly hide on md and above:\n * { [ScreenSize.XS]: \"card\", [ScreenSize.MD]: null }\n * ```\n *\n * Set `default` as a final fallback when no breakpoint entry matches.\n */\nexport type SizeMap<T> = Partial<Record<ScreenSize, T | null>> & {\n default?: T | null;\n};\n\n// ---------------------------------------------------------------------------\n// Shadcn / Tailwind-native shared primitive types\n//\n// These types replace what was previously imported from `@pihanga2/cards` and\n// are expressed in terms of Shadcn's design system and Tailwind utility tokens.\n// ---------------------------------------------------------------------------\n\n/**\n * Shadcn button / badge visual variant.\n *\n * Maps directly to the `variant` prop accepted by `@/components/ui/button`\n * and `@/components/ui/badge`.\n */\nexport type VariantT =\n | \"default\"\n | \"destructive\"\n | \"outline\"\n | \"secondary\"\n | \"ghost\"\n | \"link\";\n\n/**\n * Shadcn component size token.\n *\n * Maps directly to the `size` prop accepted by `@/components/ui/button`.\n */\nexport type SizeT = \"default\" | \"sm\" | \"lg\" | \"icon\";\n\n/**\n * Tailwind colour token (e.g. `\"red\"`, `\"emerald\"`, `\"sky\"`) or an arbitrary\n * CSS colour string. Kept as `string` so consumers can pass any Tailwind\n * palette key without being locked to a finite union.\n */\nexport type ColorT = string;\n\n/**\n * A decorator displayed before or after a button / menu-item label.\n *\n * Expressed as a registered icon name (resolved at render time via the icon\n * registry) or an arbitrary Tailwind-class string for inline SVG icons.\n */\nexport type DecoratorT = string;\n"],"mappings":";AAMA,IAAY,IAAL,yBAAA,GAAA;QACL,EAAA,KAAA,MACA,EAAA,KAAA,MACA,EAAA,KAAA,MACA,EAAA,KAAA,MACA,EAAA,KAAA,MACA,EAAA,MAAA;AACF,EAAA,CAAA,CAAA,GAMa,IAAkC;;;;;;;AAO/C,GAMa,IAAiD;KAC3C;KACA;KACA;KACA;KACA;QACC;AACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './typography.types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TypographyComponent as e } from "./typography.component.js";
|
|
2
|
+
import { TYPOGRAPHY_CARD as t, Typography as n } from "./typography.types.js";
|
|
3
|
+
import { registerCardComponent as r } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/typography/index.ts
|
|
5
|
+
r({
|
|
6
|
+
name: t,
|
|
7
|
+
component: e
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as TYPOGRAPHY_CARD, n as Typography };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/typography/index.ts"],"sourcesContent":["import {registerCardComponent} from \"@pihanga2/core\";\n\nimport {TypographyComponent} from \"./typography.component\";\nimport {TYPOGRAPHY_CARD} from \"./typography.types\";\n\nexport * from \"./typography.types\";\n\nregisterCardComponent({\n name: TYPOGRAPHY_CARD,\n component: TypographyComponent,\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;AACb,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/utils.js";
|
|
2
|
+
import { Card as t } from "@pihanga2/core";
|
|
3
|
+
import * as n from "react";
|
|
4
|
+
import { Fragment as r, jsx as i } from "react/jsx-runtime";
|
|
5
|
+
//#region src/cards/typography/typography.component.tsx
|
|
6
|
+
var a = {
|
|
7
|
+
h1: ["h1", "scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl"],
|
|
8
|
+
h2: ["h2", "scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0"],
|
|
9
|
+
h3: ["h3", "scroll-m-20 text-2xl font-semibold tracking-tight"],
|
|
10
|
+
h4: ["h4", "scroll-m-20 text-xl font-semibold tracking-tight"],
|
|
11
|
+
p: ["p", "leading-7 [&:not(:first-child)]:mt-6"],
|
|
12
|
+
blockquote: ["blockquote", "mt-6 border-l-2 pl-6 italic"],
|
|
13
|
+
code: ["code", "relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold"],
|
|
14
|
+
lead: ["p", "text-xl text-muted-foreground"],
|
|
15
|
+
large: ["div", "text-lg font-semibold"],
|
|
16
|
+
small: ["small", "text-sm font-medium leading-none"],
|
|
17
|
+
muted: ["p", "text-sm text-muted-foreground"]
|
|
18
|
+
}, o = (s) => {
|
|
19
|
+
let { text: c, childCard: l, paragraph: u, level: d, className: f, style: p, cardName: m, _dispatch: h, _cls: g } = s, [_, v] = d ? a[d] : ["div", ""];
|
|
20
|
+
function y() {
|
|
21
|
+
return l ? /* @__PURE__ */ i(t, {
|
|
22
|
+
cardName: l,
|
|
23
|
+
parentCard: m
|
|
24
|
+
}) : u ? /* @__PURE__ */ i(r, { children: u.map((e, t) => b(e, t)) }) : c;
|
|
25
|
+
}
|
|
26
|
+
function b(e, t) {
|
|
27
|
+
return typeof e == "string" ? e : e && typeof e == "object" ? o({
|
|
28
|
+
...e,
|
|
29
|
+
_dispatch: h,
|
|
30
|
+
_cls: g,
|
|
31
|
+
cardName: m,
|
|
32
|
+
key: t
|
|
33
|
+
}) : null;
|
|
34
|
+
}
|
|
35
|
+
return n.createElement(_, {
|
|
36
|
+
className: e(v, f),
|
|
37
|
+
style: p,
|
|
38
|
+
"data-pihanga": m
|
|
39
|
+
}, y());
|
|
40
|
+
};
|
|
41
|
+
//#endregion
|
|
42
|
+
export { o as TypographyComponent };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=typography.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typography.component.js","names":[],"sources":["../../../src/cards/typography/typography.component.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\nimport {cn} from \"@/lib/utils\";\nimport type {TypographyLevel, TypographyProps} from \"./typography.types\";\n\n/** Maps each level to [html element, tailwind classes] */\nconst LEVEL_CONFIG: Record<\n TypographyLevel,\n [keyof React.JSX.IntrinsicElements, string]\n> = {\n h1: [\"h1\", \"scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl\"],\n h2: [\n \"h2\",\n \"scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0\",\n ],\n h3: [\"h3\", \"scroll-m-20 text-2xl font-semibold tracking-tight\"],\n h4: [\"h4\", \"scroll-m-20 text-xl font-semibold tracking-tight\"],\n p: [\"p\", \"leading-7 [&:not(:first-child)]:mt-6\"],\n blockquote: [\"blockquote\", \"mt-6 border-l-2 pl-6 italic\"],\n code: [\n \"code\",\n \"relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold\",\n ],\n lead: [\"p\", \"text-xl text-muted-foreground\"],\n large: [\"div\", \"text-lg font-semibold\"],\n small: [\"small\", \"text-sm font-medium leading-none\"],\n muted: [\"p\", \"text-sm text-muted-foreground\"],\n};\n\nexport const TypographyComponent = (\n props: PiCardProps<TypographyProps>,\n): React.ReactNode => {\n const {\n text,\n childCard,\n paragraph,\n level,\n className,\n style,\n cardName,\n _dispatch,\n _cls,\n } = props;\n\n const [el, levelClass] = level ? LEVEL_CONFIG[level] : [\"div\", \"\"];\n\n function renderChildren(): React.ReactNode {\n if (childCard) {\n return <Card cardName={childCard} parentCard={cardName} />;\n }\n if (paragraph) {\n return <>{paragraph.map((item, i) => renderParaItem(item, i))}</>;\n }\n return text;\n }\n\n function renderParaItem(\n item: string | TypographyProps,\n key: number,\n ): React.ReactNode {\n if (typeof item === \"string\") {\n return item;\n }\n if (item && typeof item === \"object\") {\n return TypographyComponent({\n ...item,\n _dispatch,\n _cls,\n cardName,\n key,\n } as PiCardProps<TypographyProps> & {key: number});\n }\n return null;\n }\n\n return React.createElement(\n el,\n {\n className: cn(levelClass, className),\n style,\n \"data-pihanga\": cardName,\n },\n renderChildren(),\n );\n};\n"],"mappings":";;;;;AAMA,IAAM,IAGF;CACF,IAAI,CAAC,MAAM,gEAAgE;CAC3E,IAAI,CACF,MACA,4EACF;CACA,IAAI,CAAC,MAAM,mDAAmD;CAC9D,IAAI,CAAC,MAAM,kDAAkD;CAC7D,GAAG,CAAC,KAAK,sCAAsC;CAC/C,YAAY,CAAC,cAAc,6BAA6B;CACxD,MAAM,CACJ,QACA,mFACF;CACA,MAAM,CAAC,KAAK,+BAA+B;CAC3C,OAAO,CAAC,OAAO,uBAAuB;CACtC,OAAO,CAAC,SAAS,kCAAkC;CACnD,OAAO,CAAC,KAAK,+BAA+B;AAC9C,GAEa,KACX,MACoB;CACpB,IAAM,EACJ,SACA,cACA,cACA,UACA,cACA,UACA,aACA,cACA,YACE,GAEE,CAAC,GAAI,KAAc,IAAQ,EAAa,KAAS,CAAC,OAAO,EAAE;CAEjE,SAAS,IAAkC;EAOzC,OANI,IACK,kBAAC,GAAD;GAAM,UAAU;GAAW,YAAY;EAAW,CAAA,IAEvD,IACK,kBAAA,GAAA,EAAA,UAAG,EAAU,KAAK,GAAM,MAAM,EAAe,GAAM,CAAC,CAAC,EAAI,CAAA,IAE3D;CACT;CAEA,SAAS,EACP,GACA,GACiB;EAajB,OAZI,OAAO,KAAS,WACX,IAEL,KAAQ,OAAO,KAAS,WACnB,EAAoB;GACzB,GAAG;GACH;GACA;GACA;GACA;EACF,CAAiD,IAE5C;CACT;CAEA,OAAO,EAAM,cACX,GACA;EACE,WAAW,EAAG,GAAY,CAAS;EACnC;EACA,gBAAgB;CAClB,GACA,EAAe,CACjB;AACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PiCardRef } from '@pihanga2/core';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export declare const TYPOGRAPHY_CARD = "shad/typography";
|
|
4
|
+
export declare const Typography: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<TypographyProps, S, {}>) => import('@pihanga2/core').PiCardDef;
|
|
5
|
+
/**
|
|
6
|
+
* Semantic level controls both the rendered HTML element and default
|
|
7
|
+
* Tailwind prose styling (following shadcn/ui typography conventions).
|
|
8
|
+
*/
|
|
9
|
+
export type TypographyLevel = "h1" | "h2" | "h3" | "h4" | "p" | "blockquote" | "code" | "lead" | "large" | "small" | "muted";
|
|
10
|
+
export type TypographyProps = {
|
|
11
|
+
/** Plain text content. */
|
|
12
|
+
text?: string;
|
|
13
|
+
/** A child card rendered as content. */
|
|
14
|
+
childCard?: PiCardRef;
|
|
15
|
+
/** Inline paragraph: mix of literal strings and nested TypographyProps. */
|
|
16
|
+
paragraph?: (string | TypographyProps)[];
|
|
17
|
+
/** Semantic level — controls the HTML element and default prose styling. */
|
|
18
|
+
level?: TypographyLevel;
|
|
19
|
+
/** Additional CSS classes applied directly to the element. */
|
|
20
|
+
className?: string;
|
|
21
|
+
/** Inline styles applied directly to the element. */
|
|
22
|
+
style?: React.CSSProperties;
|
|
23
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/typography/typography.types.ts
|
|
3
|
+
var t = "shad/typography", n = e(t);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { t as TYPOGRAPHY_CARD, n as Typography };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=typography.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typography.types.js","names":[],"sources":["../../../src/cards/typography/typography.types.ts"],"sourcesContent":["import * as React from \"react\";\nimport {PiCardRef, createCardDeclaration} from \"@pihanga2/core\";\n\nexport const TYPOGRAPHY_CARD = \"shad/typography\";\n\nexport const Typography =\n createCardDeclaration<TypographyProps>(TYPOGRAPHY_CARD);\n\n/**\n * Semantic level controls both the rendered HTML element and default\n * Tailwind prose styling (following shadcn/ui typography conventions).\n */\nexport type TypographyLevel =\n | \"h1\"\n | \"h2\"\n | \"h3\"\n | \"h4\"\n | \"p\"\n | \"blockquote\"\n | \"code\"\n | \"lead\" // large muted intro paragraph\n | \"large\" // large text, semibold\n | \"small\" // small, medium-weight\n | \"muted\"; // small, muted-foreground\n\nexport type TypographyProps = {\n /** Plain text content. */\n text?: string;\n /** A child card rendered as content. */\n childCard?: PiCardRef;\n /** Inline paragraph: mix of literal strings and nested TypographyProps. */\n paragraph?: (string | TypographyProps)[];\n\n /** Semantic level — controls the HTML element and default prose styling. */\n level?: TypographyLevel;\n\n /** Additional CSS classes applied directly to the element. */\n className?: string;\n /** Inline styles applied directly to the element. */\n style?: React.CSSProperties;\n};\n"],"mappings":";;AAGA,IAAa,IAAkB,mBAElB,IACX,EAAuC,CAAe"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsTouchDevice(): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/lib/utils.ts"],"sourcesContent":["import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n"],"mappings":";;;AAGA,SAAgB,EAAG,GAAG,GAAsB;CAC1C,OAAO,EAAQ,EAAK,CAAM,CAAC;AAC7B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ThemeProviderContext as e } from "./theme-provider.types.js";
|
|
2
|
+
import { useContext as t } from "react";
|
|
3
|
+
//#region src/components/theme-provider/index.ts
|
|
4
|
+
var n = () => {
|
|
5
|
+
let n = t(e);
|
|
6
|
+
if (n === void 0) throw Error("useTheme must be used within a ThemeProvider");
|
|
7
|
+
return n;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { n as useTheme };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/theme-provider/index.ts"],"sourcesContent":["import {useContext} from \"react\";\nimport {ThemeProviderContext} from \"./theme-provider.types\";\n\nexport const useTheme = () => {\n const context = useContext(ThemeProviderContext);\n\n if (context === undefined)\n throw new Error(\"useTheme must be used within a ThemeProvider\");\n\n return context;\n};\n"],"mappings":";;;AAGA,IAAa,UAAiB;CAC5B,IAAM,IAAU,EAAW,CAAoB;CAE/C,IAAI,MAAY,KAAA,GACd,MAAU,MAAM,8CAA8C;CAEhE,OAAO;AACT"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ThemeProviderContext as e } from "./theme-provider.types.js";
|
|
2
|
+
import { useEffect as t, useState as n } from "react";
|
|
3
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/theme-provider/theme-provider.component.tsx
|
|
5
|
+
function i({ children: i, defaultTheme: a = "system", storageKey: o = "vite-ui-theme", ...s }) {
|
|
6
|
+
let [c, l] = n(() => localStorage.getItem(o) || a);
|
|
7
|
+
t(() => {
|
|
8
|
+
let e = window.document.documentElement;
|
|
9
|
+
if (e.classList.remove("light", "dark"), c === "system") {
|
|
10
|
+
let t = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
11
|
+
e.classList.add(t);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
e.classList.add(c);
|
|
15
|
+
}, [c]);
|
|
16
|
+
let u = {
|
|
17
|
+
theme: c,
|
|
18
|
+
setTheme: (e) => {
|
|
19
|
+
localStorage.setItem(o, e), l(e);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ r(e.Provider, {
|
|
23
|
+
...s,
|
|
24
|
+
value: u,
|
|
25
|
+
children: i
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { i as ThemeProvider };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=theme-provider.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-provider.component.js","names":[],"sources":["../../../src/components/theme-provider/theme-provider.component.tsx"],"sourcesContent":["import {useEffect, useState} from \"react\";\nimport {\n ThemeProviderContext,\n type Theme,\n type ThemeProviderProps,\n} from \"./theme-provider.types\";\n\nexport function ThemeProvider({\n children,\n defaultTheme = \"system\",\n storageKey = \"vite-ui-theme\",\n ...props\n}: ThemeProviderProps) {\n const [theme, setTheme] = useState<Theme>(\n () => (localStorage.getItem(storageKey) as Theme) || defaultTheme\n );\n\n useEffect(() => {\n const root = window.document.documentElement;\n\n root.classList.remove(\"light\", \"dark\");\n\n if (theme === \"system\") {\n const systemTheme = window.matchMedia(\"(prefers-color-scheme: dark)\")\n .matches\n ? \"dark\"\n : \"light\";\n\n root.classList.add(systemTheme);\n return;\n }\n\n root.classList.add(theme);\n }, [theme]);\n\n const value = {\n theme,\n setTheme: (theme: Theme) => {\n localStorage.setItem(storageKey, theme);\n setTheme(theme);\n },\n };\n\n return (\n <ThemeProviderContext.Provider {...props} value={value}>\n {children}\n </ThemeProviderContext.Provider>\n );\n}\n"],"mappings":";;;;AAOA,SAAgB,EAAc,EAC5B,aACA,kBAAe,UACf,gBAAa,iBACb,GAAG,KACkB;CACrB,IAAM,CAAC,GAAO,KAAY,QACjB,aAAa,QAAQ,CAAU,KAAe,CACvD;CAEA,QAAgB;EACd,IAAM,IAAO,OAAO,SAAS;EAI7B,IAFA,EAAK,UAAU,OAAO,SAAS,MAAM,GAEjC,MAAU,UAAU;GACtB,IAAM,IAAc,OAAO,WAAW,8BAA8B,EACjE,UACC,SACA;GAEJ,EAAK,UAAU,IAAI,CAAW;GAC9B;EACF;EAEA,EAAK,UAAU,IAAI,CAAK;CAC1B,GAAG,CAAC,CAAK,CAAC;CAEV,IAAM,IAAQ;EACZ;EACA,WAAW,MAAiB;GAE1B,AADA,aAAa,QAAQ,GAAY,CAAK,GACtC,EAAS,CAAK;EAChB;CACF;CAEA,OACE,kBAAC,EAAqB,UAAtB;EAA+B,GAAI;EAAc;EAC9C;CAC4B,CAAA;AAEnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type Theme = "dark" | "light" | "system";
|
|
2
|
+
export type ThemeProviderProps = {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
defaultTheme?: Theme;
|
|
5
|
+
storageKey?: string;
|
|
6
|
+
};
|
|
7
|
+
type ThemeProviderState = {
|
|
8
|
+
theme: Theme;
|
|
9
|
+
setTheme: (theme: Theme) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const ThemeProviderContext: import('react').Context<ThemeProviderState>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-provider.types.js","names":[],"sources":["../../../src/components/theme-provider/theme-provider.types.ts"],"sourcesContent":["import {createContext} from \"react\";\n\nexport type Theme = \"dark\" | \"light\" | \"system\";\n\nexport type ThemeProviderProps = {\n children: React.ReactNode;\n defaultTheme?: Theme;\n storageKey?: string;\n};\n\ntype ThemeProviderState = {\n theme: Theme;\n setTheme: (theme: Theme) => void;\n};\n\nconst initialState: ThemeProviderState = {\n theme: \"system\",\n setTheme: () => null,\n};\n\nexport const ThemeProviderContext =\n createContext<ThemeProviderState>(initialState);\n"],"mappings":";AAoBA,IAAa,IACX,EAAkC;CALlC,OAAO;CACP,gBAAgB;AAIkB,CAAY"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/utils.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
import { Avatar as n } from "radix-ui";
|
|
5
|
+
//#region src/components/ui/avatar.tsx
|
|
6
|
+
function r({ className: r, ...i }) {
|
|
7
|
+
return /* @__PURE__ */ t(n.Root, {
|
|
8
|
+
"data-slot": "avatar",
|
|
9
|
+
className: e("relative flex size-8 shrink-0 overflow-hidden rounded-full", r),
|
|
10
|
+
...i
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function i({ className: r, ...i }) {
|
|
14
|
+
return /* @__PURE__ */ t(n.Image, {
|
|
15
|
+
"data-slot": "avatar-image",
|
|
16
|
+
className: e("aspect-square size-full", r),
|
|
17
|
+
...i
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function a({ className: r, ...i }) {
|
|
21
|
+
return /* @__PURE__ */ t(n.Fallback, {
|
|
22
|
+
"data-slot": "avatar-fallback",
|
|
23
|
+
className: e("bg-muted flex size-full items-center justify-center rounded-full text-xs", r),
|
|
24
|
+
...i
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { r as Avatar, a as AvatarFallback, i as AvatarImage };
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=avatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"avatar.js","names":[],"sources":["../../../src/components/ui/avatar.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {Avatar as AvatarPrimitive} from \"radix-ui\";\n\nimport {cn} from \"@/lib/utils\";\n\nfunction Avatar({\n className,\n ...props\n}: React.ComponentProps<typeof AvatarPrimitive.Root>) {\n return (\n <AvatarPrimitive.Root\n data-slot=\"avatar\"\n className={cn(\n \"relative flex size-8 shrink-0 overflow-hidden rounded-full\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction AvatarImage({\n className,\n ...props\n}: React.ComponentProps<typeof AvatarPrimitive.Image>) {\n return (\n <AvatarPrimitive.Image\n data-slot=\"avatar-image\"\n className={cn(\"aspect-square size-full\", className)}\n {...props}\n />\n );\n}\n\nfunction AvatarFallback({\n className,\n ...props\n}: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {\n return (\n <AvatarPrimitive.Fallback\n data-slot=\"avatar-fallback\"\n className={cn(\n \"bg-muted flex size-full items-center justify-center rounded-full text-xs\",\n className,\n )}\n {...props}\n />\n );\n}\n\nexport {Avatar, AvatarFallback, AvatarImage};\n"],"mappings":";;;;;AAKA,SAAS,EAAO,EACd,cACA,GAAG,KACiD;CACpD,OACE,kBAAC,EAAgB,MAAjB;EACE,aAAU;EACV,WAAW,EACT,8DACA,CACF;EACA,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,EAAY,EACnB,cACA,GAAG,KACkD;CACrD,OACE,kBAAC,EAAgB,OAAjB;EACE,aAAU;EACV,WAAW,EAAG,2BAA2B,CAAS;EAClD,GAAI;CACL,CAAA;AAEL;AAEA,SAAS,EAAe,EACtB,cACA,GAAG,KACqD;CACxD,OACE,kBAAC,EAAgB,UAAjB;EACE,aAAU;EACV,WAAW,EACT,4EACA,CACF;EACA,GAAI;CACL,CAAA;AAEL"}
|