@drawbridge/components 0.0.50 → 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.
- package/dist/advertisement.js +2 -10
- package/dist/advertisement.mjs +1 -1
- package/dist/{chunk-5W23JUIM.mjs → chunk-L5X6LHYZ.mjs} +2 -10
- package/dist/input-number.js +44 -8
- package/dist/input-number.mjs +45 -9
- package/dist/product.js +2 -10
- package/dist/product.mjs +1 -1
- package/package.json +1 -1
package/dist/advertisement.js
CHANGED
|
@@ -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-
|
|
866
|
+
className: addToCart ? "grid grid-cols-2 gap-5" : ""
|
|
875
867
|
},
|
|
876
868
|
children: [
|
|
877
869
|
addToCart && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
package/dist/advertisement.mjs
CHANGED
|
@@ -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-
|
|
315
|
+
className: addToCart ? "grid grid-cols-2 gap-5" : ""
|
|
324
316
|
},
|
|
325
317
|
children: [
|
|
326
318
|
addToCart && /* @__PURE__ */ jsx(
|
package/dist/input-number.js
CHANGED
|
@@ -107,15 +107,44 @@ 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
|
}) => {
|
|
114
|
-
const
|
|
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
|
+
);
|
|
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);
|
|
117
145
|
}
|
|
118
146
|
;
|
|
147
|
+
const dividerBorder = "1px solid " + inputStyle(style).borderColor;
|
|
119
148
|
const increment = (0, import_react.useCallback)(
|
|
120
149
|
() => {
|
|
121
150
|
const newValue = Number(value || 0) + 1;
|
|
@@ -139,7 +168,10 @@ var InputNumber = ({
|
|
|
139
168
|
"aria-label": "decrement",
|
|
140
169
|
type: "button",
|
|
141
170
|
onClick: decrement,
|
|
142
|
-
className: (small ? "h-[34px] w-[34px]" : "h-[42px] w-[42px]") + " flex justify-center items-center text-inherit shrink-0 grow-0"
|
|
171
|
+
className: (small ? "h-[34px] w-[34px]" : "h-[42px] w-[42px]") + " flex justify-center items-center text-inherit shrink-0 grow-0",
|
|
172
|
+
// split: decrement is leftmost, so its divider is on the right (before
|
|
173
|
+
// the input); after: it follows the input, so the divider is on its left.
|
|
174
|
+
style: layout === "split" ? { borderRight: dividerBorder } : { borderLeft: dividerBorder }
|
|
143
175
|
},
|
|
144
176
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
145
177
|
"span",
|
|
@@ -166,7 +198,9 @@ var InputNumber = ({
|
|
|
166
198
|
"aria-label": "increment",
|
|
167
199
|
type: "button",
|
|
168
200
|
onClick: increment,
|
|
169
|
-
className: (small ? "h-[34px] w-[34px]" : "h-[42px] w-[42px]") + " flex justify-center items-center text-inherit shrink-0 grow-0"
|
|
201
|
+
className: (small ? "h-[34px] w-[34px]" : "h-[42px] w-[42px]") + " flex justify-center items-center text-inherit shrink-0 grow-0",
|
|
202
|
+
// increment is always rightmost, so its divider is always on its left.
|
|
203
|
+
style: { borderLeft: dividerBorder }
|
|
170
204
|
},
|
|
171
205
|
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
172
206
|
"span",
|
|
@@ -197,9 +231,11 @@ var InputNumber = ({
|
|
|
197
231
|
// an inline flex grow rather than a version-specific grow utility, so
|
|
198
232
|
// this works in BOTH consumers (app-web is Tailwind v3, share is v4).
|
|
199
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" : ""),
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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,
|
|
203
239
|
// The bordered container is the single visible border; strip the
|
|
204
240
|
// native number-input border so it doesn't double up.
|
|
205
241
|
style: {
|
|
@@ -209,8 +245,8 @@ var InputNumber = ({
|
|
|
209
245
|
minWidth: 0
|
|
210
246
|
}
|
|
211
247
|
},
|
|
212
|
-
type: "
|
|
213
|
-
value
|
|
248
|
+
type: "text",
|
|
249
|
+
value: draft
|
|
214
250
|
}
|
|
215
251
|
}
|
|
216
252
|
);
|
package/dist/input-number.mjs
CHANGED
|
@@ -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,15 +19,44 @@ 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
|
}) => {
|
|
26
|
-
const
|
|
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
|
+
);
|
|
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);
|
|
29
57
|
}
|
|
30
58
|
;
|
|
59
|
+
const dividerBorder = "1px solid " + inputStyle(style).borderColor;
|
|
31
60
|
const increment = useCallback(
|
|
32
61
|
() => {
|
|
33
62
|
const newValue = Number(value || 0) + 1;
|
|
@@ -51,7 +80,10 @@ var InputNumber = ({
|
|
|
51
80
|
"aria-label": "decrement",
|
|
52
81
|
type: "button",
|
|
53
82
|
onClick: decrement,
|
|
54
|
-
className: (small ? "h-[34px] w-[34px]" : "h-[42px] w-[42px]") + " flex justify-center items-center text-inherit shrink-0 grow-0"
|
|
83
|
+
className: (small ? "h-[34px] w-[34px]" : "h-[42px] w-[42px]") + " flex justify-center items-center text-inherit shrink-0 grow-0",
|
|
84
|
+
// split: decrement is leftmost, so its divider is on the right (before
|
|
85
|
+
// the input); after: it follows the input, so the divider is on its left.
|
|
86
|
+
style: layout === "split" ? { borderRight: dividerBorder } : { borderLeft: dividerBorder }
|
|
55
87
|
},
|
|
56
88
|
children: /* @__PURE__ */ jsx(
|
|
57
89
|
"span",
|
|
@@ -78,7 +110,9 @@ var InputNumber = ({
|
|
|
78
110
|
"aria-label": "increment",
|
|
79
111
|
type: "button",
|
|
80
112
|
onClick: increment,
|
|
81
|
-
className: (small ? "h-[34px] w-[34px]" : "h-[42px] w-[42px]") + " flex justify-center items-center text-inherit shrink-0 grow-0"
|
|
113
|
+
className: (small ? "h-[34px] w-[34px]" : "h-[42px] w-[42px]") + " flex justify-center items-center text-inherit shrink-0 grow-0",
|
|
114
|
+
// increment is always rightmost, so its divider is always on its left.
|
|
115
|
+
style: { borderLeft: dividerBorder }
|
|
82
116
|
},
|
|
83
117
|
children: /* @__PURE__ */ jsx(
|
|
84
118
|
"span",
|
|
@@ -109,9 +143,11 @@ var InputNumber = ({
|
|
|
109
143
|
// an inline flex grow rather than a version-specific grow utility, so
|
|
110
144
|
// this works in BOTH consumers (app-web is Tailwind v3, share is v4).
|
|
111
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" : ""),
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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,
|
|
115
151
|
// The bordered container is the single visible border; strip the
|
|
116
152
|
// native number-input border so it doesn't double up.
|
|
117
153
|
style: {
|
|
@@ -121,8 +157,8 @@ var InputNumber = ({
|
|
|
121
157
|
minWidth: 0
|
|
122
158
|
}
|
|
123
159
|
},
|
|
124
|
-
type: "
|
|
125
|
-
value
|
|
160
|
+
type: "text",
|
|
161
|
+
value: draft
|
|
126
162
|
}
|
|
127
163
|
}
|
|
128
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-
|
|
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