elseware-ui 3.0.0 → 3.0.1
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/LICENSE +20 -20
- package/README.md +289 -289
- package/dist/index.css +360 -286
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +10 -45
- package/dist/index.d.ts +10 -45
- package/dist/index.js +615 -374
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +612 -371
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.d.mts +13 -4
- package/dist/index.native.d.ts +13 -4
- package/dist/index.native.js +604 -42
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +603 -45
- package/dist/index.native.mjs.map +1 -1
- package/dist/{resolveGlobalConfigs-CcaOIQCE.d.mts → resolveGlobalConfigs-Cuiq_Zix.d.mts} +68 -8
- package/dist/{resolveGlobalConfigs-CcaOIQCE.d.ts → resolveGlobalConfigs-Cuiq_Zix.d.ts} +68 -8
- package/package.json +173 -171
- package/tailwind.preset.js +116 -116
package/dist/index.native.js
CHANGED
|
@@ -5,6 +5,7 @@ var tailwindMerge = require('tailwind-merge');
|
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var jsxRuntime$1 = require('nativewind/jsx-runtime');
|
|
8
|
+
var formik = require('formik');
|
|
8
9
|
|
|
9
10
|
// src/components/data-entry/button/native/Button.native.tsx
|
|
10
11
|
|
|
@@ -97,14 +98,14 @@ function useResolvedButtonConfig({
|
|
|
97
98
|
// src/data/styles.tsx
|
|
98
99
|
var variantsSolid = {
|
|
99
100
|
["default" /* default */]: "bg-gray-300 text-gray-900 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-100 dark:hover:bg-gray-600",
|
|
100
|
-
["primary" /* primary */]: "bg-
|
|
101
|
-
["secondary" /* secondary */]: "bg-
|
|
102
|
-
["success" /* success */]: "bg-
|
|
103
|
-
["danger" /* danger */]: "bg-
|
|
104
|
-
["warning" /* warning */]: "bg-
|
|
105
|
-
["info" /* info */]: "bg-
|
|
106
|
-
["light" /* light */]: "bg-
|
|
107
|
-
["dark" /* dark */]: "bg-
|
|
101
|
+
["primary" /* primary */]: "bg-eui-primary-500 text-white hover:bg-eui-primary-600",
|
|
102
|
+
["secondary" /* secondary */]: "bg-eui-secondary-500 text-white hover:bg-eui-secondary-600",
|
|
103
|
+
["success" /* success */]: "bg-eui-success-500 text-white hover:bg-eui-success-600",
|
|
104
|
+
["danger" /* danger */]: "bg-eui-danger-500 text-white hover:bg-eui-danger-600",
|
|
105
|
+
["warning" /* warning */]: "bg-eui-warning-500 text-black hover:bg-eui-warning-400",
|
|
106
|
+
["info" /* info */]: "bg-eui-info-500 text-white hover:bg-eui-info-600",
|
|
107
|
+
["light" /* light */]: "bg-eui-light-400 text-gray-900 hover:bg-eui-light-300 dark:bg-gray-200 dark:text-gray-900 dark:hover:bg-gray-100",
|
|
108
|
+
["dark" /* dark */]: "bg-eui-dark-500 text-white hover:bg-eui-dark-400 dark:bg-eui-dark-400 dark:hover:bg-eui-dark-300"
|
|
108
109
|
};
|
|
109
110
|
var variantsLite = {
|
|
110
111
|
["default" /* default */]: "bg-gray-500/10 border border-gray-300 text-gray-700 dark:bg-gray-400/10 dark:border-gray-700 dark:text-gray-200",
|
|
@@ -128,6 +129,17 @@ var variantsGhost = {
|
|
|
128
129
|
["light" /* light */]: "bg-transparent border border-gray-300 text-gray-700 hover:bg-white/10 dark:border-gray-500 dark:text-gray-100 dark:hover:bg-white/5",
|
|
129
130
|
["dark" /* dark */]: "bg-transparent border border-eui-dark-500 text-eui-dark-500 hover:bg-eui-dark-500/10 dark:text-eui-dark-300 dark:border-eui-dark-300"
|
|
130
131
|
};
|
|
132
|
+
var textVariants = {
|
|
133
|
+
["default" /* default */]: "eui-text-md",
|
|
134
|
+
["primary" /* primary */]: "text-blue-500",
|
|
135
|
+
["secondary" /* secondary */]: "text-gray-500",
|
|
136
|
+
["success" /* success */]: "text-green-500",
|
|
137
|
+
["danger" /* danger */]: "text-red-500",
|
|
138
|
+
["warning" /* warning */]: "text-yellow-500",
|
|
139
|
+
["info" /* info */]: "text-blue-400",
|
|
140
|
+
["light" /* light */]: "text-gray-300",
|
|
141
|
+
["dark" /* dark */]: "text-gray-900"
|
|
142
|
+
};
|
|
131
143
|
var shapes = {
|
|
132
144
|
["square" /* square */]: "rounded-none",
|
|
133
145
|
["roundedSquare" /* roundedSquare */]: "rounded-md",
|
|
@@ -156,7 +168,7 @@ function resolveButtonVariantStyles({
|
|
|
156
168
|
ghost: variantsGhost
|
|
157
169
|
});
|
|
158
170
|
}
|
|
159
|
-
function
|
|
171
|
+
function getButtonLabelColorClassName(className) {
|
|
160
172
|
return className.split(/\s+/).filter(
|
|
161
173
|
(token) => token.startsWith("text-") || token.startsWith("dark:text-") || token.startsWith("disabled:text-")
|
|
162
174
|
).join(" ");
|
|
@@ -203,8 +215,6 @@ function Button({
|
|
|
203
215
|
block = false,
|
|
204
216
|
compact = false,
|
|
205
217
|
mode,
|
|
206
|
-
buttonColor,
|
|
207
|
-
textColor,
|
|
208
218
|
contentClassName,
|
|
209
219
|
labelClassName,
|
|
210
220
|
className,
|
|
@@ -212,9 +222,6 @@ function Button({
|
|
|
212
222
|
appearance,
|
|
213
223
|
shape,
|
|
214
224
|
size,
|
|
215
|
-
style,
|
|
216
|
-
contentStyle,
|
|
217
|
-
labelStyle,
|
|
218
225
|
accessibilityRole = "button",
|
|
219
226
|
accessibilityState,
|
|
220
227
|
type: _type,
|
|
@@ -242,21 +249,9 @@ function Button({
|
|
|
242
249
|
appearance: resolvedAppearance,
|
|
243
250
|
variant: resolvedVariant
|
|
244
251
|
});
|
|
245
|
-
const
|
|
246
|
-
const rootStyle = {
|
|
247
|
-
...mode === "text" ? {
|
|
248
|
-
backgroundColor: "transparent",
|
|
249
|
-
borderColor: "transparent"
|
|
250
|
-
} : null,
|
|
251
|
-
...buttonColor && mode !== "text" ? {
|
|
252
|
-
backgroundColor: buttonColor,
|
|
253
|
-
borderColor: buttonColor
|
|
254
|
-
} : null,
|
|
255
|
-
...!buttonColor && textColor && resolvedAppearance !== "solid" ? { borderColor: textColor } : null
|
|
256
|
-
};
|
|
257
|
-
const labelTextStyle = textColor ? { color: textColor } : null;
|
|
252
|
+
const labelColorClassName = getButtonLabelColorClassName(variantStyles);
|
|
258
253
|
const content = text ?? children;
|
|
259
|
-
const resolvedIcon = typeof icon === "function" ? icon({ color:
|
|
254
|
+
const resolvedIcon = typeof icon === "function" ? icon({ color: "currentColor", size: iconSize }) : icon;
|
|
260
255
|
return /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
261
256
|
reactNative.Pressable,
|
|
262
257
|
{
|
|
@@ -280,10 +275,8 @@ function Button({
|
|
|
280
275
|
disabled: disabled || loading,
|
|
281
276
|
onPress,
|
|
282
277
|
style: ({ pressed }) => [
|
|
283
|
-
rootStyle,
|
|
284
278
|
pressed && !disabled && !loading ? { opacity: 0.82 } : null,
|
|
285
|
-
disabled || loading ? { opacity: 0.55 } : null
|
|
286
|
-
style
|
|
279
|
+
disabled || loading ? { opacity: 0.55 } : null
|
|
287
280
|
],
|
|
288
281
|
children: /* @__PURE__ */ jsxRuntime$1.jsxs(
|
|
289
282
|
reactNative.View,
|
|
@@ -292,7 +285,6 @@ function Button({
|
|
|
292
285
|
"z-10 flex-row items-center justify-center gap-2",
|
|
293
286
|
contentClassName
|
|
294
287
|
),
|
|
295
|
-
style: contentStyle,
|
|
296
288
|
children: [
|
|
297
289
|
loading ? /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
298
290
|
reactNative.View,
|
|
@@ -301,14 +293,7 @@ function Button({
|
|
|
301
293
|
"shrink-0 items-center justify-center",
|
|
302
294
|
metrics.slotClassName
|
|
303
295
|
),
|
|
304
|
-
children: /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
305
|
-
reactNative.ActivityIndicator,
|
|
306
|
-
{
|
|
307
|
-
className: textColorClassName,
|
|
308
|
-
color: textColor,
|
|
309
|
-
size: "small"
|
|
310
|
-
}
|
|
311
|
-
)
|
|
296
|
+
children: /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.ActivityIndicator, { className: labelColorClassName, size: "small" })
|
|
312
297
|
}
|
|
313
298
|
) : null,
|
|
314
299
|
!loading && resolvedIcon ? /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
@@ -327,11 +312,11 @@ function Button({
|
|
|
327
312
|
className: cn(
|
|
328
313
|
"font-bold",
|
|
329
314
|
metrics.labelClassName,
|
|
330
|
-
|
|
315
|
+
labelColorClassName,
|
|
331
316
|
labelClassName
|
|
332
317
|
),
|
|
333
318
|
numberOfLines: 1,
|
|
334
|
-
style:
|
|
319
|
+
style: nativeLabelBaseStyle,
|
|
335
320
|
children: content
|
|
336
321
|
}
|
|
337
322
|
) }) : content
|
|
@@ -342,9 +327,586 @@ function Button({
|
|
|
342
327
|
);
|
|
343
328
|
}
|
|
344
329
|
var Button_native_default = Button;
|
|
330
|
+
function isMultiCheckbox(props) {
|
|
331
|
+
return Array.isArray(props.options);
|
|
332
|
+
}
|
|
333
|
+
function useResolvedCheckboxConfig({
|
|
334
|
+
label,
|
|
335
|
+
placeholder,
|
|
336
|
+
variant,
|
|
337
|
+
shape
|
|
338
|
+
}) {
|
|
339
|
+
const eui = useEUIConfig();
|
|
340
|
+
return {
|
|
341
|
+
shape: shape ?? eui?.config?.global?.shape ?? "roundedSquare",
|
|
342
|
+
variant: variant ?? "secondary",
|
|
343
|
+
label: label ?? placeholder
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function useCheckboxFieldState(props) {
|
|
347
|
+
const isMulti = isMultiCheckbox(props);
|
|
348
|
+
const [multiField, multiMeta, multiHelpers] = formik.useField(
|
|
349
|
+
props
|
|
350
|
+
);
|
|
351
|
+
const [singleField, singleMeta, singleHelpers] = formik.useField(
|
|
352
|
+
props
|
|
353
|
+
);
|
|
354
|
+
return {
|
|
355
|
+
isMulti,
|
|
356
|
+
multiField,
|
|
357
|
+
multiMeta,
|
|
358
|
+
multiHelpers,
|
|
359
|
+
singleField,
|
|
360
|
+
singleMeta,
|
|
361
|
+
singleHelpers
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
// src/components/data-entry/checkbox/base/Checkbox.styles.ts
|
|
366
|
+
var checkboxShapes = shapes;
|
|
367
|
+
var checkboxGroupClassName = "flex flex-col gap-2";
|
|
368
|
+
var checkboxOptionRowClassName = "flex flex-row items-start gap-3";
|
|
369
|
+
var checkboxLabelClassName = "cursor-pointer select-none text-sm leading-relaxed text-gray-800 dark:text-gray-200";
|
|
370
|
+
var checkboxIndicatorDisabledClassName = "cursor-not-allowed opacity-50";
|
|
371
|
+
|
|
372
|
+
// src/components/data-entry/checkbox/native/Checkbox.native.styles.ts
|
|
373
|
+
var nativeCheckboxVariants = {
|
|
374
|
+
default: {
|
|
375
|
+
checkedClassName: "border-eui-secondary-600 bg-eui-secondary-600 dark:border-eui-secondary-500 dark:bg-eui-secondary-500",
|
|
376
|
+
iconClassName: "text-white"
|
|
377
|
+
},
|
|
378
|
+
primary: {
|
|
379
|
+
checkedClassName: "border-eui-primary-600 bg-eui-primary-600 dark:border-eui-primary-500 dark:bg-eui-primary-500",
|
|
380
|
+
iconClassName: "text-white"
|
|
381
|
+
},
|
|
382
|
+
secondary: {
|
|
383
|
+
checkedClassName: "border-eui-secondary-600 bg-eui-secondary-600 dark:border-eui-secondary-500 dark:bg-eui-secondary-500",
|
|
384
|
+
iconClassName: "text-white"
|
|
385
|
+
},
|
|
386
|
+
success: {
|
|
387
|
+
checkedClassName: "border-eui-success-600 bg-eui-success-600 dark:border-eui-success-500 dark:bg-eui-success-500",
|
|
388
|
+
iconClassName: "text-white"
|
|
389
|
+
},
|
|
390
|
+
danger: {
|
|
391
|
+
checkedClassName: "border-eui-danger-600 bg-eui-danger-600 dark:border-eui-danger-500 dark:bg-eui-danger-500",
|
|
392
|
+
iconClassName: "text-white"
|
|
393
|
+
},
|
|
394
|
+
warning: {
|
|
395
|
+
checkedClassName: "border-eui-warning-500 bg-eui-warning-500 dark:border-eui-warning-400 dark:bg-eui-warning-400",
|
|
396
|
+
iconClassName: "text-black"
|
|
397
|
+
},
|
|
398
|
+
info: {
|
|
399
|
+
checkedClassName: "border-eui-info-600 bg-eui-info-600 dark:border-eui-info-500 dark:bg-eui-info-500",
|
|
400
|
+
iconClassName: "text-white"
|
|
401
|
+
},
|
|
402
|
+
light: {
|
|
403
|
+
checkedClassName: "border-eui-light-400 bg-eui-light-400 dark:border-gray-200 dark:bg-gray-200",
|
|
404
|
+
iconClassName: "text-gray-900"
|
|
405
|
+
},
|
|
406
|
+
dark: {
|
|
407
|
+
checkedClassName: "border-eui-dark-500 bg-eui-dark-500 dark:border-eui-dark-300 dark:bg-eui-dark-300",
|
|
408
|
+
iconClassName: "text-white"
|
|
409
|
+
}
|
|
410
|
+
};
|
|
411
|
+
function resolveNativeCheckboxVariantStyles(variant) {
|
|
412
|
+
return nativeCheckboxVariants[variant];
|
|
413
|
+
}
|
|
414
|
+
function getIndicatorClassName({
|
|
415
|
+
checked,
|
|
416
|
+
className,
|
|
417
|
+
disabled,
|
|
418
|
+
indicatorClassName,
|
|
419
|
+
checkedIndicatorClassName,
|
|
420
|
+
resolvedShape,
|
|
421
|
+
variantCheckedClassName
|
|
422
|
+
}) {
|
|
423
|
+
return cn(
|
|
424
|
+
"h-5 w-5 shrink-0 items-center justify-center border-2 border-gray-300 bg-white dark:border-neutral-600 dark:bg-neutral-900",
|
|
425
|
+
checkboxShapes[resolvedShape],
|
|
426
|
+
indicatorClassName,
|
|
427
|
+
className,
|
|
428
|
+
checked && variantCheckedClassName,
|
|
429
|
+
checked && checkedIndicatorClassName,
|
|
430
|
+
disabled && checkboxIndicatorDisabledClassName
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
function Tick({
|
|
434
|
+
checkedIconClassName,
|
|
435
|
+
iconClassName
|
|
436
|
+
}) {
|
|
437
|
+
return /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
438
|
+
reactNative.Text,
|
|
439
|
+
{
|
|
440
|
+
className: cn(
|
|
441
|
+
"text-sm font-bold leading-none",
|
|
442
|
+
iconClassName,
|
|
443
|
+
checkedIconClassName
|
|
444
|
+
),
|
|
445
|
+
children: "\u2713"
|
|
446
|
+
}
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
function Checkbox(checkboxProps) {
|
|
450
|
+
const {
|
|
451
|
+
label,
|
|
452
|
+
placeholder,
|
|
453
|
+
variant,
|
|
454
|
+
shape,
|
|
455
|
+
disabled = false,
|
|
456
|
+
className,
|
|
457
|
+
groupClassName,
|
|
458
|
+
optionClassName,
|
|
459
|
+
indicatorClassName,
|
|
460
|
+
checkedIndicatorClassName,
|
|
461
|
+
checkedIconClassName,
|
|
462
|
+
labelClassName
|
|
463
|
+
} = checkboxProps;
|
|
464
|
+
const { shape: resolvedShape, variant: resolvedVariant, label: resolvedLabel } = useResolvedCheckboxConfig({
|
|
465
|
+
label,
|
|
466
|
+
placeholder,
|
|
467
|
+
variant,
|
|
468
|
+
shape
|
|
469
|
+
});
|
|
470
|
+
const {
|
|
471
|
+
isMulti,
|
|
472
|
+
multiField,
|
|
473
|
+
multiMeta,
|
|
474
|
+
multiHelpers,
|
|
475
|
+
singleField,
|
|
476
|
+
singleMeta,
|
|
477
|
+
singleHelpers
|
|
478
|
+
} = useCheckboxFieldState(checkboxProps);
|
|
479
|
+
const variantStyles = resolveNativeCheckboxVariantStyles(resolvedVariant);
|
|
480
|
+
const activeMeta = isMulti ? multiMeta : singleMeta;
|
|
481
|
+
const multiProps = isMultiCheckbox(checkboxProps) ? checkboxProps : null;
|
|
482
|
+
const singleChecked = singleField.value;
|
|
483
|
+
const errorText = activeMeta.touched && typeof activeMeta.error === "string" ? activeMeta.error : null;
|
|
484
|
+
return /* @__PURE__ */ jsxRuntime$1.jsxs(reactNative.View, { className: cn(checkboxGroupClassName, groupClassName), children: [
|
|
485
|
+
!isMulti && /* @__PURE__ */ jsxRuntime$1.jsxs(
|
|
486
|
+
reactNative.Pressable,
|
|
487
|
+
{
|
|
488
|
+
accessibilityRole: "checkbox",
|
|
489
|
+
accessibilityState: {
|
|
490
|
+
checked: singleChecked,
|
|
491
|
+
disabled
|
|
492
|
+
},
|
|
493
|
+
className: cn(checkboxOptionRowClassName, optionClassName),
|
|
494
|
+
disabled,
|
|
495
|
+
onPress: () => singleHelpers.setValue(!singleChecked),
|
|
496
|
+
children: [
|
|
497
|
+
/* @__PURE__ */ jsxRuntime$1.jsx(
|
|
498
|
+
reactNative.View,
|
|
499
|
+
{
|
|
500
|
+
className: getIndicatorClassName({
|
|
501
|
+
checked: singleChecked,
|
|
502
|
+
className,
|
|
503
|
+
disabled,
|
|
504
|
+
indicatorClassName,
|
|
505
|
+
checkedIndicatorClassName,
|
|
506
|
+
resolvedShape,
|
|
507
|
+
variantCheckedClassName: variantStyles.checkedClassName
|
|
508
|
+
}),
|
|
509
|
+
children: singleChecked ? /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
510
|
+
Tick,
|
|
511
|
+
{
|
|
512
|
+
checkedIconClassName,
|
|
513
|
+
iconClassName: variantStyles.iconClassName
|
|
514
|
+
}
|
|
515
|
+
) : null
|
|
516
|
+
}
|
|
517
|
+
),
|
|
518
|
+
resolvedLabel ? /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.Text, { className: cn(checkboxLabelClassName, labelClassName), children: resolvedLabel }) : null
|
|
519
|
+
]
|
|
520
|
+
}
|
|
521
|
+
),
|
|
522
|
+
isMulti && multiProps?.options.map((option) => {
|
|
523
|
+
const values = multiField.value ?? [];
|
|
524
|
+
const checked = values.includes(option.value);
|
|
525
|
+
const optionDisabled = disabled || option.disabled === true;
|
|
526
|
+
return /* @__PURE__ */ jsxRuntime$1.jsxs(
|
|
527
|
+
reactNative.Pressable,
|
|
528
|
+
{
|
|
529
|
+
accessibilityRole: "checkbox",
|
|
530
|
+
accessibilityState: {
|
|
531
|
+
checked,
|
|
532
|
+
disabled: optionDisabled
|
|
533
|
+
},
|
|
534
|
+
className: cn(checkboxOptionRowClassName, optionClassName),
|
|
535
|
+
disabled: optionDisabled,
|
|
536
|
+
onPress: () => multiHelpers.setValue(
|
|
537
|
+
checked ? values.filter((value) => value !== option.value) : [...values, option.value]
|
|
538
|
+
),
|
|
539
|
+
children: [
|
|
540
|
+
/* @__PURE__ */ jsxRuntime$1.jsx(
|
|
541
|
+
reactNative.View,
|
|
542
|
+
{
|
|
543
|
+
className: getIndicatorClassName({
|
|
544
|
+
checked,
|
|
545
|
+
className,
|
|
546
|
+
disabled: optionDisabled,
|
|
547
|
+
indicatorClassName,
|
|
548
|
+
checkedIndicatorClassName,
|
|
549
|
+
resolvedShape,
|
|
550
|
+
variantCheckedClassName: variantStyles.checkedClassName
|
|
551
|
+
}),
|
|
552
|
+
children: checked ? /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
553
|
+
Tick,
|
|
554
|
+
{
|
|
555
|
+
checkedIconClassName,
|
|
556
|
+
iconClassName: variantStyles.iconClassName
|
|
557
|
+
}
|
|
558
|
+
) : null
|
|
559
|
+
}
|
|
560
|
+
),
|
|
561
|
+
/* @__PURE__ */ jsxRuntime$1.jsx(
|
|
562
|
+
reactNative.Text,
|
|
563
|
+
{
|
|
564
|
+
className: cn(
|
|
565
|
+
checkboxLabelClassName,
|
|
566
|
+
optionDisabled && "opacity-60",
|
|
567
|
+
labelClassName
|
|
568
|
+
),
|
|
569
|
+
children: option.label
|
|
570
|
+
}
|
|
571
|
+
)
|
|
572
|
+
]
|
|
573
|
+
},
|
|
574
|
+
option.value
|
|
575
|
+
);
|
|
576
|
+
}),
|
|
577
|
+
errorText ? /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.Text, { className: "px-2 py-1 text-sm font-medium text-eui-danger-500", children: errorText }) : null
|
|
578
|
+
] });
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
// src/components/data-entry/input/input-label/base/InputLabel.styles.ts
|
|
582
|
+
var inputLabelStaticClassName = "pointer-events-none select-none px-0 text-[13.5px] leading-none text-[#6B7280]";
|
|
583
|
+
var inputLabelBaseClassName = "pointer-events-none absolute left-3 z-10 select-none bg-white/95 px-1 font-medium leading-none dark:bg-eui-dark-800";
|
|
584
|
+
var inputLabelErrorClassName = "text-[#6B7280]";
|
|
585
|
+
var inputLabelDisabledClassName = "opacity-60";
|
|
586
|
+
var nativeInputLabelColors = {
|
|
587
|
+
default: "#6B7280",
|
|
588
|
+
disabled: "#9CA3AF"
|
|
589
|
+
};
|
|
590
|
+
var nativeInputLabelStyle = {
|
|
591
|
+
left: 12,
|
|
592
|
+
position: "absolute",
|
|
593
|
+
zIndex: 10
|
|
594
|
+
};
|
|
595
|
+
var nativeInputLabelMetrics = {
|
|
596
|
+
floatingFontSize: 12,
|
|
597
|
+
floatingTop: 6,
|
|
598
|
+
restingFontSize: 16,
|
|
599
|
+
restingTop: 18
|
|
600
|
+
};
|
|
601
|
+
function getLabelColor({ disabled }) {
|
|
602
|
+
if (disabled) {
|
|
603
|
+
return nativeInputLabelColors.disabled;
|
|
604
|
+
}
|
|
605
|
+
return nativeInputLabelColors.default;
|
|
606
|
+
}
|
|
607
|
+
function InputLabel({
|
|
608
|
+
text,
|
|
609
|
+
children,
|
|
610
|
+
className,
|
|
611
|
+
floating,
|
|
612
|
+
errored = false,
|
|
613
|
+
disabled = false,
|
|
614
|
+
animatedValue
|
|
615
|
+
}) {
|
|
616
|
+
const isFloatingLabel = typeof floating === "boolean";
|
|
617
|
+
const progress = animatedValue;
|
|
618
|
+
const animatedStyle = progress ? {
|
|
619
|
+
fontSize: progress.interpolate({
|
|
620
|
+
inputRange: [0, 1],
|
|
621
|
+
outputRange: [
|
|
622
|
+
nativeInputLabelMetrics.restingFontSize,
|
|
623
|
+
nativeInputLabelMetrics.floatingFontSize
|
|
624
|
+
]
|
|
625
|
+
}),
|
|
626
|
+
lineHeight: progress.interpolate({
|
|
627
|
+
inputRange: [0, 1],
|
|
628
|
+
outputRange: [
|
|
629
|
+
nativeInputLabelMetrics.restingFontSize,
|
|
630
|
+
nativeInputLabelMetrics.floatingFontSize
|
|
631
|
+
]
|
|
632
|
+
}),
|
|
633
|
+
top: progress.interpolate({
|
|
634
|
+
inputRange: [0, 1],
|
|
635
|
+
outputRange: [
|
|
636
|
+
nativeInputLabelMetrics.restingTop,
|
|
637
|
+
nativeInputLabelMetrics.floatingTop
|
|
638
|
+
]
|
|
639
|
+
})
|
|
640
|
+
} : {
|
|
641
|
+
fontSize: floating === true ? nativeInputLabelMetrics.floatingFontSize : nativeInputLabelMetrics.restingFontSize,
|
|
642
|
+
lineHeight: floating === true ? nativeInputLabelMetrics.floatingFontSize : nativeInputLabelMetrics.restingFontSize,
|
|
643
|
+
top: floating === true ? nativeInputLabelMetrics.floatingTop : nativeInputLabelMetrics.restingTop
|
|
644
|
+
};
|
|
645
|
+
return /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
646
|
+
reactNative.Animated.Text,
|
|
647
|
+
{
|
|
648
|
+
className: cn(
|
|
649
|
+
isFloatingLabel ? inputLabelBaseClassName : inputLabelStaticClassName,
|
|
650
|
+
isFloatingLabel && "bg-transparent px-0 dark:bg-transparent",
|
|
651
|
+
errored && inputLabelErrorClassName,
|
|
652
|
+
disabled && inputLabelDisabledClassName,
|
|
653
|
+
className
|
|
654
|
+
),
|
|
655
|
+
style: [
|
|
656
|
+
isFloatingLabel ? nativeInputLabelStyle : null,
|
|
657
|
+
isFloatingLabel ? animatedStyle : null,
|
|
658
|
+
{
|
|
659
|
+
color: getLabelColor({ disabled }),
|
|
660
|
+
includeFontPadding: false
|
|
661
|
+
}
|
|
662
|
+
],
|
|
663
|
+
children: text || children
|
|
664
|
+
}
|
|
665
|
+
);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// src/components/data-entry/input/input-response/base/InputResponse.styles.ts
|
|
669
|
+
var inputResponseBaseClassName = "px-2 pt-1.5 text-sm font-medium";
|
|
670
|
+
var inputResponseVariants = textVariants;
|
|
671
|
+
function InputResponse({
|
|
672
|
+
name,
|
|
673
|
+
visibility = false,
|
|
674
|
+
variant = "default",
|
|
675
|
+
className,
|
|
676
|
+
message
|
|
677
|
+
}) {
|
|
678
|
+
const [mounted, setMounted] = react.useState(Boolean(visibility));
|
|
679
|
+
const progress = react.useRef(new reactNative.Animated.Value(visibility ? 1 : 0)).current;
|
|
680
|
+
react.useEffect(() => {
|
|
681
|
+
if (visibility) {
|
|
682
|
+
setMounted(true);
|
|
683
|
+
}
|
|
684
|
+
reactNative.Animated.timing(progress, {
|
|
685
|
+
duration: visibility ? 180 : 120,
|
|
686
|
+
easing: visibility ? reactNative.Easing.out(reactNative.Easing.cubic) : reactNative.Easing.in(reactNative.Easing.cubic),
|
|
687
|
+
toValue: visibility ? 1 : 0,
|
|
688
|
+
useNativeDriver: true
|
|
689
|
+
}).start(() => {
|
|
690
|
+
if (!visibility) {
|
|
691
|
+
setMounted(false);
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
}, [progress, visibility]);
|
|
695
|
+
if (!mounted) {
|
|
696
|
+
return null;
|
|
697
|
+
}
|
|
698
|
+
const animatedStyle = {
|
|
699
|
+
opacity: progress,
|
|
700
|
+
transform: [
|
|
701
|
+
{
|
|
702
|
+
translateY: progress.interpolate({
|
|
703
|
+
inputRange: [0, 1],
|
|
704
|
+
outputRange: [6, 0]
|
|
705
|
+
})
|
|
706
|
+
}
|
|
707
|
+
]
|
|
708
|
+
};
|
|
709
|
+
const content = message ?? /* @__PURE__ */ jsxRuntime$1.jsx(formik.ErrorMessage, { name, children: (errorMessage) => String(errorMessage) });
|
|
710
|
+
return /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.Animated.View, { className: "w-full", style: animatedStyle, children: /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
711
|
+
reactNative.Text,
|
|
712
|
+
{
|
|
713
|
+
className: cn(
|
|
714
|
+
inputResponseBaseClassName,
|
|
715
|
+
inputResponseVariants[variant],
|
|
716
|
+
className
|
|
717
|
+
),
|
|
718
|
+
style: { includeFontPadding: false },
|
|
719
|
+
children: content
|
|
720
|
+
}
|
|
721
|
+
) });
|
|
722
|
+
}
|
|
723
|
+
function resolveInputType({
|
|
724
|
+
passwordVisible,
|
|
725
|
+
type
|
|
726
|
+
}) {
|
|
727
|
+
return type === "password" && passwordVisible ? "text" : type;
|
|
728
|
+
}
|
|
729
|
+
function useResolvedInputConfig({
|
|
730
|
+
label,
|
|
731
|
+
placeholder,
|
|
732
|
+
shape,
|
|
733
|
+
type = "text"
|
|
734
|
+
}) {
|
|
735
|
+
const eui = useEUIConfig();
|
|
736
|
+
return {
|
|
737
|
+
shape: shape ?? eui?.config?.global?.shape ?? "square",
|
|
738
|
+
type,
|
|
739
|
+
label: label ?? placeholder
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
function useInputFieldState(props) {
|
|
743
|
+
const [field, meta, helpers] = formik.useField(props);
|
|
744
|
+
return {
|
|
745
|
+
field,
|
|
746
|
+
meta,
|
|
747
|
+
helpers
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// src/components/data-entry/input/input/base/Input.styles.ts
|
|
752
|
+
var inputShapes = shapes;
|
|
753
|
+
var inputRootClassName = "relative w-full";
|
|
754
|
+
var inputFrameClassName = "relative h-14 w-full overflow-hidden border bg-white/95 px-3 dark:bg-eui-dark-800";
|
|
755
|
+
var inputFrameIdleClassName = "border-gray-300 hover:border-gray-400 dark:border-eui-dark-300 dark:hover:border-eui-dark-200";
|
|
756
|
+
var inputFrameActiveClassName = "border-eui-secondary-600";
|
|
757
|
+
var inputFrameErrorClassName = "border-eui-danger-500";
|
|
758
|
+
var inputFrameDisabledClassName = "cursor-not-allowed opacity-60";
|
|
759
|
+
var inputControlClassName = "w-full bg-transparent pt-5 pb-2 text-base font-medium text-gray-950 dark:text-gray-50";
|
|
760
|
+
|
|
761
|
+
// src/components/data-entry/input/input/native/Input.native.styles.ts
|
|
762
|
+
var nativeInputControlClassName = "h-full";
|
|
763
|
+
var nativePasswordInputClassName = "pr-16";
|
|
764
|
+
var nativePasswordToggleClassName = "absolute right-3 top-[18px] h-5 items-center justify-center";
|
|
765
|
+
var nativePasswordToggleTextClassName = "text-xs font-semibold text-eui-dark-200";
|
|
766
|
+
var nativeInputControlStyle = {
|
|
767
|
+
backgroundColor: "transparent",
|
|
768
|
+
borderBottomWidth: 0,
|
|
769
|
+
borderColor: "transparent",
|
|
770
|
+
borderWidth: 0,
|
|
771
|
+
includeFontPadding: false,
|
|
772
|
+
outlineColor: "transparent",
|
|
773
|
+
outlineStyle: "none",
|
|
774
|
+
textAlignVertical: "center"
|
|
775
|
+
};
|
|
776
|
+
function Input(inputProps) {
|
|
777
|
+
const {
|
|
778
|
+
type = "text",
|
|
779
|
+
label,
|
|
780
|
+
placeholder,
|
|
781
|
+
inputClassName,
|
|
782
|
+
labelClassName,
|
|
783
|
+
responseClassName,
|
|
784
|
+
step: _step,
|
|
785
|
+
shape,
|
|
786
|
+
disabled = false,
|
|
787
|
+
className,
|
|
788
|
+
onBlur,
|
|
789
|
+
onFocus,
|
|
790
|
+
onChange: _onChange,
|
|
791
|
+
..._props
|
|
792
|
+
} = inputProps;
|
|
793
|
+
const { field, helpers, meta } = useInputFieldState(inputProps);
|
|
794
|
+
const [focused, setFocused] = react.useState(false);
|
|
795
|
+
const [passwordVisible, setPasswordVisible] = react.useState(false);
|
|
796
|
+
const labelProgress = react.useRef(
|
|
797
|
+
new reactNative.Animated.Value(String(field.value ?? "").length > 0 ? 1 : 0)
|
|
798
|
+
).current;
|
|
799
|
+
const {
|
|
800
|
+
shape: resolvedShape,
|
|
801
|
+
type: resolvedType,
|
|
802
|
+
label: resolvedLabel
|
|
803
|
+
} = useResolvedInputConfig({
|
|
804
|
+
label,
|
|
805
|
+
placeholder,
|
|
806
|
+
shape,
|
|
807
|
+
type
|
|
808
|
+
});
|
|
809
|
+
const inputType = resolveInputType({
|
|
810
|
+
passwordVisible,
|
|
811
|
+
type: resolvedType
|
|
812
|
+
});
|
|
813
|
+
const hasError = Boolean(meta.touched && meta.error);
|
|
814
|
+
const errorText = hasError && typeof meta.error === "string" ? meta.error : null;
|
|
815
|
+
const hasValue = String(field.value ?? "").length > 0;
|
|
816
|
+
const floating = focused || hasValue;
|
|
817
|
+
react.useEffect(() => {
|
|
818
|
+
reactNative.Animated.timing(labelProgress, {
|
|
819
|
+
duration: 190,
|
|
820
|
+
easing: reactNative.Easing.out(reactNative.Easing.cubic),
|
|
821
|
+
toValue: floating ? 1 : 0,
|
|
822
|
+
useNativeDriver: false
|
|
823
|
+
}).start();
|
|
824
|
+
}, [floating, labelProgress]);
|
|
825
|
+
const handleBlur = (event) => {
|
|
826
|
+
setFocused(false);
|
|
827
|
+
helpers.setTouched(true);
|
|
828
|
+
onBlur?.(event);
|
|
829
|
+
};
|
|
830
|
+
const handleFocus = (event) => {
|
|
831
|
+
setFocused(true);
|
|
832
|
+
onFocus?.(event);
|
|
833
|
+
};
|
|
834
|
+
return /* @__PURE__ */ jsxRuntime$1.jsxs(reactNative.View, { className: inputRootClassName, children: [
|
|
835
|
+
/* @__PURE__ */ jsxRuntime$1.jsx(
|
|
836
|
+
reactNative.View,
|
|
837
|
+
{
|
|
838
|
+
className: cn(
|
|
839
|
+
inputFrameClassName,
|
|
840
|
+
hasError ? inputFrameErrorClassName : focused ? inputFrameActiveClassName : inputFrameIdleClassName,
|
|
841
|
+
inputShapes[resolvedShape],
|
|
842
|
+
disabled && inputFrameDisabledClassName,
|
|
843
|
+
className
|
|
844
|
+
),
|
|
845
|
+
children: /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
846
|
+
reactNative.TextInput,
|
|
847
|
+
{
|
|
848
|
+
accessibilityLabel: resolvedLabel,
|
|
849
|
+
className: cn(
|
|
850
|
+
inputControlClassName,
|
|
851
|
+
nativeInputControlClassName,
|
|
852
|
+
type === "password" && nativePasswordInputClassName,
|
|
853
|
+
inputClassName
|
|
854
|
+
),
|
|
855
|
+
editable: !disabled,
|
|
856
|
+
keyboardType: inputType === "number" ? "numeric" : "default",
|
|
857
|
+
onBlur: handleBlur,
|
|
858
|
+
onChangeText: (value) => helpers.setValue(value),
|
|
859
|
+
onFocus: handleFocus,
|
|
860
|
+
placeholder: "",
|
|
861
|
+
secureTextEntry: type === "password" && !passwordVisible,
|
|
862
|
+
style: nativeInputControlStyle,
|
|
863
|
+
underlineColorAndroid: "transparent",
|
|
864
|
+
value: field.value ?? ""
|
|
865
|
+
}
|
|
866
|
+
)
|
|
867
|
+
}
|
|
868
|
+
),
|
|
869
|
+
/* @__PURE__ */ jsxRuntime$1.jsx(
|
|
870
|
+
InputLabel,
|
|
871
|
+
{
|
|
872
|
+
animatedValue: labelProgress,
|
|
873
|
+
disabled,
|
|
874
|
+
errored: hasError,
|
|
875
|
+
floating,
|
|
876
|
+
text: resolvedLabel,
|
|
877
|
+
className: labelClassName
|
|
878
|
+
}
|
|
879
|
+
),
|
|
880
|
+
type === "password" ? /* @__PURE__ */ jsxRuntime$1.jsx(
|
|
881
|
+
reactNative.Pressable,
|
|
882
|
+
{
|
|
883
|
+
accessibilityRole: "button",
|
|
884
|
+
accessibilityLabel: passwordVisible ? "Hide password" : "Show password",
|
|
885
|
+
className: nativePasswordToggleClassName,
|
|
886
|
+
disabled,
|
|
887
|
+
onPress: () => setPasswordVisible((current) => !current),
|
|
888
|
+
children: /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.Text, { className: nativePasswordToggleTextClassName, children: passwordVisible ? "Hide" : "Show" })
|
|
889
|
+
}
|
|
890
|
+
) : null,
|
|
891
|
+
/* @__PURE__ */ jsxRuntime$1.jsx(
|
|
892
|
+
InputResponse,
|
|
893
|
+
{
|
|
894
|
+
message: errorText,
|
|
895
|
+
name: field.name,
|
|
896
|
+
visibility: Boolean(errorText),
|
|
897
|
+
variant: "danger",
|
|
898
|
+
className: responseClassName
|
|
899
|
+
}
|
|
900
|
+
)
|
|
901
|
+
] });
|
|
902
|
+
}
|
|
345
903
|
|
|
346
904
|
exports.Button = Button_native_default;
|
|
905
|
+
exports.Checkbox = Checkbox;
|
|
347
906
|
exports.EUIProvider = EUIProvider;
|
|
907
|
+
exports.Input = Input;
|
|
908
|
+
exports.InputLabel = InputLabel;
|
|
909
|
+
exports.InputResponse = InputResponse;
|
|
348
910
|
exports.resolveWithGlobal = resolveWithGlobal;
|
|
349
911
|
exports.useEUIConfig = useEUIConfig;
|
|
350
912
|
//# sourceMappingURL=index.native.js.map
|