asta-ui 0.4.0 → 0.5.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/dist/base/checkbox-aui-052.d.ts +2 -0
- package/dist/base/checkbox-aui-052.js +9 -0
- package/dist/base/checkbox-aui-053.d.ts +2 -0
- package/dist/base/checkbox-aui-053.js +9 -0
- package/dist/base/checkbox-aui-054.d.ts +2 -0
- package/dist/base/checkbox-aui-054.js +9 -0
- package/dist/base/combobox-aui-046.d.ts +2 -0
- package/dist/base/combobox-aui-046.js +9 -0
- package/dist/base/combobox-aui-047.d.ts +2 -0
- package/dist/base/combobox-aui-047.js +9 -0
- package/dist/base/date-picker-aui-050.d.ts +2 -0
- package/dist/base/date-picker-aui-050.js +9 -0
- package/dist/base/date-picker-aui-051.d.ts +2 -0
- package/dist/base/date-picker-aui-051.js +9 -0
- package/dist/base/input-aui-029.d.ts +2 -0
- package/dist/base/input-aui-029.js +9 -0
- package/dist/base/input-aui-030.d.ts +2 -0
- package/dist/base/input-aui-030.js +9 -0
- package/dist/base/input-aui-031.d.ts +2 -0
- package/dist/base/input-aui-031.js +9 -0
- package/dist/base/input-aui-032.d.ts +2 -0
- package/dist/base/input-aui-032.js +11 -0
- package/dist/base/input-aui-033.d.ts +2 -0
- package/dist/base/input-aui-033.js +11 -0
- package/dist/base/input-aui-034.d.ts +2 -0
- package/dist/base/input-aui-034.js +9 -0
- package/dist/base/otp-input-aui-041.d.ts +2 -0
- package/dist/base/otp-input-aui-041.js +9 -0
- package/dist/base/otp-input-aui-042.d.ts +2 -0
- package/dist/base/otp-input-aui-042.js +9 -0
- package/dist/base/password-input-aui-039.d.ts +2 -0
- package/dist/base/password-input-aui-039.js +9 -0
- package/dist/base/password-input-aui-040.d.ts +2 -0
- package/dist/base/password-input-aui-040.js +11 -0
- package/dist/base/radio-group-aui-055.d.ts +2 -0
- package/dist/base/radio-group-aui-055.js +9 -0
- package/dist/base/radio-group-aui-056.d.ts +2 -0
- package/dist/base/radio-group-aui-056.js +9 -0
- package/dist/base/radio-group-aui-057.d.ts +2 -0
- package/dist/base/radio-group-aui-057.js +9 -0
- package/dist/base/select-aui-043.d.ts +2 -0
- package/dist/base/select-aui-043.js +9 -0
- package/dist/base/select-aui-044.d.ts +2 -0
- package/dist/base/select-aui-044.js +9 -0
- package/dist/base/select-aui-045.d.ts +2 -0
- package/dist/base/select-aui-045.js +9 -0
- package/dist/base/slider-aui-061.d.ts +2 -0
- package/dist/base/slider-aui-061.js +9 -0
- package/dist/base/slider-aui-062.d.ts +2 -0
- package/dist/base/slider-aui-062.js +9 -0
- package/dist/base/slider-aui-063.d.ts +2 -0
- package/dist/base/slider-aui-063.js +9 -0
- package/dist/base/switch-aui-058.d.ts +2 -0
- package/dist/base/switch-aui-058.js +9 -0
- package/dist/base/switch-aui-059.d.ts +2 -0
- package/dist/base/switch-aui-059.js +9 -0
- package/dist/base/switch-aui-060.d.ts +2 -0
- package/dist/base/switch-aui-060.js +9 -0
- package/dist/base/tag-input-aui-048.d.ts +2 -0
- package/dist/base/tag-input-aui-048.js +9 -0
- package/dist/base/tag-input-aui-049.d.ts +2 -0
- package/dist/base/tag-input-aui-049.js +9 -0
- package/dist/base/textarea-aui-035.d.ts +2 -0
- package/dist/base/textarea-aui-035.js +9 -0
- package/dist/base/textarea-aui-036.d.ts +2 -0
- package/dist/base/textarea-aui-036.js +9 -0
- package/dist/base/textarea-aui-037.d.ts +2 -0
- package/dist/base/textarea-aui-037.js +9 -0
- package/dist/base/textarea-aui-038.d.ts +2 -0
- package/dist/base/textarea-aui-038.js +11 -0
- package/dist/base.js +239 -21
- package/dist/checkbox-aui-052.d.ts +2 -0
- package/dist/checkbox-aui-052.js +9 -0
- package/dist/checkbox-aui-053.d.ts +2 -0
- package/dist/checkbox-aui-053.js +9 -0
- package/dist/checkbox-aui-054.d.ts +2 -0
- package/dist/checkbox-aui-054.js +9 -0
- package/dist/chunk-2LSUWI2Z.js +180 -0
- package/dist/chunk-3XMVXIOF.js +267 -0
- package/dist/chunk-4YNUJFTL.js +165 -0
- package/dist/chunk-5OHHGQV6.js +175 -0
- package/dist/chunk-5TMFFW3Y.js +149 -0
- package/dist/chunk-ANZANDQM.js +107 -0
- package/dist/chunk-BIYNJDPD.js +158 -0
- package/dist/chunk-BV5HEXB5.js +339 -0
- package/dist/chunk-CDQNLDO6.js +156 -0
- package/dist/chunk-CZCZB5YP.js +142 -0
- package/dist/chunk-D6LGKFZH.js +140 -0
- package/dist/chunk-EKPTPTKK.js +93 -0
- package/dist/chunk-EVCUN45S.js +167 -0
- package/dist/chunk-FGQPCDXI.js +136 -0
- package/dist/chunk-GERWW3CA.js +311 -0
- package/dist/chunk-GJ3R6IZL.js +232 -0
- package/dist/chunk-HVFB44HO.js +219 -0
- package/dist/chunk-I2WXKWTQ.js +151 -0
- package/dist/chunk-J6GK2V2C.js +252 -0
- package/dist/chunk-JVTDNOHQ.js +173 -0
- package/dist/chunk-K5PWBSVO.js +200 -0
- package/dist/chunk-KQCXQY5K.js +155 -0
- package/dist/chunk-KXWC2UHE.js +308 -0
- package/dist/chunk-NICNFGHT.js +138 -0
- package/dist/chunk-P3USWDWR.js +331 -0
- package/dist/chunk-QYI7LQBQ.js +208 -0
- package/dist/chunk-U6N7CZYN.js +305 -0
- package/dist/chunk-UMDVPRJW.js +117 -0
- package/dist/chunk-VPZP6TCT.js +155 -0
- package/dist/chunk-VVAL2JZJ.js +332 -0
- package/dist/chunk-VWYHP4SB.js +154 -0
- package/dist/chunk-W7RITVDV.js +182 -0
- package/dist/chunk-WSTQ6WZO.js +193 -0
- package/dist/chunk-Z5GNX2S3.js +171 -0
- package/dist/chunk-ZBF2UYXP.js +225 -0
- package/dist/combobox-aui-046.d.ts +2 -0
- package/dist/combobox-aui-046.js +9 -0
- package/dist/combobox-aui-047.d.ts +2 -0
- package/dist/combobox-aui-047.js +9 -0
- package/dist/date-picker-aui-050.d.ts +2 -0
- package/dist/date-picker-aui-050.js +9 -0
- package/dist/date-picker-aui-051.d.ts +2 -0
- package/dist/date-picker-aui-051.js +9 -0
- package/dist/index.js +239 -21
- package/dist/input-aui-029.d.ts +2 -0
- package/dist/input-aui-029.js +9 -0
- package/dist/input-aui-030.d.ts +2 -0
- package/dist/input-aui-030.js +9 -0
- package/dist/input-aui-031.d.ts +2 -0
- package/dist/input-aui-031.js +9 -0
- package/dist/input-aui-032.d.ts +2 -0
- package/dist/input-aui-032.js +11 -0
- package/dist/input-aui-033.d.ts +2 -0
- package/dist/input-aui-033.js +11 -0
- package/dist/input-aui-034.d.ts +2 -0
- package/dist/input-aui-034.js +9 -0
- package/dist/otp-input-aui-041.d.ts +2 -0
- package/dist/otp-input-aui-041.js +9 -0
- package/dist/otp-input-aui-042.d.ts +2 -0
- package/dist/otp-input-aui-042.js +9 -0
- package/dist/password-input-aui-039.d.ts +2 -0
- package/dist/password-input-aui-039.js +9 -0
- package/dist/password-input-aui-040.d.ts +2 -0
- package/dist/password-input-aui-040.js +11 -0
- package/dist/radio-group-aui-055.d.ts +2 -0
- package/dist/radio-group-aui-055.js +9 -0
- package/dist/radio-group-aui-056.d.ts +2 -0
- package/dist/radio-group-aui-056.js +9 -0
- package/dist/radio-group-aui-057.d.ts +2 -0
- package/dist/radio-group-aui-057.js +9 -0
- package/dist/select-aui-043.d.ts +2 -0
- package/dist/select-aui-043.js +9 -0
- package/dist/select-aui-044.d.ts +2 -0
- package/dist/select-aui-044.js +9 -0
- package/dist/select-aui-045.d.ts +2 -0
- package/dist/select-aui-045.js +9 -0
- package/dist/slider-aui-061.d.ts +2 -0
- package/dist/slider-aui-061.js +9 -0
- package/dist/slider-aui-062.d.ts +2 -0
- package/dist/slider-aui-062.js +9 -0
- package/dist/slider-aui-063.d.ts +2 -0
- package/dist/slider-aui-063.js +9 -0
- package/dist/switch-aui-058.d.ts +2 -0
- package/dist/switch-aui-058.js +9 -0
- package/dist/switch-aui-059.d.ts +2 -0
- package/dist/switch-aui-059.js +9 -0
- package/dist/switch-aui-060.d.ts +2 -0
- package/dist/switch-aui-060.js +9 -0
- package/dist/tag-input-aui-048.d.ts +2 -0
- package/dist/tag-input-aui-048.js +9 -0
- package/dist/tag-input-aui-049.d.ts +2 -0
- package/dist/tag-input-aui-049.js +9 -0
- package/dist/textarea-aui-035.d.ts +2 -0
- package/dist/textarea-aui-035.js +9 -0
- package/dist/textarea-aui-036.d.ts +2 -0
- package/dist/textarea-aui-036.js +9 -0
- package/dist/textarea-aui-037.d.ts +2 -0
- package/dist/textarea-aui-037.js +9 -0
- package/dist/textarea-aui-038.d.ts +2 -0
- package/dist/textarea-aui-038.js +11 -0
- package/dist/types/components/kit/variants/checkbox-aui-052.d.ts +29 -0
- package/dist/types/components/kit/variants/checkbox-aui-053.d.ts +24 -0
- package/dist/types/components/kit/variants/checkbox-aui-054.d.ts +33 -0
- package/dist/types/components/kit/variants/combobox-aui-046.d.ts +23 -0
- package/dist/types/components/kit/variants/combobox-aui-047.d.ts +24 -0
- package/dist/types/components/kit/variants/date-picker-aui-050.d.ts +26 -0
- package/dist/types/components/kit/variants/date-picker-aui-051.d.ts +23 -0
- package/dist/types/components/kit/variants/input-aui-029.d.ts +21 -0
- package/dist/types/components/kit/variants/input-aui-030.d.ts +29 -0
- package/dist/types/components/kit/variants/input-aui-031.d.ts +24 -0
- package/dist/types/components/kit/variants/input-aui-032.d.ts +36 -0
- package/dist/types/components/kit/variants/input-aui-033.d.ts +23 -0
- package/dist/types/components/kit/variants/input-aui-034.d.ts +29 -0
- package/dist/types/components/kit/variants/otp-input-aui-041.d.ts +20 -0
- package/dist/types/components/kit/variants/otp-input-aui-042.d.ts +23 -0
- package/dist/types/components/kit/variants/password-input-aui-039.d.ts +16 -0
- package/dist/types/components/kit/variants/password-input-aui-040.d.ts +24 -0
- package/dist/types/components/kit/variants/radio-group-aui-055.d.ts +27 -0
- package/dist/types/components/kit/variants/radio-group-aui-056.d.ts +28 -0
- package/dist/types/components/kit/variants/radio-group-aui-057.d.ts +26 -0
- package/dist/types/components/kit/variants/select-aui-043.d.ts +29 -0
- package/dist/types/components/kit/variants/select-aui-044.d.ts +24 -0
- package/dist/types/components/kit/variants/select-aui-045.d.ts +29 -0
- package/dist/types/components/kit/variants/slider-aui-061.d.ts +20 -0
- package/dist/types/components/kit/variants/slider-aui-062.d.ts +24 -0
- package/dist/types/components/kit/variants/slider-aui-063.d.ts +17 -0
- package/dist/types/components/kit/variants/switch-aui-058.d.ts +24 -0
- package/dist/types/components/kit/variants/switch-aui-059.d.ts +20 -0
- package/dist/types/components/kit/variants/switch-aui-060.d.ts +15 -0
- package/dist/types/components/kit/variants/tag-input-aui-048.d.ts +16 -0
- package/dist/types/components/kit/variants/tag-input-aui-049.d.ts +15 -0
- package/dist/types/components/kit/variants/textarea-aui-035.d.ts +19 -0
- package/dist/types/components/kit/variants/textarea-aui-036.d.ts +23 -0
- package/dist/types/components/kit/variants/textarea-aui-037.d.ts +30 -0
- package/dist/types/components/kit/variants/textarea-aui-038.d.ts +28 -0
- package/dist/types/packages/asta-ui/src/base/checkbox-aui-052.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/checkbox-aui-053.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/checkbox-aui-054.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/combobox-aui-046.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/combobox-aui-047.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/date-picker-aui-050.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/date-picker-aui-051.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/input-aui-029.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/input-aui-030.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/input-aui-031.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/input-aui-032.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/input-aui-033.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/input-aui-034.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/otp-input-aui-041.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/otp-input-aui-042.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/password-input-aui-039.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/password-input-aui-040.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/radio-group-aui-055.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/radio-group-aui-056.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/radio-group-aui-057.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/select-aui-043.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/select-aui-044.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/select-aui-045.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/slider-aui-061.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/slider-aui-062.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/slider-aui-063.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/switch-aui-058.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/switch-aui-059.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/switch-aui-060.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/tag-input-aui-048.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/tag-input-aui-049.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/textarea-aui-035.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/textarea-aui-036.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/textarea-aui-037.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base/textarea-aui-038.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/base.d.ts +70 -0
- package/dist/types/packages/asta-ui/src/checkbox-aui-052.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/checkbox-aui-053.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/checkbox-aui-054.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/combobox-aui-046.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/combobox-aui-047.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/date-picker-aui-050.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/date-picker-aui-051.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/index.d.ts +70 -0
- package/dist/types/packages/asta-ui/src/input-aui-029.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/input-aui-030.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/input-aui-031.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/input-aui-032.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/input-aui-033.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/input-aui-034.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/otp-input-aui-041.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/otp-input-aui-042.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/password-input-aui-039.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/password-input-aui-040.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/radio-group-aui-055.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/radio-group-aui-056.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/radio-group-aui-057.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/select-aui-043.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/select-aui-044.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/select-aui-045.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/slider-aui-061.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/slider-aui-062.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/slider-aui-063.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/switch-aui-058.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/switch-aui-059.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/switch-aui-060.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/tag-input-aui-048.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/tag-input-aui-049.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/textarea-aui-035.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/textarea-aui-036.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/textarea-aui-037.d.ts +2 -0
- package/dist/types/packages/asta-ui/src/textarea-aui-038.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// components/kit/variants/tag-input-aui-048.tsx
|
|
4
|
+
import { useId, useRef, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var cx = (...c) => c.filter(Boolean).join(" ");
|
|
7
|
+
var EASE = "cubic-bezier(.16,1,.3,1)";
|
|
8
|
+
var CSS = `
|
|
9
|
+
@keyframes aui048-in { 0% { opacity: 0; transform: scale(.7) } 60% { opacity: 1; transform: scale(1.04) } 100% { transform: none } }
|
|
10
|
+
@keyframes aui048-shake { 0%,100% { transform: none } 20% { transform: translateX(-5px) } 40% { transform: translateX(4px) } 60% { transform: translateX(-3px) } 80% { transform: translateX(2px) } }
|
|
11
|
+
@keyframes aui048-bad { 0% { opacity: 0; transform: scale(.7) } 30% { opacity: 1; transform: none } 45% { transform: translateX(-5px) } 60% { transform: translateX(4px) } 75% { transform: translateX(-2px) } 100% { transform: none } }
|
|
12
|
+
@keyframes aui048-line { from { opacity: 0; transform: translateY(5px) } }
|
|
13
|
+
@media (prefers-reduced-motion: reduce) { .aui048 *, .aui048 { animation: none !important; transition: none !important } }
|
|
14
|
+
`;
|
|
15
|
+
var isEmailAddress = (v) => /^[^\s@,;<>]+@[^\s@,;<>]+\.[a-z]{2,}$/i.test(v);
|
|
16
|
+
var clean = (raw) => {
|
|
17
|
+
const m = raw.match(/<([^>]+)>/);
|
|
18
|
+
return (m ? m[1] : raw).trim().replace(/^mailto:/i, "").toLowerCase();
|
|
19
|
+
};
|
|
20
|
+
function EmailTagInput({
|
|
21
|
+
value,
|
|
22
|
+
defaultValue = [],
|
|
23
|
+
onChange,
|
|
24
|
+
domain = "astabyte.com",
|
|
25
|
+
max = 20,
|
|
26
|
+
label = "To",
|
|
27
|
+
placeholder = "Add people by email",
|
|
28
|
+
name,
|
|
29
|
+
className
|
|
30
|
+
}) {
|
|
31
|
+
const [inner, setInner] = useState(defaultValue);
|
|
32
|
+
const list = value ?? inner;
|
|
33
|
+
const [text, setText] = useState("");
|
|
34
|
+
const [shake, setShake] = useState(null);
|
|
35
|
+
const input = useRef(null);
|
|
36
|
+
const id = useId();
|
|
37
|
+
const set = (next) => {
|
|
38
|
+
if (value === void 0) setInner(next);
|
|
39
|
+
onChange?.(next);
|
|
40
|
+
};
|
|
41
|
+
const add = (parts) => {
|
|
42
|
+
const next = [...list];
|
|
43
|
+
for (const p of parts) {
|
|
44
|
+
const e = clean(p);
|
|
45
|
+
if (!e) continue;
|
|
46
|
+
if (next.includes(e)) {
|
|
47
|
+
setShake((s) => ({ email: e, n: (s?.n ?? 0) + 1 }));
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (next.length >= max) break;
|
|
51
|
+
next.push(e);
|
|
52
|
+
}
|
|
53
|
+
if (next.length !== list.length) set(next);
|
|
54
|
+
setText("");
|
|
55
|
+
};
|
|
56
|
+
const remove = (e) => {
|
|
57
|
+
set(list.filter((x) => x !== e));
|
|
58
|
+
input.current?.focus();
|
|
59
|
+
};
|
|
60
|
+
const edit = (e) => {
|
|
61
|
+
set(list.filter((x) => x !== e));
|
|
62
|
+
setText(e);
|
|
63
|
+
input.current?.focus();
|
|
64
|
+
};
|
|
65
|
+
const bad = list.filter((e) => !isEmailAddress(e));
|
|
66
|
+
const mates = list.filter((e) => isEmailAddress(e) && e.endsWith(`@${domain}`)).length;
|
|
67
|
+
const guests = list.length - bad.length - mates;
|
|
68
|
+
const status = bad.length ? `${bad.length} ${bad.length === 1 ? "address needs" : "addresses need"} a fix. Click to edit.` : list.length ? [mates && `${mates} ${mates === 1 ? "teammate" : "teammates"}`, guests && `${guests} ${guests === 1 ? "guest" : "guests"}`].filter(Boolean).join(" \xB7 ") : "Separate with a comma, a space or paste a list";
|
|
69
|
+
return /* @__PURE__ */ jsxs("div", { className: cx("aui048 w-full", className), children: [
|
|
70
|
+
/* @__PURE__ */ jsx("style", { href: "asta-aui048", precedence: "asta", children: CSS }),
|
|
71
|
+
/* @__PURE__ */ jsxs(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
onClick: () => input.current?.focus(),
|
|
75
|
+
className: cx(
|
|
76
|
+
"flex min-h-12 w-full cursor-text flex-wrap items-center gap-1.5 rounded-[11px] bg-paper py-1.5 pl-3 pr-1.5 transition-shadow duration-300",
|
|
77
|
+
"shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_12%,transparent)] hover:shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_22%,transparent)]",
|
|
78
|
+
"focus-within:!shadow-[inset_0_0_0_1px_var(--brand),0_0_0_4px_color-mix(in_srgb,var(--brand)_14%,transparent)]"
|
|
79
|
+
),
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "mr-1 font-mono text-[11px] uppercase tracking-[0.08em] text-mute", children: label }),
|
|
82
|
+
/* @__PURE__ */ jsx("ul", { className: "contents", "aria-label": "Recipients", children: list.map((e) => {
|
|
83
|
+
const ok = isEmailAddress(e);
|
|
84
|
+
const mate = ok && e.endsWith(`@${domain}`);
|
|
85
|
+
const shaking = shake?.email === e;
|
|
86
|
+
const [local, host] = e.split("@");
|
|
87
|
+
return /* @__PURE__ */ jsxs(
|
|
88
|
+
"li",
|
|
89
|
+
{
|
|
90
|
+
className: cx(
|
|
91
|
+
"flex h-8 max-w-full items-center gap-1.5 rounded-[8px] pl-1 pr-0.5 text-[13px] transition-colors duration-200",
|
|
92
|
+
ok ? "bg-paper-2 text-ink" : "bg-paper text-ink shadow-[inset_0_0_0_1px_var(--ink)] [background-image:repeating-linear-gradient(135deg,color-mix(in_srgb,var(--ink)_6%,transparent)_0_4px,transparent_4px_8px)]"
|
|
93
|
+
),
|
|
94
|
+
style: { animation: shaking ? `aui048-shake .42s ${EASE}` : ok ? `aui048-in .45s ${EASE} both` : `aui048-bad .7s ${EASE} both` },
|
|
95
|
+
children: [
|
|
96
|
+
ok ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx("flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-[10.5px] font-semibold uppercase", mate ? "bg-brand text-white" : "bg-paper text-ink shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_16%,transparent)]"), children: local[0] }) : /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-ink text-[12px] font-semibold text-paper", children: "!" }),
|
|
97
|
+
/* @__PURE__ */ jsxs(
|
|
98
|
+
"button",
|
|
99
|
+
{
|
|
100
|
+
type: "button",
|
|
101
|
+
tabIndex: ok ? -1 : 0,
|
|
102
|
+
disabled: ok,
|
|
103
|
+
onClick: (ev) => {
|
|
104
|
+
ev.stopPropagation();
|
|
105
|
+
edit(e);
|
|
106
|
+
},
|
|
107
|
+
"aria-label": ok ? e : `Fix ${e}, not a valid email`,
|
|
108
|
+
"aria-invalid": !ok || void 0,
|
|
109
|
+
className: "min-w-0 truncate rounded-[4px] text-left outline-none focus-visible:ring-2 focus-visible:ring-brand/50 disabled:cursor-text",
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: local }),
|
|
112
|
+
host !== void 0 && /* @__PURE__ */ jsxs("span", { className: "text-mute", children: [
|
|
113
|
+
"@",
|
|
114
|
+
host
|
|
115
|
+
] })
|
|
116
|
+
]
|
|
117
|
+
}
|
|
118
|
+
),
|
|
119
|
+
ok && !mate && /* @__PURE__ */ jsx("span", { className: "rounded-[4px] bg-paper px-1 font-mono text-[9.5px] uppercase tracking-[0.06em] text-mute", children: "Guest" }),
|
|
120
|
+
/* @__PURE__ */ jsx(
|
|
121
|
+
"button",
|
|
122
|
+
{
|
|
123
|
+
type: "button",
|
|
124
|
+
onClick: (ev) => {
|
|
125
|
+
ev.stopPropagation();
|
|
126
|
+
remove(e);
|
|
127
|
+
},
|
|
128
|
+
"aria-label": `Remove ${e}`,
|
|
129
|
+
className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-[5px] text-mute outline-none transition-colors hover:bg-[color-mix(in_srgb,var(--ink)_8%,transparent)] hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50",
|
|
130
|
+
children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "h-3 w-3", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "m4.5 4.5 7 7M11.5 4.5l-7 7" }) })
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
shaking ? `${e}-${shake.n}` : e
|
|
136
|
+
);
|
|
137
|
+
}) }),
|
|
138
|
+
/* @__PURE__ */ jsx(
|
|
139
|
+
"input",
|
|
140
|
+
{
|
|
141
|
+
ref: input,
|
|
142
|
+
id,
|
|
143
|
+
type: "text",
|
|
144
|
+
value: text,
|
|
145
|
+
inputMode: "email",
|
|
146
|
+
autoComplete: "off",
|
|
147
|
+
spellCheck: false,
|
|
148
|
+
placeholder: list.length ? "" : placeholder,
|
|
149
|
+
"aria-describedby": `${id}-status`,
|
|
150
|
+
onChange: (e) => {
|
|
151
|
+
const v = e.target.value;
|
|
152
|
+
if (/[,;\s]/.test(v)) add(v.split(/[,;\s]+/));
|
|
153
|
+
else setText(v);
|
|
154
|
+
},
|
|
155
|
+
onPaste: (e) => {
|
|
156
|
+
const v = e.clipboardData.getData("text");
|
|
157
|
+
if (/[,;\s]/.test(v.trim())) {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
add(v.split(/[,;\n]+|\s+(?![^<]*>)/));
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
onKeyDown: (e) => {
|
|
163
|
+
if ((e.key === "Enter" || e.key === "Tab" && text.trim()) && text.trim()) {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
add([text]);
|
|
166
|
+
} else if (e.key === "Backspace" && !text && list.length) {
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
edit(list[list.length - 1]);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
onBlur: () => text.trim() && add([text]),
|
|
172
|
+
className: "h-8 min-w-[5rem] flex-1 bg-transparent px-1 text-[14px] text-ink outline-none placeholder:text-mute"
|
|
173
|
+
}
|
|
174
|
+
)
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
),
|
|
178
|
+
name && list.filter(isEmailAddress).map((e) => /* @__PURE__ */ jsx("input", { type: "hidden", name, value: e }, e)),
|
|
179
|
+
/* @__PURE__ */ jsx("p", { id: `${id}-status`, "aria-live": "polite", className: "mt-2 flex h-5 items-center gap-1.5 overflow-hidden pl-1 text-[12px] text-mute", children: /* @__PURE__ */ jsxs("span", { className: cx("flex items-center gap-1.5", bad.length > 0 && "text-ink"), style: { animation: `aui048-line .4s ${EASE} both` }, children: [
|
|
180
|
+
bad.length > 0 && /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", className: "h-3.5 w-3.5 shrink-0", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", "aria-hidden": true, children: [
|
|
181
|
+
/* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6.25" }),
|
|
182
|
+
/* @__PURE__ */ jsx("path", { d: "M8 4.8v3.6M8 11h.01" })
|
|
183
|
+
] }),
|
|
184
|
+
status
|
|
185
|
+
] }, status) })
|
|
186
|
+
] });
|
|
187
|
+
}
|
|
188
|
+
var tag_input_aui_048_default = EmailTagInput;
|
|
189
|
+
|
|
190
|
+
export {
|
|
191
|
+
EmailTagInput,
|
|
192
|
+
tag_input_aui_048_default
|
|
193
|
+
};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// components/kit/variants/slider-aui-062.tsx
|
|
4
|
+
import { useId, useRef, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var cx = (...c) => c.filter(Boolean).join(" ");
|
|
7
|
+
var EASE = "cubic-bezier(.16,1,.3,1)";
|
|
8
|
+
var SPRING = "cubic-bezier(.34,1.56,.64,1)";
|
|
9
|
+
var CSS = `
|
|
10
|
+
@keyframes aui062-rise { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
|
|
11
|
+
@media (prefers-reduced-motion: reduce) { .aui062 * { animation: none !important; transition: none !important } }
|
|
12
|
+
`;
|
|
13
|
+
var rise = (i) => ({ animation: `aui062-rise .6s ${EASE} ${80 + i * 55}ms both` });
|
|
14
|
+
var HALF = 12;
|
|
15
|
+
var STEPS = [
|
|
16
|
+
{ label: "50 GB", price: 4, note: "30 days of version history" },
|
|
17
|
+
{ label: "100 GB", price: 6, note: "30 days of version history" },
|
|
18
|
+
{ label: "250 GB", price: 10, note: "90 days of version history" },
|
|
19
|
+
{ label: "500 GB", price: 16, note: "90 days of version history" },
|
|
20
|
+
{ label: "1 TB", price: 24, note: "One year of version history" },
|
|
21
|
+
{ label: "2 TB", price: 40, note: "One year of history and legal hold" }
|
|
22
|
+
];
|
|
23
|
+
function Roll({ value }) {
|
|
24
|
+
const chars = String(value).split("");
|
|
25
|
+
return /* @__PURE__ */ jsx("span", { className: "inline-flex tabular-nums", "aria-hidden": true, children: chars.map((ch, i) => /* @__PURE__ */ jsx("span", { className: "relative inline-block h-[1em] w-[0.6em] overflow-hidden", children: /* @__PURE__ */ jsx("span", { className: "absolute inset-x-0 top-0 flex flex-col transition-transform duration-500", style: { transform: `translateY(${-Number(ch) * 10}%)`, transitionTimingFunction: EASE, transitionDelay: `${(chars.length - 1 - i) * 40}ms` }, children: Array.from({ length: 10 }, (_, n) => /* @__PURE__ */ jsx("span", { className: "block h-[1em] text-center leading-[1em]", children: n }, n)) }) }, chars.length - i)) });
|
|
26
|
+
}
|
|
27
|
+
function StepSlider({ steps = STEPS, value, defaultValue = 3, onValueChange, label = "Storage", currency = "$", disabled, name, className }) {
|
|
28
|
+
const uid = useId();
|
|
29
|
+
const last = steps.length - 1;
|
|
30
|
+
const [inner, setInner] = useState(defaultValue);
|
|
31
|
+
const index = Math.min(last, Math.max(0, value ?? inner));
|
|
32
|
+
const [pos, setPos] = useState(null);
|
|
33
|
+
const track = useRef(null);
|
|
34
|
+
const thumb = useRef(null);
|
|
35
|
+
const box = useRef(null);
|
|
36
|
+
const p = pos ?? index;
|
|
37
|
+
const near = Math.round(p);
|
|
38
|
+
const k = last ? p / last : 0;
|
|
39
|
+
const step = steps[near];
|
|
40
|
+
const set = (i) => {
|
|
41
|
+
const n = Math.min(last, Math.max(0, i));
|
|
42
|
+
if (n === index) return;
|
|
43
|
+
if (value === void 0) setInner(n);
|
|
44
|
+
onValueChange?.(n);
|
|
45
|
+
};
|
|
46
|
+
const fromX = (x) => {
|
|
47
|
+
const b = box.current;
|
|
48
|
+
if (!b) return index;
|
|
49
|
+
return Math.min(1, Math.max(0, (x - b.left) / b.width)) * last;
|
|
50
|
+
};
|
|
51
|
+
const down = (e) => {
|
|
52
|
+
if (disabled || !track.current) return;
|
|
53
|
+
const r = track.current.getBoundingClientRect();
|
|
54
|
+
box.current = { left: r.left + HALF, width: r.width - HALF * 2 };
|
|
55
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
56
|
+
const f = fromX(e.clientX);
|
|
57
|
+
setPos(f);
|
|
58
|
+
set(Math.round(f));
|
|
59
|
+
thumb.current?.focus({ preventScroll: true });
|
|
60
|
+
};
|
|
61
|
+
const move = (e) => {
|
|
62
|
+
if (pos === null) return;
|
|
63
|
+
const f = fromX(e.clientX);
|
|
64
|
+
setPos(f);
|
|
65
|
+
set(Math.round(f));
|
|
66
|
+
};
|
|
67
|
+
const up = () => {
|
|
68
|
+
if (pos === null) return;
|
|
69
|
+
set(Math.round(pos));
|
|
70
|
+
setPos(null);
|
|
71
|
+
};
|
|
72
|
+
const key = (e) => {
|
|
73
|
+
const map = { ArrowRight: index + 1, ArrowUp: index + 1, ArrowLeft: index - 1, ArrowDown: index - 1, Home: 0, End: last, PageUp: index + 2, PageDown: index - 2 };
|
|
74
|
+
if (!(e.key in map)) return;
|
|
75
|
+
e.preventDefault();
|
|
76
|
+
set(map[e.key]);
|
|
77
|
+
};
|
|
78
|
+
const motion = pos !== null ? "none" : `transform 520ms ${SPRING}`;
|
|
79
|
+
return /* @__PURE__ */ jsxs(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
className: cx(
|
|
83
|
+
"aui062 w-full max-w-[460px] rounded-[14px] bg-paper p-5 sm:p-6",
|
|
84
|
+
"shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent),0_1px_2px_rgb(0_0_0/0.04),0_18px_40px_-20px_rgb(0_0_0/0.25)]",
|
|
85
|
+
disabled && "opacity-60",
|
|
86
|
+
className
|
|
87
|
+
),
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ jsx("style", { href: "asta-aui062", precedence: "asta", children: CSS }),
|
|
90
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-end justify-between gap-4", style: rise(0), children: [
|
|
91
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
92
|
+
/* @__PURE__ */ jsxs("p", { id: `${uid}-l`, className: "font-mono text-[11px] uppercase tracking-[0.08em] text-mute", children: [
|
|
93
|
+
"Astabyte Drive \xB7 ",
|
|
94
|
+
label
|
|
95
|
+
] }),
|
|
96
|
+
/* @__PURE__ */ jsx("span", { className: "relative mt-2 block h-[40px] overflow-hidden text-[36px] font-medium tracking-[-0.045em] text-ink", "aria-live": "polite", children: /* @__PURE__ */ jsx("span", { className: "absolute inset-x-0 top-0 flex flex-col transition-transform duration-500", style: { transform: `translateY(${-near * 40}px)`, transitionTimingFunction: EASE }, children: steps.map((s, i) => /* @__PURE__ */ jsx("span", { "aria-hidden": i !== near, className: "block h-[40px] whitespace-nowrap leading-[40px]", children: s.label }, s.label)) }) })
|
|
97
|
+
] }),
|
|
98
|
+
/* @__PURE__ */ jsxs("p", { className: "shrink-0 pb-1 text-right", children: [
|
|
99
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-start justify-end text-[22px] font-medium leading-none tracking-[-0.03em] text-ink", children: [
|
|
100
|
+
/* @__PURE__ */ jsx("span", { className: "mr-0.5 mt-[2px] text-[12px] tracking-normal text-mute", children: currency }),
|
|
101
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: step.price }),
|
|
102
|
+
/* @__PURE__ */ jsx(Roll, { value: step.price })
|
|
103
|
+
] }),
|
|
104
|
+
/* @__PURE__ */ jsx("span", { className: "mt-1 block text-[11.5px] text-mute", children: "per month" })
|
|
105
|
+
] })
|
|
106
|
+
] }),
|
|
107
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 h-5 text-[13px] text-mute", style: rise(1), children: /* @__PURE__ */ jsx("span", { className: "block", style: { animation: `aui062-rise .4s ${EASE} both` }, children: step.note }, near) }),
|
|
108
|
+
/* @__PURE__ */ jsxs("div", { className: "relative mt-6 select-none", style: rise(2), children: [
|
|
109
|
+
/* @__PURE__ */ jsxs("div", { ref: track, onPointerDown: down, onPointerMove: move, onPointerUp: up, onPointerCancel: up, className: cx("relative flex h-7 touch-none items-center", disabled ? "pointer-events-none" : "cursor-pointer"), children: [
|
|
110
|
+
/* @__PURE__ */ jsx("div", { className: "relative h-2 w-full overflow-hidden rounded-full bg-[color-mix(in_srgb,var(--ink)_9%,transparent)]", children: /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0", style: { left: HALF, right: HALF, transform: `translateX(${k * 100}%)`, transition: motion }, children: /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 right-full w-[4000px] bg-brand" }) }) }),
|
|
111
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": true, className: "pointer-events-none absolute inset-y-0", style: { left: HALF, right: HALF }, children: steps.map((s, i) => /* @__PURE__ */ jsxs("span", { className: "absolute top-1/2 h-1 w-1 -translate-x-1/2 -translate-y-1/2 rounded-full", style: { left: `${i / last * 100}%` }, children: [
|
|
112
|
+
/* @__PURE__ */ jsx("span", { className: "absolute inset-0 rounded-full bg-[color-mix(in_srgb,var(--ink)_28%,transparent)]" }),
|
|
113
|
+
/* @__PURE__ */ jsx("span", { className: "absolute inset-0 rounded-full bg-white transition-opacity duration-200", style: { opacity: i <= p ? 0.9 : 0 } })
|
|
114
|
+
] }, s.label)) }),
|
|
115
|
+
/* @__PURE__ */ jsx("div", { className: "pointer-events-none absolute inset-y-0", style: { left: HALF, right: HALF, transform: `translateX(${k * 100}%)`, transition: motion }, children: /* @__PURE__ */ jsxs(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
ref: thumb,
|
|
119
|
+
role: "slider",
|
|
120
|
+
tabIndex: disabled ? -1 : 0,
|
|
121
|
+
"aria-labelledby": `${uid}-l`,
|
|
122
|
+
"aria-valuemin": 0,
|
|
123
|
+
"aria-valuemax": last,
|
|
124
|
+
"aria-valuenow": index,
|
|
125
|
+
"aria-valuetext": `${steps[index].label}, ${currency}${steps[index].price} per month`,
|
|
126
|
+
"aria-disabled": disabled || void 0,
|
|
127
|
+
onKeyDown: key,
|
|
128
|
+
className: "group/th pointer-events-auto absolute left-0 top-1/2 h-6 w-6 -translate-x-1/2 -translate-y-1/2 rounded-full outline-none",
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ jsx(
|
|
131
|
+
"span",
|
|
132
|
+
{
|
|
133
|
+
className: "absolute inset-0 rounded-[8px] bg-white shadow-[0_0_0_1px_color-mix(in_srgb,var(--ink)_12%,transparent),0_1px_3px_rgb(0_0_0/0.2),0_6px_14px_-4px_rgb(0_0_0/0.25)] transition-transform duration-300 group-focus-visible/th:shadow-[0_0_0_4px_color-mix(in_srgb,var(--brand)_30%,transparent),0_1px_3px_rgb(0_0_0/0.2)]",
|
|
134
|
+
style: { transform: pos !== null ? "scale(1.1) rotate(45deg)" : "rotate(45deg)", transitionTimingFunction: SPRING }
|
|
135
|
+
}
|
|
136
|
+
),
|
|
137
|
+
/* @__PURE__ */ jsx("span", { className: "absolute inset-0 grid place-items-center", children: /* @__PURE__ */ jsxs("span", { className: "flex gap-[3px]", children: [
|
|
138
|
+
/* @__PURE__ */ jsx("span", { className: "h-2 w-px bg-[color-mix(in_srgb,var(--ink)_35%,transparent)]" }),
|
|
139
|
+
/* @__PURE__ */ jsx("span", { className: "h-2 w-px bg-[color-mix(in_srgb,var(--ink)_35%,transparent)]" })
|
|
140
|
+
] }) })
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
) })
|
|
144
|
+
] }),
|
|
145
|
+
name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: steps[index].label }),
|
|
146
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": true, className: "relative mt-2 h-4", style: { marginLeft: HALF, marginRight: HALF }, children: steps.map((s, i) => {
|
|
147
|
+
const on = i === near;
|
|
148
|
+
return /* @__PURE__ */ jsx(
|
|
149
|
+
"button",
|
|
150
|
+
{
|
|
151
|
+
type: "button",
|
|
152
|
+
tabIndex: -1,
|
|
153
|
+
onClick: () => set(i),
|
|
154
|
+
className: cx("absolute top-0 whitespace-nowrap text-[11px] tabular-nums transition-[transform,opacity,color] duration-300", on ? "font-medium text-ink" : "text-mute hover:text-ink"),
|
|
155
|
+
style: { left: `${i / last * 100}%`, transform: `translateX(-50%) translateY(${on ? -2 : 0}px) scale(${on ? 1.08 : 1})`, transitionTimingFunction: EASE },
|
|
156
|
+
children: s.label
|
|
157
|
+
},
|
|
158
|
+
s.label
|
|
159
|
+
);
|
|
160
|
+
}) })
|
|
161
|
+
] })
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
var slider_aui_062_default = StepSlider;
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
StepSlider,
|
|
170
|
+
slider_aui_062_default
|
|
171
|
+
};
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// components/kit/variants/input-aui-034.tsx
|
|
4
|
+
import { useId, useRef, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var cx = (...c) => c.filter(Boolean).join(" ");
|
|
7
|
+
var EASE = "cubic-bezier(.16,1,.3,1)";
|
|
8
|
+
var CSS = `
|
|
9
|
+
@keyframes aui034-new { from { opacity: 0; transform: translateY(40%) } to { opacity: 1; transform: none } }
|
|
10
|
+
@keyframes aui034-blink { 0%, 45% { opacity: 1 } 55%, 100% { opacity: 0 } }
|
|
11
|
+
@keyframes aui034-rise { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
|
|
12
|
+
@media (prefers-reduced-motion: reduce) { .aui034 * { animation: none !important; transition: none !important } }
|
|
13
|
+
`;
|
|
14
|
+
var CURRENCIES = [
|
|
15
|
+
{ code: "USD", symbol: "$", rate: 1 },
|
|
16
|
+
{ code: "EUR", symbol: "\u20AC", rate: 0.92 },
|
|
17
|
+
{ code: "GBP", symbol: "\xA3", rate: 0.79 }
|
|
18
|
+
];
|
|
19
|
+
var fmt = (raw) => {
|
|
20
|
+
const [int, dec] = raw.split(".");
|
|
21
|
+
const grouped = (int || "0").replace(/^0+(?=\d)/, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
22
|
+
return dec === void 0 ? grouped : `${grouped}.${dec}`;
|
|
23
|
+
};
|
|
24
|
+
var toRaw = (n) => Number.isInteger(n) ? String(n) : n.toFixed(2).replace(/0+$/, "").replace(/\.$/, "");
|
|
25
|
+
var money = (n) => n.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
26
|
+
function Digit({ d, delay }) {
|
|
27
|
+
return /* @__PURE__ */ jsx("span", { className: "relative inline-block h-[1em] overflow-hidden", style: { animation: `aui034-new .45s ${EASE} both` }, children: /* @__PURE__ */ jsx("span", { className: "flex flex-col transition-transform duration-700", style: { transform: `translateY(${-d * 10}%)`, transitionTimingFunction: EASE, transitionDelay: `${delay}ms` }, children: Array.from({ length: 10 }, (_, n) => /* @__PURE__ */ jsx("span", { className: "block h-[1em] leading-[1em]", children: n }, n)) }) });
|
|
28
|
+
}
|
|
29
|
+
function AmountInput({
|
|
30
|
+
label = "Amount",
|
|
31
|
+
value,
|
|
32
|
+
defaultValue = 0,
|
|
33
|
+
onChange,
|
|
34
|
+
currencies = CURRENCIES,
|
|
35
|
+
currency: currencyProp,
|
|
36
|
+
onCurrencyChange,
|
|
37
|
+
quick = [50, 100, 250, 500],
|
|
38
|
+
max = 1e4,
|
|
39
|
+
note = "No fee \xB7 Arrives in your Astabyte balance instantly",
|
|
40
|
+
className
|
|
41
|
+
}) {
|
|
42
|
+
const id = useId();
|
|
43
|
+
const input = useRef(null);
|
|
44
|
+
const [inner, setInner] = useState(toRaw(defaultValue));
|
|
45
|
+
const [code, setCode] = useState(currencies[0].code);
|
|
46
|
+
const [focused, setFocused] = useState(false);
|
|
47
|
+
const [capped, setCapped] = useState(false);
|
|
48
|
+
const cur = currencies.find((c) => c.code === (currencyProp ?? code)) ?? currencies[0];
|
|
49
|
+
const ci = currencies.indexOf(cur);
|
|
50
|
+
const raw = value !== void 0 && Number(inner || 0) !== value ? toRaw(value) : inner;
|
|
51
|
+
const num = Number(raw || 0);
|
|
52
|
+
const commit = (next) => {
|
|
53
|
+
let r = next;
|
|
54
|
+
let hit = false;
|
|
55
|
+
if (Number(r || 0) > max) {
|
|
56
|
+
r = String(max);
|
|
57
|
+
hit = true;
|
|
58
|
+
}
|
|
59
|
+
setCapped(hit);
|
|
60
|
+
setInner(r);
|
|
61
|
+
onChange?.(Number(r || 0), cur.code);
|
|
62
|
+
};
|
|
63
|
+
const onType = (v) => {
|
|
64
|
+
let s = v.replace(/[^\d.]/g, "");
|
|
65
|
+
const dot = s.indexOf(".");
|
|
66
|
+
if (dot >= 0) s = s.slice(0, dot + 1) + s.slice(dot + 1).replace(/\./g, "").slice(0, 2);
|
|
67
|
+
s = s.replace(/^0+(?=\d)/, "").slice(0, 9);
|
|
68
|
+
commit(s);
|
|
69
|
+
};
|
|
70
|
+
const switchTo = (i) => {
|
|
71
|
+
const next = currencies[(i + currencies.length) % currencies.length];
|
|
72
|
+
if (next.code === cur.code) return;
|
|
73
|
+
const converted = Math.round(num / cur.rate * next.rate * 100) / 100;
|
|
74
|
+
if (currencyProp === void 0) setCode(next.code);
|
|
75
|
+
onCurrencyChange?.(next.code);
|
|
76
|
+
setCapped(false);
|
|
77
|
+
setInner(toRaw(converted));
|
|
78
|
+
onChange?.(converted, next.code);
|
|
79
|
+
};
|
|
80
|
+
const onSwitchKey = (e) => {
|
|
81
|
+
if (e.key === "ArrowRight" || e.key === "ArrowDown") {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
switchTo(ci + 1);
|
|
84
|
+
} else if (e.key === "ArrowLeft" || e.key === "ArrowUp") {
|
|
85
|
+
e.preventDefault();
|
|
86
|
+
switchTo(ci - 1);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const shown = fmt(raw);
|
|
90
|
+
const chars = shown.split("");
|
|
91
|
+
const len = chars.length;
|
|
92
|
+
const dotAt = shown.indexOf(".");
|
|
93
|
+
const size = len > 9 ? "text-[38px]" : len > 7 ? "text-[46px]" : "text-[56px]";
|
|
94
|
+
const hasDot = raw.includes(".");
|
|
95
|
+
const ghost = hasDot ? "00".slice(raw.split(".")[1].length) : ".00";
|
|
96
|
+
return /* @__PURE__ */ jsxs(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
className: cx(
|
|
100
|
+
"aui034 relative isolate w-full overflow-hidden rounded-[14px] bg-ink p-5 text-paper sm:p-6",
|
|
101
|
+
"shadow-[0_1px_2px_rgb(0_0_0/0.1),0_30px_60px_-28px_rgb(0_0_0/0.55)]",
|
|
102
|
+
className
|
|
103
|
+
),
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ jsx("style", { href: "asta-input-aui-034", precedence: "asta", children: CSS }),
|
|
106
|
+
/* @__PURE__ */ jsx(
|
|
107
|
+
"div",
|
|
108
|
+
{
|
|
109
|
+
"aria-hidden": true,
|
|
110
|
+
className: "pointer-events-none absolute -top-24 left-1/2 -z-10 h-56 w-[120%] -translate-x-1/2 rounded-full bg-[radial-gradient(closest-side,color-mix(in_srgb,var(--brand)_38%,transparent),transparent)] transition-opacity duration-500",
|
|
111
|
+
style: { opacity: focused ? 1 : 0.55 }
|
|
112
|
+
}
|
|
113
|
+
),
|
|
114
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", style: { animation: `aui034-rise .6s ${EASE} .1s both` }, children: [
|
|
115
|
+
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "truncate whitespace-nowrap font-mono text-[11px] uppercase tracking-[0.08em] text-[color-mix(in_srgb,var(--paper)_60%,transparent)]", children: label }),
|
|
116
|
+
/* @__PURE__ */ jsxs(
|
|
117
|
+
"div",
|
|
118
|
+
{
|
|
119
|
+
role: "radiogroup",
|
|
120
|
+
"aria-label": "Currency",
|
|
121
|
+
className: "relative grid rounded-[8px] bg-[color-mix(in_srgb,var(--paper)_8%,transparent)] p-0.5",
|
|
122
|
+
style: { gridTemplateColumns: `repeat(${currencies.length}, 3rem)` },
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ jsx(
|
|
125
|
+
"span",
|
|
126
|
+
{
|
|
127
|
+
"aria-hidden": true,
|
|
128
|
+
className: "absolute bottom-0.5 left-0.5 top-0.5 w-12 rounded-[6px] bg-paper transition-transform duration-500",
|
|
129
|
+
style: { transform: `translateX(${ci * 100}%)`, transitionTimingFunction: EASE }
|
|
130
|
+
}
|
|
131
|
+
),
|
|
132
|
+
currencies.map((c, i) => /* @__PURE__ */ jsx(
|
|
133
|
+
"button",
|
|
134
|
+
{
|
|
135
|
+
type: "button",
|
|
136
|
+
role: "radio",
|
|
137
|
+
"aria-checked": i === ci,
|
|
138
|
+
tabIndex: i === ci ? 0 : -1,
|
|
139
|
+
onClick: () => switchTo(i),
|
|
140
|
+
onKeyDown: onSwitchKey,
|
|
141
|
+
className: cx(
|
|
142
|
+
"relative h-7 rounded-[6px] text-[12px] font-medium outline-none transition-colors duration-300 focus-visible:ring-2 focus-visible:ring-brand",
|
|
143
|
+
i === ci ? "text-ink" : "text-[color-mix(in_srgb,var(--paper)_60%,transparent)] hover:text-paper"
|
|
144
|
+
),
|
|
145
|
+
children: c.code
|
|
146
|
+
},
|
|
147
|
+
c.code
|
|
148
|
+
))
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
] }),
|
|
153
|
+
/* @__PURE__ */ jsxs("div", { className: "relative mt-5 cursor-text", style: { animation: `aui034-rise .6s ${EASE} .16s both` }, children: [
|
|
154
|
+
/* @__PURE__ */ jsxs("div", { "aria-hidden": true, className: cx("flex items-start font-medium leading-none tracking-[-0.045em] tabular-nums", size), children: [
|
|
155
|
+
/* @__PURE__ */ jsx("span", { className: "mr-1 mt-[0.12em] text-[0.46em] tracking-normal text-[color-mix(in_srgb,var(--paper)_55%,transparent)]", children: cur.symbol }),
|
|
156
|
+
/* @__PURE__ */ jsx("span", { className: "inline-flex", children: chars.map((ch, i) => {
|
|
157
|
+
const key = dotAt < 0 || i < dotAt ? `i${(dotAt < 0 ? len : dotAt) - i}` : `f${i - dotAt}`;
|
|
158
|
+
return /\d/.test(ch) ? /* @__PURE__ */ jsx(Digit, { d: Number(ch), delay: Math.max(0, (dotAt < 0 ? len : dotAt) - i - 1) * 35 }, key) : /* @__PURE__ */ jsx("span", { className: "inline-block h-[1em] leading-[1em]", children: ch }, key + ch);
|
|
159
|
+
}) }),
|
|
160
|
+
/* @__PURE__ */ jsxs("span", { className: "relative inline-block h-[1em] leading-[1em] text-[color-mix(in_srgb,var(--paper)_28%,transparent)]", children: [
|
|
161
|
+
/* @__PURE__ */ jsx(
|
|
162
|
+
"span",
|
|
163
|
+
{
|
|
164
|
+
className: "absolute -left-px top-[0.1em] h-[0.8em] w-[2px] rounded-full bg-brand",
|
|
165
|
+
style: { opacity: focused ? void 0 : 0, animation: focused ? "aui034-blink 1.05s steps(1) infinite" : "none" }
|
|
166
|
+
}
|
|
167
|
+
),
|
|
168
|
+
ghost
|
|
169
|
+
] })
|
|
170
|
+
] }),
|
|
171
|
+
/* @__PURE__ */ jsx(
|
|
172
|
+
"input",
|
|
173
|
+
{
|
|
174
|
+
ref: input,
|
|
175
|
+
id,
|
|
176
|
+
inputMode: "decimal",
|
|
177
|
+
autoComplete: "off",
|
|
178
|
+
"aria-label": `${label} in ${cur.code}`,
|
|
179
|
+
"aria-describedby": `${id}-note`,
|
|
180
|
+
value: raw,
|
|
181
|
+
onChange: (e) => onType(e.target.value),
|
|
182
|
+
onFocus: (e) => {
|
|
183
|
+
setFocused(true);
|
|
184
|
+
const el = e.currentTarget;
|
|
185
|
+
el.setSelectionRange(el.value.length, el.value.length);
|
|
186
|
+
},
|
|
187
|
+
onBlur: () => setFocused(false),
|
|
188
|
+
className: "absolute inset-0 h-full w-full cursor-text opacity-0"
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
] }),
|
|
192
|
+
/* @__PURE__ */ jsx("p", { id: `${id}-note`, "aria-live": "polite", className: "mt-3 text-[12.5px] text-[color-mix(in_srgb,var(--paper)_55%,transparent)]", style: { animation: `aui034-rise .6s ${EASE} .22s both` }, children: capped ? `Up to ${cur.symbol}${money(max)} per top-up.` : note }),
|
|
193
|
+
/* @__PURE__ */ jsx("div", { className: "mt-5 grid grid-cols-4 gap-1.5", style: { animation: `aui034-rise .6s ${EASE} .28s both` }, children: quick.map((q) => {
|
|
194
|
+
const on = num === q;
|
|
195
|
+
return /* @__PURE__ */ jsxs(
|
|
196
|
+
"button",
|
|
197
|
+
{
|
|
198
|
+
type: "button",
|
|
199
|
+
"aria-pressed": on,
|
|
200
|
+
onClick: () => {
|
|
201
|
+
commit(String(q));
|
|
202
|
+
input.current?.focus();
|
|
203
|
+
},
|
|
204
|
+
className: cx(
|
|
205
|
+
"h-9 rounded-[8px] text-[13px] font-medium tabular-nums outline-none transition-[background-color,color,transform] duration-300 active:scale-[.96] focus-visible:ring-2 focus-visible:ring-brand",
|
|
206
|
+
on ? "bg-brand text-paper" : "bg-[color-mix(in_srgb,var(--paper)_7%,transparent)] text-[color-mix(in_srgb,var(--paper)_80%,transparent)] hover:-translate-y-px hover:bg-[color-mix(in_srgb,var(--paper)_12%,transparent)]"
|
|
207
|
+
),
|
|
208
|
+
children: [
|
|
209
|
+
cur.symbol,
|
|
210
|
+
q.toLocaleString("en-US")
|
|
211
|
+
]
|
|
212
|
+
},
|
|
213
|
+
q
|
|
214
|
+
);
|
|
215
|
+
}) })
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
var input_aui_034_default = AmountInput;
|
|
221
|
+
|
|
222
|
+
export {
|
|
223
|
+
AmountInput,
|
|
224
|
+
input_aui_034_default
|
|
225
|
+
};
|