@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,19 @@
|
|
|
1
|
+
import { PiCardProps } from '@pihanga2/core';
|
|
2
|
+
import { LoadingSkeletonProps } from './loading-skeleton.types';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
/**
|
|
5
|
+
* LoadingSkeletonComponent
|
|
6
|
+
*
|
|
7
|
+
* While `loading` is `true`: renders `rows` animated shimmer rows inside a
|
|
8
|
+
* flex column wrapper.
|
|
9
|
+
*
|
|
10
|
+
* **Presets** — `rowSize` and `spacing` select named height / gap values
|
|
11
|
+
* without needing Tailwind knowledge.
|
|
12
|
+
*
|
|
13
|
+
* **Raw overrides** — `rowClassName` (overrides `rowSize`) and `className`
|
|
14
|
+
* (overrides `spacing`) accept arbitrary Tailwind classes for custom layouts.
|
|
15
|
+
*
|
|
16
|
+
* While `loading` is `false`: transparently passes through to `content` (no
|
|
17
|
+
* extra DOM wrapper) or renders nothing when `content` is omitted.
|
|
18
|
+
*/
|
|
19
|
+
export declare const LoadingSkeletonComponent: (props: PiCardProps<LoadingSkeletonProps>) => React.ReactNode;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Card as e } from "@pihanga2/core";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
4
|
+
//#region src/cards/loadingSkeleton/loading-skeleton.component.tsx
|
|
5
|
+
var n = {
|
|
6
|
+
xs: "h-3",
|
|
7
|
+
sm: "h-5",
|
|
8
|
+
md: "h-10",
|
|
9
|
+
lg: "h-14",
|
|
10
|
+
xl: "h-20"
|
|
11
|
+
}, r = {
|
|
12
|
+
sm: "gap-2",
|
|
13
|
+
md: "gap-3",
|
|
14
|
+
lg: "gap-4"
|
|
15
|
+
}, i = (i) => {
|
|
16
|
+
let { cardName: a, loading: o, rows: s = 3, rowSize: c = "md", spacing: l = "md", rowClassName: u, className: d, content: f } = i;
|
|
17
|
+
if (o) {
|
|
18
|
+
let e = u ?? `rounded-md bg-foreground/15 ${n[c]}`;
|
|
19
|
+
return /* @__PURE__ */ t("div", {
|
|
20
|
+
"data-pihanga": a,
|
|
21
|
+
className: d ?? `flex w-full flex-col ${r[l]}`,
|
|
22
|
+
children: Array.from({ length: s }).map((n, r) => /* @__PURE__ */ t("div", { className: `animate-pulse ${e}` }, r))
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return f ? /* @__PURE__ */ t(e, {
|
|
26
|
+
cardName: f,
|
|
27
|
+
parentCard: a
|
|
28
|
+
}) : null;
|
|
29
|
+
};
|
|
30
|
+
//#endregion
|
|
31
|
+
export { i as LoadingSkeletonComponent };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=loading-skeleton.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-skeleton.component.js","names":[],"sources":["../../../src/cards/loadingSkeleton/loading-skeleton.component.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\nimport type {\n LoadingSkeletonProps,\n SkeletonRowSize,\n SkeletonSpacing,\n} from \"./loading-skeleton.types\";\n\n// ── Preset maps ───────────────────────────────────────────────────────────────\n\n/** Height class for each named `rowSize` preset. */\nconst ROW_SIZE_CLASS: Record<SkeletonRowSize, string> = {\n xs: \"h-3\", // 12 px — tiny text / timestamp lines\n sm: \"h-5\", // 20 px — small text or menu items\n md: \"h-10\", // 40 px — standard input / row\n lg: \"h-14\", // 56 px — large card rows\n xl: \"h-20\", // 80 px — wide widget / hero section\n};\n\n/** Gap class for each named `spacing` preset. */\nconst SPACING_CLASS: Record<SkeletonSpacing, string> = {\n sm: \"gap-2\", // 8 px\n md: \"gap-3\", // 12 px\n lg: \"gap-4\", // 16 px\n};\n\n// ── Component ─────────────────────────────────────────────────────────────────\n\n/**\n * LoadingSkeletonComponent\n *\n * While `loading` is `true`: renders `rows` animated shimmer rows inside a\n * flex column wrapper.\n *\n * **Presets** — `rowSize` and `spacing` select named height / gap values\n * without needing Tailwind knowledge.\n *\n * **Raw overrides** — `rowClassName` (overrides `rowSize`) and `className`\n * (overrides `spacing`) accept arbitrary Tailwind classes for custom layouts.\n *\n * While `loading` is `false`: transparently passes through to `content` (no\n * extra DOM wrapper) or renders nothing when `content` is omitted.\n */\nexport const LoadingSkeletonComponent = (\n props: PiCardProps<LoadingSkeletonProps>,\n): React.ReactNode => {\n const {\n cardName,\n loading,\n rows = 3,\n rowSize = \"md\",\n spacing = \"md\",\n rowClassName,\n className,\n content,\n } = props;\n\n if (loading) {\n // rawClassName takes precedence over the preset; preset is the fallback.\n const rowCls =\n rowClassName ?? `rounded-md bg-foreground/15 ${ROW_SIZE_CLASS[rowSize]}`;\n const wrapperCls =\n className ?? `flex w-full flex-col ${SPACING_CLASS[spacing]}`;\n\n return (\n <div data-pihanga={cardName} className={wrapperCls}>\n {Array.from({length: rows}).map((_, i) => (\n <div key={i} className={`animate-pulse ${rowCls}`} />\n ))}\n </div>\n );\n }\n\n if (content) {\n // Transparent pass-through: no extra wrapper element.\n return <Card cardName={content} parentCard={cardName} />;\n }\n\n // Loaded with no content card — render nothing.\n return null;\n};\n"],"mappings":";;;;AAWA,IAAM,IAAkD;CACtD,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN,GAGM,IAAiD;CACrD,IAAI;CACJ,IAAI;CACJ,IAAI;AACN,GAmBa,KACX,MACoB;CACpB,IAAM,EACJ,aACA,YACA,UAAO,GACP,aAAU,MACV,aAAU,MACV,iBACA,cACA,eACE;CAEJ,IAAI,GAAS;EAEX,IAAM,IACJ,KAAgB,+BAA+B,EAAe;EAIhE,OACE,kBAAC,OAAD;GAAK,gBAAc;GAAU,WAH7B,KAAa,wBAAwB,EAAc;aAIhD,MAAM,KAAK,EAAC,QAAQ,EAAI,CAAC,EAAE,KAAK,GAAG,MAClC,kBAAC,OAAD,EAAa,WAAW,iBAAiB,IAAW,GAA1C,CAA0C,CACrD;EACE,CAAA;CAET;CAQA,OANI,IAEK,kBAAC,GAAD;EAAM,UAAU;EAAS,YAAY;CAAW,CAAA,IAIlD;AACT"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { PiCardRef } from '@pihanga2/core';
|
|
2
|
+
export declare const LOADING_SKELETON_CARD = "shad/loading-skeleton";
|
|
3
|
+
export declare const LoadingSkeleton: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<LoadingSkeletonProps, S, {}>) => import('@pihanga2/core').PiCardDef;
|
|
4
|
+
/**
|
|
5
|
+
* Named height presets for skeleton rows.
|
|
6
|
+
*
|
|
7
|
+
* | Value | Height | Typical use |
|
|
8
|
+
* |-------|----------|---------------------------------|
|
|
9
|
+
* | `xs` | 12 px | Tiny text / timestamp lines |
|
|
10
|
+
* | `sm` | 20 px | Small text or menu items |
|
|
11
|
+
* | `md` | 40 px | Standard input / row (default) |
|
|
12
|
+
* | `lg` | 56 px | Large card rows |
|
|
13
|
+
* | `xl` | 80 px | Wide widget / hero section |
|
|
14
|
+
*/
|
|
15
|
+
export type SkeletonRowSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
16
|
+
/**
|
|
17
|
+
* Named gap presets between skeleton rows.
|
|
18
|
+
*
|
|
19
|
+
* | Value | Gap |
|
|
20
|
+
* |-------|--------|
|
|
21
|
+
* | `sm` | 8 px |
|
|
22
|
+
* | `md` | 12 px |
|
|
23
|
+
* | `lg` | 16 px |
|
|
24
|
+
*/
|
|
25
|
+
export type SkeletonSpacing = "sm" | "md" | "lg";
|
|
26
|
+
/**
|
|
27
|
+
* Props for the `shad/loading-skeleton` card.
|
|
28
|
+
*
|
|
29
|
+
* Shows animated shimmer rows while `loading` is `true`; once `loading`
|
|
30
|
+
* becomes `false` it transparently passes through to `content` (or renders
|
|
31
|
+
* nothing when `content` is omitted).
|
|
32
|
+
*
|
|
33
|
+
* **Quick setup** — use the preset props:
|
|
34
|
+
* ```ts
|
|
35
|
+
* registerCard("myApp/area", LoadingSkeleton({
|
|
36
|
+
* loading: memo((s: AppState) => s.dataLoading),
|
|
37
|
+
* rows: 4,
|
|
38
|
+
* rowSize: "lg",
|
|
39
|
+
* spacing: "lg",
|
|
40
|
+
* content: "myApp/dataList",
|
|
41
|
+
* }));
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* **Custom Tailwind** — override with raw class strings:
|
|
45
|
+
* ```ts
|
|
46
|
+
* registerCard("myApp/area", LoadingSkeleton({
|
|
47
|
+
* loading: memo((s: AppState) => s.dataLoading),
|
|
48
|
+
* rows: 4,
|
|
49
|
+
* rowClassName: "h-32 rounded-xl bg-primary/10",
|
|
50
|
+
* className: "grid grid-cols-2 gap-4 w-full",
|
|
51
|
+
* content: "myApp/cardGrid",
|
|
52
|
+
* }));
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export type LoadingSkeletonProps = {
|
|
56
|
+
/** When `true`, render animated skeleton rows; when `false` render
|
|
57
|
+
* `content` (or nothing if `content` is omitted). */
|
|
58
|
+
loading: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Number of placeholder rows to render while loading.
|
|
61
|
+
* @default 3
|
|
62
|
+
*/
|
|
63
|
+
rows?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Named height preset for each shimmer row.
|
|
66
|
+
* Ignored when `rowClassName` is provided.
|
|
67
|
+
* @default "md"
|
|
68
|
+
*/
|
|
69
|
+
rowSize?: SkeletonRowSize;
|
|
70
|
+
/**
|
|
71
|
+
* Named gap preset between shimmer rows.
|
|
72
|
+
* Ignored when `className` is provided.
|
|
73
|
+
* @default "md"
|
|
74
|
+
*/
|
|
75
|
+
spacing?: SkeletonSpacing;
|
|
76
|
+
/**
|
|
77
|
+
* Raw Tailwind classes for every shimmer row.
|
|
78
|
+
* When set, takes precedence over `rowSize`.
|
|
79
|
+
* Must include a height (`h-*`) and optionally `rounded-*` and `bg-*`.
|
|
80
|
+
* Tip: use `bg-foreground/15` for good contrast in both themes.
|
|
81
|
+
*/
|
|
82
|
+
rowClassName?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Raw Tailwind classes for the outer `<div>` wrapper (loading state only).
|
|
85
|
+
* When set, takes precedence over `spacing`.
|
|
86
|
+
* Include `w-full` to ensure rows fill the container.
|
|
87
|
+
*/
|
|
88
|
+
className?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Card to render when `loading` is `false`.
|
|
91
|
+
* When omitted the card renders nothing in the loaded state.
|
|
92
|
+
*/
|
|
93
|
+
content?: PiCardRef;
|
|
94
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/loadingSkeleton/loading-skeleton.types.ts
|
|
3
|
+
var t = "shad/loading-skeleton", n = e(t);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { t as LOADING_SKELETON_CARD, n as LoadingSkeleton };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=loading-skeleton.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loading-skeleton.types.js","names":[],"sources":["../../../src/cards/loadingSkeleton/loading-skeleton.types.ts"],"sourcesContent":["import {createCardDeclaration} from \"@pihanga2/core\";\nimport type {PiCardRef} from \"@pihanga2/core\";\n\n// ── Card id ───────────────────────────────────────────────────────────────────\n\nexport const LOADING_SKELETON_CARD = \"shad/loading-skeleton\";\n\n// ── Card declaration factory ──────────────────────────────────────────────────\n\nexport const LoadingSkeleton = createCardDeclaration<LoadingSkeletonProps>(\n LOADING_SKELETON_CARD,\n);\n\n// ── Preset enums ──────────────────────────────────────────────────────────────\n\n/**\n * Named height presets for skeleton rows.\n *\n * | Value | Height | Typical use |\n * |-------|----------|---------------------------------|\n * | `xs` | 12 px | Tiny text / timestamp lines |\n * | `sm` | 20 px | Small text or menu items |\n * | `md` | 40 px | Standard input / row (default) |\n * | `lg` | 56 px | Large card rows |\n * | `xl` | 80 px | Wide widget / hero section |\n */\nexport type SkeletonRowSize = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\n/**\n * Named gap presets between skeleton rows.\n *\n * | Value | Gap |\n * |-------|--------|\n * | `sm` | 8 px |\n * | `md` | 12 px |\n * | `lg` | 16 px |\n */\nexport type SkeletonSpacing = \"sm\" | \"md\" | \"lg\";\n\n// ── Props ─────────────────────────────────────────────────────────────────────\n\n/**\n * Props for the `shad/loading-skeleton` card.\n *\n * Shows animated shimmer rows while `loading` is `true`; once `loading`\n * becomes `false` it transparently passes through to `content` (or renders\n * nothing when `content` is omitted).\n *\n * **Quick setup** — use the preset props:\n * ```ts\n * registerCard(\"myApp/area\", LoadingSkeleton({\n * loading: memo((s: AppState) => s.dataLoading),\n * rows: 4,\n * rowSize: \"lg\",\n * spacing: \"lg\",\n * content: \"myApp/dataList\",\n * }));\n * ```\n *\n * **Custom Tailwind** — override with raw class strings:\n * ```ts\n * registerCard(\"myApp/area\", LoadingSkeleton({\n * loading: memo((s: AppState) => s.dataLoading),\n * rows: 4,\n * rowClassName: \"h-32 rounded-xl bg-primary/10\",\n * className: \"grid grid-cols-2 gap-4 w-full\",\n * content: \"myApp/cardGrid\",\n * }));\n * ```\n */\nexport type LoadingSkeletonProps = {\n /** When `true`, render animated skeleton rows; when `false` render\n * `content` (or nothing if `content` is omitted). */\n loading: boolean;\n\n /**\n * Number of placeholder rows to render while loading.\n * @default 3\n */\n rows?: number;\n\n // ── Preset controls (no Tailwind knowledge needed) ────────────────────────\n\n /**\n * Named height preset for each shimmer row.\n * Ignored when `rowClassName` is provided.\n * @default \"md\"\n */\n rowSize?: SkeletonRowSize;\n\n /**\n * Named gap preset between shimmer rows.\n * Ignored when `className` is provided.\n * @default \"md\"\n */\n spacing?: SkeletonSpacing;\n\n // ── Raw Tailwind overrides (power users) ──────────────────────────────────\n\n /**\n * Raw Tailwind classes for every shimmer row.\n * When set, takes precedence over `rowSize`.\n * Must include a height (`h-*`) and optionally `rounded-*` and `bg-*`.\n * Tip: use `bg-foreground/15` for good contrast in both themes.\n */\n rowClassName?: string;\n\n /**\n * Raw Tailwind classes for the outer `<div>` wrapper (loading state only).\n * When set, takes precedence over `spacing`.\n * Include `w-full` to ensure rows fill the container.\n */\n className?: string;\n\n /**\n * Card to render when `loading` is `false`.\n * When omitted the card renders nothing in the loaded state.\n */\n content?: PiCardRef;\n};\n// No events — display-only card.\n"],"mappings":";;AAKA,IAAa,IAAwB,yBAIxB,IAAkB,EAC7B,CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './markdownViewer.types';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
import { PluggableList } from 'unified';
|
|
3
|
+
import { Components } from 'react-markdown';
|
|
4
|
+
export declare const MARKDOWN_CARD = "markdown-viewer";
|
|
5
|
+
export declare const MarkdownViewer: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<MarkdownViewerProps, S, {}>) => import('@pihanga2/core').PiCardDef;
|
|
6
|
+
export type MarkdownViewerProps = {
|
|
7
|
+
/** Markdown source string to render directly. */
|
|
8
|
+
source?: string;
|
|
9
|
+
/** URL/path to a file whose text content will be fetched and rendered. */
|
|
10
|
+
path?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Truncate rendered text to approximately this many characters (word boundary).
|
|
13
|
+
* A negative value (default: -1) disables truncation.
|
|
14
|
+
*/
|
|
15
|
+
maxBodyLength?: number;
|
|
16
|
+
remarkPlugins?: PluggableList;
|
|
17
|
+
rehypePlugins?: PluggableList;
|
|
18
|
+
remarkRehypeOptions?: object;
|
|
19
|
+
/**
|
|
20
|
+
* Custom element renderers passed directly to `react-markdown`.
|
|
21
|
+
* Merged on top of the card's built-in defaults (code/pre styling).
|
|
22
|
+
* Use this to override how individual HTML elements are rendered.
|
|
23
|
+
*/
|
|
24
|
+
components?: Components;
|
|
25
|
+
/** Additional CSS class to apply to the outer wrapper div. */
|
|
26
|
+
className?: string;
|
|
27
|
+
style?: CSSProperties;
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './menu.types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MenuComponent as e } from "./menu.component.js";
|
|
2
|
+
import { MENU_ACTION as t, MENU_CARD as n, Menu as r, onMenuClicked as i } from "./menu.types.js";
|
|
3
|
+
import { actionTypesToEvents as a, registerCardComponent as o } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/menu/index.ts
|
|
5
|
+
o({
|
|
6
|
+
name: n,
|
|
7
|
+
component: e,
|
|
8
|
+
events: a(t)
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as MENU_ACTION, n as MENU_CARD, r as Menu, i as onMenuClicked };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/menu/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {MenuComponent} from \"./menu.component\";\nimport {MENU_ACTION, MENU_CARD} from \"./menu.types\";\n\nexport * from \"./menu.types\";\n\nregisterCardComponent({\n name: MENU_CARD,\n component: MenuComponent,\n events: actionTypesToEvents(MENU_ACTION),\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAW;AACzC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Menubar as e, MenubarContent as t, MenubarItem as n, MenubarMenu as r, MenubarSeparator as i, MenubarTrigger as a } from "../../components/ui/menubar.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
4
|
+
//#region src/cards/menu/menu.component.tsx
|
|
5
|
+
var c = (c) => {
|
|
6
|
+
let { menuButton: l, items: u, className: d, cardName: f, onClicked: p } = c;
|
|
7
|
+
return /* @__PURE__ */ o(e, {
|
|
8
|
+
className: d,
|
|
9
|
+
"data-pihanga": f,
|
|
10
|
+
children: /* @__PURE__ */ s(r, { children: [/* @__PURE__ */ o(a, {
|
|
11
|
+
disabled: l.isDisabled,
|
|
12
|
+
children: l.label
|
|
13
|
+
}), /* @__PURE__ */ o(t, { children: u.map((e, t) => e === null ? /* @__PURE__ */ o(i, {}, t) : /* @__PURE__ */ o(n, {
|
|
14
|
+
disabled: e.disabled,
|
|
15
|
+
onClick: () => p({ itemID: e.id }),
|
|
16
|
+
children: e.title ?? e.id
|
|
17
|
+
}, e.id)) })] })
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { c as MenuComponent };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=menu.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.component.js","names":[],"sources":["../../../src/cards/menu/menu.component.tsx"],"sourcesContent":["import React from \"react\";\nimport type {PiCardProps} from \"@pihanga2/core\";\nimport {\n Menubar,\n MenubarContent,\n MenubarItem,\n MenubarMenu,\n MenubarSeparator,\n MenubarTrigger,\n} from \"@/components/ui/menubar\";\nimport type {MenuEvents, MenuProps} from \"./menu.types\";\n\nexport const MenuComponent = (\n props: PiCardProps<MenuProps, MenuEvents>,\n): React.ReactNode => {\n const {menuButton, items, className, cardName, onClicked} = props;\n\n return (\n <Menubar className={className} data-pihanga={cardName}>\n <MenubarMenu>\n <MenubarTrigger disabled={menuButton.isDisabled}>\n {menuButton.label}\n </MenubarTrigger>\n <MenubarContent>\n {items.map((item, idx) => {\n if (item === null) {\n return <MenubarSeparator key={idx} />;\n }\n return (\n <MenubarItem\n key={item.id}\n disabled={item.disabled}\n onClick={() => onClicked({itemID: item.id})}\n >\n {item.title ?? item.id}\n </MenubarItem>\n );\n })}\n </MenubarContent>\n </MenubarMenu>\n </Menubar>\n );\n};\n"],"mappings":";;;;AAYA,IAAa,KACX,MACoB;CACpB,IAAM,EAAC,eAAY,UAAO,cAAW,aAAU,iBAAa;CAE5D,OACE,kBAAC,GAAD;EAAoB;EAAW,gBAAc;YAC3C,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;GAAgB,UAAU,EAAW;aAClC,EAAW;EACE,CAAA,GAChB,kBAAC,GAAD,EAAA,UACG,EAAM,KAAK,GAAM,MACZ,MAAS,OACJ,kBAAC,GAAD,CAA6B,GAAN,CAAM,IAGpC,kBAAC,GAAD;GAEE,UAAU,EAAK;GACf,eAAe,EAAU,EAAC,QAAQ,EAAK,GAAE,CAAC;aAEzC,EAAK,SAAS,EAAK;EACT,GALN,EAAK,EAKC,CAEhB,EACa,CAAA,CACL,EAAA,CAAA;CACN,CAAA;AAEb"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ColorT, DecoratorT, SizeT, VariantT } from '../types';
|
|
2
|
+
export declare const MENU_CARD = "shad/menu";
|
|
3
|
+
export declare const Menu: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<MenuProps<unknown, unknown>, S, MenuEvents>) => import('@pihanga2/core').PiCardDef;
|
|
4
|
+
export declare const MENU_ACTION: {
|
|
5
|
+
CLICKED: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const onMenuClicked: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
8
|
+
cardID: string;
|
|
9
|
+
} & MenuClickEvent>) => void;
|
|
10
|
+
export type BaseButtonProps = {
|
|
11
|
+
label: string;
|
|
12
|
+
tooltip?: string;
|
|
13
|
+
isDisabled?: boolean;
|
|
14
|
+
isLoading?: boolean;
|
|
15
|
+
loadingPosition?: "center" | "start" | "end";
|
|
16
|
+
size?: SizeT;
|
|
17
|
+
color?: ColorT;
|
|
18
|
+
variant?: VariantT;
|
|
19
|
+
startDecorator?: DecoratorT;
|
|
20
|
+
endDecorator?: DecoratorT;
|
|
21
|
+
};
|
|
22
|
+
export type MenuItemT = {
|
|
23
|
+
id: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
color?: ColorT;
|
|
27
|
+
variant?: VariantT;
|
|
28
|
+
startDecorator?: DecoratorT;
|
|
29
|
+
endDecorator?: DecoratorT;
|
|
30
|
+
};
|
|
31
|
+
/** A `null` entry renders as a visual separator between menu items. */
|
|
32
|
+
export type MenuSeparatorT = null;
|
|
33
|
+
export type PlacementT = "auto-end" | "auto-start" | "auto" | "bottom-end" | "bottom-start" | "bottom" | "left-end" | "left-start" | "left" | "right-end" | "right-start" | "right" | "top-end" | "top-start" | "top";
|
|
34
|
+
export type MenuProps<S = unknown, T = unknown> = {
|
|
35
|
+
/** Configuration for the trigger button that opens the menu. */
|
|
36
|
+
menuButton: BaseButtonProps;
|
|
37
|
+
/** Ordered list of menu items; `null` entries render as separators. */
|
|
38
|
+
items: (MenuItemT | MenuSeparatorT)[];
|
|
39
|
+
placement?: PlacementT;
|
|
40
|
+
size?: SizeT;
|
|
41
|
+
color?: ColorT;
|
|
42
|
+
variant?: VariantT;
|
|
43
|
+
className?: string;
|
|
44
|
+
style?: S;
|
|
45
|
+
theme?: T;
|
|
46
|
+
};
|
|
47
|
+
export type MenuClickEvent = {
|
|
48
|
+
/** The `id` of the menu item that was clicked. */
|
|
49
|
+
itemID: string;
|
|
50
|
+
};
|
|
51
|
+
export type MenuEvents = {
|
|
52
|
+
onClicked: MenuClickEvent;
|
|
53
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/menu/menu.types.ts
|
|
3
|
+
var r = "shad/menu", i = e(r), a = n(r, ["clicked"]), o = t(a.CLICKED);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { a as MENU_ACTION, r as MENU_CARD, i as Menu, o as onMenuClicked };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=menu.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.types.js","names":[],"sources":["../../../src/cards/menu/menu.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\nimport type {ColorT, DecoratorT, SizeT, VariantT} from \"../types\";\n\nexport const MENU_CARD = \"shad/menu\";\nexport const Menu = createCardDeclaration<MenuProps, MenuEvents>(MENU_CARD);\n\nexport const MENU_ACTION = registerActions(MENU_CARD, [\"clicked\"]);\n\nexport const onMenuClicked = createOnAction<MenuClickEvent>(\n MENU_ACTION.CLICKED,\n);\n\n// ---------------------------------------------------------------------------\n// Shared button props (re-used by trigger buttons)\n// ---------------------------------------------------------------------------\n\nexport type BaseButtonProps = {\n label: string;\n tooltip?: string;\n isDisabled?: boolean;\n isLoading?: boolean;\n loadingPosition?: \"center\" | \"start\" | \"end\";\n size?: SizeT;\n color?: ColorT;\n variant?: VariantT;\n startDecorator?: DecoratorT;\n endDecorator?: DecoratorT;\n};\n\n// ---------------------------------------------------------------------------\n// Menu item types\n// ---------------------------------------------------------------------------\n\nexport type MenuItemT = {\n id: string;\n title?: string;\n disabled?: boolean;\n color?: ColorT;\n variant?: VariantT;\n startDecorator?: DecoratorT;\n endDecorator?: DecoratorT;\n};\n\n/** A `null` entry renders as a visual separator between menu items. */\nexport type MenuSeparatorT = null;\n\n// ---------------------------------------------------------------------------\n// Placement\n// ---------------------------------------------------------------------------\n\nexport type PlacementT =\n | \"auto-end\"\n | \"auto-start\"\n | \"auto\"\n | \"bottom-end\"\n | \"bottom-start\"\n | \"bottom\"\n | \"left-end\"\n | \"left-start\"\n | \"left\"\n | \"right-end\"\n | \"right-start\"\n | \"right\"\n | \"top-end\"\n | \"top-start\"\n | \"top\";\n\n// ---------------------------------------------------------------------------\n// Card props & events\n// ---------------------------------------------------------------------------\n\nexport type MenuProps<S = unknown, T = unknown> = {\n /** Configuration for the trigger button that opens the menu. */\n menuButton: BaseButtonProps;\n /** Ordered list of menu items; `null` entries render as separators. */\n items: (MenuItemT | MenuSeparatorT)[];\n placement?: PlacementT;\n size?: SizeT;\n color?: ColorT;\n variant?: VariantT;\n className?: string;\n style?: S;\n theme?: T;\n};\n\nexport type MenuClickEvent = {\n /** The `id` of the menu item that was clicked. */\n itemID: string;\n};\n\nexport type MenuEvents = {\n onClicked: MenuClickEvent;\n};\n"],"mappings":";;AAOA,IAAa,IAAY,aACZ,IAAO,EAA6C,CAAS,GAE7D,IAAc,EAAgB,GAAW,CAAC,SAAS,CAAC,GAEpD,IAAgB,EAC3B,EAAY,OACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './mode-toggle.types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ModeToggleComponent as e } from "./mode-toggle.component.js";
|
|
2
|
+
import { MODE_TOGGLE_ACTION as t, MODE_TOGGLE_CARD as n, ModeToggle as r, onModeToggleChanged as i } from "./mode-toggle.types.js";
|
|
3
|
+
import { actionTypesToEvents as a, registerCardComponent as o } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/modeToggle/index.ts
|
|
5
|
+
o({
|
|
6
|
+
name: n,
|
|
7
|
+
component: e,
|
|
8
|
+
events: a(t)
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as MODE_TOGGLE_ACTION, n as MODE_TOGGLE_CARD, r as ModeToggle, i as onModeToggleChanged };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/modeToggle/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {ModeToggleComponent} from \"./mode-toggle.component\";\nimport {MODE_TOGGLE_ACTION, MODE_TOGGLE_CARD} from \"./mode-toggle.types\";\n\nexport * from \"./mode-toggle.types\";\n\nregisterCardComponent({\n name: MODE_TOGGLE_CARD,\n component: ModeToggleComponent,\n events: actionTypesToEvents(MODE_TOGGLE_ACTION),\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAkB;AAChD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { PiCardProps } from '@pihanga2/core';
|
|
3
|
+
import { ModeToggleEvents, ModeToggleProps } from './mode-toggle.types';
|
|
4
|
+
export declare const ModeToggleComponent: (props: PiCardProps<ModeToggleProps, ModeToggleEvents>) => React.ReactNode;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Button as e } from "../../components/ui/button.js";
|
|
2
|
+
import { useTheme as t } from "../../components/theme-provider/index.js";
|
|
3
|
+
import "react";
|
|
4
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
5
|
+
import { Moon as i, Sun as a } from "lucide-react";
|
|
6
|
+
//#region src/cards/modeToggle/mode-toggle.component.tsx
|
|
7
|
+
var o = (o) => {
|
|
8
|
+
let { setTheme: s, theme: c } = t(), { variant: l, className: u, onModeChanged: d, cardName: f } = o;
|
|
9
|
+
function p() {
|
|
10
|
+
let e = c === "dark" ? "light" : "dark";
|
|
11
|
+
s(e), d({ mode: e });
|
|
12
|
+
}
|
|
13
|
+
return /* @__PURE__ */ r(e, {
|
|
14
|
+
variant: l ?? "outline",
|
|
15
|
+
size: "icon",
|
|
16
|
+
onClick: p,
|
|
17
|
+
className: u,
|
|
18
|
+
"data-pihanga": f,
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ n(a, { className: "h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" }),
|
|
21
|
+
/* @__PURE__ */ n(i, { className: "absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }),
|
|
22
|
+
/* @__PURE__ */ n("span", {
|
|
23
|
+
className: "sr-only",
|
|
24
|
+
children: "Toggle theme"
|
|
25
|
+
})
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
export { o as ModeToggleComponent };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=mode-toggle.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode-toggle.component.js","names":[],"sources":["../../../src/cards/modeToggle/mode-toggle.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {Moon, Sun} from \"lucide-react\";\nimport type {PiCardProps} from \"@pihanga2/core\";\nimport {Button} from \"@/components/ui/button\";\nimport {useTheme} from \"@/components/theme-provider\";\nimport type {ModeToggleEvents, ModeToggleProps} from \"./mode-toggle.types\";\n\nexport const ModeToggleComponent = (\n props: PiCardProps<ModeToggleProps, ModeToggleEvents>,\n): React.ReactNode => {\n const {setTheme, theme} = useTheme();\n const {variant, className, onModeChanged, cardName} = props;\n\n function onClick() {\n const mode = theme === \"dark\" ? \"light\" : \"dark\";\n setTheme(mode);\n onModeChanged({mode});\n }\n\n return (\n <Button\n variant={variant ?? \"outline\"}\n size=\"icon\"\n onClick={onClick}\n className={className}\n data-pihanga={cardName}\n >\n <Sun className=\"h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0\" />\n <Moon className=\"absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100\" />\n <span className=\"sr-only\">Toggle theme</span>\n </Button>\n );\n};\n"],"mappings":";;;;;;AAOA,IAAa,KACX,MACoB;CACpB,IAAM,EAAC,aAAU,aAAS,EAAS,GAC7B,EAAC,YAAS,cAAW,kBAAe,gBAAY;CAEtD,SAAS,IAAU;EACjB,IAAM,IAAO,MAAU,SAAS,UAAU;EAE1C,AADA,EAAS,CAAI,GACb,EAAc,EAAC,QAAI,CAAC;CACtB;CAEA,OACE,kBAAC,GAAD;EACE,SAAS,KAAW;EACpB,MAAK;EACI;EACE;EACX,gBAAc;YALhB;GAOE,kBAAC,GAAD,EAAK,WAAU,uFAAwF,CAAA;GACvG,kBAAC,GAAD,EAAM,WAAU,+FAAgG,CAAA;GAChH,kBAAC,QAAD;IAAM,WAAU;cAAU;GAAkB,CAAA;EACtC;;AAEZ"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { VariantT } from '../types';
|
|
2
|
+
export declare const MODE_TOGGLE_CARD = "shad/mode-toggle";
|
|
3
|
+
export declare const ModeToggle: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<ModeToggleProps, S, ModeToggleEvents>) => import('@pihanga2/core').PiCardDef;
|
|
4
|
+
export declare const MODE_TOGGLE_ACTION: {
|
|
5
|
+
MODE_CHANGED: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const onModeToggleChanged: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
8
|
+
cardID: string;
|
|
9
|
+
} & ModeChangeEvent>) => void;
|
|
10
|
+
export type ModeToggleProps = {
|
|
11
|
+
/** Visual variant of the toggle button. Defaults to `"outline"`. */
|
|
12
|
+
variant?: VariantT;
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
export type ModeChangeEvent = {
|
|
16
|
+
mode: "light" | "dark" | "system";
|
|
17
|
+
};
|
|
18
|
+
export type ModeToggleEvents = {
|
|
19
|
+
onModeChanged: ModeChangeEvent;
|
|
20
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/modeToggle/mode-toggle.types.ts
|
|
3
|
+
var r = "shad/mode-toggle", i = e(r), a = n(r, ["mode_changed"]), o = t(a.MODE_CHANGED);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { a as MODE_TOGGLE_ACTION, r as MODE_TOGGLE_CARD, i as ModeToggle, o as onModeToggleChanged };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=mode-toggle.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mode-toggle.types.js","names":[],"sources":["../../../src/cards/modeToggle/mode-toggle.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n registerActions,\n} from \"@pihanga2/core\";\nimport type {VariantT} from \"../types\";\n\nexport const MODE_TOGGLE_CARD = \"shad/mode-toggle\";\nexport const ModeToggle = createCardDeclaration<\n ModeToggleProps,\n ModeToggleEvents\n>(MODE_TOGGLE_CARD);\n\nexport const MODE_TOGGLE_ACTION = registerActions(MODE_TOGGLE_CARD, [\n \"mode_changed\",\n]);\n\nexport const onModeToggleChanged = createOnAction<ModeChangeEvent>(\n MODE_TOGGLE_ACTION.MODE_CHANGED,\n);\n\n// ---------------------------------------------------------------------------\n// Card props & events\n// ---------------------------------------------------------------------------\n\nexport type ModeToggleProps = {\n /** Visual variant of the toggle button. Defaults to `\"outline\"`. */\n variant?: VariantT;\n className?: string;\n};\n\nexport type ModeChangeEvent = {\n mode: \"light\" | \"dark\" | \"system\";\n};\n\nexport type ModeToggleEvents = {\n onModeChanged: ModeChangeEvent;\n};\n"],"mappings":";;AAOA,IAAa,IAAmB,oBACnB,IAAa,EAGxB,CAAgB,GAEL,IAAqB,EAAgB,GAAkB,CAClE,cACF,CAAC,GAEY,IAAsB,EACjC,EAAmB,YACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './navbarSearch.type';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Component as e } from "./navbarSearch.component.js";
|
|
2
|
+
import { NAVBAR_SEARCH_ACTION as t, NAVBAR_SEARCH_CARD as n, NavbarSearch as r, onNavbarSearchFocus as i, onNavbarSearchItems as a, onNavbarSearchSubmit as o } from "./navbarSearch.type.js";
|
|
3
|
+
import { actionTypesToEvents as s, registerCardComponent as c } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/navbarSearch/index.ts
|
|
5
|
+
c({
|
|
6
|
+
name: n,
|
|
7
|
+
component: e,
|
|
8
|
+
events: s(t)
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as NAVBAR_SEARCH_ACTION, n as NAVBAR_SEARCH_CARD, r as NavbarSearch, i as onNavbarSearchFocus, a as onNavbarSearchItems, o as onNavbarSearchSubmit };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/navbarSearch/index.ts"],"sourcesContent":["import {\n actionTypesToEvents,\n registerCardComponent,\n} from \"@pihanga2/core\";\n\nimport {Component} from \"./navbarSearch.component\";\nimport {NAVBAR_SEARCH_ACTION, NAVBAR_SEARCH_CARD} from \"./navbarSearch.type\";\n\nexport * from \"./navbarSearch.type\";\n\nregisterCardComponent({\n name: NAVBAR_SEARCH_CARD,\n component: Component,\n events: actionTypesToEvents(NAVBAR_SEARCH_ACTION),\n});\n"],"mappings":";;;;AAUA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAoB;AAClD,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Input as e } from "../../components/ui/input.js";
|
|
2
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
|
+
//#region src/cards/navbarSearch/navbarSearch.component.tsx
|
|
4
|
+
var r = (r) => {
|
|
5
|
+
let { searchItems: i, placeholder: a = "Load Spec...", onSearchSubmit: o, onSearchItems: s, onSearchFocus: c, cardName: l } = r, u = i?.length ? `${l}-search` : void 0, d = (e, t) => {
|
|
6
|
+
let n = e.trim();
|
|
7
|
+
n && (o?.({ search: n }), t && (t.value = "", f("")), t?.blur());
|
|
8
|
+
}, f = (e) => {
|
|
9
|
+
s?.({ search: e });
|
|
10
|
+
}, p = (e, t) => {
|
|
11
|
+
i?.includes(e) && d(e, t);
|
|
12
|
+
}, m = (e) => {
|
|
13
|
+
e && e.showPicker?.();
|
|
14
|
+
};
|
|
15
|
+
return /* @__PURE__ */ t("form", {
|
|
16
|
+
onSubmit: (e) => {
|
|
17
|
+
e.preventDefault();
|
|
18
|
+
let t = new FormData(e.currentTarget);
|
|
19
|
+
d(String(t.get("search") || ""), e.currentTarget.elements.namedItem("search"));
|
|
20
|
+
},
|
|
21
|
+
autoComplete: "off",
|
|
22
|
+
className: "ml-auto flex-1 sm:flex-initial",
|
|
23
|
+
"data-pihanga": l,
|
|
24
|
+
children: /* @__PURE__ */ n("div", {
|
|
25
|
+
className: "relative",
|
|
26
|
+
children: [/* @__PURE__ */ t(e, {
|
|
27
|
+
type: "search",
|
|
28
|
+
placeholder: a,
|
|
29
|
+
name: "search",
|
|
30
|
+
list: u,
|
|
31
|
+
autoComplete: "off",
|
|
32
|
+
className: "sm:w-[300px] md:w-[200px] lg:w-[300px]",
|
|
33
|
+
onFocus: () => {
|
|
34
|
+
c?.({});
|
|
35
|
+
},
|
|
36
|
+
onClick: (e) => {
|
|
37
|
+
m(e.currentTarget);
|
|
38
|
+
},
|
|
39
|
+
onBeforeInput: (e) => {
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
},
|
|
42
|
+
onKeyDown: (e) => {
|
|
43
|
+
let t = new Set([
|
|
44
|
+
"Tab",
|
|
45
|
+
"Enter",
|
|
46
|
+
"Escape",
|
|
47
|
+
"ArrowDown",
|
|
48
|
+
"ArrowUp",
|
|
49
|
+
"ArrowLeft",
|
|
50
|
+
"ArrowRight",
|
|
51
|
+
"Home",
|
|
52
|
+
"End",
|
|
53
|
+
"Shift",
|
|
54
|
+
"Control",
|
|
55
|
+
"Alt",
|
|
56
|
+
"Meta"
|
|
57
|
+
]);
|
|
58
|
+
if (!(e.ctrlKey || e.metaKey || e.altKey)) {
|
|
59
|
+
if (t.has(e.key)) {
|
|
60
|
+
e.key === "ArrowDown" && m(e.currentTarget);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
onInput: (e) => {
|
|
67
|
+
let t = e.target, n = t.value;
|
|
68
|
+
f(n), p(n, t);
|
|
69
|
+
},
|
|
70
|
+
onChange: (e) => {
|
|
71
|
+
let t = e.target, n = t.value;
|
|
72
|
+
f(n), p(n, t);
|
|
73
|
+
},
|
|
74
|
+
onBlur: (e) => {
|
|
75
|
+
let t = e.target, n = t.value;
|
|
76
|
+
p(n, t);
|
|
77
|
+
}
|
|
78
|
+
}), u && /* @__PURE__ */ t("datalist", {
|
|
79
|
+
id: u,
|
|
80
|
+
children: i.map((e) => /* @__PURE__ */ t("option", { value: e }, e))
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
//#endregion
|
|
86
|
+
export { r as Component };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=navbarSearch.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navbarSearch.component.js","names":[],"sources":["../../../src/cards/navbarSearch/navbarSearch.component.tsx"],"sourcesContent":["import {Input} from \"@/registry/ui/input\";\nimport type {PiCardProps} from \"@pihanga2/core\";\nimport type {\n NavbarSearchEvents,\n NavbarSearchProps,\n} from \"./navbarSearch.type\";\n\nexport const Component = (\n props: PiCardProps<NavbarSearchProps, NavbarSearchEvents>,\n): React.ReactNode => {\n const {\n searchItems,\n placeholder = \"Load Spec...\",\n onSearchSubmit,\n onSearchItems,\n onSearchFocus,\n cardName,\n } = props;\n const listId = searchItems?.length ? `${cardName}-search` : undefined;\n\n const submitSearch = (value: string, input?: HTMLInputElement | null) => {\n const search = value.trim();\n if (!search) return;\n onSearchSubmit?.({search});\n if (input) {\n input.value = \"\";\n emitSearchInput(\"\");\n }\n input?.blur();\n };\n\n const emitSearchInput = (value: string) => {\n onSearchItems?.({search: value});\n };\n\n const maybeSubmit = (value: string, input?: HTMLInputElement | null) => {\n if (searchItems?.includes(value)) {\n submitSearch(value, input);\n }\n };\n\n const openNativeSuggestions = (input: HTMLInputElement | null) => {\n if (!input) {\n return;\n }\n\n const pickerInput = input as HTMLInputElement & {\n showPicker?: () => void;\n };\n pickerInput.showPicker?.();\n };\n\n const blockManualTyping = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const allowedKeys = new Set([\n \"Tab\",\n \"Enter\",\n \"Escape\",\n \"ArrowDown\",\n \"ArrowUp\",\n \"ArrowLeft\",\n \"ArrowRight\",\n \"Home\",\n \"End\",\n \"Shift\",\n \"Control\",\n \"Alt\",\n \"Meta\",\n ]);\n\n if (event.ctrlKey || event.metaKey || event.altKey) {\n return;\n }\n\n if (allowedKeys.has(event.key)) {\n if (event.key === \"ArrowDown\") {\n openNativeSuggestions(event.currentTarget);\n }\n return;\n }\n\n event.preventDefault();\n };\n\n return (\n <form\n onSubmit={(el) => {\n el.preventDefault();\n const data = new FormData(el.currentTarget);\n submitSearch(\n String(data.get(\"search\") || \"\"),\n el.currentTarget.elements.namedItem(\"search\") as HTMLInputElement | null,\n );\n }}\n autoComplete=\"off\"\n className=\"ml-auto flex-1 sm:flex-initial\"\n data-pihanga={cardName}\n >\n <div className=\"relative\">\n <Input\n type=\"search\"\n placeholder={placeholder}\n name=\"search\"\n list={listId}\n autoComplete=\"off\"\n className=\"sm:w-[300px] md:w-[200px] lg:w-[300px]\"\n onFocus={() => {\n onSearchFocus?.({});\n }}\n onClick={(e) => {\n openNativeSuggestions(e.currentTarget);\n }}\n onBeforeInput={(e) => {\n e.preventDefault();\n }}\n onKeyDown={blockManualTyping}\n onInput={(e) => {\n const input = e.target as HTMLInputElement;\n const value = input.value;\n emitSearchInput(value);\n maybeSubmit(value, input);\n }}\n onChange={(e) => {\n const input = e.target as HTMLInputElement;\n const value = input.value;\n emitSearchInput(value);\n maybeSubmit(value, input);\n }}\n onBlur={(e) => {\n const input = e.target as HTMLInputElement;\n const value = input.value;\n maybeSubmit(value, input);\n }}\n />\n {listId && (\n <datalist id={listId}>\n {searchItems!.map((item) => (\n <option key={item} value={item} />\n ))}\n </datalist>\n )}\n </div>\n </form>\n );\n};\n"],"mappings":";;;AAOA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,gBACA,iBAAc,gBACd,mBACA,kBACA,kBACA,gBACE,GACE,IAAS,GAAa,SAAS,GAAG,EAAS,WAAW,KAAA,GAEtD,KAAgB,GAAe,MAAoC;EACvE,IAAM,IAAS,EAAM,KAAK;EACrB,MACL,IAAiB,EAAC,UAAM,CAAC,GACrB,MACF,EAAM,QAAQ,IACd,EAAgB,EAAE,IAEpB,GAAO,KAAK;CACd,GAEM,KAAmB,MAAkB;EACzC,IAAgB,EAAC,QAAQ,EAAK,CAAC;CACjC,GAEM,KAAe,GAAe,MAAoC;EACtE,AAAI,GAAa,SAAS,CAAK,KAC7B,EAAa,GAAO,CAAK;CAE7B,GAEM,KAAyB,MAAmC;EAC3D,KAOL,EAAY,aAAa;CAC3B;CAiCA,OACE,kBAAC,QAAD;EACE,WAAW,MAAO;GAChB,EAAG,eAAe;GAClB,IAAM,IAAO,IAAI,SAAS,EAAG,aAAa;GAC1C,EACE,OAAO,EAAK,IAAI,QAAQ,KAAK,EAAE,GAC/B,EAAG,cAAc,SAAS,UAAU,QAAQ,CAC9C;EACF;EACA,cAAa;EACb,WAAU;EACV,gBAAc;YAEd,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,GAAD;IACE,MAAK;IACQ;IACb,MAAK;IACL,MAAM;IACN,cAAa;IACb,WAAU;IACV,eAAe;KACb,IAAgB,CAAC,CAAC;IACpB;IACA,UAAU,MAAM;KACd,EAAsB,EAAE,aAAa;IACvC;IACA,gBAAgB,MAAM;KACpB,EAAE,eAAe;IACnB;IACA,YA9DmB,MAAiD;KAC1E,IAAM,IAAc,IAAI,IAAI;MAC1B;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;MACA;KACF,CAAC;KAEG,QAAM,WAAW,EAAM,WAAW,EAAM,SAI5C;UAAI,EAAY,IAAI,EAAM,GAAG,GAAG;OAC9B,AAAI,EAAM,QAAQ,eAChB,EAAsB,EAAM,aAAa;OAE3C;MACF;MAEA,EAAM,eAAe;KAFrB;IAGF;IAkCQ,UAAU,MAAM;KACd,IAAM,IAAQ,EAAE,QACV,IAAQ,EAAM;KAEpB,AADA,EAAgB,CAAK,GACrB,EAAY,GAAO,CAAK;IAC1B;IACA,WAAW,MAAM;KACf,IAAM,IAAQ,EAAE,QACV,IAAQ,EAAM;KAEpB,AADA,EAAgB,CAAK,GACrB,EAAY,GAAO,CAAK;IAC1B;IACA,SAAS,MAAM;KACb,IAAM,IAAQ,EAAE,QACV,IAAQ,EAAM;KACpB,EAAY,GAAO,CAAK;IAC1B;GACD,CAAA,GACA,KACC,kBAAC,YAAD;IAAU,IAAI;cACX,EAAa,KAAK,MACjB,kBAAC,UAAD,EAAmB,OAAO,EAAO,GAApB,CAAoB,CAClC;GACO,CAAA,CAET;;CACD,CAAA;AAEV"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export declare const NAVBAR_SEARCH_CARD = "navbarSearch";
|
|
2
|
+
export declare const NavbarSearch: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<NavbarSearchProps, S, NavbarSearchEvents>) => import('@pihanga2/core').PiCardDef;
|
|
3
|
+
export declare const NAVBAR_SEARCH_ACTION: {
|
|
4
|
+
SEARCH_SUBMIT: string;
|
|
5
|
+
SEARCH_ITEMS: string;
|
|
6
|
+
SEARCH_FOCUS: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const onNavbarSearchSubmit: <S extends import('@pihanga2/core').ReduxState>(register: import('@pihanga2/core').PiRegister, f: import('@pihanga2/core').ReduceF<S, import('@pihanga2/core').ReduxAction & {
|
|
9
|
+
cardID: string;
|
|
10
|
+
} & NavbarSearchEvent>) => void;
|
|
11
|
+
export declare const onNavbarSearchItems: <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
|
+
} & NavbarSearchInputEvent>) => void;
|
|
14
|
+
export declare const onNavbarSearchFocus: <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
|
+
} & NavbarSearchFocusEvent>) => void;
|
|
17
|
+
export type NavbarSearchProps = {
|
|
18
|
+
searchItems?: string[];
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
};
|
|
21
|
+
export type NavbarSearchEvent = {
|
|
22
|
+
search: string;
|
|
23
|
+
};
|
|
24
|
+
export type NavbarSearchInputEvent = {
|
|
25
|
+
search: string;
|
|
26
|
+
};
|
|
27
|
+
export type NavbarSearchFocusEvent = Record<string, never>;
|
|
28
|
+
export type NavbarSearchEvents = {
|
|
29
|
+
onSearchSubmit: NavbarSearchEvent;
|
|
30
|
+
onSearchItems?: NavbarSearchInputEvent;
|
|
31
|
+
onSearchFocus?: NavbarSearchFocusEvent;
|
|
32
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/navbarSearch/navbarSearch.type.ts
|
|
3
|
+
var r = "navbarSearch", i = e(r), a = n(r, [
|
|
4
|
+
"search_submit",
|
|
5
|
+
"search_items",
|
|
6
|
+
"search_focus"
|
|
7
|
+
]), o = t(a.SEARCH_SUBMIT), s = t(a.SEARCH_ITEMS), c = t(a.SEARCH_FOCUS);
|
|
8
|
+
//#endregion
|
|
9
|
+
export { a as NAVBAR_SEARCH_ACTION, r as NAVBAR_SEARCH_CARD, i as NavbarSearch, c as onNavbarSearchFocus, s as onNavbarSearchItems, o as onNavbarSearchSubmit };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=navbarSearch.type.js.map
|