@timeax/form-palette 0.0.5 → 0.0.7
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/dist/index.d.mts +85 -1
- package/dist/index.d.ts +85 -1
- package/dist/index.js +46 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -979,6 +979,90 @@ interface LayoutResolveContext<T = unknown> {
|
|
|
979
979
|
*/
|
|
980
980
|
type LayoutResolver<T = unknown> = (ctx: LayoutResolveContext<T>) => FieldLayoutConfig;
|
|
981
981
|
|
|
982
|
+
type MaskMode$1 = "raw" | "masked";
|
|
983
|
+
/**
|
|
984
|
+
* Mask-related props for the Shadcn text variant.
|
|
985
|
+
*
|
|
986
|
+
* These are forwarded to the underlying <Input>, which in turn wires
|
|
987
|
+
* them into the InputMask implementation.
|
|
988
|
+
*/
|
|
989
|
+
interface ShadcnTextMaskProps {
|
|
990
|
+
/**
|
|
991
|
+
* Mask pattern – Primereact style.
|
|
992
|
+
* Example: "99/99/9999", "(999) 999-9999"
|
|
993
|
+
*/
|
|
994
|
+
mask?: string;
|
|
995
|
+
/**
|
|
996
|
+
* Per-symbol definitions for slots.
|
|
997
|
+
* Kept for future custom engine; not used by the current
|
|
998
|
+
* react-input-mask implementation.
|
|
999
|
+
*/
|
|
1000
|
+
maskDefinitions?: Record<string, RegExp>;
|
|
1001
|
+
/**
|
|
1002
|
+
* Character used to visually represent an empty slot.
|
|
1003
|
+
* Default: "_".
|
|
1004
|
+
*/
|
|
1005
|
+
slotChar?: string;
|
|
1006
|
+
/**
|
|
1007
|
+
* If true, when the value is effectively "empty" (no unmasked chars),
|
|
1008
|
+
* we emit an empty string "" instead of a fully-masked placeholder.
|
|
1009
|
+
*
|
|
1010
|
+
* NOTE: This behaviour is implemented in the variant, not Input,
|
|
1011
|
+
* so we preserve your existing semantics.
|
|
1012
|
+
*/
|
|
1013
|
+
autoClear?: boolean;
|
|
1014
|
+
/**
|
|
1015
|
+
* Whether the *model* value is raw or masked.
|
|
1016
|
+
*
|
|
1017
|
+
* - "raw" or true → onValue receives unmasked value
|
|
1018
|
+
* - "masked" or false/undefined → onValue receives full masked string
|
|
1019
|
+
*
|
|
1020
|
+
* NOTE: detail.raw is **always** the masked string.
|
|
1021
|
+
*/
|
|
1022
|
+
unmask?: MaskMode$1 | boolean;
|
|
1023
|
+
/**
|
|
1024
|
+
* Placeholder for future caret-mode logic when we go back
|
|
1025
|
+
* to a custom engine. Currently unused, kept for API compatibility.
|
|
1026
|
+
*/
|
|
1027
|
+
maskInsertMode?: "stream" | "caret";
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Extra UI props for the Shadcn text input (pure HTML-level).
|
|
1031
|
+
*
|
|
1032
|
+
* These are forwarded straight to the underlying <Input />.
|
|
1033
|
+
*/
|
|
1034
|
+
type ShadcnTextUiProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "size"> & {
|
|
1035
|
+
/**
|
|
1036
|
+
* Extra classes applied only to the *inner* input element
|
|
1037
|
+
* (the actual <input>, not the wrapper box).
|
|
1038
|
+
*/
|
|
1039
|
+
inputClassName?: string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Fixed prefix rendered as part of the input value, NOT as an icon.
|
|
1042
|
+
* E.g. "₦", "ID: ".
|
|
1043
|
+
*
|
|
1044
|
+
* The underlying <Input> will:
|
|
1045
|
+
* - take the model value (without prefix),
|
|
1046
|
+
* - render prefix + value,
|
|
1047
|
+
* - expose the full visible string in event.target.value.
|
|
1048
|
+
*/
|
|
1049
|
+
prefix?: string;
|
|
1050
|
+
/**
|
|
1051
|
+
* Fixed suffix rendered as part of the input value, NOT as an icon.
|
|
1052
|
+
* E.g. "%", "kg".
|
|
1053
|
+
*/
|
|
1054
|
+
suffix?: string;
|
|
1055
|
+
/**
|
|
1056
|
+
* If true (default), we strip the prefix from the value
|
|
1057
|
+
* before emitting it via `onValue`.
|
|
1058
|
+
*/
|
|
1059
|
+
stripPrefix?: boolean;
|
|
1060
|
+
/**
|
|
1061
|
+
* If true (default), we strip the suffix from the value
|
|
1062
|
+
* before emitting it via `onValue`.
|
|
1063
|
+
*/
|
|
1064
|
+
stripSuffix?: boolean;
|
|
1065
|
+
} & ShadcnTextMaskProps;
|
|
982
1066
|
/**
|
|
983
1067
|
* Props for the Shadcn-based text variant.
|
|
984
1068
|
*
|
|
@@ -1000,7 +1084,7 @@ type ShadcnTextVariantProps = ExtraFieldProps<VariantBaseProps<string | undefine
|
|
|
1000
1084
|
* (true) or controls are visually separate (false).
|
|
1001
1085
|
*/
|
|
1002
1086
|
extendBoxToControls?: boolean;
|
|
1003
|
-
};
|
|
1087
|
+
} & ShadcnTextUiProps;
|
|
1004
1088
|
|
|
1005
1089
|
type InputRef = HTMLInputElement;
|
|
1006
1090
|
interface InputNumberValueChangeEvent {
|
package/dist/index.d.ts
CHANGED
|
@@ -979,6 +979,90 @@ interface LayoutResolveContext<T = unknown> {
|
|
|
979
979
|
*/
|
|
980
980
|
type LayoutResolver<T = unknown> = (ctx: LayoutResolveContext<T>) => FieldLayoutConfig;
|
|
981
981
|
|
|
982
|
+
type MaskMode$1 = "raw" | "masked";
|
|
983
|
+
/**
|
|
984
|
+
* Mask-related props for the Shadcn text variant.
|
|
985
|
+
*
|
|
986
|
+
* These are forwarded to the underlying <Input>, which in turn wires
|
|
987
|
+
* them into the InputMask implementation.
|
|
988
|
+
*/
|
|
989
|
+
interface ShadcnTextMaskProps {
|
|
990
|
+
/**
|
|
991
|
+
* Mask pattern – Primereact style.
|
|
992
|
+
* Example: "99/99/9999", "(999) 999-9999"
|
|
993
|
+
*/
|
|
994
|
+
mask?: string;
|
|
995
|
+
/**
|
|
996
|
+
* Per-symbol definitions for slots.
|
|
997
|
+
* Kept for future custom engine; not used by the current
|
|
998
|
+
* react-input-mask implementation.
|
|
999
|
+
*/
|
|
1000
|
+
maskDefinitions?: Record<string, RegExp>;
|
|
1001
|
+
/**
|
|
1002
|
+
* Character used to visually represent an empty slot.
|
|
1003
|
+
* Default: "_".
|
|
1004
|
+
*/
|
|
1005
|
+
slotChar?: string;
|
|
1006
|
+
/**
|
|
1007
|
+
* If true, when the value is effectively "empty" (no unmasked chars),
|
|
1008
|
+
* we emit an empty string "" instead of a fully-masked placeholder.
|
|
1009
|
+
*
|
|
1010
|
+
* NOTE: This behaviour is implemented in the variant, not Input,
|
|
1011
|
+
* so we preserve your existing semantics.
|
|
1012
|
+
*/
|
|
1013
|
+
autoClear?: boolean;
|
|
1014
|
+
/**
|
|
1015
|
+
* Whether the *model* value is raw or masked.
|
|
1016
|
+
*
|
|
1017
|
+
* - "raw" or true → onValue receives unmasked value
|
|
1018
|
+
* - "masked" or false/undefined → onValue receives full masked string
|
|
1019
|
+
*
|
|
1020
|
+
* NOTE: detail.raw is **always** the masked string.
|
|
1021
|
+
*/
|
|
1022
|
+
unmask?: MaskMode$1 | boolean;
|
|
1023
|
+
/**
|
|
1024
|
+
* Placeholder for future caret-mode logic when we go back
|
|
1025
|
+
* to a custom engine. Currently unused, kept for API compatibility.
|
|
1026
|
+
*/
|
|
1027
|
+
maskInsertMode?: "stream" | "caret";
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Extra UI props for the Shadcn text input (pure HTML-level).
|
|
1031
|
+
*
|
|
1032
|
+
* These are forwarded straight to the underlying <Input />.
|
|
1033
|
+
*/
|
|
1034
|
+
type ShadcnTextUiProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "value" | "defaultValue" | "onChange" | "size"> & {
|
|
1035
|
+
/**
|
|
1036
|
+
* Extra classes applied only to the *inner* input element
|
|
1037
|
+
* (the actual <input>, not the wrapper box).
|
|
1038
|
+
*/
|
|
1039
|
+
inputClassName?: string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Fixed prefix rendered as part of the input value, NOT as an icon.
|
|
1042
|
+
* E.g. "₦", "ID: ".
|
|
1043
|
+
*
|
|
1044
|
+
* The underlying <Input> will:
|
|
1045
|
+
* - take the model value (without prefix),
|
|
1046
|
+
* - render prefix + value,
|
|
1047
|
+
* - expose the full visible string in event.target.value.
|
|
1048
|
+
*/
|
|
1049
|
+
prefix?: string;
|
|
1050
|
+
/**
|
|
1051
|
+
* Fixed suffix rendered as part of the input value, NOT as an icon.
|
|
1052
|
+
* E.g. "%", "kg".
|
|
1053
|
+
*/
|
|
1054
|
+
suffix?: string;
|
|
1055
|
+
/**
|
|
1056
|
+
* If true (default), we strip the prefix from the value
|
|
1057
|
+
* before emitting it via `onValue`.
|
|
1058
|
+
*/
|
|
1059
|
+
stripPrefix?: boolean;
|
|
1060
|
+
/**
|
|
1061
|
+
* If true (default), we strip the suffix from the value
|
|
1062
|
+
* before emitting it via `onValue`.
|
|
1063
|
+
*/
|
|
1064
|
+
stripSuffix?: boolean;
|
|
1065
|
+
} & ShadcnTextMaskProps;
|
|
982
1066
|
/**
|
|
983
1067
|
* Props for the Shadcn-based text variant.
|
|
984
1068
|
*
|
|
@@ -1000,7 +1084,7 @@ type ShadcnTextVariantProps = ExtraFieldProps<VariantBaseProps<string | undefine
|
|
|
1000
1084
|
* (true) or controls are visually separate (false).
|
|
1001
1085
|
*/
|
|
1002
1086
|
extendBoxToControls?: boolean;
|
|
1003
|
-
};
|
|
1087
|
+
} & ShadcnTextUiProps;
|
|
1004
1088
|
|
|
1005
1089
|
type InputRef = HTMLInputElement;
|
|
1006
1090
|
interface InputNumberValueChangeEvent {
|
package/dist/index.js
CHANGED
|
@@ -41905,7 +41905,7 @@ function FieldGroup({ className, ...props }) {
|
|
|
41905
41905
|
{
|
|
41906
41906
|
"data-slot": "field-group",
|
|
41907
41907
|
className: cn(
|
|
41908
|
-
"group/field-group
|
|
41908
|
+
"group/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",
|
|
41909
41909
|
className
|
|
41910
41910
|
),
|
|
41911
41911
|
...props
|
|
@@ -42456,6 +42456,22 @@ function InputField(props) {
|
|
|
42456
42456
|
}),
|
|
42457
42457
|
[layout, sublabel, description, helpText, visualError, tagsContent]
|
|
42458
42458
|
);
|
|
42459
|
+
const hasLabelSlotsAt = (placement) => {
|
|
42460
|
+
let found = false;
|
|
42461
|
+
graph.getSlotsFor("label", placement).render((slots) => {
|
|
42462
|
+
if (slots.length > 0) {
|
|
42463
|
+
found = true;
|
|
42464
|
+
}
|
|
42465
|
+
return null;
|
|
42466
|
+
});
|
|
42467
|
+
return found;
|
|
42468
|
+
};
|
|
42469
|
+
const hasLabelLeftSlots = hasLabelSlotsAt("left");
|
|
42470
|
+
const hasLabelRightSlots = hasLabelSlotsAt("right");
|
|
42471
|
+
const hasLabelAboveSlots = hasLabelSlotsAt("above");
|
|
42472
|
+
const hasLabelBelowSlots = hasLabelSlotsAt("below");
|
|
42473
|
+
const hasAnyLabelBlockContent = !!label || hasLabelLeftSlots || hasLabelRightSlots || hasLabelAboveSlots || hasLabelBelowSlots;
|
|
42474
|
+
const hasLabelRowContent = !!label || hasLabelLeftSlots || hasLabelRightSlots;
|
|
42459
42475
|
const inlineLabelSide = lp === "right" ? "right" : lp === "hidden" ? "hidden" : "left";
|
|
42460
42476
|
const inlineInputColClass = [
|
|
42461
42477
|
isCompactInline ? "flex-none" : "flex-1 min-w-0",
|
|
@@ -42503,7 +42519,7 @@ function InputField(props) {
|
|
|
42503
42519
|
)
|
|
42504
42520
|
)
|
|
42505
42521
|
] });
|
|
42506
|
-
const inlineLabelColumn = inlineLabelSide === "hidden" ? null : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
42522
|
+
const inlineLabelColumn = inlineLabelSide === "hidden" || !hasAnyLabelBlockContent ? null : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
42507
42523
|
"div",
|
|
42508
42524
|
{
|
|
42509
42525
|
className: ["flex flex-col gap-0", inlineLabelColClass].filter(Boolean).join(" "),
|
|
@@ -42513,7 +42529,7 @@ function InputField(props) {
|
|
|
42513
42529
|
(slot) => renderHelperSlot("label", slot, classes)
|
|
42514
42530
|
)
|
|
42515
42531
|
),
|
|
42516
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
42532
|
+
hasLabelRowContent && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
42517
42533
|
"div",
|
|
42518
42534
|
{
|
|
42519
42535
|
className: [
|
|
@@ -42540,7 +42556,16 @@ function InputField(props) {
|
|
|
42540
42556
|
children: /* @__PURE__ */ jsxRuntime.jsxs(FieldTitle, { children: [
|
|
42541
42557
|
label,
|
|
42542
42558
|
" ",
|
|
42543
|
-
required ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
42559
|
+
required ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
42560
|
+
"span",
|
|
42561
|
+
{
|
|
42562
|
+
className: cn(
|
|
42563
|
+
"text-destructive",
|
|
42564
|
+
classes == null ? void 0 : classes.required
|
|
42565
|
+
),
|
|
42566
|
+
children: "*"
|
|
42567
|
+
}
|
|
42568
|
+
) : ""
|
|
42544
42569
|
] })
|
|
42545
42570
|
}
|
|
42546
42571
|
),
|
|
@@ -42566,7 +42591,11 @@ function InputField(props) {
|
|
|
42566
42591
|
"flex items-start gap-2",
|
|
42567
42592
|
classes == null ? void 0 : classes.inlineRow
|
|
42568
42593
|
].filter(Boolean).join(" ");
|
|
42569
|
-
const
|
|
42594
|
+
const hasStackedLabelBlock = lp !== "hidden" && hasAnyLabelBlockContent;
|
|
42595
|
+
const stackedGroupClassName = [
|
|
42596
|
+
hasStackedLabelBlock && hasLabelRowContent ? "mt-1" : null,
|
|
42597
|
+
classes == null ? void 0 : classes.group
|
|
42598
|
+
].filter(Boolean).join(" ");
|
|
42570
42599
|
const Element2 = contain ? "div" : React54__namespace.Fragment;
|
|
42571
42600
|
const attrs = (a = "l") => contain ? a === "l" ? { className: "p-4 border-b border-input" } : { className: "px-4 pt-2 pb-4" } : {};
|
|
42572
42601
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -42602,7 +42631,7 @@ function InputField(props) {
|
|
|
42602
42631
|
) : (
|
|
42603
42632
|
// STACKED MODE
|
|
42604
42633
|
/* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
42605
|
-
|
|
42634
|
+
hasStackedLabelBlock && /* @__PURE__ */ jsxRuntime.jsxs(Element2, { ...attrs(), children: [
|
|
42606
42635
|
graph.getSlotsFor("label", "above").render(
|
|
42607
42636
|
(slots) => slots.map(
|
|
42608
42637
|
(slot) => renderHelperSlot(
|
|
@@ -42612,7 +42641,7 @@ function InputField(props) {
|
|
|
42612
42641
|
)
|
|
42613
42642
|
)
|
|
42614
42643
|
),
|
|
42615
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
42644
|
+
hasLabelRowContent && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
42616
42645
|
"div",
|
|
42617
42646
|
{
|
|
42618
42647
|
className: [
|
|
@@ -42639,7 +42668,16 @@ function InputField(props) {
|
|
|
42639
42668
|
children: /* @__PURE__ */ jsxRuntime.jsxs(FieldTitle, { children: [
|
|
42640
42669
|
label,
|
|
42641
42670
|
" ",
|
|
42642
|
-
required ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
42671
|
+
required ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
42672
|
+
"span",
|
|
42673
|
+
{
|
|
42674
|
+
className: cn(
|
|
42675
|
+
"text-destructive",
|
|
42676
|
+
classes == null ? void 0 : classes.required
|
|
42677
|
+
),
|
|
42678
|
+
children: "*"
|
|
42679
|
+
}
|
|
42680
|
+
) : ""
|
|
42643
42681
|
] })
|
|
42644
42682
|
}
|
|
42645
42683
|
),
|