@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,38 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/utils.js";
|
|
2
|
+
import { useFormContext as t } from "../form/form.context.js";
|
|
3
|
+
import { Field as n, FieldDescription as r, FieldError as i, FieldLabel as a } from "../../components/ui/field.js";
|
|
4
|
+
import { Card as o } from "@pihanga2/core";
|
|
5
|
+
import s, { useMemo as c } from "react";
|
|
6
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
|
+
//#region src/cards/field/field.component.tsx
|
|
8
|
+
var d = (d) => {
|
|
9
|
+
let { label: f, fieldCard: p, name: m, description: h, error: g, className: _, cardName: v } = d, y = t(), b = y.isInForm && m ? y.errors[m] : g, x = s.useId(), S = !!b, C = c(() => ({
|
|
10
|
+
cardName: p,
|
|
11
|
+
parentCard: v,
|
|
12
|
+
id: x,
|
|
13
|
+
invalid: S
|
|
14
|
+
}), [
|
|
15
|
+
v,
|
|
16
|
+
p,
|
|
17
|
+
x,
|
|
18
|
+
S
|
|
19
|
+
]);
|
|
20
|
+
return /* @__PURE__ */ u(n, {
|
|
21
|
+
"data-invalid": !!b || void 0,
|
|
22
|
+
className: e(_),
|
|
23
|
+
"data-pihanga": v,
|
|
24
|
+
children: [
|
|
25
|
+
/* @__PURE__ */ l(a, {
|
|
26
|
+
htmlFor: x,
|
|
27
|
+
children: f
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ l(o, { ...C }),
|
|
30
|
+
h && /* @__PURE__ */ l(r, { children: h }),
|
|
31
|
+
/* @__PURE__ */ l(i, { children: b })
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { d as FieldCardComponent };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=field.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.component.js","names":[],"sources":["../../../src/cards/field/field.component.tsx"],"sourcesContent":["import React, {useMemo} from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\nimport {\n Field,\n FieldDescription,\n FieldError,\n FieldLabel,\n} from \"@/components/ui/field\";\nimport {cn} from \"@/lib/utils\";\nimport {useFormContext} from \"@/cards/form/form.context\";\nimport type {PiFieldProps} from \"./field.types\";\n\nexport const FieldCardComponent = (\n props: PiCardProps<PiFieldProps>,\n): React.ReactNode => {\n const {\n label,\n fieldCard,\n name,\n description,\n error: propError,\n className,\n cardName,\n } = props;\n\n // When name is provided and we're inside a pi/form, use the form error.\n const form = useFormContext();\n const error = form.isInForm && name ? form.errors[name] : propError;\n\n // Stable id that links <FieldLabel htmlFor> to the inner control's id.\n const fieldId = React.useId();\n\n // Memoize the extra props forwarded to the inner card so that Pihanga does\n // not see a brand-new object on every render (which would cause it to treat\n // the inner card as a new/changed card and unmount/remount it).\n const isInvalid = Boolean(error);\n /*\n Pihanga's Card forwards every prop other than cardName / parentCard to\n the bound component. We inject `id` (so the control's element gets\n the id that FieldLabel points at) and `invalid` (so the control can\n set aria-invalid without needing its own error/label logic).\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fieldCardProps = useMemo<any>(\n () => ({\n cardName: fieldCard,\n parentCard: cardName,\n id: fieldId,\n invalid: isInvalid,\n }),\n [cardName, fieldCard, fieldId, isInvalid],\n );\n\n return (\n <Field\n data-invalid={Boolean(error) || undefined}\n className={cn(className)}\n data-pihanga={cardName}\n >\n <FieldLabel htmlFor={fieldId}>{label}</FieldLabel>\n\n <Card {...fieldCardProps} />\n\n {description && <FieldDescription>{description}</FieldDescription>}\n <FieldError>{error}</FieldError>\n </Field>\n );\n};\n"],"mappings":";;;;;;;AAYA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,UACA,cACA,SACA,gBACA,OAAO,GACP,cACA,gBACE,GAGE,IAAO,EAAe,GACtB,IAAQ,EAAK,YAAY,IAAO,EAAK,OAAO,KAAQ,GAGpD,IAAU,EAAM,MAAM,GAKtB,IAAY,EAAQ,GAQpB,IAAiB,SACd;EACL,UAAU;EACV,YAAY;EACZ,IAAI;EACJ,SAAS;CACX,IACA;EAAC;EAAU;EAAW;EAAS;CAAS,CAC1C;CAEA,OACE,kBAAC,GAAD;EACE,gBAAc,EAAQ,KAAU,KAAA;EAChC,WAAW,EAAG,CAAS;EACvB,gBAAc;YAHhB;GAKE,kBAAC,GAAD;IAAY,SAAS;cAAU;GAAkB,CAAA;GAEjD,kBAAC,GAAD,EAAM,GAAI,EAAiB,CAAA;GAE1B,KAAe,kBAAC,GAAD,EAAA,UAAmB,EAA8B,CAAA;GACjE,kBAAC,GAAD,EAAA,UAAa,EAAkB,CAAA;EAC1B;;AAEX"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PiCardRef } from '@pihanga2/core';
|
|
2
|
+
export declare const PI_FIELD_CARD = "pi/field";
|
|
3
|
+
export declare const Field: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<PiFieldProps, S, {}>) => import('@pihanga2/core').PiCardDef;
|
|
4
|
+
export type PiFieldProps = {
|
|
5
|
+
/** Visible label rendered above the control. */
|
|
6
|
+
label: string;
|
|
7
|
+
/**
|
|
8
|
+
* The Pihanga card reference for the plain control to render
|
|
9
|
+
* (e.g. pi/text-field, pi/select, pi/checkbox, …).
|
|
10
|
+
*
|
|
11
|
+
* The field card will forward an `id` prop and an `invalid` boolean to the
|
|
12
|
+
* inner card via Pihanga's standard prop-passing mechanism so the control
|
|
13
|
+
* can wire up accessibility attributes without needing its own label logic.
|
|
14
|
+
*/
|
|
15
|
+
fieldCard: PiCardRef;
|
|
16
|
+
/**
|
|
17
|
+
* Field name — when provided the card reads the current error from
|
|
18
|
+
* FormContext (when inside a pi/form) to decide whether to show an error.
|
|
19
|
+
*/
|
|
20
|
+
name?: string;
|
|
21
|
+
/** Secondary help text rendered below the control. */
|
|
22
|
+
description?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Static error message. Overridden by the form-context error when `name`
|
|
25
|
+
* is provided and the card is inside a pi/form.
|
|
26
|
+
*/
|
|
27
|
+
error?: string;
|
|
28
|
+
/** Additional CSS classes applied to the outer Field wrapper. */
|
|
29
|
+
className?: string;
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field.types.js","names":[],"sources":["../../../src/cards/field/field.types.ts"],"sourcesContent":["import {createCardDeclaration, PiCardRef} from \"@pihanga2/core\";\n\nexport const PI_FIELD_CARD = \"pi/field\";\n\nexport const Field = createCardDeclaration<PiFieldProps>(PI_FIELD_CARD);\n\nexport type PiFieldProps = {\n /** Visible label rendered above the control. */\n label: string;\n\n /**\n * The Pihanga card reference for the plain control to render\n * (e.g. pi/text-field, pi/select, pi/checkbox, …).\n *\n * The field card will forward an `id` prop and an `invalid` boolean to the\n * inner card via Pihanga's standard prop-passing mechanism so the control\n * can wire up accessibility attributes without needing its own label logic.\n */\n fieldCard: PiCardRef;\n\n /**\n * Field name — when provided the card reads the current error from\n * FormContext (when inside a pi/form) to decide whether to show an error.\n */\n name?: string;\n\n /** Secondary help text rendered below the control. */\n description?: string;\n\n /**\n * Static error message. Overridden by the form-context error when `name`\n * is provided and the card is inside a pi/form.\n */\n error?: string;\n\n /** Additional CSS classes applied to the outer Field wrapper. */\n className?: string;\n};\n"],"mappings":";;AAEA,IAAa,IAAgB,YAEhB,IAAQ,EAAoC,CAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './field.types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FieldCardComponent as e } from "./field.component.js";
|
|
2
|
+
import { Field as t, PI_FIELD_CARD as n } from "./field.types.js";
|
|
3
|
+
import { registerCardComponent as r } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/field/index.ts
|
|
5
|
+
r({
|
|
6
|
+
name: n,
|
|
7
|
+
component: e
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as Field, n as PI_FIELD_CARD };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/field/index.ts"],"sourcesContent":["import {registerCardComponent} from \"@pihanga2/core\";\n\nimport {FieldCardComponent} from \"./field.component\";\nimport {PI_FIELD_CARD} from \"./field.types\";\n\nexport * from \"./field.types\";\n\n// pi/field has no events of its own; events fire from the inner fieldCard.\nregisterCardComponent({\n name: PI_FIELD_CARD,\n component: FieldCardComponent,\n});\n"],"mappings":";;;;AAQA,EAAsB;CACpB,MAAM;CACN,WAAW;AACb,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Card as e } from "@pihanga2/core";
|
|
2
|
+
import "react";
|
|
3
|
+
import t from "clsx";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
//#region src/cards/flexGrid/flexGrid.component.tsx
|
|
6
|
+
var r = (r) => {
|
|
7
|
+
let { cardName: i, cards: a = {}, template: o, height: s = "auto", margin: c = 0, overflow: l = "hidden", style: u, className: d, _cls: f } = r, p = {
|
|
8
|
+
display: "grid",
|
|
9
|
+
gridGap: o.gap || "10px",
|
|
10
|
+
height: s,
|
|
11
|
+
margin: c,
|
|
12
|
+
width: "100%",
|
|
13
|
+
...u?.root
|
|
14
|
+
};
|
|
15
|
+
o.area && (p.gridTemplateAreas = o.area.map((e) => `"${e.join(" ")}"`).join(" ")), o.rows && (p.gridTemplateRows = o.rows.join(" ")), o.columns && (p.gridTemplateColumns = o.columns.join(" "));
|
|
16
|
+
function m(t) {
|
|
17
|
+
let [r, a] = t, s = {
|
|
18
|
+
overflow: l,
|
|
19
|
+
...u?.item
|
|
20
|
+
};
|
|
21
|
+
return o.area && (s.gridArea = r), /* @__PURE__ */ n("div", {
|
|
22
|
+
style: s,
|
|
23
|
+
"data-pihanga-grid": r,
|
|
24
|
+
children: /* @__PURE__ */ n(e, {
|
|
25
|
+
cardName: a,
|
|
26
|
+
parentCard: i
|
|
27
|
+
})
|
|
28
|
+
}, r);
|
|
29
|
+
}
|
|
30
|
+
return /* @__PURE__ */ n("div", {
|
|
31
|
+
style: p,
|
|
32
|
+
className: t(f("root"), d),
|
|
33
|
+
"data-pihanga": i,
|
|
34
|
+
children: Object.entries(a).map(m)
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
//#endregion
|
|
38
|
+
export { r as FlexGridComponent };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=flexGrid.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flexGrid.component.js","names":[],"sources":["../../../src/cards/flexGrid/flexGrid.component.tsx"],"sourcesContent":["import React from \"react\";\nimport {Card} from \"@pihanga2/core\";\nimport type {PiCardProps, PiCardRef} from \"@pihanga2/core\";\nimport type {FlexGridProps} from \"./flexGrid.types\";\nimport clsx from \"clsx\";\n\nexport const FlexGridComponent = (\n props: PiCardProps<FlexGridProps>,\n): React.ReactNode => {\n const {\n cardName,\n cards = {},\n template,\n height = \"auto\", //'100vh',\n margin = 0,\n overflow = \"hidden\", // 'scroll',\n style,\n className,\n _cls,\n } = props;\n\n // console.log(\"AREA\", area)\n const _style: React.CSSProperties & Record<string, unknown> = {\n display: \"grid\",\n gridGap: template.gap || \"10px\",\n height,\n margin,\n width: \"100%\",\n ...style?.root,\n };\n\n if (template.area) {\n const areaRows = template.area.map((row: string[]) => `\"${row.join(\" \")}\"`);\n _style.gridTemplateAreas = areaRows.join(\" \");\n }\n if (template.rows) {\n _style.gridTemplateRows = template.rows.join(\" \");\n }\n if (template.columns) {\n _style.gridTemplateColumns = template.columns.join(\" \");\n }\n\n function renderGridCard(v: [string, PiCardRef]): React.ReactElement {\n const [name, gridCard] = v;\n const _style = {\n overflow,\n ...style?.item,\n };\n if (template.area) {\n _style.gridArea = name;\n }\n return (\n <div style={_style} data-pihanga-grid={name} key={name}>\n <Card cardName={gridCard} parentCard={cardName} />\n </div>\n );\n }\n\n return (\n <div\n style={_style}\n className={clsx(_cls(\"root\"), className)}\n data-pihanga={cardName}\n >\n {(Object.entries(cards) as [string, PiCardRef][]).map(renderGridCard)}\n </div>\n );\n};\n"],"mappings":";;;;;AAMA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,aACA,WAAQ,CAAC,GACT,aACA,YAAS,QACT,YAAS,GACT,cAAW,UACX,UACA,cACA,YACE,GAGE,IAAwD;EAC5D,SAAS;EACT,SAAS,EAAS,OAAO;EACzB;EACA;EACA,OAAO;EACP,GAAG,GAAO;CACZ;CASA,AAPI,EAAS,SAEX,EAAO,oBADU,EAAS,KAAK,KAAK,MAAkB,IAAI,EAAI,KAAK,GAAG,EAAE,EAC7C,EAAS,KAAK,GAAG,IAE1C,EAAS,SACX,EAAO,mBAAmB,EAAS,KAAK,KAAK,GAAG,IAE9C,EAAS,YACX,EAAO,sBAAsB,EAAS,QAAQ,KAAK,GAAG;CAGxD,SAAS,EAAe,GAA4C;EAClE,IAAM,CAAC,GAAM,KAAY,GACnB,IAAS;GACb;GACA,GAAG,GAAO;EACZ;EAIA,OAHI,EAAS,SACX,EAAO,WAAW,IAGlB,kBAAC,OAAD;GAAK,OAAO;GAAQ,qBAAmB;aACrC,kBAAC,GAAD;IAAM,UAAU;IAAU,YAAY;GAAW,CAAA;EAC9C,GAF6C,CAE7C;CAET;CAEA,OACE,kBAAC,OAAD;EACE,OAAO;EACP,WAAW,EAAK,EAAK,MAAM,GAAG,CAAS;EACvC,gBAAc;YAEZ,OAAO,QAAQ,CAAK,EAA4B,IAAI,CAAc;CACjE,CAAA;AAET"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PiCardRef } from '@pihanga2/core';
|
|
2
|
+
export declare const FLEX_GRID_CARD = "flex_grid";
|
|
3
|
+
export declare const FlexGrid: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<FlexGridProps, S, {}>) => import('@pihanga2/core').PiCardDef;
|
|
4
|
+
export type FlexGridProps = {
|
|
5
|
+
cards: {
|
|
6
|
+
[name: string]: PiCardRef;
|
|
7
|
+
};
|
|
8
|
+
template: TemplateT;
|
|
9
|
+
height?: string;
|
|
10
|
+
margin?: string;
|
|
11
|
+
overflow?: string;
|
|
12
|
+
style?: {
|
|
13
|
+
root?: React.CSSProperties;
|
|
14
|
+
item?: React.CSSProperties;
|
|
15
|
+
};
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
export type TemplateT = {
|
|
19
|
+
area?: string[][];
|
|
20
|
+
rows?: string[];
|
|
21
|
+
columns?: string[];
|
|
22
|
+
gap?: string;
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flexGrid.types.js","names":[],"sources":["../../../src/cards/flexGrid/flexGrid.types.ts"],"sourcesContent":["import { createCardDeclaration, PiCardRef } from \"@pihanga2/core\"\n\nexport const FLEX_GRID_CARD = \"flex_grid\"\nexport const FlexGrid = createCardDeclaration<FlexGridProps>(FLEX_GRID_CARD)\n\nexport type FlexGridProps = {\n cards: { [name: string]: PiCardRef }\n template: TemplateT\n height?: string\n margin?: string\n overflow?: string\n\n style?: {\n root?: React.CSSProperties\n item?: React.CSSProperties\n }\n className?: string\n}\n\n// body {\n// display: grid;\n// grid-template-areas:\n// \"header header header\"\n// \"nav article ads\"\n// \"footer footer footer\";\n// grid-template-rows: 60px 1fr 60px;\n// grid-template-columns: 20% 1fr 15%;\n// grid-gap: 10px;\n// height: 100vh;\n// margin: 0;\n// }\n\n// https://css-tricks.com/snippets/css/complete-guide-grid/\nexport type TemplateT = {\n area?: string[][] // name of card dict\n rows?: string[] // grid-template-rows (e.g [\"min-content\", \"1fr\", \"min-content\"])\n columns?: string[] // grid-template-cols (e.g. [\"1fr\", \"50px\", \"1fr\", \"1fr\"])\n gap?: string\n}\n"],"mappings":";;AAEA,IAAa,IAAiB,aACjB,IAAW,EAAqC,CAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './flexGrid.types';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FlexGridComponent as e } from "./flexGrid.component.js";
|
|
2
|
+
import { FLEX_GRID_CARD as t, FlexGrid as n } from "./flexGrid.types.js";
|
|
3
|
+
import { registerCardComponent as r } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/flexGrid/index.ts
|
|
5
|
+
r({
|
|
6
|
+
name: t,
|
|
7
|
+
component: e
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { t as FLEX_GRID_CARD, n as FlexGrid };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/flexGrid/index.ts"],"sourcesContent":["import {registerCardComponent} from \"@pihanga2/core\";\n\nimport {FlexGridComponent} from \"./flexGrid.component\";\nimport {FLEX_GRID_CARD} from \"./flexGrid.types\";\n\nexport * from \"./flexGrid.types\";\n\nregisterCardComponent({\n name: FLEX_GRID_CARD,\n component: FlexGridComponent,\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;AACb,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { cn as e } from "../../lib/utils.js";
|
|
2
|
+
import { FormContext as t } from "./form.context.js";
|
|
3
|
+
import { Card as n } from "@pihanga2/core";
|
|
4
|
+
import { useCallback as r, useState as i } from "react";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
//#region src/cards/form/form.component.tsx
|
|
7
|
+
var s = (s) => {
|
|
8
|
+
let { id: c, content: l = [], initialValues: u = {}, submitLabel: d = "Submit", className: f, cardName: p, onSubmitted: m } = s, [h, g] = i(() => ({ ...u })), [_, v] = i({}), y = r((e, t) => {
|
|
9
|
+
g((n) => ({
|
|
10
|
+
...n,
|
|
11
|
+
[e]: t
|
|
12
|
+
})), v((t) => {
|
|
13
|
+
if (!t[e]) return t;
|
|
14
|
+
let n = { ...t };
|
|
15
|
+
return delete n[e], n;
|
|
16
|
+
});
|
|
17
|
+
}, []), b = r((e, t) => {
|
|
18
|
+
v((n) => {
|
|
19
|
+
if (t === null) {
|
|
20
|
+
let t = { ...n };
|
|
21
|
+
return delete t[e], t;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
...n,
|
|
25
|
+
[e]: t
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
}, []), x = r((e) => {
|
|
29
|
+
e.preventDefault(), m({
|
|
30
|
+
id: c,
|
|
31
|
+
formData: h
|
|
32
|
+
});
|
|
33
|
+
}, [
|
|
34
|
+
c,
|
|
35
|
+
h,
|
|
36
|
+
m
|
|
37
|
+
]), S = {
|
|
38
|
+
formData: h,
|
|
39
|
+
errors: _,
|
|
40
|
+
handleChange: y,
|
|
41
|
+
setError: b,
|
|
42
|
+
isInForm: !0
|
|
43
|
+
};
|
|
44
|
+
return /* @__PURE__ */ a(t.Provider, {
|
|
45
|
+
value: S,
|
|
46
|
+
children: /* @__PURE__ */ o("form", {
|
|
47
|
+
onSubmit: x,
|
|
48
|
+
className: e("flex flex-col gap-4", f),
|
|
49
|
+
"data-pihanga": p,
|
|
50
|
+
children: [l.map((e, t) => /* @__PURE__ */ a(n, {
|
|
51
|
+
cardName: e,
|
|
52
|
+
parentCard: p
|
|
53
|
+
}, t)), /* @__PURE__ */ a("button", {
|
|
54
|
+
type: "submit",
|
|
55
|
+
className: "inline-flex h-9 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
56
|
+
children: d
|
|
57
|
+
})]
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { s as FormComponent };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=form.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.component.js","names":[],"sources":["../../../src/cards/form/form.component.tsx"],"sourcesContent":["import React, {useState, useCallback} from \"react\";\nimport {Card, type PiCardProps} from \"@pihanga2/core\";\nimport {cn} from \"@/lib/utils\";\nimport {FormContext, type FormContextValue} from \"./form.context\";\nimport type {PiFormEvents, PiFormProps} from \"./form.types\";\n\nexport const FormComponent = (\n props: PiCardProps<PiFormProps, PiFormEvents>,\n): React.ReactNode => {\n const {\n id,\n content = [],\n initialValues = {},\n submitLabel = \"Submit\",\n className,\n cardName,\n onSubmitted,\n } = props;\n\n const [formData, setFormData] = useState<Record<string, unknown>>(() => ({\n ...initialValues,\n }));\n const [errors, setErrors] = useState<Record<string, string>>({});\n\n const handleChange = useCallback((fieldName: string, value: unknown) => {\n setFormData((prev) => ({...prev, [fieldName]: value}));\n // Clear validation error when the user modifies the field\n setErrors((prev) => {\n if (!prev[fieldName]) return prev;\n const next = {...prev};\n delete next[fieldName];\n return next;\n });\n }, []);\n\n const setError = useCallback((fieldName: string, error: string | null) => {\n setErrors((prev) => {\n if (error === null) {\n const next = {...prev};\n delete next[fieldName];\n return next;\n }\n return {...prev, [fieldName]: error};\n });\n }, []);\n\n const handleSubmit = useCallback(\n (e: React.FormEvent) => {\n e.preventDefault();\n onSubmitted({id, formData});\n },\n [id, formData, onSubmitted],\n );\n\n const contextValue: FormContextValue = {\n formData,\n errors,\n handleChange,\n setError,\n isInForm: true,\n };\n\n return (\n <FormContext.Provider value={contextValue}>\n <form\n onSubmit={handleSubmit}\n className={cn(\"flex flex-col gap-4\", className)}\n data-pihanga={cardName}\n >\n {content.map((cref, idx) => (\n <Card key={idx} cardName={cref} parentCard={cardName} />\n ))}\n <button\n type=\"submit\"\n className=\"inline-flex h-9 items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50\"\n >\n {submitLabel}\n </button>\n </form>\n </FormContext.Provider>\n );\n};\n"],"mappings":";;;;;;AAMA,IAAa,KACX,MACoB;CACpB,IAAM,EACJ,OACA,aAAU,CAAC,GACX,mBAAgB,CAAC,GACjB,iBAAc,UACd,cACA,aACA,mBACE,GAEE,CAAC,GAAU,KAAe,SAAyC,EACvE,GAAG,EACL,EAAE,GACI,CAAC,GAAQ,KAAa,EAAiC,CAAC,CAAC,GAEzD,IAAe,GAAa,GAAmB,MAAmB;EAGtE,AAFA,GAAa,OAAU;GAAC,GAAG;IAAO,IAAY;EAAK,EAAE,GAErD,GAAW,MAAS;GAClB,IAAI,CAAC,EAAK,IAAY,OAAO;GAC7B,IAAM,IAAO,EAAC,GAAG,EAAI;GAErB,OADA,OAAO,EAAK,IACL;EACT,CAAC;CACH,GAAG,CAAC,CAAC,GAEC,IAAW,GAAa,GAAmB,MAAyB;EACxE,GAAW,MAAS;GAClB,IAAI,MAAU,MAAM;IAClB,IAAM,IAAO,EAAC,GAAG,EAAI;IAErB,OADA,OAAO,EAAK,IACL;GACT;GACA,OAAO;IAAC,GAAG;KAAO,IAAY;GAAK;EACrC,CAAC;CACH,GAAG,CAAC,CAAC,GAEC,IAAe,GAClB,MAAuB;EAEtB,AADA,EAAE,eAAe,GACjB,EAAY;GAAC;GAAI;EAAQ,CAAC;CAC5B,GACA;EAAC;EAAI;EAAU;CAAW,CAC5B,GAEM,IAAiC;EACrC;EACA;EACA;EACA;EACA,UAAU;CACZ;CAEA,OACE,kBAAC,EAAY,UAAb;EAAsB,OAAO;YAC3B,kBAAC,QAAD;GACE,UAAU;GACV,WAAW,EAAG,uBAAuB,CAAS;GAC9C,gBAAc;aAHhB,CAKG,EAAQ,KAAK,GAAM,MAClB,kBAAC,GAAD;IAAgB,UAAU;IAAM,YAAY;GAAW,GAA5C,CAA4C,CACxD,GACD,kBAAC,UAAD;IACE,MAAK;IACL,WAAU;cAET;GACK,CAAA,CACJ;;CACc,CAAA;AAE1B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Shape of the data provided by FormContext.
|
|
4
|
+
* When inside a <Form> card, isInForm is true and all fields are populated.
|
|
5
|
+
* When outside (fallback), isInForm is false.
|
|
6
|
+
*/
|
|
7
|
+
export interface FormContextValue {
|
|
8
|
+
formData: Record<string, unknown>;
|
|
9
|
+
errors: Record<string, string>;
|
|
10
|
+
handleChange: (fieldName: string, value: unknown) => void;
|
|
11
|
+
setError: (fieldName: string, error: string | null) => void;
|
|
12
|
+
isInForm: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const FormContext: React.Context<FormContextValue | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Hook that reads the nearest FormContext.
|
|
17
|
+
* Returns a fallback (isInForm=false) when called outside a <Form> card.
|
|
18
|
+
*
|
|
19
|
+
* Usage in field components:
|
|
20
|
+
* const form = useFormContext();
|
|
21
|
+
* const value = form.isInForm && name ? form.formData[name] ?? '' : propValue;
|
|
22
|
+
*/
|
|
23
|
+
export declare const useFormContext: () => FormContextValue;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import e, { useContext as t } from "react";
|
|
2
|
+
//#region src/cards/form/form.context.tsx
|
|
3
|
+
var n = {
|
|
4
|
+
formData: {},
|
|
5
|
+
errors: {},
|
|
6
|
+
handleChange: () => {},
|
|
7
|
+
setError: () => {},
|
|
8
|
+
isInForm: !1
|
|
9
|
+
}, r = e.createContext(null), i = () => t(r) ?? n;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { r as FormContext, i as useFormContext };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=form.context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.context.js","names":[],"sources":["../../../src/cards/form/form.context.tsx"],"sourcesContent":["import React, {useContext} from \"react\";\n\n/**\n * Shape of the data provided by FormContext.\n * When inside a <Form> card, isInForm is true and all fields are populated.\n * When outside (fallback), isInForm is false.\n */\nexport interface FormContextValue {\n formData: Record<string, unknown>;\n errors: Record<string, string>;\n handleChange: (fieldName: string, value: unknown) => void;\n setError: (fieldName: string, error: string | null) => void;\n isInForm: boolean;\n}\n\nconst FALLBACK_CONTEXT: FormContextValue = {\n formData: {},\n errors: {},\n handleChange: () => {},\n setError: () => {},\n isInForm: false,\n};\n\nexport const FormContext = React.createContext<FormContextValue | null>(null);\n\n/**\n * Hook that reads the nearest FormContext.\n * Returns a fallback (isInForm=false) when called outside a <Form> card.\n *\n * Usage in field components:\n * const form = useFormContext();\n * const value = form.isInForm && name ? form.formData[name] ?? '' : propValue;\n */\nexport const useFormContext = (): FormContextValue => {\n const ctx = useContext(FormContext);\n return ctx ?? FALLBACK_CONTEXT;\n};\n"],"mappings":";;AAeA,IAAM,IAAqC;CACzC,UAAU,CAAC;CACX,QAAQ,CAAC;CACT,oBAAoB,CAAC;CACrB,gBAAgB,CAAC;CACjB,UAAU;AACZ,GAEa,IAAc,EAAM,cAAuC,IAAI,GAU/D,UACC,EAAW,CAChB,KAAO"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { PiCardRef } from '@pihanga2/core';
|
|
2
|
+
export declare const PI_FORM_CARD = "pi/form";
|
|
3
|
+
export declare const Form: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<PiFormProps, S, PiFormEvents>) => import('@pihanga2/core').PiCardDef;
|
|
4
|
+
export declare const PI_FORM_ACTION: {
|
|
5
|
+
SUBMITTED: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const onPiFormSubmitted: <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
|
+
} & PiFormSubmittedEvent>) => void;
|
|
10
|
+
export type PiFormProps = {
|
|
11
|
+
/**
|
|
12
|
+
* Optional id passed through to events for identification.
|
|
13
|
+
*/
|
|
14
|
+
id?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Ordered list of field card refs to render inside the form.
|
|
17
|
+
* Each card (e.g. TextField, Checkbox, FormSelect) will be rendered
|
|
18
|
+
* in order and wrapped by a FormContext.Provider so they can read
|
|
19
|
+
* and write shared form state.
|
|
20
|
+
*/
|
|
21
|
+
content?: PiCardRef[];
|
|
22
|
+
/**
|
|
23
|
+
* Initial values for the form fields, keyed by field name.
|
|
24
|
+
*/
|
|
25
|
+
initialValues?: Record<string, unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Label for the submit button.
|
|
28
|
+
* @default "Submit"
|
|
29
|
+
*/
|
|
30
|
+
submitLabel?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Additional CSS classes for the <form> element.
|
|
33
|
+
*/
|
|
34
|
+
className?: string;
|
|
35
|
+
};
|
|
36
|
+
export type PiFormSubmittedEvent = {
|
|
37
|
+
id?: string;
|
|
38
|
+
/** Snapshot of form state at the time of submission. */
|
|
39
|
+
formData: Record<string, unknown>;
|
|
40
|
+
};
|
|
41
|
+
export type PiFormEvents = {
|
|
42
|
+
onSubmitted: PiFormSubmittedEvent;
|
|
43
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createCardDeclaration as e, createOnAction as t, registerActions as n } from "@pihanga2/core";
|
|
2
|
+
//#region src/cards/form/form.types.ts
|
|
3
|
+
var r = "pi/form", i = e(r), a = n(r, ["submitted"]), o = t(a.SUBMITTED);
|
|
4
|
+
//#endregion
|
|
5
|
+
export { i as Form, a as PI_FORM_ACTION, r as PI_FORM_CARD, o as onPiFormSubmitted };
|
|
6
|
+
|
|
7
|
+
//# sourceMappingURL=form.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form.types.js","names":[],"sources":["../../../src/cards/form/form.types.ts"],"sourcesContent":["import {\n createCardDeclaration,\n createOnAction,\n type PiCardRef,\n registerActions,\n} from \"@pihanga2/core\";\n\nexport const PI_FORM_CARD = \"pi/form\";\n\nexport const Form = createCardDeclaration<PiFormProps, PiFormEvents>(\n PI_FORM_CARD,\n);\n\nexport const PI_FORM_ACTION = registerActions(PI_FORM_CARD, [\"submitted\"]);\n\nexport const onPiFormSubmitted = createOnAction<PiFormSubmittedEvent>(\n PI_FORM_ACTION.SUBMITTED,\n);\n\nexport type PiFormProps = {\n /**\n * Optional id passed through to events for identification.\n */\n id?: string;\n\n /**\n * Ordered list of field card refs to render inside the form.\n * Each card (e.g. TextField, Checkbox, FormSelect) will be rendered\n * in order and wrapped by a FormContext.Provider so they can read\n * and write shared form state.\n */\n content?: PiCardRef[];\n\n /**\n * Initial values for the form fields, keyed by field name.\n */\n initialValues?: Record<string, unknown>;\n\n /**\n * Label for the submit button.\n * @default \"Submit\"\n */\n submitLabel?: string;\n\n /**\n * Additional CSS classes for the <form> element.\n */\n className?: string;\n};\n\nexport type PiFormSubmittedEvent = {\n id?: string;\n /** Snapshot of form state at the time of submission. */\n formData: Record<string, unknown>;\n};\n\nexport type PiFormEvents = {\n onSubmitted: PiFormSubmittedEvent;\n};\n"],"mappings":";;AAOA,IAAa,IAAe,WAEf,IAAO,EAClB,CACF,GAEa,IAAiB,EAAgB,GAAc,CAAC,WAAW,CAAC,GAE5D,IAAoB,EAC/B,EAAe,SACjB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FormContext as e, useFormContext as t } from "./form.context.js";
|
|
2
|
+
import { FormComponent as n } from "./form.component.js";
|
|
3
|
+
import { Form as r, PI_FORM_ACTION as i, PI_FORM_CARD as a, onPiFormSubmitted as o } from "./form.types.js";
|
|
4
|
+
import { actionTypesToEvents as s, registerCardComponent as c } from "@pihanga2/core";
|
|
5
|
+
//#region src/cards/form/index.ts
|
|
6
|
+
c({
|
|
7
|
+
name: a,
|
|
8
|
+
component: n,
|
|
9
|
+
events: s(i)
|
|
10
|
+
});
|
|
11
|
+
//#endregion
|
|
12
|
+
export { r as Form, e as FormContext, i as PI_FORM_ACTION, a as PI_FORM_CARD, o as onPiFormSubmitted, t as useFormContext };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/form/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {FormComponent} from \"./form.component\";\nimport {PI_FORM_ACTION, PI_FORM_CARD} from \"./form.types\";\n\nexport * from \"./form.types\";\nexport * from \"./form.context\";\n\nregisterCardComponent({\n name: PI_FORM_CARD,\n component: FormComponent,\n events: actionTypesToEvents(PI_FORM_ACTION),\n});\n"],"mappings":";;;;;AAQA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAc;AAC5C,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TooltipProvider as e } from "../../components/ui/tooltip.js";
|
|
2
|
+
import { ThemeProvider as t } from "../../components/theme-provider/theme-provider.component.js";
|
|
3
|
+
import { Card as n } from "@pihanga2/core";
|
|
4
|
+
import { StrictMode as r } from "react";
|
|
5
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
6
|
+
//#region src/cards/framework/framework.component.tsx
|
|
7
|
+
var a = (a) => {
|
|
8
|
+
let { page: o, theme: s = "dark", cardName: c } = a;
|
|
9
|
+
return /* @__PURE__ */ i(r, { children: /* @__PURE__ */ i(t, {
|
|
10
|
+
defaultTheme: s,
|
|
11
|
+
storageKey: "shadcn-ui-theme",
|
|
12
|
+
children: /* @__PURE__ */ i(e, { children: /* @__PURE__ */ i(n, {
|
|
13
|
+
cardName: o,
|
|
14
|
+
parentCard: c
|
|
15
|
+
}) })
|
|
16
|
+
}) });
|
|
17
|
+
};
|
|
18
|
+
//#endregion
|
|
19
|
+
export { a as Component };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=framework.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework.component.js","names":[],"sources":["../../../src/cards/framework/framework.component.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {StrictMode} from \"react\";\nimport {ThemeProvider} from \"@/components/theme-provider/theme-provider.component\";\n\nimport {Card, type PiCardProps, type WindowProps} from \"@pihanga2/core\";\nimport {TooltipProvider} from \"@/components/ui/tooltip\";\n\nexport const Component = (props: PiCardProps<WindowProps>): React.ReactNode => {\n const {page, theme = \"dark\", cardName} = props;\n\n return (\n <StrictMode>\n <ThemeProvider defaultTheme={theme} storageKey=\"shadcn-ui-theme\">\n <TooltipProvider>\n <Card cardName={page} parentCard={cardName} />\n </TooltipProvider>\n </ThemeProvider>\n </StrictMode>\n );\n};\n"],"mappings":";;;;;;AAOA,IAAa,KAAa,MAAqD;CAC7E,IAAM,EAAC,SAAM,WAAQ,QAAQ,gBAAY;CAEzC,OACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;EAAe,cAAc;EAAO,YAAW;YAC7C,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GAAM,UAAU;GAAM,YAAY;EAAW,CAAA,EAC9B,CAAA;CACJ,CAAA,EACL,CAAA;AAEhB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Component as e } from "./framework.component.js";
|
|
2
|
+
import { createCardDeclaration as t, registerCardComponent as n } from "@pihanga2/core";
|
|
3
|
+
//#region src/cards/framework/index.ts
|
|
4
|
+
var r = "shad/framework", i = t(r);
|
|
5
|
+
n({
|
|
6
|
+
name: r,
|
|
7
|
+
component: e
|
|
8
|
+
});
|
|
9
|
+
//#endregion
|
|
10
|
+
export { i as SdFramework };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/framework/index.ts"],"sourcesContent":["import {\n type WindowProps,\n createCardDeclaration,\n registerCardComponent,\n} from \"@pihanga2/core\";\n\nimport {Component} from \"./framework.component\";\n\nconst CARD_TYPE = \"shad/framework\";\nexport const SdFramework = createCardDeclaration<WindowProps>(CARD_TYPE);\n\nregisterCardComponent({\n name: CARD_TYPE,\n component: Component,\n});\n"],"mappings":";;;AAQA,IAAM,IAAY,kBACL,IAAc,EAAmC,CAAS;AAEvE,EAAsB;CACpB,MAAM;CACN,WAAW;AACb,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PiCardDef } from '@pihanga2/core';
|
|
2
|
+
import { GraphData, GraphOptions } from '@antv/g6';
|
|
3
|
+
export declare const GRAPHIN_CARD = "graphin";
|
|
4
|
+
export declare const Graphin: <S extends import('@pihanga2/core').ReduxState>(p: import('@pihanga2/core').PiMapProps<GraphinProps, S, {}>) => PiCardDef;
|
|
5
|
+
export type GraphinProps = {
|
|
6
|
+
data: GraphData;
|
|
7
|
+
options?: Partial<Omit<GraphOptions, "data">>;
|
|
8
|
+
tooltip?: GraphinTooltip;
|
|
9
|
+
style?: {
|
|
10
|
+
root?: React.CSSProperties;
|
|
11
|
+
item?: React.CSSProperties;
|
|
12
|
+
};
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
export type GraphinTooltip = {
|
|
16
|
+
node?: PiCardDef;
|
|
17
|
+
edge?: PiCardDef;
|
|
18
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GraphinTooltip } from './graphin.types';
|
|
2
|
+
export type TooltipContext<T = Record<string, unknown>> = {
|
|
3
|
+
isEdge?: boolean;
|
|
4
|
+
elementID?: string;
|
|
5
|
+
elementData?: T;
|
|
6
|
+
};
|
|
7
|
+
export declare function TooltipComponent(props: {
|
|
8
|
+
contentCards: GraphinTooltip;
|
|
9
|
+
parentCard: string;
|
|
10
|
+
}): React.ReactNode;
|
package/cards/icons.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
type G = {
|
|
3
|
+
name2icon: {
|
|
4
|
+
[name: string]: React.ElementType;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
_PihangaIcons: G;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare function registerIcon(name: string, el: React.ElementType): string;
|
|
13
|
+
export declare function getIconElement(name: string): React.ElementType | undefined;
|
|
14
|
+
export declare function getIcon(name: string, props?: any): React.ReactNode;
|
|
15
|
+
export {};
|
package/cards/icons.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import e from "react";
|
|
2
|
+
//#region src/cards/icons.ts
|
|
3
|
+
window._PihangaIcons = window._PihangaIcons || { name2icon: {} };
|
|
4
|
+
var t = window._PihangaIcons.name2icon;
|
|
5
|
+
function n(e) {
|
|
6
|
+
return t[e];
|
|
7
|
+
}
|
|
8
|
+
function r(n, r) {
|
|
9
|
+
let i = t[n];
|
|
10
|
+
return i ? e.createElement(i, r) : null;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { r as getIcon, n as getIconElement };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.js","names":[],"sources":["../../src/cards/icons.ts"],"sourcesContent":["import React from \"react\";\n\ntype G = {\n name2icon: {[name: string]: React.ElementType};\n};\n\ndeclare global {\n interface Window {\n _PihangaIcons: G;\n }\n}\n\nwindow._PihangaIcons = window._PihangaIcons || {\n name2icon: {},\n};\n\nconst name2icon = window._PihangaIcons.name2icon;\n\n\n\nexport function registerIcon(name: string, el: React.ElementType): string {\n if (name2icon[name] !== undefined) {\n throw new Error(`icon '${name}' already registered`);\n }\n name2icon[name] = el;\n return name;\n}\n\nexport function getIconElement(name: string): React.ElementType | undefined {\n return name2icon[name];\n}\n\n// can't figure out what the proper return type is, SVvgIconT does\n// NOT work with <IconButton>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function getIcon(name: string, props?: any): React.ReactNode {\n const icon = name2icon[name];\n if (!icon) return null;\n const el = React.createElement(icon, props);\n return el;\n}\n"],"mappings":";;AAYA,OAAO,gBAAgB,OAAO,iBAAiB,EAC7C,WAAW,CAAC,EACd;AAEA,IAAM,IAAY,OAAO,cAAc;AAYvC,SAAgB,EAAe,GAA6C;CAC1E,OAAO,EAAU;AACnB;AAKA,SAAgB,EAAQ,GAAc,GAA8B;CAClE,IAAM,IAAO,EAAU;CAGvB,OAFK,IACM,EAAM,cAAc,GAAM,CAC9B,IAFW;AAGpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './input.types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InputComponent as e } from "./input.component.js";
|
|
2
|
+
import { PI_INPUT_ACTION as t, PI_INPUT_CARD as n, PiInput as r, onPiInputChanged as i, onPiInputCommitted as a } from "./input.types.js";
|
|
3
|
+
import { actionTypesToEvents as o, registerCardComponent as s } from "@pihanga2/core";
|
|
4
|
+
//#region src/cards/input/index.ts
|
|
5
|
+
s({
|
|
6
|
+
name: n,
|
|
7
|
+
component: e,
|
|
8
|
+
events: o(t)
|
|
9
|
+
});
|
|
10
|
+
//#endregion
|
|
11
|
+
export { t as PI_INPUT_ACTION, n as PI_INPUT_CARD, r as PiInput, i as onPiInputChanged, a as onPiInputCommitted };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/cards/input/index.ts"],"sourcesContent":["import {actionTypesToEvents, registerCardComponent} from \"@pihanga2/core\";\n\nimport {InputComponent} from \"./input.component\";\nimport {PI_INPUT_ACTION, PI_INPUT_CARD} from \"./input.types\";\n\nexport * from \"./input.types\";\n\nregisterCardComponent({\n name: PI_INPUT_CARD,\n component: InputComponent,\n events: actionTypesToEvents(PI_INPUT_ACTION),\n});\n"],"mappings":";;;;AAOA,EAAsB;CACpB,MAAM;CACN,WAAW;CACX,QAAQ,EAAoB,CAAe;AAC7C,CAAC"}
|