@timeax/form-palette 0.0.3 → 0.0.5

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.
Files changed (120) hide show
  1. package/{src/schema/adapter.ts → dist/adapters.d.mts} +118 -43
  2. package/dist/adapters.d.ts +292 -0
  3. package/dist/adapters.js +13283 -0
  4. package/dist/adapters.js.map +1 -0
  5. package/dist/adapters.mjs +13269 -0
  6. package/dist/adapters.mjs.map +1 -0
  7. package/dist/index.d.mts +3744 -0
  8. package/dist/index.d.ts +3744 -0
  9. package/dist/index.js +43014 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/index.mjs +42965 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/package.json +22 -7
  14. package/.scaffold-cache.json +0 -537
  15. package/src/.scaffold-cache.json +0 -544
  16. package/src/adapters/axios.ts +0 -117
  17. package/src/adapters/index.ts +0 -91
  18. package/src/adapters/inertia.ts +0 -187
  19. package/src/core/adapter-registry.ts +0 -87
  20. package/src/core/bound/bind-host.ts +0 -14
  21. package/src/core/bound/observe-bound-field.ts +0 -172
  22. package/src/core/bound/wait-for-bound-field.ts +0 -57
  23. package/src/core/context.ts +0 -23
  24. package/src/core/core-provider.tsx +0 -818
  25. package/src/core/core-root.tsx +0 -72
  26. package/src/core/core-shell.tsx +0 -44
  27. package/src/core/errors/error-strip.tsx +0 -71
  28. package/src/core/errors/index.ts +0 -2
  29. package/src/core/errors/map-error-bag.ts +0 -51
  30. package/src/core/errors/map-zod.ts +0 -39
  31. package/src/core/hooks/use-button.ts +0 -220
  32. package/src/core/hooks/use-core-context.ts +0 -20
  33. package/src/core/hooks/use-core-utility.ts +0 -0
  34. package/src/core/hooks/use-core.ts +0 -13
  35. package/src/core/hooks/use-field.ts +0 -497
  36. package/src/core/hooks/use-optional-field.ts +0 -28
  37. package/src/core/index.ts +0 -0
  38. package/src/core/registry/binder-registry.ts +0 -82
  39. package/src/core/registry/field-registry.ts +0 -187
  40. package/src/core/test.tsx +0 -17
  41. package/src/global.d.ts +0 -14
  42. package/src/index.ts +0 -68
  43. package/src/input/index.ts +0 -4
  44. package/src/input/input-field.tsx +0 -854
  45. package/src/input/input-layout-graph.ts +0 -230
  46. package/src/input/input-props.ts +0 -190
  47. package/src/lib/get-global-countries.ts +0 -87
  48. package/src/lib/utils.ts +0 -6
  49. package/src/presets/index.ts +0 -0
  50. package/src/presets/shadcn-preset.ts +0 -0
  51. package/src/presets/shadcn-variants/checkbox.tsx +0 -849
  52. package/src/presets/shadcn-variants/chips.tsx +0 -756
  53. package/src/presets/shadcn-variants/color.tsx +0 -284
  54. package/src/presets/shadcn-variants/custom.tsx +0 -227
  55. package/src/presets/shadcn-variants/date.tsx +0 -796
  56. package/src/presets/shadcn-variants/file.tsx +0 -764
  57. package/src/presets/shadcn-variants/keyvalue.tsx +0 -556
  58. package/src/presets/shadcn-variants/multiselect.tsx +0 -1132
  59. package/src/presets/shadcn-variants/number.tsx +0 -176
  60. package/src/presets/shadcn-variants/password.tsx +0 -737
  61. package/src/presets/shadcn-variants/phone.tsx +0 -628
  62. package/src/presets/shadcn-variants/radio.tsx +0 -578
  63. package/src/presets/shadcn-variants/select.tsx +0 -956
  64. package/src/presets/shadcn-variants/slider.tsx +0 -622
  65. package/src/presets/shadcn-variants/text.tsx +0 -343
  66. package/src/presets/shadcn-variants/textarea.tsx +0 -66
  67. package/src/presets/shadcn-variants/toggle.tsx +0 -218
  68. package/src/presets/shadcn-variants/treeselect.tsx +0 -784
  69. package/src/presets/ui/badge.tsx +0 -46
  70. package/src/presets/ui/button.tsx +0 -60
  71. package/src/presets/ui/calendar.tsx +0 -214
  72. package/src/presets/ui/checkbox.tsx +0 -115
  73. package/src/presets/ui/custom.tsx +0 -0
  74. package/src/presets/ui/dialog.tsx +0 -141
  75. package/src/presets/ui/field.tsx +0 -246
  76. package/src/presets/ui/input-mask.tsx +0 -739
  77. package/src/presets/ui/input-otp.tsx +0 -77
  78. package/src/presets/ui/input.tsx +0 -1011
  79. package/src/presets/ui/label.tsx +0 -22
  80. package/src/presets/ui/number.tsx +0 -1370
  81. package/src/presets/ui/popover.tsx +0 -46
  82. package/src/presets/ui/radio-group.tsx +0 -43
  83. package/src/presets/ui/scroll-area.tsx +0 -56
  84. package/src/presets/ui/select.tsx +0 -190
  85. package/src/presets/ui/separator.tsx +0 -28
  86. package/src/presets/ui/slider.tsx +0 -61
  87. package/src/presets/ui/switch.tsx +0 -32
  88. package/src/presets/ui/textarea.tsx +0 -634
  89. package/src/presets/ui/time-dropdowns.tsx +0 -350
  90. package/src/schema/core.ts +0 -429
  91. package/src/schema/field-map.ts +0 -0
  92. package/src/schema/field.ts +0 -224
  93. package/src/schema/index.ts +0 -0
  94. package/src/schema/input-field.ts +0 -260
  95. package/src/schema/presets.ts +0 -0
  96. package/src/schema/variant.ts +0 -216
  97. package/src/variants/core/checkbox.tsx +0 -54
  98. package/src/variants/core/chips.tsx +0 -22
  99. package/src/variants/core/color.tsx +0 -16
  100. package/src/variants/core/custom.tsx +0 -18
  101. package/src/variants/core/date.tsx +0 -25
  102. package/src/variants/core/file.tsx +0 -9
  103. package/src/variants/core/keyvalue.tsx +0 -12
  104. package/src/variants/core/multiselect.tsx +0 -28
  105. package/src/variants/core/number.tsx +0 -115
  106. package/src/variants/core/password.tsx +0 -35
  107. package/src/variants/core/phone.tsx +0 -16
  108. package/src/variants/core/radio.tsx +0 -38
  109. package/src/variants/core/select.tsx +0 -15
  110. package/src/variants/core/slider.tsx +0 -55
  111. package/src/variants/core/text.tsx +0 -114
  112. package/src/variants/core/textarea.tsx +0 -22
  113. package/src/variants/core/toggle.tsx +0 -50
  114. package/src/variants/core/treeselect.tsx +0 -11
  115. package/src/variants/helpers/selection-summary.tsx +0 -236
  116. package/src/variants/index.ts +0 -75
  117. package/src/variants/registry.ts +0 -38
  118. package/src/variants/select-shared.ts +0 -0
  119. package/src/variants/shared.ts +0 -126
  120. package/tsconfig.json +0 -14
