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,331 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// components/kit/variants/select-aui-045.tsx
|
|
4
|
+
import { useEffect, useId, 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 aui045-pop { from { opacity: 0; transform: translateY(var(--aui045-y, -6px)) scale(.97) } }
|
|
10
|
+
@keyframes aui045-row { from { opacity: 0; transform: translateY(5px) } }
|
|
11
|
+
@keyframes aui045-tick { from { opacity: 0; transform: translateY(45%) } }
|
|
12
|
+
@media (prefers-reduced-motion: reduce) { .aui045 *, .aui045 { animation: none !important; transition: none !important } }
|
|
13
|
+
`;
|
|
14
|
+
var ZONES = [
|
|
15
|
+
{
|
|
16
|
+
label: "Asia and Pacific",
|
|
17
|
+
options: [
|
|
18
|
+
{ value: "jakarta", label: "Jakarta", description: "Indonesia", timeZone: "Asia/Jakarta" },
|
|
19
|
+
{ value: "singapore", label: "Singapore", description: "Singapore", timeZone: "Asia/Singapore" },
|
|
20
|
+
{ value: "tokyo", label: "Tokyo", description: "Japan", timeZone: "Asia/Tokyo" },
|
|
21
|
+
{ value: "sydney", label: "Sydney", description: "Australia", timeZone: "Australia/Sydney" }
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "Europe",
|
|
26
|
+
options: [
|
|
27
|
+
{ value: "london", label: "London", description: "United Kingdom", timeZone: "Europe/London" },
|
|
28
|
+
{ value: "berlin", label: "Berlin", description: "Germany", timeZone: "Europe/Berlin" },
|
|
29
|
+
{ value: "lisbon", label: "Lisbon", description: "Portugal", timeZone: "Europe/Lisbon" }
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "Americas",
|
|
34
|
+
options: [
|
|
35
|
+
{ value: "new-york", label: "New York", description: "United States", timeZone: "America/New_York" },
|
|
36
|
+
{ value: "sao-paulo", label: "S\xE3o Paulo", description: "Brazil", timeZone: "America/Sao_Paulo" },
|
|
37
|
+
{ value: "san-francisco", label: "San Francisco", description: "United States", timeZone: "America/Los_Angeles" }
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
var fmtCache = /* @__PURE__ */ new Map();
|
|
42
|
+
function zoneInfo(tz, now) {
|
|
43
|
+
let f = fmtCache.get(tz);
|
|
44
|
+
if (!f) {
|
|
45
|
+
try {
|
|
46
|
+
f = {
|
|
47
|
+
time: new Intl.DateTimeFormat("en-GB", { timeZone: tz, hour: "2-digit", minute: "2-digit" }),
|
|
48
|
+
off: new Intl.DateTimeFormat("en-US", { timeZone: tz, timeZoneName: "shortOffset" }),
|
|
49
|
+
hour: new Intl.DateTimeFormat("en-GB", { timeZone: tz, hour: "numeric", hourCycle: "h23" })
|
|
50
|
+
};
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
fmtCache.set(tz, f);
|
|
55
|
+
}
|
|
56
|
+
const d = new Date(now);
|
|
57
|
+
const off = f.off.formatToParts(d).find((p) => p.type === "timeZoneName")?.value ?? "";
|
|
58
|
+
const h = Number(f.hour.format(d));
|
|
59
|
+
return { time: f.time.format(d), offset: off === "GMT" ? "GMT+0" : off, day: h >= 7 && h < 19 };
|
|
60
|
+
}
|
|
61
|
+
function roomBelow(el, need) {
|
|
62
|
+
const r = el.getBoundingClientRect();
|
|
63
|
+
let top = 0;
|
|
64
|
+
let bottom = window.innerHeight;
|
|
65
|
+
for (let p = el.parentElement; p && p !== document.body; p = p.parentElement) {
|
|
66
|
+
if (/hidden|auto|scroll|clip/.test(getComputedStyle(p).overflowY)) {
|
|
67
|
+
const c = p.getBoundingClientRect();
|
|
68
|
+
top = c.top;
|
|
69
|
+
bottom = c.bottom;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const below = bottom - r.bottom;
|
|
74
|
+
return below >= need || below >= r.top - top;
|
|
75
|
+
}
|
|
76
|
+
function useNow(el, enabled) {
|
|
77
|
+
const [now, setNow] = useState(() => Date.now());
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!enabled) return;
|
|
80
|
+
let seen = true;
|
|
81
|
+
const io = new IntersectionObserver(([e]) => seen = e.isIntersecting);
|
|
82
|
+
if (el.current) io.observe(el.current);
|
|
83
|
+
const tick = () => !document.hidden && seen && setNow(Date.now());
|
|
84
|
+
const id = setInterval(tick, 15e3);
|
|
85
|
+
document.addEventListener("visibilitychange", tick);
|
|
86
|
+
return () => {
|
|
87
|
+
clearInterval(id);
|
|
88
|
+
io.disconnect();
|
|
89
|
+
document.removeEventListener("visibilitychange", tick);
|
|
90
|
+
};
|
|
91
|
+
}, [el, enabled]);
|
|
92
|
+
return now;
|
|
93
|
+
}
|
|
94
|
+
function Match({ text, q }) {
|
|
95
|
+
const i = q ? text.toLowerCase().indexOf(q.toLowerCase()) : -1;
|
|
96
|
+
if (i < 0) return /* @__PURE__ */ jsx(Fragment, { children: text });
|
|
97
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
98
|
+
text.slice(0, i),
|
|
99
|
+
/* @__PURE__ */ jsx("mark", { className: "rounded-[3px] bg-[color-mix(in_srgb,var(--brand)_14%,transparent)] text-ink", children: text.slice(i, i + q.length) }),
|
|
100
|
+
text.slice(i + q.length)
|
|
101
|
+
] });
|
|
102
|
+
}
|
|
103
|
+
function DayDot({ day }) {
|
|
104
|
+
return /* @__PURE__ */ jsx(
|
|
105
|
+
"span",
|
|
106
|
+
{
|
|
107
|
+
"aria-hidden": true,
|
|
108
|
+
className: cx("h-2 w-2 shrink-0 rounded-full", day ? "bg-brand shadow-[0_0_0_3px_color-mix(in_srgb,var(--brand)_16%,transparent)]" : "shadow-[inset_0_0_0_1.5px_color-mix(in_srgb,var(--ink)_40%,transparent)]")
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
function GroupedSelect({ groups = ZONES, value, defaultValue, onChange, label = "Time zone", searchPlaceholder = "Search city or country", name, disabled, className }) {
|
|
113
|
+
const all = useMemo(() => groups.flatMap((g) => g.options), [groups]);
|
|
114
|
+
const [inner, setInner] = useState(defaultValue ?? all[0]?.value);
|
|
115
|
+
const current = value ?? inner;
|
|
116
|
+
const sel = all.find((o) => o.value === current);
|
|
117
|
+
const [open, setOpen] = useState(false);
|
|
118
|
+
const [down, setDown] = useState(true);
|
|
119
|
+
const [q, setQ] = useState("");
|
|
120
|
+
const [active, setActive] = useState(0);
|
|
121
|
+
const root = useRef(null);
|
|
122
|
+
const btn = useRef(null);
|
|
123
|
+
const search = useRef(null);
|
|
124
|
+
const list = useRef(null);
|
|
125
|
+
const uid = useId();
|
|
126
|
+
const now = useNow(root, all.some((o) => o.timeZone));
|
|
127
|
+
const t = q.trim().toLowerCase();
|
|
128
|
+
const shown = useMemo(
|
|
129
|
+
() => groups.map((g) => ({ label: g.label, options: t ? g.options.filter((o) => `${o.label} ${o.description ?? ""}`.toLowerCase().includes(t)) : g.options })).filter((g) => g.options.length),
|
|
130
|
+
[groups, t]
|
|
131
|
+
);
|
|
132
|
+
const flat = useMemo(() => shown.flatMap((g) => g.options), [shown]);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (open) search.current?.focus({ preventScroll: true });
|
|
135
|
+
}, [open]);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
if (open) list.current?.querySelector(`[data-i="${active}"]`)?.scrollIntoView({ block: "nearest" });
|
|
138
|
+
}, [active, open]);
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (!open) return;
|
|
141
|
+
const onDown = (e) => {
|
|
142
|
+
if (!root.current?.contains(e.target)) setOpen(false);
|
|
143
|
+
};
|
|
144
|
+
document.addEventListener("pointerdown", onDown);
|
|
145
|
+
return () => document.removeEventListener("pointerdown", onDown);
|
|
146
|
+
}, [open]);
|
|
147
|
+
const show = () => {
|
|
148
|
+
if (disabled || !btn.current) return;
|
|
149
|
+
setDown(roomBelow(btn.current, 250));
|
|
150
|
+
setQ("");
|
|
151
|
+
setActive(Math.max(0, all.findIndex((o) => o.value === current)));
|
|
152
|
+
setOpen(true);
|
|
153
|
+
};
|
|
154
|
+
const close = () => {
|
|
155
|
+
setOpen(false);
|
|
156
|
+
btn.current?.focus({ preventScroll: true });
|
|
157
|
+
};
|
|
158
|
+
const pick = (o) => {
|
|
159
|
+
if (!o || o.disabled) return;
|
|
160
|
+
if (value === void 0) setInner(o.value);
|
|
161
|
+
onChange?.(o.value);
|
|
162
|
+
close();
|
|
163
|
+
};
|
|
164
|
+
const step = (from, d) => {
|
|
165
|
+
let n = from;
|
|
166
|
+
for (let k = 0; k < flat.length; k++) {
|
|
167
|
+
n = Math.min(flat.length - 1, Math.max(0, n + d));
|
|
168
|
+
if (!flat[n]?.disabled) return n;
|
|
169
|
+
}
|
|
170
|
+
return from;
|
|
171
|
+
};
|
|
172
|
+
const onKey = (e) => {
|
|
173
|
+
if (e.key === "ArrowDown") setActive((a) => step(a, 1));
|
|
174
|
+
else if (e.key === "ArrowUp") setActive((a) => step(a, -1));
|
|
175
|
+
else if (e.key === "PageDown") setActive((a) => Math.min(flat.length - 1, a + 5));
|
|
176
|
+
else if (e.key === "PageUp") setActive((a) => Math.max(0, a - 5));
|
|
177
|
+
else if (e.key === "Enter") pick(flat[active]);
|
|
178
|
+
else if (e.key === "Escape") close();
|
|
179
|
+
else if (e.key === "Tab") return setOpen(false);
|
|
180
|
+
else return;
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
};
|
|
183
|
+
const selInfo = sel?.timeZone ? zoneInfo(sel.timeZone, now) : null;
|
|
184
|
+
let i = -1;
|
|
185
|
+
return /* @__PURE__ */ jsxs("div", { ref: root, className: cx("aui045 relative w-full", open && "z-40", className), children: [
|
|
186
|
+
/* @__PURE__ */ jsx("style", { href: "asta-aui045", precedence: "asta", children: CSS }),
|
|
187
|
+
/* @__PURE__ */ jsxs(
|
|
188
|
+
"button",
|
|
189
|
+
{
|
|
190
|
+
ref: btn,
|
|
191
|
+
type: "button",
|
|
192
|
+
disabled,
|
|
193
|
+
"aria-haspopup": "listbox",
|
|
194
|
+
"aria-expanded": open,
|
|
195
|
+
"aria-controls": open ? `${uid}-list` : void 0,
|
|
196
|
+
"aria-label": `${label}: ${sel?.label ?? ""}`,
|
|
197
|
+
onClick: () => open ? close() : show(),
|
|
198
|
+
onKeyDown: (e) => {
|
|
199
|
+
if (!open && ["ArrowDown", "ArrowUp", "Enter", " "].includes(e.key)) {
|
|
200
|
+
e.preventDefault();
|
|
201
|
+
show();
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
className: cx(
|
|
205
|
+
"group flex h-11 w-full items-center gap-2.5 rounded-[10px] bg-paper px-3.5 text-left outline-none transition-[box-shadow,transform] duration-300 active:scale-[.995] disabled:cursor-not-allowed disabled:opacity-45",
|
|
206
|
+
"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)]",
|
|
207
|
+
"focus-visible:shadow-[inset_0_0_0_1px_var(--brand),0_0_0_4px_color-mix(in_srgb,var(--brand)_14%,transparent)]",
|
|
208
|
+
open && "!shadow-[inset_0_0_0_1px_var(--brand),0_0_0_4px_color-mix(in_srgb,var(--brand)_14%,transparent)]"
|
|
209
|
+
),
|
|
210
|
+
children: [
|
|
211
|
+
selInfo && /* @__PURE__ */ jsx(DayDot, { day: selInfo.day }),
|
|
212
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 truncate text-[14px] text-ink", style: { animation: `aui045-row .4s ${EASE} both` }, children: [
|
|
213
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium tracking-[-0.01em]", children: sel?.label }),
|
|
214
|
+
selInfo && /* @__PURE__ */ jsxs("span", { className: "text-mute", children: [
|
|
215
|
+
" \xB7 ",
|
|
216
|
+
selInfo.offset
|
|
217
|
+
] })
|
|
218
|
+
] }, current),
|
|
219
|
+
selInfo && /* @__PURE__ */ jsx("span", { className: "overflow-hidden font-mono text-[12.5px] tabular-nums text-ink-2", suppressHydrationWarning: true, children: /* @__PURE__ */ jsx("span", { className: "inline-block", style: { animation: `aui045-tick .5s ${EASE} both` }, children: selInfo.time }, selInfo.time) }),
|
|
220
|
+
/* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: cx("h-4 w-4 shrink-0 text-mute transition-transform duration-300", open && "rotate-180"), fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "m4 6 4 4 4-4" }) })
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
),
|
|
224
|
+
name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: current ?? "" }),
|
|
225
|
+
open && /* @__PURE__ */ jsxs(
|
|
226
|
+
"div",
|
|
227
|
+
{
|
|
228
|
+
className: cx(
|
|
229
|
+
"absolute inset-x-0 z-50 overflow-hidden rounded-[13px] bg-paper",
|
|
230
|
+
"shadow-[0_0_0_1px_color-mix(in_srgb,var(--ink)_9%,transparent),0_22px_48px_-16px_rgb(0_0_0/0.3),0_4px_10px_-4px_rgb(0_0_0/0.08)]",
|
|
231
|
+
down ? "top-full mt-2 origin-top" : "bottom-full mb-2 origin-bottom [--aui045-y:6px]"
|
|
232
|
+
),
|
|
233
|
+
style: { animation: `aui045-pop .3s ${EASE} both` },
|
|
234
|
+
onKeyDown: onKey,
|
|
235
|
+
children: [
|
|
236
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-3.5 py-1 shadow-[0_1px_0_color-mix(in_srgb,var(--ink)_7%,transparent)]", children: [
|
|
237
|
+
/* @__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.6", "aria-hidden": true, children: [
|
|
238
|
+
/* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4.5" }),
|
|
239
|
+
/* @__PURE__ */ jsx("path", { d: "m10.5 10.5 3 3" })
|
|
240
|
+
] }),
|
|
241
|
+
/* @__PURE__ */ jsx(
|
|
242
|
+
"input",
|
|
243
|
+
{
|
|
244
|
+
ref: search,
|
|
245
|
+
value: q,
|
|
246
|
+
onChange: (e) => {
|
|
247
|
+
setQ(e.target.value);
|
|
248
|
+
setActive(0);
|
|
249
|
+
},
|
|
250
|
+
onBlur: (e) => !root.current?.contains(e.relatedTarget) && setOpen(false),
|
|
251
|
+
placeholder: searchPlaceholder,
|
|
252
|
+
role: "combobox",
|
|
253
|
+
"aria-expanded": true,
|
|
254
|
+
"aria-autocomplete": "list",
|
|
255
|
+
"aria-controls": `${uid}-list`,
|
|
256
|
+
"aria-activedescendant": flat[active] ? `${uid}-o-${active}` : void 0,
|
|
257
|
+
"aria-label": `Search ${label.toLowerCase()}`,
|
|
258
|
+
className: "h-10 min-w-0 flex-1 bg-transparent text-[13.5px] text-ink outline-none placeholder:text-mute"
|
|
259
|
+
}
|
|
260
|
+
),
|
|
261
|
+
/* @__PURE__ */ jsx("kbd", { className: "rounded-[5px] bg-paper-2 px-1.5 py-0.5 font-mono text-[10px] text-mute", children: "esc" })
|
|
262
|
+
] }),
|
|
263
|
+
/* @__PURE__ */ jsxs("div", { ref: list, id: `${uid}-list`, role: "listbox", "aria-label": label, className: "max-h-[184px] overflow-y-auto overscroll-contain pb-1 [scrollbar-width:thin]", children: [
|
|
264
|
+
shown.map((g, gi) => /* @__PURE__ */ jsxs("div", { role: "group", "aria-labelledby": `${uid}-g-${gi}`, children: [
|
|
265
|
+
/* @__PURE__ */ jsxs("div", { id: `${uid}-g-${gi}`, className: "sticky top-0 z-10 flex items-center justify-between bg-paper px-3.5 pb-1 pt-2.5 font-mono text-[10.5px] uppercase tracking-[0.08em] text-mute", children: [
|
|
266
|
+
/* @__PURE__ */ jsx("span", { children: g.label }),
|
|
267
|
+
/* @__PURE__ */ jsx("span", { className: "tabular-nums", children: g.options.length })
|
|
268
|
+
] }),
|
|
269
|
+
g.options.map((o) => {
|
|
270
|
+
i++;
|
|
271
|
+
const n = i;
|
|
272
|
+
const info = o.timeZone ? zoneInfo(o.timeZone, now) : null;
|
|
273
|
+
const on = o.value === current;
|
|
274
|
+
return /* @__PURE__ */ jsxs(
|
|
275
|
+
"div",
|
|
276
|
+
{
|
|
277
|
+
id: `${uid}-o-${n}`,
|
|
278
|
+
"data-i": n,
|
|
279
|
+
role: "option",
|
|
280
|
+
"aria-selected": on,
|
|
281
|
+
"aria-disabled": o.disabled || void 0,
|
|
282
|
+
onPointerMove: () => !o.disabled && active !== n && setActive(n),
|
|
283
|
+
onPointerDown: (e) => e.preventDefault(),
|
|
284
|
+
onClick: () => pick(o),
|
|
285
|
+
className: cx(
|
|
286
|
+
"mx-1 flex h-10 cursor-pointer select-none items-center gap-2.5 rounded-[8px] px-2.5 transition-colors duration-150",
|
|
287
|
+
n === active && !o.disabled && "bg-paper-2",
|
|
288
|
+
o.disabled && "cursor-not-allowed opacity-40"
|
|
289
|
+
),
|
|
290
|
+
style: { animation: `aui045-row .4s ${EASE} ${Math.min(n, 8) * 25}ms both` },
|
|
291
|
+
children: [
|
|
292
|
+
info && /* @__PURE__ */ jsx(DayDot, { day: info.day }),
|
|
293
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1 truncate text-[13.5px] text-ink", children: [
|
|
294
|
+
/* @__PURE__ */ jsx("span", { className: cx(on && "font-medium"), children: /* @__PURE__ */ jsx(Match, { text: o.label, q: t }) }),
|
|
295
|
+
o.description && /* @__PURE__ */ jsxs("span", { className: "text-mute", children: [
|
|
296
|
+
" ",
|
|
297
|
+
/* @__PURE__ */ jsx(Match, { text: o.description, q: t })
|
|
298
|
+
] })
|
|
299
|
+
] }),
|
|
300
|
+
/* @__PURE__ */ jsx("span", { className: "shrink-0 font-mono text-[11.5px] tabular-nums text-mute", suppressHydrationWarning: true, children: info ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
301
|
+
/* @__PURE__ */ jsx("span", { className: "text-ink-2", children: info.time }),
|
|
302
|
+
" ",
|
|
303
|
+
info.offset.replace("GMT", "")
|
|
304
|
+
] }) : o.hint }),
|
|
305
|
+
/* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", className: cx("h-3.5 w-3.5 shrink-0 text-brand transition-[opacity,transform] duration-300", on ? "scale-100 opacity-100" : "scale-50 opacity-0"), fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "m3.5 8.5 3 3 6-7" }) })
|
|
306
|
+
]
|
|
307
|
+
},
|
|
308
|
+
o.value
|
|
309
|
+
);
|
|
310
|
+
})
|
|
311
|
+
] }, g.label)),
|
|
312
|
+
!flat.length && /* @__PURE__ */ jsxs("div", { className: "px-4 py-8 text-center", children: [
|
|
313
|
+
/* @__PURE__ */ jsxs("p", { className: "text-[13px] text-ink", children: [
|
|
314
|
+
"No match for \u201C",
|
|
315
|
+
q.trim(),
|
|
316
|
+
"\u201D"
|
|
317
|
+
] }),
|
|
318
|
+
/* @__PURE__ */ jsx("p", { className: "mt-0.5 text-[12px] text-mute", children: "Try a city or a country name" })
|
|
319
|
+
] })
|
|
320
|
+
] })
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
)
|
|
324
|
+
] });
|
|
325
|
+
}
|
|
326
|
+
var select_aui_045_default = GroupedSelect;
|
|
327
|
+
|
|
328
|
+
export {
|
|
329
|
+
GroupedSelect,
|
|
330
|
+
select_aui_045_default
|
|
331
|
+
};
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// components/kit/variants/select-aui-044.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 aui044-in { from { opacity: 0; transform: translateY(70%) } }
|
|
10
|
+
@keyframes aui044-out { to { opacity: 0; transform: translateY(-70%) } }
|
|
11
|
+
@keyframes aui044-pop { from { opacity: 0; transform: translateY(var(--aui044-y, -4px)) scale(.96) } }
|
|
12
|
+
@keyframes aui044-row { from { opacity: 0; transform: translateX(-4px) } }
|
|
13
|
+
@media (prefers-reduced-motion: reduce) { .aui044 *, .aui044 { animation: none !important; transition: none !important } }
|
|
14
|
+
`;
|
|
15
|
+
var FREQ = [
|
|
16
|
+
{ value: "instant", label: "Instantly", pill: "instantly", hint: "Live" },
|
|
17
|
+
{ value: "hourly", label: "Hourly", pill: "every hour", hint: ":00" },
|
|
18
|
+
{ value: "daily", label: "Daily", pill: "daily", hint: "09:00" },
|
|
19
|
+
{ value: "weekly", label: "Weekly", pill: "weekly", hint: "Mon" }
|
|
20
|
+
];
|
|
21
|
+
function place(el, h, w) {
|
|
22
|
+
const r = el.getBoundingClientRect();
|
|
23
|
+
let c = { top: 0, bottom: window.innerHeight, left: 0, right: window.innerWidth };
|
|
24
|
+
for (let p = el.parentElement; p && p !== document.body; p = p.parentElement) {
|
|
25
|
+
const s = getComputedStyle(p);
|
|
26
|
+
if (/hidden|auto|scroll|clip/.test(s.overflowY + s.overflowX)) {
|
|
27
|
+
c = p.getBoundingClientRect();
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const below = c.bottom - r.bottom;
|
|
32
|
+
return { down: below >= h || below >= r.top - c.top, right: c.right - r.left < w && r.right - c.left >= w };
|
|
33
|
+
}
|
|
34
|
+
function PillSelect({ options = FREQ, value, defaultValue, onChange, label = "Frequency", name, disabled, className }) {
|
|
35
|
+
const [inner, setInner] = useState(defaultValue ?? options[2]?.value ?? options[0]?.value);
|
|
36
|
+
const current = value ?? inner;
|
|
37
|
+
const picked = Math.max(0, options.findIndex((o) => o.value === current));
|
|
38
|
+
const sel = options[picked];
|
|
39
|
+
const text = sel?.pill ?? sel?.label ?? "";
|
|
40
|
+
const [last, setLast] = useState({ value: current, text });
|
|
41
|
+
const [prev, setPrev] = useState(null);
|
|
42
|
+
if (last.value !== current) {
|
|
43
|
+
setPrev(last.text);
|
|
44
|
+
setLast({ value: current, text });
|
|
45
|
+
}
|
|
46
|
+
const [open, setOpen] = useState(false);
|
|
47
|
+
const [pos, setPos] = useState({ down: true, right: false });
|
|
48
|
+
const [active, setActive] = useState(picked);
|
|
49
|
+
const root = useRef(null);
|
|
50
|
+
const btn = useRef(null);
|
|
51
|
+
const list = useRef(null);
|
|
52
|
+
const buf = useRef("");
|
|
53
|
+
const bufT = useRef(void 0);
|
|
54
|
+
const uid = useId();
|
|
55
|
+
useEffect(() => () => clearTimeout(bufT.current), []);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (open) list.current?.focus({ preventScroll: true });
|
|
58
|
+
}, [open]);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (!open) return;
|
|
61
|
+
const onDown = (e) => {
|
|
62
|
+
if (!root.current?.contains(e.target)) setOpen(false);
|
|
63
|
+
};
|
|
64
|
+
document.addEventListener("pointerdown", onDown);
|
|
65
|
+
return () => document.removeEventListener("pointerdown", onDown);
|
|
66
|
+
}, [open]);
|
|
67
|
+
const show = () => {
|
|
68
|
+
if (disabled || !btn.current) return;
|
|
69
|
+
setPos(place(btn.current, options.length * 38 + 24, 216));
|
|
70
|
+
setActive(picked);
|
|
71
|
+
setOpen(true);
|
|
72
|
+
};
|
|
73
|
+
const close = () => {
|
|
74
|
+
setOpen(false);
|
|
75
|
+
btn.current?.focus({ preventScroll: true });
|
|
76
|
+
};
|
|
77
|
+
const pick = (i) => {
|
|
78
|
+
const o = options[i];
|
|
79
|
+
if (!o || o.disabled) return;
|
|
80
|
+
if (value === void 0) setInner(o.value);
|
|
81
|
+
onChange?.(o.value);
|
|
82
|
+
close();
|
|
83
|
+
};
|
|
84
|
+
const step = (from, d) => {
|
|
85
|
+
let n = from;
|
|
86
|
+
for (let k = 0; k < options.length; k++) {
|
|
87
|
+
n = (n + d + options.length) % options.length;
|
|
88
|
+
if (!options[n].disabled) return n;
|
|
89
|
+
}
|
|
90
|
+
return from;
|
|
91
|
+
};
|
|
92
|
+
const onListKey = (e) => {
|
|
93
|
+
if (e.key === "ArrowDown") setActive((a) => step(a, 1));
|
|
94
|
+
else if (e.key === "ArrowUp") setActive((a) => step(a, -1));
|
|
95
|
+
else if (e.key === "Home") setActive(step(-1, 1));
|
|
96
|
+
else if (e.key === "End") setActive(step(options.length, -1));
|
|
97
|
+
else if (e.key === "Enter" || e.key === " ") pick(active);
|
|
98
|
+
else if (e.key === "Escape") close();
|
|
99
|
+
else if (e.key === "Tab") return setOpen(false);
|
|
100
|
+
else if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
|
101
|
+
buf.current += e.key.toLowerCase();
|
|
102
|
+
clearTimeout(bufT.current);
|
|
103
|
+
bufT.current = setTimeout(() => buf.current = "", 500);
|
|
104
|
+
const s = buf.current;
|
|
105
|
+
const start = s.length === 1 ? active + 1 : active;
|
|
106
|
+
for (let k = 0; k < options.length; k++) {
|
|
107
|
+
const i = (start + k) % options.length;
|
|
108
|
+
if (!options[i].disabled && options[i].label.toLowerCase().startsWith(s)) {
|
|
109
|
+
setActive(i);
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} else return;
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
};
|
|
116
|
+
return /* @__PURE__ */ jsxs("span", { ref: root, className: cx("aui044 relative inline-block align-baseline", open && "z-40", className), children: [
|
|
117
|
+
/* @__PURE__ */ jsx("style", { href: "asta-aui044", precedence: "asta", children: CSS }),
|
|
118
|
+
/* @__PURE__ */ jsxs(
|
|
119
|
+
"button",
|
|
120
|
+
{
|
|
121
|
+
ref: btn,
|
|
122
|
+
type: "button",
|
|
123
|
+
disabled,
|
|
124
|
+
"aria-haspopup": "listbox",
|
|
125
|
+
"aria-expanded": open,
|
|
126
|
+
"aria-controls": open ? `${uid}-list` : void 0,
|
|
127
|
+
"aria-label": `${label}: ${sel?.label ?? ""}`,
|
|
128
|
+
onClick: () => open ? close() : show(),
|
|
129
|
+
onKeyDown: (e) => {
|
|
130
|
+
if (!open && ["ArrowDown", "ArrowUp", "Enter", " "].includes(e.key)) {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
show();
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
className: cx(
|
|
136
|
+
"group/pill relative -my-1 inline-flex items-baseline gap-[0.3em] rounded-[8px] px-[0.4em] py-[0.08em] font-medium text-brand outline-none transition-[background-color,box-shadow,transform] duration-300 active:scale-[.97] disabled:cursor-not-allowed disabled:opacity-45",
|
|
137
|
+
"bg-[color-mix(in_srgb,var(--brand)_9%,transparent)] hover:bg-[color-mix(in_srgb,var(--brand)_15%,transparent)]",
|
|
138
|
+
"focus-visible:shadow-[0_0_0_2px_var(--paper),0_0_0_4px_color-mix(in_srgb,var(--brand)_45%,transparent)]",
|
|
139
|
+
open && "bg-[color-mix(in_srgb,var(--brand)_15%,transparent)] shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--brand)_45%,transparent)]"
|
|
140
|
+
),
|
|
141
|
+
children: [
|
|
142
|
+
/* @__PURE__ */ jsxs("span", { className: "relative inline-block overflow-hidden whitespace-nowrap align-baseline", children: [
|
|
143
|
+
/* @__PURE__ */ jsx("span", { className: "inline-block", style: { animation: prev ? `aui044-in .5s ${EASE} both` : void 0 }, children: text }, current),
|
|
144
|
+
prev && /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "absolute left-0 top-0 inline-block", style: { animation: `aui044-out .45s ${EASE} both` }, children: prev }, `out-${current}`)
|
|
145
|
+
] }),
|
|
146
|
+
/* @__PURE__ */ jsx("svg", { viewBox: "0 0 12 12", className: cx("h-[0.55em] w-[0.55em] shrink-0 self-center opacity-70 transition-transform duration-300", open && "rotate-180"), fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "m3 4.5 3 3 3-3" }) })
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
),
|
|
150
|
+
name && /* @__PURE__ */ jsx("input", { type: "hidden", name, value: current ?? "" }),
|
|
151
|
+
open && /* @__PURE__ */ jsxs(
|
|
152
|
+
"ul",
|
|
153
|
+
{
|
|
154
|
+
ref: list,
|
|
155
|
+
id: `${uid}-list`,
|
|
156
|
+
role: "listbox",
|
|
157
|
+
tabIndex: -1,
|
|
158
|
+
"aria-label": label,
|
|
159
|
+
"aria-activedescendant": `${uid}-o-${active}`,
|
|
160
|
+
onKeyDown: onListKey,
|
|
161
|
+
onBlur: (e) => !root.current?.contains(e.relatedTarget) && setOpen(false),
|
|
162
|
+
className: cx(
|
|
163
|
+
"absolute z-50 w-[216px] rounded-[12px] bg-paper p-1 text-left text-[13.5px] font-normal leading-normal tracking-normal outline-none",
|
|
164
|
+
"shadow-[0_0_0_1px_color-mix(in_srgb,var(--ink)_9%,transparent),0_18px_40px_-14px_rgb(0_0_0/0.28),0_4px_10px_-4px_rgb(0_0_0/0.08)]",
|
|
165
|
+
pos.down ? "top-full mt-2" : "bottom-full mb-2 [--aui044-y:4px]",
|
|
166
|
+
pos.right ? "right-0" : "left-0",
|
|
167
|
+
pos.down ? pos.right ? "origin-top-right" : "origin-top-left" : pos.right ? "origin-bottom-right" : "origin-bottom-left"
|
|
168
|
+
),
|
|
169
|
+
style: { animation: `aui044-pop .28s ${EASE} both` },
|
|
170
|
+
children: [
|
|
171
|
+
/* @__PURE__ */ jsx("li", { role: "presentation", className: "px-2.5 pb-1 pt-1.5 font-mono text-[10.5px] uppercase tracking-[0.08em] text-mute", children: label }),
|
|
172
|
+
options.map((o, i) => {
|
|
173
|
+
const on = i === picked;
|
|
174
|
+
return /* @__PURE__ */ jsxs(
|
|
175
|
+
"li",
|
|
176
|
+
{
|
|
177
|
+
id: `${uid}-o-${i}`,
|
|
178
|
+
role: "option",
|
|
179
|
+
"aria-selected": on,
|
|
180
|
+
"aria-disabled": o.disabled || void 0,
|
|
181
|
+
onPointerMove: () => !o.disabled && active !== i && setActive(i),
|
|
182
|
+
onClick: () => pick(i),
|
|
183
|
+
className: cx(
|
|
184
|
+
"flex h-[38px] cursor-pointer select-none items-center gap-2.5 rounded-[8px] px-2.5 transition-colors duration-150",
|
|
185
|
+
i === active && !o.disabled ? "bg-paper-2 text-ink" : "text-ink-2",
|
|
186
|
+
o.disabled && "cursor-not-allowed opacity-40"
|
|
187
|
+
),
|
|
188
|
+
style: { animation: `aui044-row .35s ${EASE} ${40 + i * 30}ms both` },
|
|
189
|
+
children: [
|
|
190
|
+
/* @__PURE__ */ jsx("span", { className: cx("h-1.5 w-1.5 shrink-0 rounded-full transition-[transform,background-color] duration-300", on ? "scale-100 bg-brand" : "scale-50 bg-[color-mix(in_srgb,var(--ink)_25%,transparent)]"), "aria-hidden": true }),
|
|
191
|
+
/* @__PURE__ */ jsx("span", { className: cx("min-w-0 flex-1 truncate", on && "font-medium text-ink"), children: o.label }),
|
|
192
|
+
o.hint && /* @__PURE__ */ jsx("span", { className: "font-mono text-[11px] tabular-nums text-mute", children: o.hint })
|
|
193
|
+
]
|
|
194
|
+
},
|
|
195
|
+
o.value
|
|
196
|
+
);
|
|
197
|
+
})
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
] });
|
|
202
|
+
}
|
|
203
|
+
var select_aui_044_default = PillSelect;
|
|
204
|
+
|
|
205
|
+
export {
|
|
206
|
+
PillSelect,
|
|
207
|
+
select_aui_044_default
|
|
208
|
+
};
|