@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,196 @@
|
|
|
1
|
+
import { PiCardRef } from '@pihanga2/core';
|
|
2
|
+
export declare const DATA_TABLE_CARD = "shad/data-table";
|
|
3
|
+
export declare const DataTable: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<DataTableProps<Record<string, unknown>>, S, DataTableEvents>) => import('@pihanga2/core').PiCardDef;
|
|
4
|
+
export declare const DATA_TABLE_ACTION: {
|
|
5
|
+
ROW_CLICKED: string;
|
|
6
|
+
SORT_CHANGED: string;
|
|
7
|
+
SHOW_DETAIL: string;
|
|
8
|
+
HIDE_DETAIL: string;
|
|
9
|
+
PAGE_CHANGED: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const onDataTableRowClicked: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
12
|
+
cardID: string;
|
|
13
|
+
} & DataTableRowClickedEvent>) => void;
|
|
14
|
+
export declare const onDataTableSortChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
15
|
+
cardID: string;
|
|
16
|
+
} & DataTableSortChangedEvent>) => void;
|
|
17
|
+
export declare const onDataTableShowDetail: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
18
|
+
cardID: string;
|
|
19
|
+
} & DataTableDetailEvent>) => void;
|
|
20
|
+
export declare const onDataTableHideDetail: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
21
|
+
cardID: string;
|
|
22
|
+
} & DataTableDetailEvent>) => void;
|
|
23
|
+
export declare const onDataTablePageChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
24
|
+
cardID: string;
|
|
25
|
+
} & DataTablePageChangedEvent>) => void;
|
|
26
|
+
/** Shared base for all column definitions */
|
|
27
|
+
export type DataTableColumnBase = {
|
|
28
|
+
/** Key into the row's `data` object used to retrieve the cell value */
|
|
29
|
+
key: string;
|
|
30
|
+
/**
|
|
31
|
+
* Column header label.
|
|
32
|
+
* Defaults to the `key` with camelCase expanded to "Title Case".
|
|
33
|
+
*/
|
|
34
|
+
title?: string;
|
|
35
|
+
/** Column width as a CSS value (e.g. "120px", "10%", "1fr") */
|
|
36
|
+
width?: string | number;
|
|
37
|
+
/** Horizontal alignment of cell content. Defaults to "left". */
|
|
38
|
+
align?: "left" | "center" | "right";
|
|
39
|
+
/** Whether the column header is clickable for sorting */
|
|
40
|
+
sortable?: boolean;
|
|
41
|
+
/** Extra CSS class applied to the `<th>` header cell */
|
|
42
|
+
headerClassName?: string;
|
|
43
|
+
/** Extra CSS class applied to every `<td>` data cell in this column */
|
|
44
|
+
cellClassName?: string;
|
|
45
|
+
};
|
|
46
|
+
/** Plain text column — cell value rendered as a string */
|
|
47
|
+
export type TextColumn = DataTableColumnBase & {
|
|
48
|
+
type?: "text";
|
|
49
|
+
};
|
|
50
|
+
/** Numeric column with optional custom formatter */
|
|
51
|
+
export type NumberColumn = DataTableColumnBase & {
|
|
52
|
+
type: "number";
|
|
53
|
+
/** Custom number formatter; defaults to `String(value)` */
|
|
54
|
+
format?: (n: number) => string;
|
|
55
|
+
};
|
|
56
|
+
/** Badge/chip column — cell value is rendered inside a `<Badge>` */
|
|
57
|
+
export type BadgeColumn = DataTableColumnBase & {
|
|
58
|
+
type: "badge";
|
|
59
|
+
/**
|
|
60
|
+
* Map from cell value (as a string) to a shadcn Badge variant.
|
|
61
|
+
* Falls back to "secondary" for unrecognised values.
|
|
62
|
+
*/
|
|
63
|
+
variants?: Record<string, "default" | "secondary" | "destructive" | "outline">;
|
|
64
|
+
};
|
|
65
|
+
/** Date column with optional custom formatter */
|
|
66
|
+
export type DateColumn = DataTableColumnBase & {
|
|
67
|
+
type: "date";
|
|
68
|
+
/** Custom date formatter; defaults to `toLocaleDateString()` */
|
|
69
|
+
format?: (d: Date | string) => string;
|
|
70
|
+
};
|
|
71
|
+
/** Boolean column — renders a check-mark or cross icon */
|
|
72
|
+
export type BooleanColumn = DataTableColumnBase & {
|
|
73
|
+
type: "boolean";
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Card column — cell value must be a `PiCardRef` (string).
|
|
77
|
+
* The referenced card is rendered inline via Pihanga's `<Card />`.
|
|
78
|
+
* This enables full reuse of any registered Pihanga card as cell content.
|
|
79
|
+
*/
|
|
80
|
+
export type CardColumn = DataTableColumnBase & {
|
|
81
|
+
type: "card";
|
|
82
|
+
};
|
|
83
|
+
export type DataTableColumn = TextColumn | NumberColumn | BadgeColumn | DateColumn | BooleanColumn | CardColumn;
|
|
84
|
+
export type DataTableRow<T = Record<string, unknown>> = {
|
|
85
|
+
/** Unique row identifier used as the React key and in events */
|
|
86
|
+
id: string | number;
|
|
87
|
+
/**
|
|
88
|
+
* Row payload — values are keyed by the column's `key` field.
|
|
89
|
+
* For "card" columns the value should be a `PiCardRef` string.
|
|
90
|
+
*/
|
|
91
|
+
data: T;
|
|
92
|
+
/**
|
|
93
|
+
* When set, the row shows an expand/collapse toggle button.
|
|
94
|
+
* The referenced card is rendered full-width below the row on expand.
|
|
95
|
+
* Use `onShowDetail` / `onHideDetail` events to track expanded state in
|
|
96
|
+
* your redux store and update `detailCard` per row as needed.
|
|
97
|
+
*/
|
|
98
|
+
detailCard?: PiCardRef;
|
|
99
|
+
};
|
|
100
|
+
export type DataTableProps<T = Record<string, unknown>> = {
|
|
101
|
+
/** Column definitions — order determines display order */
|
|
102
|
+
columns: DataTableColumn[];
|
|
103
|
+
/** Row data */
|
|
104
|
+
rows: DataTableRow<T>[];
|
|
105
|
+
/** Optional visible `<caption>` rendered below the table */
|
|
106
|
+
caption?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Key of the currently sorted column.
|
|
109
|
+
* When provided the sort state is controlled; otherwise managed internally.
|
|
110
|
+
*/
|
|
111
|
+
sortKey?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Sort direction.
|
|
114
|
+
* When provided together with `sortKey` the sort state is controlled.
|
|
115
|
+
*/
|
|
116
|
+
sortAscending?: boolean;
|
|
117
|
+
/** Maximum number of rows per page. Omit to disable pagination. */
|
|
118
|
+
pageSize?: number;
|
|
119
|
+
/** Current page index (0-based). Treated as controlled when provided. */
|
|
120
|
+
currentPage?: number;
|
|
121
|
+
/**
|
|
122
|
+
* Total row count, used for server-side pagination display.
|
|
123
|
+
* Leave unset for client-side pagination derived from `rows.length`.
|
|
124
|
+
*/
|
|
125
|
+
totalRows?: number;
|
|
126
|
+
/** Keep the header visible while the body scrolls */
|
|
127
|
+
stickyHeader?: boolean;
|
|
128
|
+
/** Alternate row background colour (zebra striping) */
|
|
129
|
+
striped?: boolean;
|
|
130
|
+
/** Highlight rows on hover (default: true) */
|
|
131
|
+
hoverable?: boolean;
|
|
132
|
+
/** Use compact row padding */
|
|
133
|
+
compact?: boolean;
|
|
134
|
+
/** Card rendered when `rows` is empty */
|
|
135
|
+
emptyCard?: PiCardRef;
|
|
136
|
+
/** Fallback text when `rows` is empty and `emptyCard` is not set */
|
|
137
|
+
emptyText?: string;
|
|
138
|
+
className?: string;
|
|
139
|
+
};
|
|
140
|
+
export type DataTableRowClickedEvent = {
|
|
141
|
+
rowId: string | number;
|
|
142
|
+
row: DataTableRow;
|
|
143
|
+
};
|
|
144
|
+
export type DataTableSortChangedEvent = {
|
|
145
|
+
/** The column key that was clicked */
|
|
146
|
+
key: string;
|
|
147
|
+
/** `true` = ascending, `false` = descending */
|
|
148
|
+
ascending: boolean;
|
|
149
|
+
};
|
|
150
|
+
export type DataTableDetailEvent = {
|
|
151
|
+
rowId: string | number;
|
|
152
|
+
row: DataTableRow;
|
|
153
|
+
};
|
|
154
|
+
export type DataTablePageChangedEvent = {
|
|
155
|
+
/** New page index (0-based) */
|
|
156
|
+
page: number;
|
|
157
|
+
pageSize: number;
|
|
158
|
+
};
|
|
159
|
+
export type DataTableEvents = {
|
|
160
|
+
onRowClicked: DataTableRowClickedEvent;
|
|
161
|
+
onSortChanged: DataTableSortChangedEvent;
|
|
162
|
+
onShowDetail: DataTableDetailEvent;
|
|
163
|
+
onHideDetail: DataTableDetailEvent;
|
|
164
|
+
onPageChanged: DataTablePageChangedEvent;
|
|
165
|
+
};
|
|
166
|
+
/** Configuration for a single field shown in the detail panel. */
|
|
167
|
+
export type DataTableRowDetailField = {
|
|
168
|
+
/** Key to look up in `row.data` */
|
|
169
|
+
key: string;
|
|
170
|
+
/** Optional human-readable label prefix (e.g. "Director") */
|
|
171
|
+
label?: string;
|
|
172
|
+
/** Render style: "title" → h4 bold, "muted" → muted foreground, "text" (default) → plain */
|
|
173
|
+
type?: "title" | "text" | "muted";
|
|
174
|
+
/** Additional Tailwind class names forwarded to the element */
|
|
175
|
+
className?: string;
|
|
176
|
+
};
|
|
177
|
+
export type DataTableRowDetailProps = {
|
|
178
|
+
/**
|
|
179
|
+
* The row to display. Set this via a state mapper so a single template
|
|
180
|
+
* card works for all rows:
|
|
181
|
+
* ```ts
|
|
182
|
+
* DataTableRowDetail({
|
|
183
|
+
* row: (_, ctx) => ctx.ctxtProps?.row,
|
|
184
|
+
* fields: [{ key: "title", type: "title" }, ...],
|
|
185
|
+
* })
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
row?: DataTableRow<Record<string, unknown>>;
|
|
189
|
+
/**
|
|
190
|
+
* Fields to render in order.
|
|
191
|
+
* When omitted, every key in `row.data` is rendered as a plain key:value pair.
|
|
192
|
+
*/
|
|
193
|
+
fields?: DataTableRowDetailField[];
|
|
194
|
+
};
|
|
195
|
+
export declare const DATA_TABLE_ROW_DETAIL_CARD = "shad/data-table-row-detail";
|
|
196
|
+
export declare const DataTableRowDetail: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<DataTableRowDetailProps, S, {}>) => import('@pihanga2/core').PiCardDef;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/dataTable/dataTable.types.ts
|
|
3
|
+
var r = "shad/data-table", i = e(r), a = n(r, [
|
|
4
|
+
"row_clicked",
|
|
5
|
+
"sort_changed",
|
|
6
|
+
"show_detail",
|
|
7
|
+
"hide_detail",
|
|
8
|
+
"page_changed"
|
|
9
|
+
]), o = t(a.ROW_CLICKED), s = t(a.SORT_CHANGED), c = t(a.SHOW_DETAIL), l = t(a.HIDE_DETAIL), u = t(a.PAGE_CHANGED), d = "shad/data-table-row-detail", f = e(d);
|
|
10
|
+
//#endregion
|
|
11
|
+
export { a as DATA_TABLE_ACTION, r as DATA_TABLE_CARD, d as DATA_TABLE_ROW_DETAIL_CARD, i as DataTable, f as DataTableRowDetail, l as onDataTableHideDetail, u as onDataTablePageChanged, o as onDataTableRowClicked, c as onDataTableShowDetail, s as onDataTableSortChanged };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=dataTable.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataTable.types.js","names":[],"sources":["../../../src/cards/dataTable/dataTable.types.ts"],"sourcesContent":["import {\n PiCardRef,\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const DATA_TABLE_CARD = \"shad/data-table\";\n\nexport const DataTable = createCardDeclaration<DataTableProps, DataTableEvents>(\n DATA_TABLE_CARD,\n);\n\nexport const DATA_TABLE_ACTION = registerActions(DATA_TABLE_CARD, [\n \"row_clicked\",\n \"sort_changed\",\n \"show_detail\",\n \"hide_detail\",\n \"page_changed\",\n]);\n\nexport const onDataTableRowClicked = createOnAction<DataTableRowClickedEvent>(\n DATA_TABLE_ACTION.ROW_CLICKED,\n);\nexport const onDataTableSortChanged = createOnAction<DataTableSortChangedEvent>(\n DATA_TABLE_ACTION.SORT_CHANGED,\n);\nexport const onDataTableShowDetail = createOnAction<DataTableDetailEvent>(\n DATA_TABLE_ACTION.SHOW_DETAIL,\n);\nexport const onDataTableHideDetail = createOnAction<DataTableDetailEvent>(\n DATA_TABLE_ACTION.HIDE_DETAIL,\n);\nexport const onDataTablePageChanged = createOnAction<DataTablePageChangedEvent>(\n DATA_TABLE_ACTION.PAGE_CHANGED,\n);\n\n// ---------------------------------------------------------------------------\n// Column type definitions\n// ---------------------------------------------------------------------------\n\n/** Shared base for all column definitions */\nexport type DataTableColumnBase = {\n /** Key into the row's `data` object used to retrieve the cell value */\n key: string;\n /**\n * Column header label.\n * Defaults to the `key` with camelCase expanded to \"Title Case\".\n */\n title?: string;\n /** Column width as a CSS value (e.g. \"120px\", \"10%\", \"1fr\") */\n width?: string | number;\n /** Horizontal alignment of cell content. Defaults to \"left\". */\n align?: \"left\" | \"center\" | \"right\";\n /** Whether the column header is clickable for sorting */\n sortable?: boolean;\n /** Extra CSS class applied to the `<th>` header cell */\n headerClassName?: string;\n /** Extra CSS class applied to every `<td>` data cell in this column */\n cellClassName?: string;\n};\n\n/** Plain text column — cell value rendered as a string */\nexport type TextColumn = DataTableColumnBase & {\n type?: \"text\";\n};\n\n/** Numeric column with optional custom formatter */\nexport type NumberColumn = DataTableColumnBase & {\n type: \"number\";\n /** Custom number formatter; defaults to `String(value)` */\n format?: (n: number) => string;\n};\n\n/** Badge/chip column — cell value is rendered inside a `<Badge>` */\nexport type BadgeColumn = DataTableColumnBase & {\n type: \"badge\";\n /**\n * Map from cell value (as a string) to a shadcn Badge variant.\n * Falls back to \"secondary\" for unrecognised values.\n */\n variants?: Record<\n string,\n \"default\" | \"secondary\" | \"destructive\" | \"outline\"\n >;\n};\n\n/** Date column with optional custom formatter */\nexport type DateColumn = DataTableColumnBase & {\n type: \"date\";\n /** Custom date formatter; defaults to `toLocaleDateString()` */\n format?: (d: Date | string) => string;\n};\n\n/** Boolean column — renders a check-mark or cross icon */\nexport type BooleanColumn = DataTableColumnBase & {\n type: \"boolean\";\n};\n\n/**\n * Card column — cell value must be a `PiCardRef` (string).\n * The referenced card is rendered inline via Pihanga's `<Card />`.\n * This enables full reuse of any registered Pihanga card as cell content.\n */\nexport type CardColumn = DataTableColumnBase & {\n type: \"card\";\n};\n\nexport type DataTableColumn =\n | TextColumn\n | NumberColumn\n | BadgeColumn\n | DateColumn\n | BooleanColumn\n | CardColumn;\n\n// ---------------------------------------------------------------------------\n// Row\n// ---------------------------------------------------------------------------\n\nexport type DataTableRow<T = Record<string, unknown>> = {\n /** Unique row identifier used as the React key and in events */\n id: string | number;\n /**\n * Row payload — values are keyed by the column's `key` field.\n * For \"card\" columns the value should be a `PiCardRef` string.\n */\n data: T;\n /**\n * When set, the row shows an expand/collapse toggle button.\n * The referenced card is rendered full-width below the row on expand.\n * Use `onShowDetail` / `onHideDetail` events to track expanded state in\n * your redux store and update `detailCard` per row as needed.\n */\n detailCard?: PiCardRef;\n};\n\n// ---------------------------------------------------------------------------\n// Props\n// ---------------------------------------------------------------------------\n\nexport type DataTableProps<T = Record<string, unknown>> = {\n /** Column definitions — order determines display order */\n columns: DataTableColumn[];\n /** Row data */\n rows: DataTableRow<T>[];\n /** Optional visible `<caption>` rendered below the table */\n caption?: string;\n\n // --- Sorting ---\n /**\n * Key of the currently sorted column.\n * When provided the sort state is controlled; otherwise managed internally.\n */\n sortKey?: string;\n /**\n * Sort direction.\n * When provided together with `sortKey` the sort state is controlled.\n */\n sortAscending?: boolean;\n\n // --- Pagination ---\n /** Maximum number of rows per page. Omit to disable pagination. */\n pageSize?: number;\n /** Current page index (0-based). Treated as controlled when provided. */\n currentPage?: number;\n /**\n * Total row count, used for server-side pagination display.\n * Leave unset for client-side pagination derived from `rows.length`.\n */\n totalRows?: number;\n\n // --- Display ---\n /** Keep the header visible while the body scrolls */\n stickyHeader?: boolean;\n /** Alternate row background colour (zebra striping) */\n striped?: boolean;\n /** Highlight rows on hover (default: true) */\n hoverable?: boolean;\n /** Use compact row padding */\n compact?: boolean;\n\n // --- Empty state ---\n /** Card rendered when `rows` is empty */\n emptyCard?: PiCardRef;\n /** Fallback text when `rows` is empty and `emptyCard` is not set */\n emptyText?: string;\n\n className?: string;\n};\n\n// ---------------------------------------------------------------------------\n// Events\n// ---------------------------------------------------------------------------\n\nexport type DataTableRowClickedEvent = {\n rowId: string | number;\n row: DataTableRow;\n};\n\nexport type DataTableSortChangedEvent = {\n /** The column key that was clicked */\n key: string;\n /** `true` = ascending, `false` = descending */\n ascending: boolean;\n};\n\nexport type DataTableDetailEvent = {\n rowId: string | number;\n row: DataTableRow;\n};\n\nexport type DataTablePageChangedEvent = {\n /** New page index (0-based) */\n page: number;\n pageSize: number;\n};\n\nexport type DataTableEvents = {\n onRowClicked: DataTableRowClickedEvent;\n onSortChanged: DataTableSortChangedEvent;\n onShowDetail: DataTableDetailEvent;\n onHideDetail: DataTableDetailEvent;\n onPageChanged: DataTablePageChangedEvent;\n};\n\n// ---------------------------------------------------------------------------\n// DataTableRowDetail — generic single-template detail panel\n// ---------------------------------------------------------------------------\n\n/** Configuration for a single field shown in the detail panel. */\nexport type DataTableRowDetailField = {\n /** Key to look up in `row.data` */\n key: string;\n /** Optional human-readable label prefix (e.g. \"Director\") */\n label?: string;\n /** Render style: \"title\" → h4 bold, \"muted\" → muted foreground, \"text\" (default) → plain */\n type?: \"title\" | \"text\" | \"muted\";\n /** Additional Tailwind class names forwarded to the element */\n className?: string;\n};\n\nexport type DataTableRowDetailProps = {\n /**\n * The row to display. Set this via a state mapper so a single template\n * card works for all rows:\n * ```ts\n * DataTableRowDetail({\n * row: (_, ctx) => ctx.ctxtProps?.row,\n * fields: [{ key: \"title\", type: \"title\" }, ...],\n * })\n * ```\n */\n row?: DataTableRow<Record<string, unknown>>;\n /**\n * Fields to render in order.\n * When omitted, every key in `row.data` is rendered as a plain key:value pair.\n */\n fields?: DataTableRowDetailField[];\n};\n\nexport const DATA_TABLE_ROW_DETAIL_CARD = \"shad/data-table-row-detail\";\nexport const DataTableRowDetail =\n createCardDeclaration<DataTableRowDetailProps>(DATA_TABLE_ROW_DETAIL_CARD);\n"],"mappings":";;AAOA,IAAa,IAAkB,mBAElB,IAAY,EACvB,CACF,GAEa,IAAoB,EAAgB,GAAiB;CAChE;CACA;CACA;CACA;CACA;AACF,CAAC,GAEY,IAAwB,EACnC,EAAkB,WACpB,GACa,IAAyB,EACpC,EAAkB,YACpB,GACa,IAAwB,EACnC,EAAkB,WACpB,GACa,IAAwB,EACnC,EAAkB,WACpB,GACa,IAAyB,EACpC,EAAkB,YACpB,GAkOa,IAA6B,8BAC7B,IACX,EAA+C,CAA0B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { PiCardProps } from '@pihanga2/core';
|
|
3
|
+
import { DataTableRowDetailProps } from './dataTable.types';
|
|
4
|
+
/**
|
|
5
|
+
* DataTableRowDetail — generic detail-panel card for use with DataTable.
|
|
6
|
+
*
|
|
7
|
+
* Register it ONCE as a template, then reference it in every row via
|
|
8
|
+
* `detailCard`. The DataTable passes the row via `cardKey` + `row` context
|
|
9
|
+
* props so a state mapper on the `row` field delivers the correct data:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* registerCard(
|
|
13
|
+
* "app/myTable/rowDetail",
|
|
14
|
+
* DataTableRowDetail({
|
|
15
|
+
* // State mapper — ctx.ctxtProps.row is injected by the DataTable
|
|
16
|
+
* row: (_, ctx) => ctx.ctxtProps?.row,
|
|
17
|
+
* fields: [
|
|
18
|
+
* { key: "title", type: "title" },
|
|
19
|
+
* { key: "director", label: "Director" },
|
|
20
|
+
* { key: "plot", type: "muted" },
|
|
21
|
+
* ],
|
|
22
|
+
* }),
|
|
23
|
+
* );
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const DataTableRowDetailComponent: (props: PiCardProps<DataTableRowDetailProps>) => React.ReactNode;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/utils.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Fragment as t, jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/cards/dataTable/dataTableRowDetail.component.tsx
|
|
5
|
+
var i = (i) => {
|
|
6
|
+
let { row: a, fields: o, cardName: s } = i;
|
|
7
|
+
if (!a?.data) return null;
|
|
8
|
+
let c = a.data;
|
|
9
|
+
return !o || o.length === 0 ? /* @__PURE__ */ n("div", {
|
|
10
|
+
className: "flex flex-col gap-1 text-sm",
|
|
11
|
+
"data-pihanga": s,
|
|
12
|
+
children: Object.entries(c).map(([e, t]) => /* @__PURE__ */ r("div", { children: [/* @__PURE__ */ r("span", {
|
|
13
|
+
className: "font-medium text-muted-foreground",
|
|
14
|
+
children: [e, ": "]
|
|
15
|
+
}), /* @__PURE__ */ n("span", { children: String(t ?? "") })] }, e))
|
|
16
|
+
}) : /* @__PURE__ */ n("div", {
|
|
17
|
+
className: "flex flex-col gap-1",
|
|
18
|
+
"data-pihanga": s,
|
|
19
|
+
children: o.map((i) => {
|
|
20
|
+
let a = c[i.key], o = a == null ? "" : String(a);
|
|
21
|
+
switch (i.type) {
|
|
22
|
+
case "title": return /* @__PURE__ */ n("h4", {
|
|
23
|
+
className: "text-base font-semibold",
|
|
24
|
+
children: o
|
|
25
|
+
}, i.key);
|
|
26
|
+
case "muted": return /* @__PURE__ */ n("p", {
|
|
27
|
+
className: "text-sm text-muted-foreground",
|
|
28
|
+
children: i.label ? /* @__PURE__ */ r(t, { children: [/* @__PURE__ */ r("span", {
|
|
29
|
+
className: "font-medium",
|
|
30
|
+
children: [i.label, ": "]
|
|
31
|
+
}), o] }) : o
|
|
32
|
+
}, i.key);
|
|
33
|
+
default: return /* @__PURE__ */ n("p", {
|
|
34
|
+
className: e("text-sm", i.className),
|
|
35
|
+
children: i.label ? /* @__PURE__ */ r(t, { children: [/* @__PURE__ */ r("span", {
|
|
36
|
+
className: "font-medium",
|
|
37
|
+
children: [i.label, ": "]
|
|
38
|
+
}), o] }) : o
|
|
39
|
+
}, i.key);
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { i as DataTableRowDetailComponent };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=dataTableRowDetail.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataTableRowDetail.component.js","names":[],"sources":["../../../src/cards/dataTable/dataTableRowDetail.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {type PiCardProps} from \"@pihanga2/core\";\nimport {cn} from \"@/lib/utils\";\nimport type {\n DataTableRowDetailField,\n DataTableRowDetailProps,\n} from \"./dataTable.types\";\n\n/**\n * DataTableRowDetail — generic detail-panel card for use with DataTable.\n *\n * Register it ONCE as a template, then reference it in every row via\n * `detailCard`. The DataTable passes the row via `cardKey` + `row` context\n * props so a state mapper on the `row` field delivers the correct data:\n *\n * ```ts\n * registerCard(\n * \"app/myTable/rowDetail\",\n * DataTableRowDetail({\n * // State mapper — ctx.ctxtProps.row is injected by the DataTable\n * row: (_, ctx) => ctx.ctxtProps?.row,\n * fields: [\n * { key: \"title\", type: \"title\" },\n * { key: \"director\", label: \"Director\" },\n * { key: \"plot\", type: \"muted\" },\n * ],\n * }),\n * );\n * ```\n */\nexport const DataTableRowDetailComponent = (\n props: PiCardProps<DataTableRowDetailProps>,\n): React.ReactNode => {\n const {row, fields, cardName} = props;\n\n if (!row?.data) {\n return null;\n }\n\n const data = row.data as Record<string, unknown>;\n\n /** If no `fields` config, auto-render all keys as plain text */\n if (!fields || fields.length === 0) {\n return (\n <div className=\"flex flex-col gap-1 text-sm\" data-pihanga={cardName}>\n {Object.entries(data).map(([key, value]) => (\n <div key={key}>\n <span className=\"font-medium text-muted-foreground\">{key}: </span>\n <span>{String(value ?? \"\")}</span>\n </div>\n ))}\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col gap-1\" data-pihanga={cardName}>\n {fields.map((field: DataTableRowDetailField) => {\n const value = data[field.key];\n const display = value == null ? \"\" : String(value);\n\n switch (field.type) {\n case \"title\":\n return (\n <h4 key={field.key} className=\"text-base font-semibold\">\n {display}\n </h4>\n );\n\n case \"muted\":\n return (\n <p key={field.key} className=\"text-sm text-muted-foreground\">\n {field.label ? (\n <>\n <span className=\"font-medium\">{field.label}: </span>\n {display}\n </>\n ) : (\n display\n )}\n </p>\n );\n\n default:\n // \"text\" or any unknown type\n return (\n <p key={field.key} className={cn(\"text-sm\", field.className)}>\n {field.label ? (\n <>\n <span className=\"font-medium\">{field.label}: </span>\n {display}\n </>\n ) : (\n display\n )}\n </p>\n );\n }\n })}\n </div>\n );\n};\n"],"mappings":";;;;AA8BA,IAAa,KACX,MACoB;CACpB,IAAM,EAAC,QAAK,WAAQ,gBAAY;CAEhC,IAAI,CAAC,GAAK,MACR,OAAO;CAGT,IAAM,IAAO,EAAI;CAgBjB,OAbI,CAAC,KAAU,EAAO,WAAW,IAE7B,kBAAC,OAAD;EAAK,WAAU;EAA8B,gBAAc;YACxD,OAAO,QAAQ,CAAI,EAAE,KAAK,CAAC,GAAK,OAC/B,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,QAAD;GAAM,WAAU;aAAhB,CAAqD,GAAI,IAAQ;MACjE,kBAAC,QAAD,EAAA,UAAO,OAAO,KAAS,EAAE,EAAQ,CAAA,CAC9B,EAAA,GAHK,CAGL,CACN;CACE,CAAA,IAKP,kBAAC,OAAD;EAAK,WAAU;EAAsB,gBAAc;YAChD,EAAO,KAAK,MAAmC;GAC9C,IAAM,IAAQ,EAAK,EAAM,MACnB,IAAU,KAAS,OAAO,KAAK,OAAO,CAAK;GAEjD,QAAQ,EAAM,MAAd;IACE,KAAK,SACH,OACE,kBAAC,MAAD;KAAoB,WAAU;eAC3B;IACC,GAFK,EAAM,GAEX;IAGR,KAAK,SACH,OACE,kBAAC,KAAD;KAAmB,WAAU;eAC1B,EAAM,QACL,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,QAAD;MAAM,WAAU;gBAAhB,CAA+B,EAAM,OAAM,IAAQ;SAClD,CACD,EAAA,CAAA,IAEF;IAED,GATK,EAAM,GASX;IAGP,SAEE,OACE,kBAAC,KAAD;KAAmB,WAAW,EAAG,WAAW,EAAM,SAAS;eACxD,EAAM,QACL,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,QAAD;MAAM,WAAU;gBAAhB,CAA+B,EAAM,OAAM,IAAQ;SAClD,CACD,EAAA,CAAA,IAEF;IAED,GATK,EAAM,GASX;GAET;EACF,CAAC;CACE,CAAA;AAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dataTable.types';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DataTableComponent as e } from "./dataTable.component.js";
|
|
2
|
+
import { DataTableRowDetailComponent as t } from "./dataTableRowDetail.component.js";
|
|
3
|
+
import { DATA_TABLE_ACTION as n, DATA_TABLE_CARD as r, DATA_TABLE_ROW_DETAIL_CARD as i, DataTable as a, DataTableRowDetail as o, onDataTableHideDetail as s, onDataTablePageChanged as c, onDataTableRowClicked as l, onDataTableShowDetail as u, onDataTableSortChanged as d } from "./dataTable.types.js";
|
|
4
|
+
import { actionTypesToEvents as f, registerCardComponent as p } from "@pihanga2/core";
|
|
5
|
+
p({
|
|
6
|
+
name: r,
|
|
7
|
+
component: e,
|
|
8
|
+
events: f(n)
|
|
9
|
+
}), p({
|
|
10
|
+
name: i,
|
|
11
|
+
component: t
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
export { n as DATA_TABLE_ACTION, r as DATA_TABLE_CARD, i as DATA_TABLE_ROW_DETAIL_CARD, a as DataTable, o as DataTableRowDetail, s as onDataTableHideDetail, c as onDataTablePageChanged, l as onDataTableRowClicked, u as onDataTableShowDetail, d as onDataTableSortChanged };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/dataTable/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {DataTableComponent} from \"./dataTable.component\";\nimport {DataTableRowDetailComponent} from \"./dataTableRowDetail.component\";\nimport {\n DATA_TABLE_ACTION,\n DATA_TABLE_CARD,\n DATA_TABLE_ROW_DETAIL_CARD,\n} from \"./dataTable.types\";\n\nexport * from \"./dataTable.types\";\n\nregisterCardComponent({\n name: DATA_TABLE_CARD,\n component: DataTableComponent,\n events: actionTypesToEvents(DATA_TABLE_ACTION),\n});\n\nregisterCardComponent({\n name: DATA_TABLE_ROW_DETAIL_CARD,\n component: DataTableRowDetailComponent,\n});\n"],"mappings":";;;;AAYA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAiB;AAC/C,CAAC,GAED,EAAsB;CACpB,MAAM;CACN,WAAW;AACb,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Button as e } from "../../components/ui/button.js";
|
|
2
|
+
import { Dialog as t, DialogBody as n, DialogContent as r, DialogDescription as i, DialogFooter as a, DialogHeader as o, DialogTitle as s, DialogTrigger as c } from "../../components/ui/dialog.js";
|
|
3
|
+
import { Card as l } from "@pihanga2/core";
|
|
4
|
+
import u from "react";
|
|
5
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
6
|
+
//#region src/cards/dialog/dialog.component.tsx
|
|
7
|
+
var p = (p) => {
|
|
8
|
+
let { id: m, trigger: h, content: g, title: _, description: v, open: y, size: b, variant: x, desktopVariant: S, mobileVariant: C, dismissible: w, hideClose: T, className: E, footer: D, footerCloseButtonText: O, cardName: k, onOpened: A, onClosed: j, onOpenChanged: M } = p, N = O === void 0 ? "Close" : O, [P, F] = u.useState(!1), I = y ?? P, L = u.useRef(y);
|
|
9
|
+
u.useEffect(() => {
|
|
10
|
+
L.current === !0 && y === !1 && I === !1 && j({
|
|
11
|
+
id: m,
|
|
12
|
+
reason: "programmatic"
|
|
13
|
+
}), L.current = y;
|
|
14
|
+
}, [
|
|
15
|
+
y,
|
|
16
|
+
I,
|
|
17
|
+
m,
|
|
18
|
+
j
|
|
19
|
+
]);
|
|
20
|
+
let R = (e) => {
|
|
21
|
+
y === void 0 && F(e), M({
|
|
22
|
+
open: e,
|
|
23
|
+
id: m
|
|
24
|
+
}), e ? A({ id: m }) : y === void 0 && j({
|
|
25
|
+
id: m,
|
|
26
|
+
reason: "user"
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
function z() {
|
|
30
|
+
return h ? /* @__PURE__ */ d("span", {
|
|
31
|
+
className: "inline-flex",
|
|
32
|
+
"data-pihanga-trigger-wrapper": !0,
|
|
33
|
+
children: /* @__PURE__ */ d(l, {
|
|
34
|
+
cardName: h,
|
|
35
|
+
parentCard: k
|
|
36
|
+
})
|
|
37
|
+
}) : null;
|
|
38
|
+
}
|
|
39
|
+
function B() {
|
|
40
|
+
return !_ && !v ? null : /* @__PURE__ */ f(o, { children: [_ && /* @__PURE__ */ d(s, { children: _ }), v && /* @__PURE__ */ d(i, { children: v })] });
|
|
41
|
+
}
|
|
42
|
+
function V() {
|
|
43
|
+
return D ? /* @__PURE__ */ d(a, {
|
|
44
|
+
className: "bg-muted/50",
|
|
45
|
+
children: /* @__PURE__ */ d(l, {
|
|
46
|
+
cardName: D,
|
|
47
|
+
parentCard: k
|
|
48
|
+
})
|
|
49
|
+
}) : N === null ? null : /* @__PURE__ */ d(a, {
|
|
50
|
+
className: "bg-muted/50",
|
|
51
|
+
children: /* @__PURE__ */ d(e, {
|
|
52
|
+
variant: "outline",
|
|
53
|
+
onClick: () => R(!1),
|
|
54
|
+
children: N
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
let H = !!(_ || v || D || N);
|
|
59
|
+
return /* @__PURE__ */ f(t, {
|
|
60
|
+
open: I,
|
|
61
|
+
onOpenChange: R,
|
|
62
|
+
children: [h && /* @__PURE__ */ d(c, {
|
|
63
|
+
asChild: !0,
|
|
64
|
+
children: z()
|
|
65
|
+
}), /* @__PURE__ */ f(r, {
|
|
66
|
+
"data-pihanga": k,
|
|
67
|
+
size: b,
|
|
68
|
+
variant: x,
|
|
69
|
+
desktopVariant: S,
|
|
70
|
+
mobileVariant: C,
|
|
71
|
+
dismissible: w,
|
|
72
|
+
hideClose: T,
|
|
73
|
+
fixed: H,
|
|
74
|
+
className: E,
|
|
75
|
+
children: [
|
|
76
|
+
B(),
|
|
77
|
+
/* @__PURE__ */ d(n, { children: /* @__PURE__ */ d(l, {
|
|
78
|
+
cardName: g,
|
|
79
|
+
parentCard: k
|
|
80
|
+
}) }),
|
|
81
|
+
V()
|
|
82
|
+
]
|
|
83
|
+
})]
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
//#endregion
|
|
87
|
+
export { p as DialogComponent };
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=dialog.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.component.js","names":[],"sources":["../../../src/cards/dialog/dialog.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\n\nimport {\n Dialog as DialogRoot,\n DialogTrigger,\n DialogContent,\n DialogHeader,\n DialogTitle,\n DialogDescription,\n DialogBody,\n DialogFooter,\n} from \"@/registry/ui/dialog\";\nimport {Button} from \"@/registry/ui/button\";\n\nimport type {PiDialogEvents, PiDialogProps} from \"./dialog.types\";\n\nexport const DialogComponent = (\n props: PiCardProps<PiDialogProps, PiDialogEvents>,\n): React.ReactNode => {\n const {\n id,\n trigger,\n content,\n title,\n description,\n open: controlledOpen,\n size,\n variant,\n desktopVariant,\n mobileVariant,\n dismissible,\n hideClose,\n className,\n footer,\n footerCloseButtonText,\n cardName,\n onOpened,\n onClosed,\n onOpenChanged,\n } = props;\n\n // Apply default for footer close button text\n const effectiveFooterCloseButtonText =\n footerCloseButtonText === undefined ? \"Close\" : footerCloseButtonText;\n\n // Internal state for uncontrolled mode\n const [internalOpen, setInternalOpen] = React.useState(false);\n\n // Use controlled open if provided, otherwise use internal state\n const open = controlledOpen ?? internalOpen;\n\n // Track previous open state to detect programmatic changes\n const prevControlledOpenRef = React.useRef(controlledOpen);\n\n React.useEffect(() => {\n // Detect programmatic close via props.open changing from true to false\n if (\n prevControlledOpenRef.current === true &&\n controlledOpen === false &&\n open === false\n ) {\n // This is a programmatic close\n onClosed({id, reason: \"programmatic\"});\n }\n prevControlledOpenRef.current = controlledOpen;\n }, [controlledOpen, open, id, onClosed]);\n\n const handleOpenChange = (nextOpen: boolean) => {\n // Update internal state if not controlled\n if (controlledOpen === undefined) {\n setInternalOpen(nextOpen);\n }\n\n // Emit events\n onOpenChanged({open: nextOpen, id});\n\n if (nextOpen) {\n onOpened({id});\n } else {\n // When user dismisses (not programmatic), reason is 'user'\n // We only get here from user actions when controlled open is undefined\n // or when the dialog component itself triggers the change\n if (controlledOpen === undefined) {\n onClosed({id, reason: \"user\"});\n }\n }\n };\n\n function renderTrigger() {\n if (!trigger) return null;\n\n // Similar to dropDownMenu: wrap trigger in a DOM element so Radix\n // can attach handlers via asChild even when trigger is a Pihanga card.\n return (\n <span className=\"inline-flex\" data-pihanga-trigger-wrapper>\n <Card cardName={trigger} parentCard={cardName} />\n </span>\n );\n }\n\n function renderHeader() {\n if (!title && !description) return null;\n\n return (\n <DialogHeader>\n {title && <DialogTitle>{title}</DialogTitle>}\n {description && <DialogDescription>{description}</DialogDescription>}\n </DialogHeader>\n );\n }\n\n function renderFooter() {\n // Custom footer card takes precedence\n if (footer) {\n return (\n <DialogFooter className=\"bg-muted/50\">\n <Card cardName={footer} parentCard={cardName} />\n </DialogFooter>\n );\n }\n\n // Default close button (if not explicitly disabled)\n if (effectiveFooterCloseButtonText !== null) {\n return (\n <DialogFooter className=\"bg-muted/50\">\n <Button variant=\"outline\" onClick={() => handleOpenChange(false)}>\n {effectiveFooterCloseButtonText}\n </Button>\n </DialogFooter>\n );\n }\n\n // No footer\n return null;\n }\n\n // Use fixed layout when we have header or footer\n const hasFixedLayout = !!(\n title ||\n description ||\n footer ||\n effectiveFooterCloseButtonText\n );\n\n return (\n <DialogRoot open={open} onOpenChange={handleOpenChange}>\n {trigger && <DialogTrigger asChild>{renderTrigger()}</DialogTrigger>}\n <DialogContent\n data-pihanga={cardName}\n size={size}\n variant={variant}\n desktopVariant={desktopVariant}\n mobileVariant={mobileVariant}\n dismissible={dismissible}\n hideClose={hideClose}\n fixed={hasFixedLayout}\n className={className}\n >\n {renderHeader()}\n <DialogBody>\n <Card cardName={content} parentCard={cardName} />\n </DialogBody>\n {renderFooter()}\n </DialogContent>\n </DialogRoot>\n );\n};\n"],"mappings":";;;;;;AAiBA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,OACA,YACA,YACA,UACA,gBACA,MAAM,GACN,SACA,YACA,mBACA,kBACA,gBACA,cACA,cACA,WACA,0BACA,aACA,aACA,aACA,qBACE,GAGE,IACJ,MAA0B,KAAA,IAAY,UAAU,GAG5C,CAAC,GAAc,KAAmB,EAAM,SAAS,EAAK,GAGtD,IAAO,KAAkB,GAGzB,IAAwB,EAAM,OAAO,CAAc;CAEzD,EAAM,gBAAgB;EAUpB,AAPE,EAAsB,YAAY,MAClC,MAAmB,MACnB,MAAS,MAGT,EAAS;GAAC;GAAI,QAAQ;EAAc,CAAC,GAEvC,EAAsB,UAAU;CAClC,GAAG;EAAC;EAAgB;EAAM;EAAI;CAAQ,CAAC;CAEvC,IAAM,KAAoB,MAAsB;EAS9C,AAPI,MAAmB,KAAA,KACrB,EAAgB,CAAQ,GAI1B,EAAc;GAAC,MAAM;GAAU;EAAE,CAAC,GAE9B,IACF,EAAS,EAAC,MAAE,CAAC,IAKT,MAAmB,KAAA,KACrB,EAAS;GAAC;GAAI,QAAQ;EAAM,CAAC;CAGnC;CAEA,SAAS,IAAgB;EAKvB,OAJK,IAKH,kBAAC,QAAD;GAAM,WAAU;GAAc,gCAAA;aAC5B,kBAAC,GAAD;IAAM,UAAU;IAAS,YAAY;GAAW,CAAA;EAC5C,CAAA,IAPa;CASvB;CAEA,SAAS,IAAe;EAGtB,OAFI,CAAC,KAAS,CAAC,IAAoB,OAGjC,kBAAC,GAAD,EAAA,UAAA,CACG,KAAS,kBAAC,GAAD,EAAA,UAAc,EAAmB,CAAA,GAC1C,KAAe,kBAAC,GAAD,EAAA,UAAoB,EAA+B,CAAA,CACvD,EAAA,CAAA;CAElB;CAEA,SAAS,IAAe;EAsBtB,OApBI,IAEA,kBAAC,GAAD;GAAc,WAAU;aACtB,kBAAC,GAAD;IAAM,UAAU;IAAQ,YAAY;GAAW,CAAA;EACnC,CAAA,IAKd,MAAmC,OAWhC,OATH,kBAAC,GAAD;GAAc,WAAU;aACtB,kBAAC,GAAD;IAAQ,SAAQ;IAAU,eAAe,EAAiB,EAAK;cAC5D;GACK,CAAA;EACI,CAAA;CAMpB;CAGA,IAAM,IAAiB,CAAC,EACtB,KACA,KACA,KACA;CAGF,OACE,kBAAC,GAAD;EAAkB;EAAM,cAAc;YAAtC,CACG,KAAW,kBAAC,GAAD;GAAe,SAAA;aAAS,EAAc;EAAiB,CAAA,GACnE,kBAAC,GAAD;GACE,gBAAc;GACR;GACG;GACO;GACD;GACF;GACF;GACX,OAAO;GACI;aATb;IAWG,EAAa;IACd,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;KAAM,UAAU;KAAS,YAAY;IAAW,CAAA,EACtC,CAAA;IACX,EAAa;GACD;IACL;;AAEhB"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { PiCardRef } from '@pihanga2/core';
|
|
2
|
+
export declare const PI_DIALOG_CARD = "pi/dialog";
|
|
3
|
+
export declare const Dialog: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<PiDialogProps, S, PiDialogEvents>) => import('@pihanga2/core').PiCardDef;
|
|
4
|
+
export declare const PI_DIALOG_ACTION: {
|
|
5
|
+
CLOSED: string;
|
|
6
|
+
OPENED: string;
|
|
7
|
+
OPEN_CHANGED: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const onDialogOpened: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
10
|
+
cardID: string;
|
|
11
|
+
} & DialogOpenedEvent>) => void;
|
|
12
|
+
export declare const onDialogClosed: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
13
|
+
cardID: string;
|
|
14
|
+
} & DialogClosedEvent>) => void;
|
|
15
|
+
export declare const onDialogOpenChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
16
|
+
cardID: string;
|
|
17
|
+
} & DialogOpenChangedEvent>) => void;
|
|
18
|
+
export type PiDialogProps = {
|
|
19
|
+
/**
|
|
20
|
+
* Optional id passed through to events for identification.
|
|
21
|
+
*/
|
|
22
|
+
id?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional dialog trigger card (e.g., a button).
|
|
25
|
+
*
|
|
26
|
+
* When provided, this card will be used as the dialog trigger.
|
|
27
|
+
* When omitted, the dialog must be controlled via the `open` prop.
|
|
28
|
+
*
|
|
29
|
+
* Wrapped in a DOM element so Radix can attach trigger handlers
|
|
30
|
+
* even when rendered via Pihanga's <Card />.
|
|
31
|
+
*/
|
|
32
|
+
trigger?: PiCardRef;
|
|
33
|
+
/**
|
|
34
|
+
* Card to render as the dialog body content.
|
|
35
|
+
*/
|
|
36
|
+
content: PiCardRef;
|
|
37
|
+
/**
|
|
38
|
+
* Optional dialog title (rendered in header).
|
|
39
|
+
*/
|
|
40
|
+
title?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Optional dialog description (rendered in header below title).
|
|
43
|
+
*/
|
|
44
|
+
description?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Controlled open state.
|
|
47
|
+
*
|
|
48
|
+
* When provided, dialog visibility is fully managed externally.
|
|
49
|
+
* When undefined, dialog manages its own state.
|
|
50
|
+
*/
|
|
51
|
+
open?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Dialog size variant.
|
|
54
|
+
*/
|
|
55
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl";
|
|
56
|
+
/**
|
|
57
|
+
* Dialog variant.
|
|
58
|
+
*/
|
|
59
|
+
variant?: "modal" | "drawer" | "full";
|
|
60
|
+
/**
|
|
61
|
+
* Desktop variant (defaults to 'modal').
|
|
62
|
+
* On desktop, this variant will be used instead of the main variant.
|
|
63
|
+
*/
|
|
64
|
+
desktopVariant?: "modal" | "drawer" | "full";
|
|
65
|
+
/**
|
|
66
|
+
* Mobile variant (defaults to 'drawer').
|
|
67
|
+
* On mobile, this variant will be used instead of the main variant.
|
|
68
|
+
*/
|
|
69
|
+
mobileVariant?: "modal" | "drawer" | "full";
|
|
70
|
+
/**
|
|
71
|
+
* Whether clicking outside closes the dialog (default: true).
|
|
72
|
+
*/
|
|
73
|
+
dismissible?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Hide the X close button (default: false).
|
|
76
|
+
*/
|
|
77
|
+
hideClose?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Additional CSS classes for the dialog content.
|
|
80
|
+
*/
|
|
81
|
+
className?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Optional footer card to render at the bottom of the dialog.
|
|
84
|
+
* When provided, this takes precedence over the default close button.
|
|
85
|
+
*/
|
|
86
|
+
footer?: PiCardRef;
|
|
87
|
+
/**
|
|
88
|
+
* Text for the default close button in the footer.
|
|
89
|
+
* Only used when `footer` is not provided.
|
|
90
|
+
* Set to `null` to hide the default close button entirely.
|
|
91
|
+
* @default "Close"
|
|
92
|
+
*/
|
|
93
|
+
footerCloseButtonText?: string | null;
|
|
94
|
+
};
|
|
95
|
+
export type DialogOpenedEvent = {
|
|
96
|
+
id?: string;
|
|
97
|
+
};
|
|
98
|
+
export type DialogClosedEvent = {
|
|
99
|
+
id?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Reason for closing:
|
|
102
|
+
* - 'user': User dismissed (clicked outside, pressed ESC, clicked X)
|
|
103
|
+
* - 'programmatic': Closed via props.open change
|
|
104
|
+
*/
|
|
105
|
+
reason?: "user" | "programmatic";
|
|
106
|
+
};
|
|
107
|
+
export type DialogOpenChangedEvent = {
|
|
108
|
+
open: boolean;
|
|
109
|
+
id?: string;
|
|
110
|
+
};
|
|
111
|
+
export type PiDialogEvents = {
|
|
112
|
+
onOpened: DialogOpenedEvent;
|
|
113
|
+
onClosed: DialogClosedEvent;
|
|
114
|
+
onOpenChanged: DialogOpenChangedEvent;
|
|
115
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/dialog/dialog.types.ts
|
|
3
|
+
var r = "pi/dialog", i = e(r), a = n(r, [
|
|
4
|
+
"opened",
|
|
5
|
+
"closed",
|
|
6
|
+
"open_changed"
|
|
7
|
+
]), o = t(a.OPENED), s = t(a.CLOSED), c = t(a.OPEN_CHANGED);
|
|
8
|
+
//#endregion
|
|
9
|
+
export { i as Dialog, a as PI_DIALOG_ACTION, r as PI_DIALOG_CARD, s as onDialogClosed, c as onDialogOpenChanged, o as onDialogOpened };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=dialog.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.types.js","names":[],"sources":["../../../src/cards/dialog/dialog.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n type PiCardRef,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_DIALOG_CARD = \"pi/dialog\";\n\nexport const Dialog = createCardDeclaration<PiDialogProps, PiDialogEvents>(\n PI_DIALOG_CARD,\n);\n\nexport const PI_DIALOG_ACTION = registerActions(PI_DIALOG_CARD, [\n \"opened\",\n \"closed\",\n \"open_changed\",\n]);\n\nexport const onDialogOpened = createOnAction<DialogOpenedEvent>(\n PI_DIALOG_ACTION.OPENED,\n);\n\nexport const onDialogClosed = createOnAction<DialogClosedEvent>(\n PI_DIALOG_ACTION.CLOSED,\n);\n\nexport const onDialogOpenChanged = createOnAction<DialogOpenChangedEvent>(\n PI_DIALOG_ACTION.OPEN_CHANGED,\n);\n\nexport type PiDialogProps = {\n /**\n * Optional id passed through to events for identification.\n */\n id?: string;\n\n /**\n * Optional dialog trigger card (e.g., a button).\n *\n * When provided, this card will be used as the dialog trigger.\n * When omitted, the dialog must be controlled via the `open` prop.\n *\n * Wrapped in a DOM element so Radix can attach trigger handlers\n * even when rendered via Pihanga's <Card />.\n */\n trigger?: PiCardRef;\n\n /**\n * Card to render as the dialog body content.\n */\n content: PiCardRef;\n\n /**\n * Optional dialog title (rendered in header).\n */\n title?: string;\n\n /**\n * Optional dialog description (rendered in header below title).\n */\n description?: string;\n\n /**\n * Controlled open state.\n *\n * When provided, dialog visibility is fully managed externally.\n * When undefined, dialog manages its own state.\n */\n open?: boolean;\n\n /**\n * Dialog size variant.\n */\n size?: \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\" | \"2xl\" | \"3xl\" | \"4xl\";\n\n /**\n * Dialog variant.\n */\n variant?: \"modal\" | \"drawer\" | \"full\";\n\n /**\n * Desktop variant (defaults to 'modal').\n * On desktop, this variant will be used instead of the main variant.\n */\n desktopVariant?: \"modal\" | \"drawer\" | \"full\";\n\n /**\n * Mobile variant (defaults to 'drawer').\n * On mobile, this variant will be used instead of the main variant.\n */\n mobileVariant?: \"modal\" | \"drawer\" | \"full\";\n\n /**\n * Whether clicking outside closes the dialog (default: true).\n */\n dismissible?: boolean;\n\n /**\n * Hide the X close button (default: false).\n */\n hideClose?: boolean;\n\n /**\n * Additional CSS classes for the dialog content.\n */\n className?: string;\n\n /**\n * Optional footer card to render at the bottom of the dialog.\n * When provided, this takes precedence over the default close button.\n */\n footer?: PiCardRef;\n\n /**\n * Text for the default close button in the footer.\n * Only used when `footer` is not provided.\n * Set to `null` to hide the default close button entirely.\n * @default \"Close\"\n */\n footerCloseButtonText?: string | null;\n};\n\nexport type DialogOpenedEvent = {\n id?: string;\n};\n\nexport type DialogClosedEvent = {\n id?: string;\n /**\n * Reason for closing:\n * - 'user': User dismissed (clicked outside, pressed ESC, clicked X)\n * - 'programmatic': Closed via props.open change\n */\n reason?: \"user\" | \"programmatic\";\n};\n\nexport type DialogOpenChangedEvent = {\n open: boolean;\n id?: string;\n};\n\nexport type PiDialogEvents = {\n onOpened: DialogOpenedEvent;\n onClosed: DialogClosedEvent;\n onOpenChanged: DialogOpenChangedEvent;\n};\n"],"mappings":";;AAOA,IAAa,IAAiB,aAEjB,IAAS,EACpB,CACF,GAEa,IAAmB,EAAgB,GAAgB;CAC9D;CACA;CACA;AACF,CAAC,GAEY,IAAiB,EAC5B,EAAiB,MACnB,GAEa,IAAiB,EAC5B,EAAiB,MACnB,GAEa,IAAsB,EACjC,EAAiB,YACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dialog.types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DialogComponent as e } from "./dialog.component.js";
|
|
2
|
+
import { Dialog as t, PI_DIALOG_ACTION as n, PI_DIALOG_CARD as r, onDialogClosed as i, onDialogOpenChanged as a, onDialogOpened as o } from "./dialog.types.js";
|
|
3
|
+
import { actionTypesToEvents as s, registerCardComponent as c } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/dialog/index.ts
|
|
5
|
+
c({
|
|
6
|
+
name: r,
|
|
7
|
+
component: e,
|
|
8
|
+
events: s(n)
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as Dialog, n as PI_DIALOG_ACTION, r as PI_DIALOG_CARD, i as onDialogClosed, a as onDialogOpenChanged, o as onDialogOpened };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/dialog/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {DialogComponent} from \"./dialog.component\";\nimport {PI_DIALOG_ACTION, PI_DIALOG_CARD} from \"./dialog.types\";\n\nexport * from \"./dialog.types\";\n\nregisterCardComponent({\n name: PI_DIALOG_CARD,\n component: DialogComponent,\n events: actionTypesToEvents(PI_DIALOG_ACTION),\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAgB;AAC9C,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { PiCardProps } from '@pihanga2/core';
|
|
3
|
+
import { DropDownMenuEvents, DropDownMenuProps } from './drop-down.types';
|
|
4
|
+
export declare const Component: (props: PiCardProps<DropDownMenuProps, DropDownMenuEvents>) => React.ReactNode;
|