@@ -1,176 +0,0 @@
1
- import React from "react";
2
- import { InputNumber, InputNumberProps, InputNumberValueChangeEvent } from "../ui/number";
3
- import { cn } from "@/lib/utils";
4
- import { ChevronUp, ChevronDown, Plus, Minus } from "lucide-react";
5
-
6
- // Wrapper-level props for the variant
7
- export type ShadcnNumberVariantProps =
8
- // All the usual number stuff (mode, locale, prefix, suffix, etc.)
9
- Omit<InputNumberProps,
10
- | "onValueChange"
11
- | "onChange"
12
- | "leadingControl"
13
- | "trailingControl"
14
- >
15
- & {
16
- /**
17
- * Show +/- buttons around the numeric field.
18
- * Defaults to false.
19
- */
20
- showButtons?: boolean;
21
-
22
- /**
23
- * How the step buttons are laid out when showButtons is true.
24
- *
25
- * - 'inline': "-" on the left, "+" on the right
26
- * - 'stacked': vertical +/- stack on the right
27
- */
28
- buttonLayout?: "inline" | "stacked";
29
- };
30
-
31
-
32
- export const ShadcnNumberVariant = React.forwardRef<
33
- HTMLInputElement,
34
- ShadcnNumberVariantProps
35
- >(function ShadcnNumberVariant(props, forwardedRef) {
36
- const {
37
- showButtons,
38
- buttonLayout = "stacked",
39
- disabled, // Extract disabled to style buttons
40
- ...rest
41
- } = props;
42
-
43
- // we still want access to these for stepping logic
44
- const {
45
- step = 1,
46
- min,
47
- value,
48
- max,
49
- onValue: onValueChange,
50
- name,
51
- id,
52
- inputId,
53
- } = rest as ShadcnNumberVariantProps;
54
-
55
- const handleChange = React.useCallback(
56
- (e: InputNumberValueChangeEvent) => {
57
- if (onValueChange) {
58
- onValueChange(e.value as any, {
59
- source: "user",
60
- nativeEvent: e.originalEvent as any,
61
- raw: e.value,
62
- });
63
- }
64
- },
65
- [onValueChange]
66
- );
67
-
68
- const handleStep = React.useCallback(
69
- (direction: 1 | -1, originalEvent: React.SyntheticEvent<any>) => {
70
- if (disabled) return;
71
-
72
- const current = value ?? 0;
73
- let next = current + direction * step;
74
-
75
- if (typeof min === "number") next = Math.max(next, min);
76
- if (typeof max === "number") next = Math.min(next, max);
77
-
78
- // Prime-style event
79
- const e: InputNumberValueChangeEvent = {
80
- originalEvent,
81
- value: next,
82
- stopPropagation: () => originalEvent.stopPropagation(),
83
- preventDefault: () => originalEvent.preventDefault(),
84
- target: {
85
- name,
86
- id: id ?? inputId ?? null,
87
- value: next,
88
- },
89
- };
90
-
91
- handleChange(e)
92
- },
93
- [value, step, min, max, onValueChange, name, id, inputId, disabled, handleChange]
94
- );
95
-
96
- // --- Styles ---
97
- // Common styles for the interactive buttons
98
- const btnBase = "flex h-full items-center justify-center bg-transparent text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground disabled:opacity-50 disabled:cursor-not-allowed";
99
-
100
- // Build controls based on layout
101
- let leadingControl: React.ReactNode | undefined;
102
- let trailingControl: React.ReactNode | undefined;
103
-
104
- if (showButtons) {
105
- if (buttonLayout === "inline") {
106
- // INLINE: "-" on the left, "+" on the right
107
- leadingControl = (
108
- <button
109
- type="button"
110
- tabIndex={-1} // Prevent tabbing to buttons
111
- disabled={disabled}
112
- onClick={(e) => handleStep(-1, e)}
113
- className={cn(btnBase, "border-r border-input px-3")}
114
- aria-label="Decrease value"
115
- >
116
- <Minus className="h-4 w-4" />
117
- </button>
118
- );
119
-
120
- trailingControl = (
121
- <button
122
- type="button"
123
- tabIndex={-1}
124
- disabled={disabled}
125
- onClick={(e) => handleStep(1, e)}
126
- className={cn(btnBase, "border-l border-input px-3")}
127
- aria-label="Increase value"
128
- >
129
- <Plus className="h-4 w-4" />
130
- </button>
131
- );
132
- } else {
133
- // STACKED: vertical +/- on the right
134
- trailingControl = (
135
- <div className="flex h-full flex-col border-l border-input">
136
- <button
137
- type="button"
138
- tabIndex={-1}
139
- disabled={disabled}
140
- onClick={(e) => handleStep(1, e)}
141
- className={cn(btnBase, "h-1/2 px-2 border-b border-input")}
142
- aria-label="Increase value"
143
- >
144
- <ChevronUp className="h-3 w-3" />
145
- </button>
146
- <button
147
- type="button"
148
- tabIndex={-1}
149
- disabled={disabled}
150
- onClick={(e) => handleStep(-1, e)}
151
- className={cn(btnBase, "h-1/2 px-2")}
152
- aria-label="Decrease value"
153
- >
154
- <ChevronDown className="h-3 w-3" />
155
- </button>
156
- </div>
157
- );
158
- }
159
- }
160
-
161
- return (
162
- <InputNumber
163
- ref={forwardedRef}
164
- value={value}
165
- disabled={disabled}
166
- {...rest}
167
- onValueChange={handleChange}
168
- leadingControl={leadingControl}
169
- trailingControl={trailingControl}
170
- extendBoxToControls
171
- // Ensure the controls sit flush inside the container
172
- leadingControlClassName={cn("flex h-full", rest.leadingControlClassName)}
173
- trailingControlClassName={cn("flex h-full", rest.trailingControlClassName)}
174
- />
175
- );
176
- });