@nori-ui/core 0.0.2 → 0.0.4
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/{chunk-JGH6Z5LM.js → chunk-6OABNXBY.js} +2 -2
- package/dist/{chunk-JGH6Z5LM.js.map → chunk-6OABNXBY.js.map} +1 -1
- package/dist/chunk-UAKFCMWK.js +3 -0
- package/dist/chunk-UAKFCMWK.js.map +1 -0
- package/dist/{chunk-6NDARMPP.js → chunk-X3AJNNF6.js} +167 -17
- package/dist/chunk-X3AJNNF6.js.map +1 -0
- package/dist/client.cjs +374 -225
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +5 -4
- package/dist/client.js.map +1 -1
- package/dist/index.cjs +374 -225
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -2
- package/dist/stories/story-registry.cjs +179 -15
- package/dist/stories/story-registry.cjs.map +1 -1
- package/dist/stories/story-registry.js +2 -1
- package/dist/stories/story-registry.js.map +1 -1
- package/dist/theme/index.js +2 -1
- package/package.json +1 -2
- package/dist/chunk-6NDARMPP.js.map +0 -1
|
@@ -37,6 +37,21 @@ function Box({ className, children, ...rest }) {
|
|
|
37
37
|
}
|
|
38
38
|
__name(Box, "Box");
|
|
39
39
|
|
|
40
|
+
// ../tokens/build/theme.ts
|
|
41
|
+
var theme = {
|
|
42
|
+
color: {
|
|
43
|
+
danger: "#ef4444",
|
|
44
|
+
neutral: {
|
|
45
|
+
"100": "#f4f4f5",
|
|
46
|
+
"200": "#e4e4e7",
|
|
47
|
+
"300": "#d4d4d8",
|
|
48
|
+
"400": "#a1a1aa",
|
|
49
|
+
"500": "#71717a",
|
|
50
|
+
"900": "#18181b"
|
|
51
|
+
},
|
|
52
|
+
primary: {
|
|
53
|
+
"600": "#2563eb"}}};
|
|
54
|
+
|
|
40
55
|
// src/slot/compose-refs.ts
|
|
41
56
|
function composeRefs(...refs) {
|
|
42
57
|
return (node) => {
|
|
@@ -145,6 +160,30 @@ var SIZE_CLASSES = {
|
|
|
145
160
|
};
|
|
146
161
|
var ICON_SIZE = { sm: 14, md: 16, lg: 20 };
|
|
147
162
|
var BASE_CLASSES = "inline-flex flex-row items-center justify-center gap-2 rounded-md select-none";
|
|
163
|
+
var VARIANT_STYLES = {
|
|
164
|
+
primary: { backgroundColor: theme.color.primary["600"] },
|
|
165
|
+
secondary: { backgroundColor: theme.color.neutral["100"] },
|
|
166
|
+
ghost: { backgroundColor: "transparent" },
|
|
167
|
+
destructive: { backgroundColor: theme.color.danger }
|
|
168
|
+
};
|
|
169
|
+
var VARIANT_TEXT_COLOR = {
|
|
170
|
+
primary: "#ffffff",
|
|
171
|
+
secondary: theme.color.neutral["900"],
|
|
172
|
+
ghost: theme.color.neutral["900"],
|
|
173
|
+
destructive: "#ffffff"
|
|
174
|
+
};
|
|
175
|
+
var SIZE_STYLES = {
|
|
176
|
+
sm: { container: { height: 32, paddingHorizontal: 12 }, text: { fontSize: 14 } },
|
|
177
|
+
md: { container: { height: 40, paddingHorizontal: 16 }, text: { fontSize: 16 } },
|
|
178
|
+
lg: { container: { height: 48, paddingHorizontal: 20 }, text: { fontSize: 18 } }
|
|
179
|
+
};
|
|
180
|
+
var BASE_STYLE = {
|
|
181
|
+
flexDirection: "row",
|
|
182
|
+
alignItems: "center",
|
|
183
|
+
justifyContent: "center",
|
|
184
|
+
gap: 8,
|
|
185
|
+
borderRadius: 6
|
|
186
|
+
};
|
|
148
187
|
var Button = react.forwardRef(/* @__PURE__ */ __name(function Button2({
|
|
149
188
|
children,
|
|
150
189
|
variant = "primary",
|
|
@@ -157,6 +196,7 @@ var Button = react.forwardRef(/* @__PURE__ */ __name(function Button2({
|
|
|
157
196
|
className,
|
|
158
197
|
onPress,
|
|
159
198
|
testID,
|
|
199
|
+
style,
|
|
160
200
|
...rest
|
|
161
201
|
}, forwardedRef) {
|
|
162
202
|
const isInoperative = Boolean(disabled) || Boolean(loading);
|
|
@@ -167,6 +207,16 @@ var Button = react.forwardRef(/* @__PURE__ */ __name(function Button2({
|
|
|
167
207
|
isInoperative ? "opacity-60" : void 0,
|
|
168
208
|
className
|
|
169
209
|
);
|
|
210
|
+
const baseInlineStyle = [
|
|
211
|
+
BASE_STYLE,
|
|
212
|
+
VARIANT_STYLES[variant],
|
|
213
|
+
SIZE_STYLES[size].container,
|
|
214
|
+
isInoperative ? { opacity: 0.6 } : null
|
|
215
|
+
];
|
|
216
|
+
const pressableStyle = typeof style === "function" ? (state) => [baseInlineStyle, style(state)] : [baseInlineStyle, style];
|
|
217
|
+
const slotStyle = [baseInlineStyle, typeof style === "function" ? null : style];
|
|
218
|
+
const textColor = VARIANT_TEXT_COLOR[variant];
|
|
219
|
+
const textStyle = { color: textColor, fontSize: SIZE_STYLES[size].text.fontSize, fontWeight: "500" };
|
|
170
220
|
const handlePress = /* @__PURE__ */ __name((ev) => {
|
|
171
221
|
if (isInoperative) return;
|
|
172
222
|
onPress?.(ev);
|
|
@@ -175,6 +225,7 @@ var Button = react.forwardRef(/* @__PURE__ */ __name(function Button2({
|
|
|
175
225
|
const slotProps = {
|
|
176
226
|
ref: forwardedRef,
|
|
177
227
|
className: classes,
|
|
228
|
+
style: slotStyle,
|
|
178
229
|
onClick: handlePress,
|
|
179
230
|
...rest
|
|
180
231
|
};
|
|
@@ -197,12 +248,20 @@ var Button = react.forwardRef(/* @__PURE__ */ __name(function Button2({
|
|
|
197
248
|
disabled: isInoperative,
|
|
198
249
|
onPress: handlePress,
|
|
199
250
|
className: classes,
|
|
251
|
+
style: pressableStyle,
|
|
200
252
|
...pressableExtra,
|
|
201
253
|
...rest,
|
|
202
254
|
children: [
|
|
203
|
-
loading ? /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: ICON_SIZE[size], label: "Loading" }) : LeadingIcon ? /* @__PURE__ */ jsxRuntime.jsx(LeadingIcon, { size: ICON_SIZE[size] }) : null,
|
|
204
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
205
|
-
|
|
255
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: ICON_SIZE[size], label: "Loading", color: textColor }) : LeadingIcon ? /* @__PURE__ */ jsxRuntime.jsx(LeadingIcon, { size: ICON_SIZE[size], color: textColor }) : null,
|
|
256
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
257
|
+
reactNative.Text,
|
|
258
|
+
{
|
|
259
|
+
className: cn("font-medium", SIZE_CLASSES[size].includes("text-") ? void 0 : "text-md"),
|
|
260
|
+
style: textStyle,
|
|
261
|
+
children
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
TrailingIcon ? /* @__PURE__ */ jsxRuntime.jsx(TrailingIcon, { size: ICON_SIZE[size], color: textColor }) : null
|
|
206
265
|
]
|
|
207
266
|
}
|
|
208
267
|
);
|
|
@@ -250,6 +309,21 @@ function useSemanticIcon(name) {
|
|
|
250
309
|
return icons[name];
|
|
251
310
|
}
|
|
252
311
|
__name(useSemanticIcon, "useSemanticIcon");
|
|
312
|
+
var ROW_STYLE = { flexDirection: "row", alignItems: "center", gap: 8 };
|
|
313
|
+
var BOX_STYLE = {
|
|
314
|
+
width: 20,
|
|
315
|
+
height: 20,
|
|
316
|
+
borderRadius: 4,
|
|
317
|
+
borderWidth: 1,
|
|
318
|
+
borderColor: theme.color.neutral["300"],
|
|
319
|
+
backgroundColor: "#ffffff",
|
|
320
|
+
alignItems: "center",
|
|
321
|
+
justifyContent: "center"
|
|
322
|
+
};
|
|
323
|
+
var BOX_STYLE_CHECKED = {
|
|
324
|
+
backgroundColor: theme.color.primary["600"],
|
|
325
|
+
borderColor: theme.color.primary["600"]
|
|
326
|
+
};
|
|
253
327
|
function Checkbox({
|
|
254
328
|
checked,
|
|
255
329
|
defaultChecked = false,
|
|
@@ -266,6 +340,7 @@ function Checkbox({
|
|
|
266
340
|
const isControlled = checked !== void 0;
|
|
267
341
|
const value = isControlled ? Boolean(checked) : inner;
|
|
268
342
|
const ariaChecked = indeterminate ? "mixed" : value ? "true" : "false";
|
|
343
|
+
const isMarked = value || Boolean(indeterminate);
|
|
269
344
|
const toggle = react.useCallback(() => {
|
|
270
345
|
if (disabled) return;
|
|
271
346
|
const next = !value;
|
|
@@ -298,10 +373,26 @@ function Checkbox({
|
|
|
298
373
|
return /* @__PURE__ */ jsxRuntime.jsx(Slot, { ...slotProps, children });
|
|
299
374
|
}
|
|
300
375
|
const boxClasses = cn("w-5 h-5 rounded-sm border border-semantic-border-strong items-center justify-center");
|
|
301
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
376
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
377
|
+
reactNative.View,
|
|
378
|
+
{
|
|
379
|
+
className: cn("flex-row items-center gap-2", disabled ? "opacity-60" : void 0, className),
|
|
380
|
+
style: [ROW_STYLE, disabled ? { opacity: 0.6 } : null],
|
|
381
|
+
children: [
|
|
382
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
383
|
+
reactNative.Pressable,
|
|
384
|
+
{
|
|
385
|
+
onPress: toggle,
|
|
386
|
+
...commonProps,
|
|
387
|
+
className: boxClasses,
|
|
388
|
+
style: [BOX_STYLE, isMarked && !disabled ? BOX_STYLE_CHECKED : null],
|
|
389
|
+
children: isMarked && !disabled ? /* @__PURE__ */ jsxRuntime.jsx(Check, { size: 14, color: "#ffffff" }) : null
|
|
390
|
+
}
|
|
391
|
+
),
|
|
392
|
+
children ?? (label !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.color.neutral["900"], fontSize: 16 }, children: label }) : null)
|
|
393
|
+
]
|
|
394
|
+
}
|
|
395
|
+
);
|
|
305
396
|
}
|
|
306
397
|
__name(Checkbox, "Checkbox");
|
|
307
398
|
var ALIGN_CLASS = {
|
|
@@ -336,6 +427,25 @@ function HStack({ gap, align, justify, className, children, ...rest }) {
|
|
|
336
427
|
);
|
|
337
428
|
}
|
|
338
429
|
__name(HStack, "HStack");
|
|
430
|
+
var ROW_STYLE2 = { flexDirection: "row", alignItems: "center", gap: 8 };
|
|
431
|
+
var TRACK_BASE = {
|
|
432
|
+
width: 40,
|
|
433
|
+
height: 24,
|
|
434
|
+
borderRadius: 12,
|
|
435
|
+
justifyContent: "center",
|
|
436
|
+
paddingHorizontal: 2
|
|
437
|
+
};
|
|
438
|
+
var THUMB_STYLE = {
|
|
439
|
+
width: 20,
|
|
440
|
+
height: 20,
|
|
441
|
+
borderRadius: 10,
|
|
442
|
+
backgroundColor: "#ffffff",
|
|
443
|
+
shadowColor: "#000",
|
|
444
|
+
shadowOpacity: 0.15,
|
|
445
|
+
shadowRadius: 2,
|
|
446
|
+
shadowOffset: { width: 0, height: 1 },
|
|
447
|
+
elevation: 2
|
|
448
|
+
};
|
|
339
449
|
function Switch({
|
|
340
450
|
checked,
|
|
341
451
|
defaultChecked = false,
|
|
@@ -387,9 +497,22 @@ function Switch({
|
|
|
387
497
|
disabled ? "opacity-60" : void 0
|
|
388
498
|
);
|
|
389
499
|
const thumbClasses = cn("w-5 h-5 rounded-full bg-white shadow-sm", value ? "self-end" : "self-start");
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
500
|
+
const trackStyle = [
|
|
501
|
+
TRACK_BASE,
|
|
502
|
+
{ backgroundColor: value ? theme.color.primary["600"] : theme.color.neutral["300"] },
|
|
503
|
+
disabled ? { opacity: 0.6 } : null
|
|
504
|
+
];
|
|
505
|
+
const thumbStyle = [THUMB_STYLE, { alignSelf: value ? "flex-end" : "flex-start" }];
|
|
506
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { className: cn("flex-row items-center gap-2", className), style: ROW_STYLE2, children: [
|
|
507
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { onPress: toggle, ...commonProps, className: trackClasses, style: trackStyle, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { className: thumbClasses, style: thumbStyle }) }),
|
|
508
|
+
label ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
509
|
+
reactNative.Text,
|
|
510
|
+
{
|
|
511
|
+
className: "text-md text-semantic-text-default",
|
|
512
|
+
style: { color: theme.color.neutral["900"], fontSize: 16 },
|
|
513
|
+
children: label
|
|
514
|
+
}
|
|
515
|
+
) : null,
|
|
393
516
|
children
|
|
394
517
|
] });
|
|
395
518
|
}
|
|
@@ -419,6 +542,23 @@ function Text({ variant = "body-md", className, testID, children, ...rest }) {
|
|
|
419
542
|
);
|
|
420
543
|
}
|
|
421
544
|
__name(Text, "Text");
|
|
545
|
+
var CONTAINER_STYLE = { flexDirection: "column", gap: 4 };
|
|
546
|
+
var LABEL_STYLE = { fontSize: 14, fontWeight: "500", color: theme.color.neutral["900"] };
|
|
547
|
+
var FIELD_BASE_STYLE = {
|
|
548
|
+
flexDirection: "row",
|
|
549
|
+
alignItems: "center",
|
|
550
|
+
borderRadius: 6,
|
|
551
|
+
borderWidth: 1,
|
|
552
|
+
paddingHorizontal: 12
|
|
553
|
+
};
|
|
554
|
+
var INPUT_STYLE = {
|
|
555
|
+
flex: 1,
|
|
556
|
+
paddingVertical: 8,
|
|
557
|
+
fontSize: 16,
|
|
558
|
+
color: theme.color.neutral["900"]
|
|
559
|
+
};
|
|
560
|
+
var HELPER_STYLE = { fontSize: 14, color: theme.color.neutral["500"] };
|
|
561
|
+
var ERROR_STYLE = { fontSize: 14, color: theme.color.danger };
|
|
422
562
|
function TextInput({
|
|
423
563
|
label,
|
|
424
564
|
helperText,
|
|
@@ -447,8 +587,21 @@ function TextInput({
|
|
|
447
587
|
if (multiline !== void 0) inputExtras.multiline = multiline;
|
|
448
588
|
if (numberOfLines !== void 0) inputExtras.numberOfLines = numberOfLines;
|
|
449
589
|
if (onChangeText !== void 0) inputExtras.onChangeText = onChangeText;
|
|
450
|
-
|
|
451
|
-
|
|
590
|
+
const fieldStyle = [
|
|
591
|
+
FIELD_BASE_STYLE,
|
|
592
|
+
{ borderColor: hasError ? theme.color.danger : theme.color.neutral["200"] },
|
|
593
|
+
disabled ? { opacity: 0.6 } : null
|
|
594
|
+
];
|
|
595
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { className: cn("flex flex-col gap-1", containerClassName), style: CONTAINER_STYLE, children: [
|
|
596
|
+
label !== void 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
597
|
+
"label",
|
|
598
|
+
{
|
|
599
|
+
htmlFor: inputId,
|
|
600
|
+
className: "text-sm font-medium text-semantic-text-default",
|
|
601
|
+
style: LABEL_STYLE,
|
|
602
|
+
children: label
|
|
603
|
+
}
|
|
604
|
+
) : null,
|
|
452
605
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
453
606
|
reactNative.View,
|
|
454
607
|
{
|
|
@@ -457,23 +610,34 @@ function TextInput({
|
|
|
457
610
|
hasError ? "border-semantic-interactive-destructive" : "border-semantic-border-default",
|
|
458
611
|
disabled ? "opacity-60" : void 0
|
|
459
612
|
),
|
|
613
|
+
style: fieldStyle,
|
|
460
614
|
children: [
|
|
461
|
-
leading ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { className: "mr-2", children: leading }) : null,
|
|
615
|
+
leading ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { className: "mr-2", style: { marginRight: 8 }, children: leading }) : null,
|
|
462
616
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
463
617
|
reactNative.TextInput,
|
|
464
618
|
{
|
|
465
619
|
nativeID: inputId,
|
|
466
620
|
editable: !disabled,
|
|
467
621
|
className: cn("flex-1 py-2 text-md text-semantic-text-default outline-none", className),
|
|
622
|
+
style: INPUT_STYLE,
|
|
623
|
+
placeholderTextColor: theme.color.neutral["400"],
|
|
468
624
|
...inputExtras,
|
|
469
625
|
...rest
|
|
470
626
|
}
|
|
471
627
|
),
|
|
472
|
-
trailing ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { className: "ml-2", children: trailing }) : null
|
|
628
|
+
trailing ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { className: "ml-2", style: { marginLeft: 8 }, children: trailing }) : null
|
|
473
629
|
]
|
|
474
630
|
}
|
|
475
631
|
),
|
|
476
|
-
error ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
632
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
633
|
+
reactNative.Text,
|
|
634
|
+
{
|
|
635
|
+
nativeID: describeId,
|
|
636
|
+
className: "text-sm text-semantic-interactive-destructive",
|
|
637
|
+
style: ERROR_STYLE,
|
|
638
|
+
children: error
|
|
639
|
+
}
|
|
640
|
+
) : helperText ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { nativeID: describeId, className: "text-sm text-semantic-text-muted", style: HELPER_STYLE, children: helperText }) : null
|
|
477
641
|
] });
|
|
478
642
|
}
|
|
479
643
|
__name(TextInput, "TextInput");
|