@drawbridge/components 0.0.51 → 0.0.52

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.
@@ -824,15 +824,7 @@ var Product = ({
824
824
  classNameScroll: "max-h-[4.5em]",
825
825
  color: resolved.background.color.rgb
826
826
  },
827
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
828
- "p",
829
- {
830
- ...{
831
- className: "text-sm"
832
- },
833
- children: product.description
834
- }
835
- )
827
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: product.description })
836
828
  }
837
829
  )
838
830
  ]
@@ -871,7 +863,7 @@ var Product = ({
871
863
  "div",
872
864
  {
873
865
  ...{
874
- className: addToCart ? "grid grid-cols-2 gap-4" : ""
866
+ className: addToCart ? "grid grid-cols-2 gap-5" : ""
875
867
  },
876
868
  children: [
877
869
  addToCart && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  product_default
4
- } from "./chunk-NFF5ANXM.mjs";
4
+ } from "./chunk-L5X6LHYZ.mjs";
5
5
  import "./chunk-2ZYGRSSA.mjs";
6
6
  import "./chunk-XWELEL6Z.mjs";
7
7
  import "./chunk-3SAKIKZP.mjs";
@@ -273,15 +273,7 @@ var Product = ({
273
273
  classNameScroll: "max-h-[4.5em]",
274
274
  color: resolved.background.color.rgb
275
275
  },
276
- children: /* @__PURE__ */ jsx(
277
- "p",
278
- {
279
- ...{
280
- className: "text-sm"
281
- },
282
- children: product.description
283
- }
284
- )
276
+ children: /* @__PURE__ */ jsx("p", { children: product.description })
285
277
  }
286
278
  )
287
279
  ]
