asta-ui 0.4.0 → 0.5.0
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,305 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// components/kit/variants/date-picker-aui-050.tsx
|
|
4
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { Fragment, 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 aui050-rise { from { opacity: 0; transform: translateY(8px) } }
|
|
10
|
+
@keyframes aui050-next { from { opacity: 0; transform: translateX(24px) } }
|
|
11
|
+
@keyframes aui050-prev { from { opacity: 0; transform: translateX(-24px) } }
|
|
12
|
+
@keyframes aui050-pop { 0% { opacity: 0; transform: scale(.55) } 60% { opacity: 1; transform: scale(1.08) } 100% { transform: none } }
|
|
13
|
+
@keyframes aui050-tip { from { opacity: 0; transform: translate(-50%, 4px) scale(.9) } }
|
|
14
|
+
@keyframes aui050-roll { from { opacity: 0; transform: translateY(60%) } }
|
|
15
|
+
@media (prefers-reduced-motion: reduce) { .aui050 *, .aui050 { animation: none !important; transition: none !important } }
|
|
16
|
+
`;
|
|
17
|
+
var day0 = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
18
|
+
var addDays = (d, n) => new Date(d.getFullYear(), d.getMonth(), d.getDate() + n);
|
|
19
|
+
var month0 = (d) => new Date(d.getFullYear(), d.getMonth(), 1);
|
|
20
|
+
var addMonths = (d, n) => new Date(d.getFullYear(), d.getMonth() + n, 1);
|
|
21
|
+
var same = (a, b) => !!a && !!b && a.getTime() === b.getTime();
|
|
22
|
+
var key = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
23
|
+
var diff = (a, b) => Math.round((b.getTime() - a.getTime()) / 864e5);
|
|
24
|
+
function Arrow({ dir }) {
|
|
25
|
+
return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "h-4 w-4", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: dir === 1 ? "m6 3.5 4.5 4.5L6 12.5" : "m10 3.5L5.5 8l4.5 4.5" }) });
|
|
26
|
+
}
|
|
27
|
+
function RangeDatePicker({
|
|
28
|
+
value,
|
|
29
|
+
defaultValue,
|
|
30
|
+
onChange,
|
|
31
|
+
min,
|
|
32
|
+
max,
|
|
33
|
+
locale = "en-US",
|
|
34
|
+
weekStartsOn = 1,
|
|
35
|
+
startLabel = "Check-in",
|
|
36
|
+
endLabel = "Check-out",
|
|
37
|
+
unit = "night",
|
|
38
|
+
inclusive = false,
|
|
39
|
+
name,
|
|
40
|
+
className
|
|
41
|
+
}) {
|
|
42
|
+
const [today] = useState(() => day0(/* @__PURE__ */ new Date()));
|
|
43
|
+
const floor = min === null ? void 0 : day0(min ?? today);
|
|
44
|
+
const [inner, setInner] = useState(() => defaultValue ?? { start: addDays(today, 9), end: addDays(today, 14) });
|
|
45
|
+
const raw = value ?? inner;
|
|
46
|
+
const span = { start: raw.start ? day0(raw.start) : null, end: raw.end ? day0(raw.end) : null };
|
|
47
|
+
const [mode, setMode] = useState(span.start && !span.end ? "end" : "start");
|
|
48
|
+
const [view, setView] = useState(() => month0(span.start ?? today));
|
|
49
|
+
const [dir, setDir] = useState(0);
|
|
50
|
+
const [focus, setFocus] = useState(() => span.start ?? today);
|
|
51
|
+
const [hover, setHover] = useState(null);
|
|
52
|
+
const steer = useRef(false);
|
|
53
|
+
const grid = useRef(null);
|
|
54
|
+
const title = useMemo(() => new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }), [locale]);
|
|
55
|
+
const short = useMemo(() => new Intl.DateTimeFormat(locale, { weekday: "short", month: "short", day: "numeric" }), [locale]);
|
|
56
|
+
const full = useMemo(() => new Intl.DateTimeFormat(locale, { weekday: "long", month: "long", day: "numeric", year: "numeric" }), [locale]);
|
|
57
|
+
const weekdays = useMemo(() => {
|
|
58
|
+
const f = new Intl.DateTimeFormat(locale, { weekday: "narrow" });
|
|
59
|
+
const l = new Intl.DateTimeFormat(locale, { weekday: "long" });
|
|
60
|
+
return Array.from({ length: 7 }, (_, i) => {
|
|
61
|
+
const d = new Date(2026, 10, 1 + (i + weekStartsOn) % 7);
|
|
62
|
+
return { s: f.format(d), l: l.format(d) };
|
|
63
|
+
});
|
|
64
|
+
}, [locale, weekStartsOn]);
|
|
65
|
+
const off = (d) => floor && d < floor || max && d > day0(max) || false;
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (steer.current) grid.current?.querySelector(`[data-day="${key(focus)}"]`)?.focus({ preventScroll: true });
|
|
68
|
+
}, [focus, view]);
|
|
69
|
+
const set = (next) => {
|
|
70
|
+
if (value === void 0) setInner(next);
|
|
71
|
+
onChange?.(next);
|
|
72
|
+
};
|
|
73
|
+
const flip = (n) => {
|
|
74
|
+
setDir(n > 0 ? 1 : -1);
|
|
75
|
+
setView((v) => addMonths(v, n));
|
|
76
|
+
};
|
|
77
|
+
const moveTo = (d) => {
|
|
78
|
+
if (off(d)) return;
|
|
79
|
+
if (d < view) flip(-1);
|
|
80
|
+
else if (d >= addMonths(view, 2)) flip(1);
|
|
81
|
+
setFocus(d);
|
|
82
|
+
};
|
|
83
|
+
const pick = (d) => {
|
|
84
|
+
if (off(d)) return;
|
|
85
|
+
setFocus(d);
|
|
86
|
+
if (mode === "start" || !span.start || d < span.start) {
|
|
87
|
+
set({ start: d, end: span.end && span.end > d && mode === "start" ? span.end : null });
|
|
88
|
+
setMode("end");
|
|
89
|
+
} else {
|
|
90
|
+
set({ start: span.start, end: d });
|
|
91
|
+
setMode("start");
|
|
92
|
+
setHover(null);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const onKey = (e) => {
|
|
96
|
+
steer.current = true;
|
|
97
|
+
const dow = (focus.getDay() - weekStartsOn + 7) % 7;
|
|
98
|
+
if (e.key === "ArrowRight") moveTo(addDays(focus, 1));
|
|
99
|
+
else if (e.key === "ArrowLeft") moveTo(addDays(focus, -1));
|
|
100
|
+
else if (e.key === "ArrowDown") moveTo(addDays(focus, 7));
|
|
101
|
+
else if (e.key === "ArrowUp") moveTo(addDays(focus, -7));
|
|
102
|
+
else if (e.key === "Home") moveTo(addDays(focus, -dow));
|
|
103
|
+
else if (e.key === "End") moveTo(addDays(focus, 6 - dow));
|
|
104
|
+
else if (e.key === "PageDown") {
|
|
105
|
+
flip(1);
|
|
106
|
+
setFocus(addDays(focus, 28));
|
|
107
|
+
} else if (e.key === "PageUp") {
|
|
108
|
+
const to = addDays(focus, -28);
|
|
109
|
+
if (off(to)) return;
|
|
110
|
+
flip(-1);
|
|
111
|
+
setFocus(to);
|
|
112
|
+
} else if (e.key === "Enter" || e.key === " ") pick(focus);
|
|
113
|
+
else if (e.key === "Escape" && span.start && !span.end) {
|
|
114
|
+
set({ start: null, end: null });
|
|
115
|
+
setMode("start");
|
|
116
|
+
} else return;
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
};
|
|
119
|
+
const previewEnd = mode === "end" && span.start && !span.end ? hover : null;
|
|
120
|
+
const bandEnd = span.end ?? (previewEnd && span.start && previewEnd > span.start ? previewEnd : null);
|
|
121
|
+
const count = span.start && bandEnd ? diff(span.start, bandEnd) + (inclusive ? 1 : 0) : 0;
|
|
122
|
+
const countText = count ? `${count} ${unit}${count === 1 ? "" : "s"}` : "";
|
|
123
|
+
const canBack = !floor || addMonths(view, -1) >= month0(floor);
|
|
124
|
+
const month = (m, idx) => {
|
|
125
|
+
const lead = (m.getDay() - weekStartsOn + 7) % 7;
|
|
126
|
+
const first = addDays(m, -lead);
|
|
127
|
+
const cells = Array.from({ length: 42 }, (_, i) => addDays(first, i));
|
|
128
|
+
return /* @__PURE__ */ jsxs("div", { className: cx(idx === 1 && "hidden @min-[540px]:block"), children: [
|
|
129
|
+
/* @__PURE__ */ jsx("p", { "aria-live": idx === 0 ? "polite" : void 0, className: "mb-2 text-center text-[13.5px] font-medium tracking-[-0.01em] text-ink", children: title.format(m) }),
|
|
130
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-7", "aria-hidden": true, children: weekdays.map((w) => /* @__PURE__ */ jsx("span", { className: "pb-1 text-center font-mono text-[10.5px] uppercase text-mute", children: w.s }, w.l)) }),
|
|
131
|
+
/* @__PURE__ */ jsx("div", { role: "grid", "aria-label": title.format(m), className: "grid grid-cols-7 gap-y-0.5", children: cells.map((d) => {
|
|
132
|
+
if (d.getMonth() !== m.getMonth()) return /* @__PURE__ */ jsx("span", { className: "h-8", "aria-hidden": true }, key(d));
|
|
133
|
+
const dis = off(d);
|
|
134
|
+
const isStart = same(d, span.start);
|
|
135
|
+
const isEnd = same(d, span.end);
|
|
136
|
+
const inBand = !!(span.start && bandEnd && d >= span.start && d <= bandEnd && !same(span.start, bandEnd));
|
|
137
|
+
const edgeL = inBand && (isStart || (d.getDay() - weekStartsOn + 7) % 7 === 0 || d.getDate() === 1);
|
|
138
|
+
const lastDay = addDays(d, 1).getMonth() !== d.getMonth();
|
|
139
|
+
const edgeR = inBand && (same(d, bandEnd) || (d.getDay() - weekStartsOn + 7) % 7 === 6 || lastDay);
|
|
140
|
+
const ghostEnd = !!previewEnd && same(d, bandEnd);
|
|
141
|
+
const isToday = same(d, today);
|
|
142
|
+
const isFocus = same(d, focus);
|
|
143
|
+
return /* @__PURE__ */ jsxs("div", { role: "gridcell", "aria-selected": isStart || isEnd || inBand || void 0, className: "relative h-8", children: [
|
|
144
|
+
inBand && /* @__PURE__ */ jsx(
|
|
145
|
+
"span",
|
|
146
|
+
{
|
|
147
|
+
"aria-hidden": true,
|
|
148
|
+
className: cx(
|
|
149
|
+
"absolute inset-y-0 transition-opacity duration-300",
|
|
150
|
+
previewEnd ? "bg-[color-mix(in_srgb,var(--brand)_7%,transparent)]" : "bg-[color-mix(in_srgb,var(--brand)_11%,transparent)]",
|
|
151
|
+
isStart ? "left-1/2 right-0" : same(d, bandEnd) ? "left-0 right-1/2" : "inset-x-0",
|
|
152
|
+
edgeL && !isStart && "rounded-l-[8px]",
|
|
153
|
+
edgeR && !same(d, bandEnd) && "rounded-r-[8px]"
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
),
|
|
157
|
+
/* @__PURE__ */ jsxs(
|
|
158
|
+
"button",
|
|
159
|
+
{
|
|
160
|
+
type: "button",
|
|
161
|
+
"data-day": key(d),
|
|
162
|
+
tabIndex: isFocus ? 0 : -1,
|
|
163
|
+
disabled: dis,
|
|
164
|
+
"aria-label": full.format(d),
|
|
165
|
+
"aria-current": isToday ? "date" : void 0,
|
|
166
|
+
onClick: () => {
|
|
167
|
+
steer.current = false;
|
|
168
|
+
pick(d);
|
|
169
|
+
},
|
|
170
|
+
onPointerEnter: () => setHover(d),
|
|
171
|
+
onFocus: () => !isFocus && setFocus(d),
|
|
172
|
+
className: cx(
|
|
173
|
+
"relative mx-auto flex h-8 w-8 items-center justify-center rounded-[8px] text-[13px] tabular-nums outline-none transition-colors duration-150",
|
|
174
|
+
"focus-visible:ring-2 focus-visible:ring-brand/50 disabled:cursor-not-allowed disabled:text-mute disabled:opacity-40",
|
|
175
|
+
isStart || isEnd ? "font-medium text-white" : inBand ? "text-ink" : "text-ink hover:bg-paper-2",
|
|
176
|
+
ghostEnd && "shadow-[inset_0_0_0_1.5px_var(--brand)]"
|
|
177
|
+
),
|
|
178
|
+
children: [
|
|
179
|
+
(isStart || isEnd) && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "absolute inset-0 rounded-[8px] bg-brand shadow-[0_6px_14px_-6px_color-mix(in_srgb,var(--brand)_80%,transparent)]", style: { animation: `aui050-pop .4s ${EASE} both` } }),
|
|
180
|
+
/* @__PURE__ */ jsx("span", { className: "relative", children: d.getDate() }),
|
|
181
|
+
isToday && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cx("absolute bottom-1 left-1/2 h-1 w-1 -translate-x-1/2 rounded-full", isStart || isEnd ? "bg-white" : "bg-brand") })
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
ghostEnd && countText && /* @__PURE__ */ jsx(
|
|
186
|
+
"span",
|
|
187
|
+
{
|
|
188
|
+
"aria-hidden": true,
|
|
189
|
+
className: "pointer-events-none absolute -top-7 left-1/2 z-20 -translate-x-1/2 whitespace-nowrap rounded-[6px] bg-ink px-2 py-1 text-[11px] font-medium text-paper shadow-[0_8px_18px_-8px_rgb(0_0_0/0.5)]",
|
|
190
|
+
style: { animation: `aui050-tip .25s ${EASE} both` },
|
|
191
|
+
children: countText
|
|
192
|
+
},
|
|
193
|
+
key(d)
|
|
194
|
+
)
|
|
195
|
+
] }, key(d));
|
|
196
|
+
}) })
|
|
197
|
+
] }, key(m));
|
|
198
|
+
};
|
|
199
|
+
const fields = [
|
|
200
|
+
{ k: "start", label: startLabel, d: span.start },
|
|
201
|
+
{ k: "end", label: endLabel, d: span.end }
|
|
202
|
+
];
|
|
203
|
+
return /* @__PURE__ */ jsxs(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
className: cx(
|
|
207
|
+
"aui050 @container w-full rounded-[14px] bg-paper p-4 sm:p-5",
|
|
208
|
+
"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)]",
|
|
209
|
+
className
|
|
210
|
+
),
|
|
211
|
+
children: [
|
|
212
|
+
/* @__PURE__ */ jsx("style", { href: "asta-aui050", precedence: "asta", children: CSS }),
|
|
213
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", style: { animation: `aui050-rise .6s ${EASE} both` }, children: [
|
|
214
|
+
/* @__PURE__ */ jsxs("div", { className: "relative grid flex-1 grid-cols-2 rounded-[11px] bg-paper-2 p-1", children: [
|
|
215
|
+
/* @__PURE__ */ jsx(
|
|
216
|
+
"span",
|
|
217
|
+
{
|
|
218
|
+
"aria-hidden": true,
|
|
219
|
+
className: "absolute inset-y-1 left-1 w-[calc(50%-4px)] rounded-[8px] bg-paper shadow-[0_1px_2px_rgb(0_0_0/0.06),0_4px_12px_-6px_rgb(0_0_0/0.18)]",
|
|
220
|
+
style: { transform: `translateX(${mode === "end" ? "100%" : "0"})`, transition: `transform .45s ${EASE}` }
|
|
221
|
+
}
|
|
222
|
+
),
|
|
223
|
+
fields.map((f) => /* @__PURE__ */ jsxs(
|
|
224
|
+
"button",
|
|
225
|
+
{
|
|
226
|
+
type: "button",
|
|
227
|
+
"aria-pressed": mode === f.k,
|
|
228
|
+
onClick: () => {
|
|
229
|
+
setMode(f.k);
|
|
230
|
+
if (f.d) {
|
|
231
|
+
setFocus(f.d);
|
|
232
|
+
if (f.d < view || f.d >= addMonths(view, 2)) {
|
|
233
|
+
setDir(f.d > view ? 1 : -1);
|
|
234
|
+
setView(month0(f.d));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
className: "relative rounded-[8px] px-3 py-1.5 text-left outline-none focus-visible:ring-2 focus-visible:ring-brand/50",
|
|
239
|
+
children: [
|
|
240
|
+
/* @__PURE__ */ jsx("span", { className: cx("block font-mono text-[10px] uppercase tracking-[0.08em] transition-colors", mode === f.k ? "text-brand" : "text-mute"), children: f.label }),
|
|
241
|
+
/* @__PURE__ */ jsx("span", { className: cx("block truncate text-[13.5px] font-medium tracking-[-0.01em]", f.d ? "text-ink" : "text-mute"), style: { animation: `aui050-roll .4s ${EASE} both` }, children: f.d ? short.format(f.d) : "Add date" }, f.d ? key(f.d) : "none")
|
|
242
|
+
]
|
|
243
|
+
},
|
|
244
|
+
f.k
|
|
245
|
+
))
|
|
246
|
+
] }),
|
|
247
|
+
/* @__PURE__ */ jsx("div", { className: "flex gap-0.5", children: [-1, 1].map((d) => /* @__PURE__ */ jsx(
|
|
248
|
+
"button",
|
|
249
|
+
{
|
|
250
|
+
type: "button",
|
|
251
|
+
"aria-label": d === 1 ? "Next month" : "Previous month",
|
|
252
|
+
disabled: d === -1 && !canBack,
|
|
253
|
+
onClick: () => flip(d),
|
|
254
|
+
className: "flex h-8 w-8 items-center justify-center rounded-[8px] text-ink-2 outline-none transition-[background-color,transform] duration-150 hover:bg-paper-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50 active:scale-90 disabled:pointer-events-none disabled:opacity-30",
|
|
255
|
+
children: /* @__PURE__ */ jsx(Arrow, { dir: d })
|
|
256
|
+
},
|
|
257
|
+
d
|
|
258
|
+
)) })
|
|
259
|
+
] }),
|
|
260
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 overflow-hidden px-0.5 pt-1", style: { animation: `aui050-rise .6s ${EASE} 80ms both` }, children: /* @__PURE__ */ jsxs(
|
|
261
|
+
"div",
|
|
262
|
+
{
|
|
263
|
+
ref: grid,
|
|
264
|
+
onKeyDown: onKey,
|
|
265
|
+
onPointerLeave: () => setHover(null),
|
|
266
|
+
className: cx("grid grid-cols-1 gap-7 @min-[540px]:grid-cols-2", dir === 1 && "animate-[aui050-next_.4s_cubic-bezier(.16,1,.3,1)_both]", dir === -1 && "animate-[aui050-prev_.4s_cubic-bezier(.16,1,.3,1)_both]"),
|
|
267
|
+
children: [
|
|
268
|
+
month(view, 0),
|
|
269
|
+
month(addMonths(view, 1), 1)
|
|
270
|
+
]
|
|
271
|
+
},
|
|
272
|
+
key(view)
|
|
273
|
+
) }),
|
|
274
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 flex h-8 items-center justify-between gap-3", style: { animation: `aui050-rise .6s ${EASE} 160ms both` }, children: [
|
|
275
|
+
/* @__PURE__ */ jsx("p", { className: "min-w-0 truncate text-[12.5px] text-mute", "aria-live": "polite", children: span.start && span.end ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
276
|
+
/* @__PURE__ */ jsx("span", { className: "inline-block font-medium text-ink", style: { animation: `aui050-roll .4s ${EASE} both` }, children: countText }, countText),
|
|
277
|
+
" ",
|
|
278
|
+
"\xB7 ",
|
|
279
|
+
short.formatRange ? short.formatRange(span.start, span.end) : `${short.format(span.start)} \u2013 ${short.format(span.end)}`
|
|
280
|
+
] }) : span.start ? `Pick your ${endLabel.toLowerCase()} date` : `Pick your ${startLabel.toLowerCase()} date` }),
|
|
281
|
+
/* @__PURE__ */ jsx(
|
|
282
|
+
"button",
|
|
283
|
+
{
|
|
284
|
+
type: "button",
|
|
285
|
+
disabled: !span.start,
|
|
286
|
+
onClick: () => {
|
|
287
|
+
set({ start: null, end: null });
|
|
288
|
+
setMode("start");
|
|
289
|
+
},
|
|
290
|
+
className: "h-7 shrink-0 rounded-[7px] px-2.5 text-[12px] font-medium text-ink-2 outline-none transition-colors hover:bg-paper-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50 disabled:opacity-35",
|
|
291
|
+
children: "Clear"
|
|
292
|
+
}
|
|
293
|
+
)
|
|
294
|
+
] }),
|
|
295
|
+
name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: span.start && span.end ? `${key(span.start)}/${key(span.end)}` : "" })
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
var date_picker_aui_050_default = RangeDatePicker;
|
|
301
|
+
|
|
302
|
+
export {
|
|
303
|
+
RangeDatePicker,
|
|
304
|
+
date_picker_aui_050_default
|
|
305
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// components/kit/variants/input-aui-029.tsx
|
|
4
|
+
import { useId, useState } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
var cx = (...c) => c.filter(Boolean).join(" ");
|
|
7
|
+
var CSS = `
|
|
8
|
+
@keyframes aui029-in { from { opacity: 0; transform: translateY(-3px) } to { opacity: 1; transform: none } }
|
|
9
|
+
@media (prefers-reduced-motion: reduce) { .aui029 * { animation: none !important; transition: none !important } }
|
|
10
|
+
`;
|
|
11
|
+
function FloatingInput({
|
|
12
|
+
label = "Workspace name",
|
|
13
|
+
hint,
|
|
14
|
+
error,
|
|
15
|
+
start,
|
|
16
|
+
end,
|
|
17
|
+
counter,
|
|
18
|
+
className,
|
|
19
|
+
id: idProp,
|
|
20
|
+
placeholder,
|
|
21
|
+
...rest
|
|
22
|
+
}) {
|
|
23
|
+
const auto = useId();
|
|
24
|
+
const id = idProp ?? auto;
|
|
25
|
+
const controlled = rest.value !== void 0;
|
|
26
|
+
const [inner, setInner] = useState(String(rest.defaultValue ?? ""));
|
|
27
|
+
const value = controlled ? String(rest.value ?? "") : inner;
|
|
28
|
+
const msg = error ?? hint;
|
|
29
|
+
const max = rest.maxLength;
|
|
30
|
+
const lift = start ? "peer-focus:-translate-x-[26px] peer-[:not(:placeholder-shown)]:-translate-x-[26px]" : "";
|
|
31
|
+
return /* @__PURE__ */ jsxs("div", { className: cx("aui029 w-full", className), children: [
|
|
32
|
+
/* @__PURE__ */ jsx("style", { href: "asta-input-aui-029", precedence: "asta", children: CSS }),
|
|
33
|
+
/* @__PURE__ */ jsxs(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
className: cx(
|
|
37
|
+
"group/f relative flex h-14 items-center gap-2.5 rounded-[10px] bg-paper px-3.5 transition-shadow duration-300 ease-[cubic-bezier(.16,1,.3,1)]",
|
|
38
|
+
error ? "shadow-[inset_0_0_0_1.5px_var(--ink)]" : "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_14%,transparent)] hover:shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_26%,transparent)] focus-within:!shadow-[inset_0_0_0_1px_var(--brand),0_0_0_4px_color-mix(in_srgb,var(--brand)_12%,transparent)]",
|
|
39
|
+
rest.disabled && "pointer-events-none opacity-50"
|
|
40
|
+
),
|
|
41
|
+
children: [
|
|
42
|
+
start && /* @__PURE__ */ jsx("span", { className: "flex shrink-0 text-mute transition-colors duration-300 group-focus-within/f:text-ink [&_svg]:h-4 [&_svg]:w-4", children: start }),
|
|
43
|
+
/* @__PURE__ */ jsxs("div", { className: "relative h-full min-w-0 flex-1", children: [
|
|
44
|
+
/* @__PURE__ */ jsx(
|
|
45
|
+
"input",
|
|
46
|
+
{
|
|
47
|
+
id,
|
|
48
|
+
...rest,
|
|
49
|
+
placeholder: placeholder ?? " ",
|
|
50
|
+
"aria-invalid": error ? true : rest["aria-invalid"],
|
|
51
|
+
"aria-describedby": msg ? `${id}-msg` : void 0,
|
|
52
|
+
onChange: (e) => {
|
|
53
|
+
if (!controlled) setInner(e.target.value);
|
|
54
|
+
rest.onChange?.(e);
|
|
55
|
+
},
|
|
56
|
+
className: "peer h-full w-full bg-transparent pt-1.5 text-[15px] tracking-[-0.01em] text-ink outline-none placeholder:text-transparent focus:placeholder:text-mute"
|
|
57
|
+
}
|
|
58
|
+
),
|
|
59
|
+
/* @__PURE__ */ jsxs(
|
|
60
|
+
"label",
|
|
61
|
+
{
|
|
62
|
+
htmlFor: id,
|
|
63
|
+
className: cx(
|
|
64
|
+
"pointer-events-none absolute -left-1 top-1/2 -mt-[10px] flex h-5 origin-left items-center gap-1.5 whitespace-nowrap px-1 text-[15px] tracking-[-0.01em] text-mute",
|
|
65
|
+
"bg-[linear-gradient(to_bottom,transparent_44%,var(--paper)_44%)]",
|
|
66
|
+
"transition-[transform,color] duration-500 ease-[cubic-bezier(.16,1,.3,1)]",
|
|
67
|
+
"peer-focus:-translate-y-[28px] peer-focus:scale-[.8] peer-focus:text-brand",
|
|
68
|
+
"peer-[:not(:placeholder-shown)]:-translate-y-[28px] peer-[:not(:placeholder-shown)]:scale-[.8] peer-[:not(:placeholder-shown)]:text-ink",
|
|
69
|
+
lift
|
|
70
|
+
),
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium", children: label }),
|
|
73
|
+
counter && max ? /* @__PURE__ */ jsxs("span", { className: "tabular-nums text-mute opacity-0 transition-opacity duration-300 group-focus-within/f:opacity-100", children: [
|
|
74
|
+
value.length,
|
|
75
|
+
"/",
|
|
76
|
+
max
|
|
77
|
+
] }) : null
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
] }),
|
|
82
|
+
end && /* @__PURE__ */ jsx("span", { className: "flex shrink-0 items-center text-[13.5px] text-mute", children: end }),
|
|
83
|
+
/* @__PURE__ */ jsx(
|
|
84
|
+
"span",
|
|
85
|
+
{
|
|
86
|
+
"aria-hidden": true,
|
|
87
|
+
className: "pointer-events-none absolute inset-x-3 bottom-0 h-px origin-left scale-x-0 bg-brand transition-transform duration-700 ease-[cubic-bezier(.16,1,.3,1)] group-focus-within/f:scale-x-100"
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
msg && /* @__PURE__ */ jsxs(
|
|
94
|
+
"p",
|
|
95
|
+
{
|
|
96
|
+
id: `${id}-msg`,
|
|
97
|
+
role: error ? "alert" : void 0,
|
|
98
|
+
className: cx("mt-1.5 flex items-center gap-1.5 pl-1 text-[12.5px] leading-snug", error ? "text-ink" : "text-mute"),
|
|
99
|
+
style: { animation: "aui029-in .3s cubic-bezier(.16,1,.3,1) both" },
|
|
100
|
+
children: [
|
|
101
|
+
error && /* @__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: [
|
|
102
|
+
/* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6.25" }),
|
|
103
|
+
/* @__PURE__ */ jsx("path", { d: "M8 4.8v3.6M8 11h.01" })
|
|
104
|
+
] }),
|
|
105
|
+
msg
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
error ? "e" : "h"
|
|
109
|
+
)
|
|
110
|
+
] });
|
|
111
|
+
}
|
|
112
|
+
var input_aui_029_default = FloatingInput;
|
|
113
|
+
|
|
114
|
+
export {
|
|
115
|
+
FloatingInput,
|
|
116
|
+
input_aui_029_default
|
|
117
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// components/kit/variants/input-aui-033.tsx
|
|
4
|
+
import { useEffect, 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 aui033-ch { from { opacity: 0; transform: translateY(5px) } to { opacity: 1; transform: none } }
|
|
10
|
+
@keyframes aui033-in { from { opacity: 0; transform: translateY(3px) } to { opacity: 1; transform: none } }
|
|
11
|
+
@keyframes aui033-spin { to { transform: rotate(360deg) } }
|
|
12
|
+
@media (prefers-reduced-motion: reduce) { .aui033 * { animation-duration: 1ms !important; transition: none !important } .aui033 .aui033-spin { animation: aui033-spin 1.6s linear infinite !important } }
|
|
13
|
+
`;
|
|
14
|
+
var slugFromTitle = (s, keepTrailing = false) => {
|
|
15
|
+
const out = s.normalize("NFKD").replace(/[̀-ͯ]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+/, "").slice(0, 60);
|
|
16
|
+
return keepTrailing ? out : out.replace(/-+$/, "");
|
|
17
|
+
};
|
|
18
|
+
var TAKEN = ["motion-lab", "hello-world", "about", "work", "research"];
|
|
19
|
+
var fakeCheck = (slug) => new Promise((r) => setTimeout(() => r(!TAKEN.includes(slug)), 520));
|
|
20
|
+
function SlugInput({
|
|
21
|
+
label = "Title",
|
|
22
|
+
title: titleProp,
|
|
23
|
+
defaultTitle = "",
|
|
24
|
+
onTitleChange,
|
|
25
|
+
onSlugChange,
|
|
26
|
+
base = "astabyte.com/research/",
|
|
27
|
+
check = fakeCheck,
|
|
28
|
+
placeholder = "Untitled note",
|
|
29
|
+
className
|
|
30
|
+
}) {
|
|
31
|
+
const id = useId();
|
|
32
|
+
const [inner, setInner] = useState(defaultTitle);
|
|
33
|
+
const title = titleProp ?? inner;
|
|
34
|
+
const [custom, setCustom] = useState(null);
|
|
35
|
+
const [editing, setEditing] = useState(false);
|
|
36
|
+
const slug = custom ?? slugFromTitle(title);
|
|
37
|
+
const [state, setState] = useState({ slug: "", s: "idle" });
|
|
38
|
+
const run = useRef(0);
|
|
39
|
+
const slugRef = useRef(null);
|
|
40
|
+
const cb = useRef(onSlugChange);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
cb.current = onSlugChange;
|
|
43
|
+
});
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
cb.current?.(slug);
|
|
46
|
+
const n = ++run.current;
|
|
47
|
+
if (!slug) return;
|
|
48
|
+
const t = setTimeout(() => {
|
|
49
|
+
setState({ slug, s: "checking" });
|
|
50
|
+
check(slug).then(
|
|
51
|
+
(free) => n === run.current && setState({ slug, s: free ? "free" : "taken" }),
|
|
52
|
+
() => n === run.current && setState({ slug, s: "idle" })
|
|
53
|
+
);
|
|
54
|
+
}, 280);
|
|
55
|
+
return () => clearTimeout(t);
|
|
56
|
+
}, [slug, check]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (editing) slugRef.current?.focus();
|
|
59
|
+
}, [editing]);
|
|
60
|
+
const status = !slug ? "idle" : state.slug === slug ? state.s : "checking";
|
|
61
|
+
const alt = `${slug}-2`;
|
|
62
|
+
const setTitle = (v) => {
|
|
63
|
+
if (titleProp === void 0) setInner(v);
|
|
64
|
+
onTitleChange?.(v);
|
|
65
|
+
};
|
|
66
|
+
return /* @__PURE__ */ jsxs("div", { className: cx("aui033 w-full", className), children: [
|
|
67
|
+
/* @__PURE__ */ jsx("style", { href: "asta-input-aui-033", precedence: "asta", children: CSS }),
|
|
68
|
+
/* @__PURE__ */ jsx("label", { htmlFor: `${id}-t`, className: "font-mono text-[11px] uppercase tracking-[0.08em] text-mute", children: label }),
|
|
69
|
+
/* @__PURE__ */ jsx(
|
|
70
|
+
"input",
|
|
71
|
+
{
|
|
72
|
+
id: `${id}-t`,
|
|
73
|
+
value: title,
|
|
74
|
+
onChange: (e) => setTitle(e.target.value),
|
|
75
|
+
placeholder,
|
|
76
|
+
className: "mt-1 w-full bg-transparent text-[26px] font-medium leading-[1.15] tracking-[-0.035em] text-ink caret-brand outline-none placeholder:text-mute/60"
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 flex min-h-10 items-center gap-2 rounded-[9px] bg-paper-2 py-1.5 pl-3 pr-1.5 text-[13px]", children: [
|
|
80
|
+
/* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", className: "h-3.5 w-3.5 shrink-0 text-mute", fill: "none", stroke: "currentColor", strokeWidth: "1.4", "aria-hidden": true, children: [
|
|
81
|
+
/* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6" }),
|
|
82
|
+
/* @__PURE__ */ jsx("path", { d: "M2 8h12M8 2c1.8 1.7 2.6 3.7 2.6 6S9.8 12.3 8 14M8 2C6.2 3.7 5.4 5.7 5.4 8s.8 4.3 2.6 6" })
|
|
83
|
+
] }),
|
|
84
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 items-center overflow-hidden whitespace-nowrap", children: [
|
|
85
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-[3ch] truncate text-mute", children: base }),
|
|
86
|
+
editing ? /* @__PURE__ */ jsx(
|
|
87
|
+
"input",
|
|
88
|
+
{
|
|
89
|
+
ref: slugRef,
|
|
90
|
+
"aria-label": "Slug",
|
|
91
|
+
value: slug,
|
|
92
|
+
onChange: (e) => setCustom(slugFromTitle(e.target.value, true)),
|
|
93
|
+
onBlur: () => {
|
|
94
|
+
setEditing(false);
|
|
95
|
+
if (custom !== null) setCustom(slugFromTitle(custom) || null);
|
|
96
|
+
},
|
|
97
|
+
onKeyDown: (e) => {
|
|
98
|
+
if (e.key === "Enter" || e.key === "Escape") e.currentTarget.blur();
|
|
99
|
+
},
|
|
100
|
+
className: "min-w-0 flex-1 rounded-[4px] bg-paper px-1 text-ink shadow-[inset_0_0_0_1px_var(--brand)] outline-none"
|
|
101
|
+
}
|
|
102
|
+
) : /* @__PURE__ */ jsx("span", { "aria-label": slug ? `Slug ${slug}` : "No slug yet", className: "shrink-0 text-ink", children: slug ? slug.split("").map((ch, i) => /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "inline-block whitespace-pre", style: { animation: `aui033-ch .35s ${EASE} both` }, children: ch }, `${i}${ch}`)) : /* @__PURE__ */ jsx("span", { className: "text-mute/70", children: "your-title" }) })
|
|
103
|
+
] }),
|
|
104
|
+
/* @__PURE__ */ jsxs("span", { "aria-live": "polite", className: "flex shrink-0 items-center gap-1.5 text-[12.5px]", children: [
|
|
105
|
+
status === "checking" && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 text-mute", style: { animation: `aui033-in .25s ${EASE} both` }, children: [
|
|
106
|
+
/* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", className: "aui033-spin h-3.5 w-3.5", style: { animation: "aui033-spin .7s linear infinite" }, fill: "none", "aria-hidden": true, children: [
|
|
107
|
+
/* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "5.5", stroke: "currentColor", strokeOpacity: ".25", strokeWidth: "1.8" }),
|
|
108
|
+
/* @__PURE__ */ jsx("path", { d: "M13.5 8A5.5 5.5 0 0 0 8 2.5", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
|
|
109
|
+
] }),
|
|
110
|
+
/* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: "Checking" })
|
|
111
|
+
] }, "c"),
|
|
112
|
+
status === "free" && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 font-medium text-ink", style: { animation: `aui033-in .3s ${EASE} both` }, children: [
|
|
113
|
+
/* @__PURE__ */ jsx("span", { className: "h-1.5 w-1.5 rounded-full bg-brand" }),
|
|
114
|
+
"Available"
|
|
115
|
+
] }, "f"),
|
|
116
|
+
status === "taken" && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 text-ink", style: { animation: `aui033-in .3s ${EASE} both` }, children: [
|
|
117
|
+
/* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: "Taken" }),
|
|
118
|
+
/* @__PURE__ */ jsxs(
|
|
119
|
+
"button",
|
|
120
|
+
{
|
|
121
|
+
type: "button",
|
|
122
|
+
onClick: () => setCustom(alt),
|
|
123
|
+
className: "rounded-[6px] bg-paper px-1.5 py-0.5 font-medium text-brand shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--ink)_10%,transparent)] outline-none transition-transform duration-200 hover:-translate-y-px focus-visible:ring-2 focus-visible:ring-brand/50",
|
|
124
|
+
children: [
|
|
125
|
+
"Use ",
|
|
126
|
+
alt.length > 22 ? "-2" : alt
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
] }, "t")
|
|
131
|
+
] }),
|
|
132
|
+
/* @__PURE__ */ jsx(
|
|
133
|
+
"button",
|
|
134
|
+
{
|
|
135
|
+
type: "button",
|
|
136
|
+
onClick: () => {
|
|
137
|
+
if (custom !== null && !editing) setCustom(null);
|
|
138
|
+
else setEditing(true);
|
|
139
|
+
},
|
|
140
|
+
"aria-label": custom !== null && !editing ? "Follow the title again" : "Edit slug",
|
|
141
|
+
className: "grid h-7 w-7 shrink-0 place-items-center rounded-[7px] text-mute outline-none transition-colors duration-200 hover:bg-paper hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50",
|
|
142
|
+
children: custom !== null && !editing ? /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "h-3.5 w-3.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M6.5 9.5 9.5 6.5M7 4.5l1.3-1.3a2.5 2.5 0 0 1 3.5 3.5L10.5 8M9 11.5l-1.3 1.3a2.5 2.5 0 0 1-3.5-3.5L5.5 8" }) }) : /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: "h-3.5 w-3.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M10.5 2.5l3 3L6 13H3v-3l7.5-7.5Z" }) })
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
] }),
|
|
146
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1.5 pl-1 text-[12px] text-mute", children: custom !== null ? "Custom slug. Use the link to follow the title again." : "Follows the title until you edit it." })
|
|
147
|
+
] });
|
|
148
|
+
}
|
|
149
|
+
var input_aui_033_default = SlugInput;
|
|
150
|
+
|
|
151
|
+
export {
|
|
152
|
+
slugFromTitle,
|
|
153
|
+
SlugInput,
|
|
154
|
+
input_aui_033_default
|
|
155
|
+
};
|