@@ -320,7 +312,7 @@ var Product = ({
320
312
  "div",
321
313
  {
322
314
  ...{
323
- className: addToCart ? "grid grid-cols-2 gap-4" : ""
315
+ className: addToCart ? "grid grid-cols-2 gap-5" : ""
324
316
  },
325
317
  children: [
326
318
  addToCart && /* @__PURE__ */ jsx(
@@ -107,10 +107,38 @@ var InputNumber = ({
107
107
  min,
108
108
  onChange,
109
109
  small,
110
+ step = 1,
110
111
  style,
111
112
  value,
112
113
  ...rest
113
114
  }) => {
115
+ const decimal = !Number.isInteger(step);
116
+ const [draft, setDraft] = (0, import_react.useState)(
117
+ value === "" || value === null || value === void 0 ? "" : String(value)
118
+ );
119
+ (0, import_react.useEffect)(
120
+ () => {
121
+ const next = value === "" || value === null || value === void 0 ? "" : value;
122
+ if (Number(draft || 0) !== Number(next || 0)) {
123
+ setDraft(next === "" ? "" : String(next));
124
+ }
125
+ ;
126
+ },
127
+ // Intentionally excludes `draft`: this effect only reacts to external
128
+ // value changes, not to our own in-flight edits.
129
+ [value]
130
+ // eslint-disable-line react-hooks/exhaustive-deps
131
+ );
132
+ const handleChange = (0, import_react.useCallback)(
133
+ ({ target }) => {
134
+ const pattern = decimal ? /^-?\d*\.?\d*$/ : /^-?\d*$/;
135
+ if (!pattern.test(target.value)) return;
136
+ setDraft(target.value);
137
+ const numeric = target.value === "" ? 0 : Number(target.value);
138
+ if (!Number.isNaN(numeric)) onChange(numeric);
139
+ },
140
+ [decimal, onChange]
141
+ );
114
142
  const classes = [(inline ? "inline-flex items-center rounded-sm" : "input p-0 flex items-center") + " overflow-hidden"];
115
143
  if (className) {
116
144
  classes.push(className);
@@ -203,9 +231,11 @@ var InputNumber = ({
203
231
  // an inline flex grow rather than a version-specific grow utility, so
204
232
  // this works in BOTH consumers (app-web is Tailwind v3, share is v4).
205
233
  className: "text-inherit bg-transparent focus:outline-none focus:ring-0 " + (small ? "py-1 px-2" : "py-2 px-3") + (inline ? small ? " w-10" : " w-12" : "") + (layout === "split" ? " text-center" : ""),
206
- inputMode: "numeric",
207
- onChange: ({ target }) => onChange(Number(target.value)),
208
- step: 1,
234
+ // `type="text"` (not "number") so in-progress decimal strings survive
235
+ // each render; inputMode still surfaces the numeric/decimal keypad on
236
+ // mobile and handleChange enforces the numeric character set.
237
+ inputMode: decimal ? "decimal" : "numeric",
238
+ onChange: handleChange,
209
239
  // The bordered container is the single visible border; strip the
210
240
  // native number-input border so it doesn't double up.
211
241
  style: {
@@ -215,8 +245,8 @@ var InputNumber = ({
215
245
  minWidth: 0
216
246
  }
217
247
  },
218
- type: "number",
219
- value
248
+ type: "text",
249
+ value: draft
220
250
  }
221
251
  }
222
252
  );
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-FJ7PKMAC.mjs";
10
10
 
11
11
  // components/input-number.js
12
- import { useCallback } from "react";
12
+ import { useCallback, useEffect, useState } from "react";
13
13
  import { jsx, jsxs } from "react/jsx-runtime";
14
14
  var InputNumber = ({
15
15
  className,
@@ -19,10 +19,38 @@ var InputNumber = ({
19
19
  min,
20
20
  onChange,
21
21
  small,
22
+ step = 1,
22
23
  style,
23
24
  value,
24
25
  ...rest
25
26
  }) => {
27
+ const decimal = !Number.isInteger(step);
28
+ const [draft, setDraft] = useState(
29
+ value === "" || value === null || value === void 0 ? "" : String(value)
30
+ );
31
+ useEffect(
32
+ () => {
33
+ const next = value === "" || value === null || value === void 0 ? "" : value;
34
+ if (Number(draft || 0) !== Number(next || 0)) {
35
+ setDraft(next === "" ? "" : String(next));
36
+ }
37
+ ;
38
+ },
39
+ // Intentionally excludes `draft`: this effect only reacts to external
40
+ // value changes, not to our own in-flight edits.
41
+ [value]
42
+ // eslint-disable-line react-hooks/exhaustive-deps
43
+ );
44
+ const handleChange = useCallback(
45
+ ({ target }) => {
46
+ const pattern = decimal ? /^-?\d*\.?\d*$/ : /^-?\d*$/;
47
+ if (!pattern.test(target.value)) return;
48
+ setDraft(target.value);
49
+ const numeric = target.value === "" ? 0 : Number(target.value);
50
+ if (!Number.isNaN(numeric)) onChange(numeric);
51
+ },
52
+ [decimal, onChange]
53
+ );
26
54
  const classes = [(inline ? "inline-flex items-center rounded-sm" : "input p-0 flex items-center") + " overflow-hidden"];
27
55
  if (className) {
28
56
  classes.push(className);
@@ -115,9 +143,11 @@ var InputNumber = ({
115
143
  // an inline flex grow rather than a version-specific grow utility, so
116
144
  // this works in BOTH consumers (app-web is Tailwind v3, share is v4).
117
145
  className: "text-inherit bg-transparent focus:outline-none focus:ring-0 " + (small ? "py-1 px-2" : "py-2 px-3") + (inline ? small ? " w-10" : " w-12" : "") + (layout === "split" ? " text-center" : ""),
118
- inputMode: "numeric",
119
- onChange: ({ target }) => onChange(Number(target.value)),
120
- step: 1,
146
+ // `type="text"` (not "number") so in-progress decimal strings survive
147
+ // each render; inputMode still surfaces the numeric/decimal keypad on
148
+ // mobile and handleChange enforces the numeric character set.
149
+ inputMode: decimal ? "decimal" : "numeric",
150
+ onChange: handleChange,
121
151
  // The bordered container is the single visible border; strip the
122
152
  // native number-input border so it doesn't double up.
123
153
  style: {
@@ -127,8 +157,8 @@ var InputNumber = ({
127
157
  minWidth: 0
128
158
  }
129
159
  },
130
- type: "number",
131
- value
160
+ type: "text",
161
+ value: draft
132
162
  }
133
163
  }
134
164
  );
package/dist/product.js CHANGED
@@ -821,15 +821,7 @@ var Product = ({
821
821
  classNameScroll: "max-h-[4.5em]",
822
822
  color: resolved.background.color.rgb
823
823
  },
824
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
825
- "p",
826
- {
827
- ...{
828
- className: "text-sm"
829
- },
830
- children: product.description
831
- }
832
- )
824
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: product.description })
833
825
  }
834
826
  )
835
827
  ]
@@ -868,7 +860,7 @@ var Product = ({
868
860
  "div",
869
861
  {
870
862
  ...{
871
- className: addToCart ? "grid grid-cols-2 gap-4" : ""
863
+ className: addToCart ? "grid grid-cols-2 gap-5" : ""
872
864
  },
873
865
  children: [
874
866
  addToCart && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
package/dist/product.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  product_default
4
- } from "./chunk-NFF5ANXM.mjs";
4
+ } from "./chunk-L5X6LHYZ.mjs";
5
5
  import "./chunk-2ZYGRSSA.mjs";
6
6
  import "./chunk-XWELEL6Z.mjs";
7
7
  import "./chunk-3SAKIKZP.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/components",
3
- "version": "0.0.51",
3
+ "version": "0.0.52",
4
4
  "exports": {
5
5
  "./advertisement": {
6
6
  "types": "./types/advertisement.d.ts",