@bzync/rui 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/README.md +115 -0
- package/dist/autocomplete-CaysJRpk.cjs +1 -0
- package/dist/autocomplete-CfbfpcO4.js +453 -0
- package/dist/calendar-Bnld4G59.cjs +1 -0
- package/dist/calendar-CdICOROs.js +573 -0
- package/dist/charts-CxEy2c3M.js +1248 -0
- package/dist/charts-UDqS1BH1.cjs +1 -0
- package/dist/cn-BdjraxxU.cjs +1 -0
- package/dist/cn-DpgY2leY.js +1736 -0
- package/dist/component-styles-Ce56hn9T.js +16 -0
- package/dist/component-styles-TkZ7v6Ef.cjs +1 -0
- package/dist/components/accordion.cjs +1 -0
- package/dist/components/accordion.d.ts +22 -0
- package/dist/components/accordion.js +122 -0
- package/dist/components/alert.cjs +1 -0
- package/dist/components/alert.d.ts +13 -0
- package/dist/components/alert.js +165 -0
- package/dist/components/auth-backdrop.cjs +1 -0
- package/dist/components/auth-backdrop.d.ts +7 -0
- package/dist/components/auth-backdrop.js +10 -0
- package/dist/components/autocomplete/dropdown.d.ts +21 -0
- package/dist/components/autocomplete/icons.d.ts +8 -0
- package/dist/components/autocomplete/multi-trigger.d.ts +25 -0
- package/dist/components/autocomplete/single-trigger.d.ts +21 -0
- package/dist/components/autocomplete/types.d.ts +34 -0
- package/dist/components/autocomplete.cjs +1 -0
- package/dist/components/autocomplete.d.ts +5 -0
- package/dist/components/autocomplete.js +3 -0
- package/dist/components/avatar.cjs +1 -0
- package/dist/components/avatar.d.ts +17 -0
- package/dist/components/avatar.js +56 -0
- package/dist/components/badge.cjs +1 -0
- package/dist/components/badge.d.ts +12 -0
- package/dist/components/badge.js +32 -0
- package/dist/components/billing-interval-toggle.cjs +1 -0
- package/dist/components/billing-interval-toggle.d.ts +18 -0
- package/dist/components/billing-interval-toggle.js +39 -0
- package/dist/components/breadcrumb.cjs +1 -0
- package/dist/components/breadcrumb.d.ts +11 -0
- package/dist/components/breadcrumb.js +52 -0
- package/dist/components/button.cjs +1 -0
- package/dist/components/button.d.ts +17 -0
- package/dist/components/button.js +90 -0
- package/dist/components/calendar/month-view.d.ts +17 -0
- package/dist/components/calendar/types.d.ts +54 -0
- package/dist/components/calendar/week-view.d.ts +17 -0
- package/dist/components/calendar.cjs +1 -0
- package/dist/components/calendar.d.ts +3 -0
- package/dist/components/calendar.js +3 -0
- package/dist/components/callout.cjs +1 -0
- package/dist/components/callout.d.ts +9 -0
- package/dist/components/callout.js +131 -0
- package/dist/components/card.cjs +1 -0
- package/dist/components/card.d.ts +17 -0
- package/dist/components/card.js +59 -0
- package/dist/components/charts/bar-chart.d.ts +16 -0
- package/dist/components/charts/donut-chart.d.ts +10 -0
- package/dist/components/charts/funnel-chart.d.ts +8 -0
- package/dist/components/charts/gantt-chart.d.ts +15 -0
- package/dist/components/charts/heatmap-chart.d.ts +10 -0
- package/dist/components/charts/index.d.ts +11 -0
- package/dist/components/charts/line-chart.d.ts +16 -0
- package/dist/components/charts/multi-line-chart.d.ts +18 -0
- package/dist/components/charts/radar-chart.d.ts +13 -0
- package/dist/components/charts/scatter-chart.d.ts +24 -0
- package/dist/components/charts/shared.d.ts +15 -0
- package/dist/components/charts/waterfall-chart.d.ts +14 -0
- package/dist/components/charts.cjs +1 -0
- package/dist/components/charts.d.ts +2 -0
- package/dist/components/charts.js +2 -0
- package/dist/components/checkbox.cjs +1 -0
- package/dist/components/checkbox.d.ts +9 -0
- package/dist/components/checkbox.js +135 -0
- package/dist/components/code.cjs +7 -0
- package/dist/components/code.d.ts +23 -0
- package/dist/components/code.js +276 -0
- package/dist/components/command.cjs +1 -0
- package/dist/components/command.d.ts +29 -0
- package/dist/components/command.js +208 -0
- package/dist/components/confirm-dialog.cjs +1 -0
- package/dist/components/confirm-dialog.d.ts +14 -0
- package/dist/components/confirm-dialog.js +69 -0
- package/dist/components/copy-button.cjs +1 -0
- package/dist/components/copy-button.d.ts +8 -0
- package/dist/components/copy-button.js +87 -0
- package/dist/components/datatable/pagination-footer.d.ts +10 -0
- package/dist/components/datatable/rows-dropdown.d.ts +5 -0
- package/dist/components/datatable/skeleton-row.d.ts +3 -0
- package/dist/components/datatable/sort-icon.d.ts +4 -0
- package/dist/components/datatable/types.d.ts +30 -0
- package/dist/components/datatable.cjs +1 -0
- package/dist/components/datatable.d.ts +9 -0
- package/dist/components/datatable.js +3 -0
- package/dist/components/datepicker.cjs +1 -0
- package/dist/components/datepicker.d.ts +14 -0
- package/dist/components/datepicker.js +267 -0
- package/dist/components/drawer.cjs +1 -0
- package/dist/components/drawer.d.ts +18 -0
- package/dist/components/drawer.js +3 -0
- package/dist/components/dropdown-menu.cjs +1 -0
- package/dist/components/dropdown-menu.d.ts +26 -0
- package/dist/components/dropdown-menu.js +122 -0
- package/dist/components/empty-state.cjs +1 -0
- package/dist/components/empty-state.d.ts +10 -0
- package/dist/components/empty-state.js +68 -0
- package/dist/components/error-state.cjs +1 -0
- package/dist/components/error-state.d.ts +10 -0
- package/dist/components/error-state.js +80 -0
- package/dist/components/file-upload.cjs +1 -0
- package/dist/components/file-upload.d.ts +10 -0
- package/dist/components/file-upload.js +173 -0
- package/dist/components/form-field.cjs +1 -0
- package/dist/components/form-field.d.ts +10 -0
- package/dist/components/form-field.js +36 -0
- package/dist/components/info-button.cjs +1 -0
- package/dist/components/info-button.d.ts +4 -0
- package/dist/components/info-button.js +32 -0
- package/dist/components/input.cjs +1 -0
- package/dist/components/input.d.ts +19 -0
- package/dist/components/input.js +117 -0
- package/dist/components/kbd.cjs +1 -0
- package/dist/components/kbd.d.ts +6 -0
- package/dist/components/kbd.js +16 -0
- package/dist/components/label.cjs +1 -0
- package/dist/components/label.d.ts +6 -0
- package/dist/components/label.js +31 -0
- package/dist/components/layout.cjs +1 -0
- package/dist/components/layout.d.ts +51 -0
- package/dist/components/layout.js +117 -0
- package/dist/components/link.cjs +1 -0
- package/dist/components/link.d.ts +9 -0
- package/dist/components/link.js +48 -0
- package/dist/components/list.cjs +1 -0
- package/dist/components/list.d.ts +13 -0
- package/dist/components/list.js +46 -0
- package/dist/components/modal.cjs +1 -0
- package/dist/components/modal.d.ts +31 -0
- package/dist/components/modal.js +219 -0
- package/dist/components/navigation.cjs +1 -0
- package/dist/components/navigation.d.ts +42 -0
- package/dist/components/navigation.js +127 -0
- package/dist/components/number-input.cjs +1 -0
- package/dist/components/number-input.d.ts +16 -0
- package/dist/components/number-input.js +142 -0
- package/dist/components/otp-input.cjs +1 -0
- package/dist/components/otp-input.d.ts +13 -0
- package/dist/components/otp-input.js +71 -0
- package/dist/components/pagination.cjs +1 -0
- package/dist/components/pagination.d.ts +8 -0
- package/dist/components/pagination.js +77 -0
- package/dist/components/popover.cjs +1 -0
- package/dist/components/popover.d.ts +16 -0
- package/dist/components/popover.js +115 -0
- package/dist/components/progressbar.cjs +1 -0
- package/dist/components/progressbar.d.ts +15 -0
- package/dist/components/progressbar.js +108 -0
- package/dist/components/radio.cjs +1 -0
- package/dist/components/radio.d.ts +22 -0
- package/dist/components/radio.js +96 -0
- package/dist/components/richtext.cjs +1 -0
- package/dist/components/richtext.d.ts +10 -0
- package/dist/components/richtext.js +370 -0
- package/dist/components/select/option-list.d.ts +16 -0
- package/dist/components/select/select-multi.d.ts +2 -0
- package/dist/components/select/select-single.d.ts +2 -0
- package/dist/components/select/types.d.ts +54 -0
- package/dist/components/select/utils.d.ts +10 -0
- package/dist/components/select.cjs +1 -0
- package/dist/components/select.d.ts +3 -0
- package/dist/components/select.js +2 -0
- package/dist/components/seo.cjs +1 -0
- package/dist/components/seo.d.ts +45 -0
- package/dist/components/seo.js +64 -0
- package/dist/components/separator.cjs +1 -0
- package/dist/components/separator.d.ts +6 -0
- package/dist/components/separator.js +25 -0
- package/dist/components/skeleton.cjs +1 -0
- package/dist/components/skeleton.d.ts +37 -0
- package/dist/components/skeleton.js +146 -0
- package/dist/components/slider.cjs +1 -0
- package/dist/components/slider.d.ts +12 -0
- package/dist/components/slider.js +72 -0
- package/dist/components/snackbar.cjs +1 -0
- package/dist/components/snackbar.d.ts +35 -0
- package/dist/components/snackbar.js +220 -0
- package/dist/components/spinner.cjs +1 -0
- package/dist/components/spinner.d.ts +7 -0
- package/dist/components/spinner.js +31 -0
- package/dist/components/stat.cjs +1 -0
- package/dist/components/stat.d.ts +18 -0
- package/dist/components/stat.js +90 -0
- package/dist/components/status-dot.cjs +1 -0
- package/dist/components/status-dot.d.ts +10 -0
- package/dist/components/status-dot.js +29 -0
- package/dist/components/stepper.cjs +1 -0
- package/dist/components/stepper.d.ts +11 -0
- package/dist/components/stepper.js +67 -0
- package/dist/components/switch.cjs +1 -0
- package/dist/components/switch.d.ts +8 -0
- package/dist/components/switch.js +79 -0
- package/dist/components/table.cjs +1 -0
- package/dist/components/table.d.ts +12 -0
- package/dist/components/table.js +54 -0
- package/dist/components/tabs.cjs +1 -0
- package/dist/components/tabs.d.ts +22 -0
- package/dist/components/tabs.js +120 -0
- package/dist/components/tag.cjs +1 -0
- package/dist/components/tag.d.ts +12 -0
- package/dist/components/tag.js +58 -0
- package/dist/components/terminal/fs.d.ts +10 -0
- package/dist/components/terminal/shell-commands-sim.d.ts +5 -0
- package/dist/components/terminal/shell-commands.d.ts +16 -0
- package/dist/components/terminal/shell-run.d.ts +11 -0
- package/dist/components/terminal/terminal-block.d.ts +13 -0
- package/dist/components/terminal/terminal-emulator.d.ts +10 -0
- package/dist/components/terminal/types.d.ts +35 -0
- package/dist/components/terminal.cjs +1 -0
- package/dist/components/terminal.d.ts +2 -0
- package/dist/components/terminal.js +2 -0
- package/dist/components/textarea.cjs +1 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +54 -0
- package/dist/components/theme-provider.cjs +1 -0
- package/dist/components/theme-provider.d.ts +89 -0
- package/dist/components/theme-provider.js +93 -0
- package/dist/components/theme-toggle.cjs +1 -0
- package/dist/components/theme-toggle.d.ts +9 -0
- package/dist/components/theme-toggle.js +4 -0
- package/dist/components/timeline.cjs +1 -0
- package/dist/components/timeline.d.ts +14 -0
- package/dist/components/timeline.js +54 -0
- package/dist/components/tooltip.cjs +1 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +84 -0
- package/dist/components/tree.cjs +1 -0
- package/dist/components/tree.d.ts +16 -0
- package/dist/components/tree.js +92 -0
- package/dist/createLucideIcon-DDY8HuQR.js +42 -0
- package/dist/createLucideIcon-b_X_3fj-.cjs +1 -0
- package/dist/datatable-BB3v__r5.cjs +1 -0
- package/dist/datatable-DlBhUhuO.js +316 -0
- package/dist/drawer-Cbuh6qdL.cjs +1 -0
- package/dist/drawer-CqkVZT9Y.js +189 -0
- package/dist/focus-Dk1YWVPN.js +42 -0
- package/dist/focus-DmG6Ge7X.cjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +70 -0
- package/dist/index.js +215 -0
- package/dist/lib/cn.d.ts +2 -0
- package/dist/lib/component-styles.d.ts +10 -0
- package/dist/select-Ch5fp1GT.js +461 -0
- package/dist/select-q0YCMhBP.cjs +1 -0
- package/dist/styles.css +3 -0
- package/dist/terminal-BOR2cFi1.js +1060 -0
- package/dist/terminal-CpraMs50.cjs +77 -0
- package/dist/theme-toggle-CnoiorKV.js +71 -0
- package/dist/theme-toggle-Dp1-24zH.cjs +1 -0
- package/dist/use-event-callback-DGkfO_uu.js +10 -0
- package/dist/use-event-callback-Du9_9eAi.cjs +1 -0
- package/dist/utils-CQ8pvCtk.js +72 -0
- package/dist/utils-DOFJTw8o.cjs +1 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bzync
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# rui
|
|
2
|
+
|
|
3
|
+
Composable React UI components with scoped, customizable light and dark themes.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { Button, ThemeProvider, ThemeToggle } from "@bzync/rui"
|
|
7
|
+
import "@bzync/rui/styles.css"
|
|
8
|
+
|
|
9
|
+
const violet = {
|
|
10
|
+
50: "#f5f3ff", 100: "#ede9fe", 200: "#ddd6fe", 300: "#c4b5fd",
|
|
11
|
+
400: "#a78bfa", 500: "#8b5cf6", 600: "#7c3aed", 700: "#6d28d9",
|
|
12
|
+
800: "#5b21b6", 900: "#4c1d95", 950: "#2e1065",
|
|
13
|
+
} as const
|
|
14
|
+
|
|
15
|
+
export function App() {
|
|
16
|
+
return (
|
|
17
|
+
<ThemeProvider
|
|
18
|
+
applyToRoot
|
|
19
|
+
palette={{ accent: violet }}
|
|
20
|
+
lightPalette={{ tokens: { "--color-bg": "#fafafa", "--color-surface": "#fff" } }}
|
|
21
|
+
darkPalette={{ tokens: { "--color-bg": "#09090b", "--color-surface": "#18181b" } }}
|
|
22
|
+
>
|
|
23
|
+
<ThemeToggle />
|
|
24
|
+
<Button>Custom primary</Button>
|
|
25
|
+
</ThemeProvider>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Every component accepts `className` (and native element props where applicable), so one-off
|
|
31
|
+
changes compose with the defaults. `ThemeProvider` supports controlled or uncontrolled themes,
|
|
32
|
+
system preference, persistent selection, scoped themes, custom accent/neutral scales, and any
|
|
33
|
+
CSS variable through `tokens`. `ThemeToggle` accepts custom icons, labels, and classes.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm install @bzync/rui framer-motion
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Import the core stylesheet once near the application root:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import "@bzync/rui/styles.css"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
rui does not download or bundle webfonts. It uses system fallbacks by default, keeping the
|
|
48
|
+
core stylesheet small and avoiding unexpected network requests. Applications can load any font
|
|
49
|
+
and override `--font-sans`, `--font-display`, and `--font-mono` on `.rui-theme`.
|
|
50
|
+
|
|
51
|
+
## Accessibility and motion
|
|
52
|
+
|
|
53
|
+
Interactive components expose native semantics and keyboard behavior. Modal dialogs label their
|
|
54
|
+
content, trap keyboard focus, close with Escape, restore the previously focused element, and
|
|
55
|
+
preserve the page's prior scroll-lock state. rui also disables nonessential animation within its
|
|
56
|
+
theme scope when the user requests reduced motion.
|
|
57
|
+
|
|
58
|
+
## Component imports
|
|
59
|
+
|
|
60
|
+
Use subpath imports when an application only needs a small part of the library:
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
import { Button } from "@bzync/rui/button"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The root export remains available for convenience. React 18.2 and React 19 are supported.
|
|
67
|
+
|
|
68
|
+
## Documentation
|
|
69
|
+
|
|
70
|
+
The component documentation and live demos are published to
|
|
71
|
+
[bzync.github.io/rui](https://bzync.github.io/rui/). A push to `main` deploys
|
|
72
|
+
the latest documentation through GitHub Pages; maintainers can also run the
|
|
73
|
+
**Deploy documentation** workflow manually from the Actions tab.
|
|
74
|
+
|
|
75
|
+
## Releasing to npm
|
|
76
|
+
|
|
77
|
+
Add an npm publishing token to the GitHub repository as an Actions secret named
|
|
78
|
+
`NPM_TOKEN`. The release workflow runs when a `v*` tag is pushed and requires the
|
|
79
|
+
tag to match the version in `package.json` exactly.
|
|
80
|
+
|
|
81
|
+
To publish the version currently declared in `package.json`:
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
VERSION="$(node --print "require('./package.json').version")"
|
|
85
|
+
git tag -a "v${VERSION}" -m "Release v${VERSION}"
|
|
86
|
+
git push origin "v${VERSION}"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For later patch releases, commit all pending changes and run:
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
npm version patch
|
|
93
|
+
git push origin HEAD --follow-tags
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`npm version patch` updates `package.json` and `package-lock.json`, creates a
|
|
97
|
+
release commit, and creates the matching version tag. Use `minor` or `major`
|
|
98
|
+
instead of `patch` when appropriate. Before publishing, GitHub Actions runs the
|
|
99
|
+
complete release check. It also generates npm provenance when the source
|
|
100
|
+
repository is public; npm does not support provenance from private GitHub
|
|
101
|
+
repositories.
|
|
102
|
+
|
|
103
|
+
### Retrying a failed release
|
|
104
|
+
|
|
105
|
+
Do not move or reuse an existing version tag after its workflow fails. Commit
|
|
106
|
+
the fixes, create the next patch version, and push its new tag:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
git add .
|
|
110
|
+
git commit -m "Fix npm release workflow"
|
|
111
|
+
npm version patch
|
|
112
|
+
git push origin HEAD --follow-tags
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
For example, because `v0.0.2` failed, this creates and publishes `v0.0.3`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./cn-BdjraxxU.cjs"),t=require("./component-styles-TkZ7v6Ef.cjs"),n=require("./utils-DOFJTw8o.cjs"),r=require("./use-event-callback-Du9_9eAi.cjs");let i=require("framer-motion"),a=require("react"),o=require("react/jsx-runtime"),s=require("react-dom");var c=({size:e=12})=>(0,o.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,o.jsx)(`path`,{d:`M18 6 6 18M6 6l12 12`})}),l=()=>(0,o.jsxs)(`svg`,{className:`animate-spin shrink-0 w-3.5 h-3.5 text-slate-500`,viewBox:`0 0 24 24`,fill:`none`,children:[(0,o.jsx)(`circle`,{className:`opacity-20`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`3`}),(0,o.jsx)(`path`,{className:`opacity-70`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]});function u({text:e,query:t}){if(!t)return(0,o.jsx)(o.Fragment,{children:e});let n=e.toLowerCase().indexOf(t.toLowerCase());return n===-1?(0,o.jsx)(o.Fragment,{children:e}):(0,o.jsxs)(o.Fragment,{children:[e.slice(0,n),(0,o.jsx)(`mark`,{className:`bg-blue-500/25 text-blue-700 dark:text-blue-200 rounded-sm not-italic`,children:e.slice(n,n+t.length)}),e.slice(n+t.length)]})}function d({inputRef:n,inputId:r,listId:i,open:a,activeIdx:s,inputText:u,prefix:d,placeholder:f,disabled:p,error:m,loading:h,showClear:g,onInputChange:_,onFocus:v,onKeyDown:y,onClear:b,messageId:x,inputProps:S}){return(0,o.jsxs)(`div`,{className:e.t(`flex h-9 items-center gap-2 rounded-[var(--radius-md)] px-3`,t.t,m&&`border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20`,p&&`opacity-50 cursor-not-allowed`),children:[d&&(0,o.jsx)(`span`,{className:`text-slate-500 shrink-0 text-sm`,children:d}),(0,o.jsx)(`input`,{...S,ref:n,id:r,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":a,"aria-controls":i,"aria-activedescendant":s>=0?`${i}-opt-${s}`:void 0,"aria-invalid":m?!0:void 0,"aria-describedby":x,autoComplete:`off`,value:u,onChange:_,onFocus:v,onKeyDown:y,placeholder:f,disabled:p,className:`flex-1 min-w-0 bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none disabled:cursor-not-allowed`}),h&&(0,o.jsx)(l,{}),g&&!h&&(0,o.jsx)(`button`,{type:`button`,onClick:b,className:`shrink-0 text-slate-500 hover:text-slate-600 dark:hover:text-slate-300 cursor-pointer transition-colors`,children:(0,o.jsx)(c,{})})]})}function f({inputRef:n,inputId:r,listId:i,open:a,activeIdx:s,inputText:u,prefix:d,placeholder:f,disabled:p,error:m,loading:h,showClear:g,selected:_,onContainerClick:v,onInputChange:y,onFocus:b,onKeyDown:x,onRemove:S,onClearAll:C,messageId:w,inputProps:T}){return(0,o.jsxs)(`div`,{onClick:v,className:e.t(`flex min-h-9 w-full flex-wrap items-center gap-1.5 rounded-[var(--radius-md)] px-2.5 py-1.5 cursor-text`,t.t,m&&`border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20`,p&&`opacity-50 cursor-not-allowed`),children:[d&&(0,o.jsx)(`span`,{className:`text-slate-500 shrink-0 text-sm`,children:d}),_.map(e=>(0,o.jsxs)(`span`,{className:`inline-flex max-w-[200px] items-center gap-1 rounded-md border border-border bg-surface-muted px-2 py-0.5 text-xs font-medium text-foreground`,children:[e.icon&&(0,o.jsx)(`span`,{className:`shrink-0 text-slate-500 dark:text-slate-400`,children:e.icon}),(0,o.jsx)(`span`,{className:`truncate`,children:e.label}),(0,o.jsx)(`button`,{type:`button`,tabIndex:-1,onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),S(e)},disabled:p,className:`shrink-0 text-slate-500 dark:text-slate-400 hover:text-gray-900 dark:hover:text-white transition-colors cursor-pointer ml-0.5`,"aria-label":`Remove ${e.label}`,children:(0,o.jsx)(c,{size:10})})]},String(e.value))),(0,o.jsx)(`input`,{...T,ref:n,id:r,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":a,"aria-controls":i,"aria-activedescendant":s>=0?`${i}-opt-${s}`:void 0,"aria-invalid":m?!0:void 0,"aria-describedby":w,autoComplete:`off`,value:u,onChange:y,onFocus:b,onKeyDown:x,placeholder:_.length===0?f:void 0,disabled:p,className:`flex-1 min-w-[80px] bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none disabled:cursor-not-allowed py-0.5`}),(0,o.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5 shrink-0`,children:[h&&(0,o.jsx)(l,{}),g&&!h&&(0,o.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:e=>{e.stopPropagation(),C()},className:`text-slate-500 hover:text-slate-600 dark:hover:text-slate-300 transition-colors`,"aria-label":`Clear all`,children:(0,o.jsx)(c,{})}),_.length>0&&(0,o.jsx)(`span`,{className:`text-[10px] font-medium text-slate-500 tabular-nums`,children:_.length})]})]})}function p({listRef:t,listId:n,open:r,pos:a,multiple:c,loading:d,filtered:f,emptyMessage:p,activeIdx:m,setActiveIdx:h,inputText:g,selectedValues:_,singleValue:v,onSelectSingle:y,onToggleMulti:b,className:x}){return typeof document>`u`?null:(0,s.createPortal)((0,o.jsx)(i.AnimatePresence,{children:r&&a&&(0,o.jsx)(i.motion.ul,{ref:t,id:n,role:`listbox`,"aria-multiselectable":c,initial:{opacity:0,y:a.placement===`bottom`?-4:4},animate:{opacity:1,y:0},exit:{opacity:0,y:a.placement===`bottom`?-4:4},transition:{duration:.13},style:{position:`fixed`,top:a.top,left:a.left,width:a.width,maxHeight:a.maxHeight},className:e.t(`z-[110] overflow-y-auto rounded-[var(--radius-lg)] border border-border bg-surface-raised py-1 shadow-floating`,x),children:d?(0,o.jsxs)(`li`,{className:`px-4 py-3 text-sm text-slate-600 flex items-center gap-2`,children:[(0,o.jsx)(l,{}),`Loading…`]}):f.length===0?(0,o.jsx)(`li`,{className:`px-4 py-3 text-sm text-slate-600`,children:p}):f.map((t,r)=>{let i=r===m,a=c?_.includes(t.value):t.value===v;return(0,o.jsxs)(`li`,{id:`${n}-opt-${r}`,role:`option`,"aria-selected":a,onMouseDown:e=>e.preventDefault(),onClick:()=>c?b(t):y(t),onMouseEnter:()=>h(r),className:e.t(`flex min-h-9 items-center gap-3 px-3 py-2 cursor-pointer transition-colors`,i&&`bg-surface-muted`,a&&!i&&`bg-accent-50 dark:bg-accent-500/10`),children:[t.icon&&(0,o.jsx)(`span`,{className:`shrink-0 text-slate-500 dark:text-slate-400`,children:t.icon}),(0,o.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`p`,{className:e.t(`text-sm`,a?`text-accent-700 dark:text-accent-300 font-medium`:`text-foreground`),children:(0,o.jsx)(u,{text:t.label,query:g})}),t.description&&(0,o.jsx)(`p`,{className:`text-xs text-slate-500 mt-0.5 truncate`,children:t.description})]}),a&&(0,o.jsx)(`svg`,{"aria-hidden":`true`,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`text-accent-600 shrink-0`,children:(0,o.jsx)(`path`,{d:`m20 6-11 11-5-5`})})]},String(t.value))})})}),document.body)}function m(i,s){let{options:c,inputValue:l,onInputChange:u,label:m,hint:h,error:g,prefix:_,clearable:v=!0,loading:y=!1,emptyMessage:b=`No results`,maxVisible:x=8,className:S,wrapperClassName:C,listClassName:w,placeholder:T,disabled:E,id:ee,multiple:D,unstyled:te=!1,...O}=i,{value:ne,onSelect:re,onDeselect:ie,...k}=O,ae=(0,a.useId)(),A=ee??ae,j=`${A}-list`,M=`${A}-message`,[oe,se]=(0,a.useState)(``),N=l===void 0?oe:l,P=r.t(e=>u?.(e)),F=(0,a.useCallback)(e=>{l===void 0?se(e):P(e)},[l,P]),[I,L]=(0,a.useState)([]),R=(0,a.useMemo)(()=>{if(!D)return[];let e=i;return e.value===void 0?I:c.filter(t=>e.value.includes(t.value))},[D,c,i,I]),z=(0,a.useMemo)(()=>R.map(e=>e.value),[R]),[B,V]=(0,a.useState)(!1),[H,U]=(0,a.useState)(-1),W=(0,a.useRef)(null),G=(0,a.useRef)(null),K=(0,a.useRef)(null),[q,J]=(0,a.useState)(``),Y=(0,a.useMemo)(()=>{let e=q.trim().toLowerCase();return c.filter(t=>!t.disabled&&t.label.toLowerCase().includes(e)).slice(0,x)},[c,q,x]),X=(0,a.useCallback)(e=>{i.onSelect?.(e),F(e.label),V(!1),U(-1)},[i,F]),ce=(0,a.useCallback)(e=>{let t=i,n=[...R,e];t.value===void 0&&L(n),t.onSelect?.(e,n),F(``),U(-1),G.current?.focus()},[R,i,F]),Z=(0,a.useCallback)(e=>{let t=i,n=R.filter(t=>t.value!==e.value);t.value===void 0&&L(n),t.onDeselect?.(e,n)},[R,i]),Q=(0,a.useCallback)(e=>{z.includes(e.value)?Z(e):ce(e)},[z,Z,ce]),le=(0,a.useCallback)(()=>{F(``),i.onSelect?.({value:``,label:``}),V(!1)},[i,F]),ue=(0,a.useCallback)(()=>{i.value===void 0&&L([]),F(``)},[i,F]),de=(0,a.useCallback)(e=>{if(D&&e.key===`Backspace`&&N===``&&R.length>0){Z(R[R.length-1]);return}if(!B){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(V(!0),J(``));return}if(e.key===`ArrowDown`)e.preventDefault(),U(e=>Math.min(e+1,Y.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),U(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=Y[H];if(!t)return;D?Q(t):X(t)}else e.key===`Escape`&&(V(!1),U(-1))},[D,N,R,B,Y,H,Q,X,Z]);(0,a.useEffect)(()=>{H<0||!K.current||K.current.children[H]?.scrollIntoView({block:`nearest`})},[H]),(0,a.useEffect)(()=>{function e(e){let t=e.target;!W.current?.contains(t)&&!K.current?.contains(t)&&V(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[]);let fe=D?void 0:i.value,pe=!!(!D&&v&&N.length>0&&!E),me=!!(D&&v&&(R.length>0||N.length>0)&&!E),he=n.o(B,W),$=(0,a.useCallback)(e=>{F(e.target.value),J(e.target.value),V(!0),U(-1)},[F]),ge=(0,a.useCallback)(()=>{V(!0),J(``)},[]);return te?(0,o.jsxs)(`div`,{ref:W,className:e.t(S,C),children:[(0,o.jsx)(`input`,{ref:s,id:A,value:N,onChange:$,placeholder:T,disabled:E}),B&&(0,o.jsx)(`ul`,{ref:K,id:j,className:w,children:Y.map(e=>(0,o.jsx)(`li`,{onClick:()=>D?Q(e):X(e),children:e.label},String(e.value)))})]}):(0,o.jsxs)(`div`,{ref:W,className:e.t(`relative`,t.o,C,S),children:[m&&(0,o.jsxs)(`label`,{htmlFor:A,className:`text-sm font-medium leading-5 text-foreground`,children:[m,O.required&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(`span`,{"aria-hidden":`true`,className:`ml-1 text-destructive`,children:`*`}),(0,o.jsx)(`span`,{className:`sr-only`,children:` (required)`})]})]}),!D&&(0,o.jsx)(d,{inputRef:s,inputId:A,listId:j,open:B,activeIdx:H,inputText:N,prefix:_,placeholder:T,disabled:E,error:g,loading:y,showClear:pe,onInputChange:$,onFocus:ge,onKeyDown:de,onClear:le,messageId:g||h?M:void 0,inputProps:k}),D&&(0,o.jsx)(f,{inputRef:e=>{G.current=e,typeof s==`function`?s(e):s&&(s.current=e)},inputId:A,listId:j,open:B,activeIdx:H,inputText:N,prefix:_,placeholder:T,disabled:E,error:g,loading:y,showClear:me,selected:R,onContainerClick:()=>{E||(G.current?.focus(),V(!0),J(``))},onInputChange:$,onFocus:ge,onKeyDown:de,onRemove:Z,onClearAll:ue,messageId:g||h?M:void 0,inputProps:k}),(0,o.jsx)(p,{listRef:K,listId:j,open:B,pos:he,multiple:D,loading:y,filtered:Y,emptyMessage:b,activeIdx:H,setActiveIdx:U,inputText:q,selectedValues:z,singleValue:fe,onSelectSingle:X,onToggleMulti:Q,className:w}),g&&(0,o.jsx)(`p`,{id:M,"aria-live":`polite`,className:`text-xs leading-5 text-destructive`,children:g}),h&&!g&&(0,o.jsx)(`p`,{id:M,className:`text-xs leading-5 text-muted-foreground`,children:h})]})}var h=(0,a.forwardRef)(m);Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}});
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import { t as e } from "./cn-DpgY2leY.js";
|
|
2
|
+
import { o as t, t as n } from "./component-styles-Ce56hn9T.js";
|
|
3
|
+
import { o as r } from "./utils-CQ8pvCtk.js";
|
|
4
|
+
import { t as i } from "./use-event-callback-DGkfO_uu.js";
|
|
5
|
+
import { AnimatePresence as a, motion as o } from "framer-motion";
|
|
6
|
+
import { forwardRef as s, useCallback as c, useEffect as l, useId as u, useMemo as d, useRef as f, useState as p } from "react";
|
|
7
|
+
import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
8
|
+
import { createPortal as _ } from "react-dom";
|
|
9
|
+
//#region src/components/autocomplete/icons.tsx
|
|
10
|
+
var v = ({ size: e = 12 }) => /* @__PURE__ */ h("svg", {
|
|
11
|
+
width: e,
|
|
12
|
+
height: e,
|
|
13
|
+
viewBox: "0 0 24 24",
|
|
14
|
+
fill: "none",
|
|
15
|
+
stroke: "currentColor",
|
|
16
|
+
strokeWidth: "2.5",
|
|
17
|
+
strokeLinecap: "round",
|
|
18
|
+
strokeLinejoin: "round",
|
|
19
|
+
children: /* @__PURE__ */ h("path", { d: "M18 6 6 18M6 6l12 12" })
|
|
20
|
+
}), y = () => /* @__PURE__ */ g("svg", {
|
|
21
|
+
className: "animate-spin shrink-0 w-3.5 h-3.5 text-slate-500",
|
|
22
|
+
viewBox: "0 0 24 24",
|
|
23
|
+
fill: "none",
|
|
24
|
+
children: [/* @__PURE__ */ h("circle", {
|
|
25
|
+
className: "opacity-20",
|
|
26
|
+
cx: "12",
|
|
27
|
+
cy: "12",
|
|
28
|
+
r: "10",
|
|
29
|
+
stroke: "currentColor",
|
|
30
|
+
strokeWidth: "3"
|
|
31
|
+
}), /* @__PURE__ */ h("path", {
|
|
32
|
+
className: "opacity-70",
|
|
33
|
+
fill: "currentColor",
|
|
34
|
+
d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
37
|
+
function b({ text: e, query: t }) {
|
|
38
|
+
if (!t) return /* @__PURE__ */ h(m, { children: e });
|
|
39
|
+
let n = e.toLowerCase().indexOf(t.toLowerCase());
|
|
40
|
+
return n === -1 ? /* @__PURE__ */ h(m, { children: e }) : /* @__PURE__ */ g(m, { children: [
|
|
41
|
+
e.slice(0, n),
|
|
42
|
+
/* @__PURE__ */ h("mark", {
|
|
43
|
+
className: "bg-blue-500/25 text-blue-700 dark:text-blue-200 rounded-sm not-italic",
|
|
44
|
+
children: e.slice(n, n + t.length)
|
|
45
|
+
}),
|
|
46
|
+
e.slice(n + t.length)
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/components/autocomplete/single-trigger.tsx
|
|
51
|
+
function x({ inputRef: t, inputId: r, listId: i, open: a, activeIdx: o, inputText: s, prefix: c, placeholder: l, disabled: u, error: d, loading: f, showClear: p, onInputChange: m, onFocus: _, onKeyDown: b, onClear: x, messageId: S, inputProps: C }) {
|
|
52
|
+
return /* @__PURE__ */ g("div", {
|
|
53
|
+
className: e("flex h-9 items-center gap-2 rounded-[var(--radius-md)] px-3", n, d && "border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20", u && "opacity-50 cursor-not-allowed"),
|
|
54
|
+
children: [
|
|
55
|
+
c && /* @__PURE__ */ h("span", {
|
|
56
|
+
className: "text-slate-500 shrink-0 text-sm",
|
|
57
|
+
children: c
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ h("input", {
|
|
60
|
+
...C,
|
|
61
|
+
ref: t,
|
|
62
|
+
id: r,
|
|
63
|
+
role: "combobox",
|
|
64
|
+
"aria-autocomplete": "list",
|
|
65
|
+
"aria-expanded": a,
|
|
66
|
+
"aria-controls": i,
|
|
67
|
+
"aria-activedescendant": o >= 0 ? `${i}-opt-${o}` : void 0,
|
|
68
|
+
"aria-invalid": d ? !0 : void 0,
|
|
69
|
+
"aria-describedby": S,
|
|
70
|
+
autoComplete: "off",
|
|
71
|
+
value: s,
|
|
72
|
+
onChange: m,
|
|
73
|
+
onFocus: _,
|
|
74
|
+
onKeyDown: b,
|
|
75
|
+
placeholder: l,
|
|
76
|
+
disabled: u,
|
|
77
|
+
className: "flex-1 min-w-0 bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none disabled:cursor-not-allowed"
|
|
78
|
+
}),
|
|
79
|
+
f && /* @__PURE__ */ h(y, {}),
|
|
80
|
+
p && !f && /* @__PURE__ */ h("button", {
|
|
81
|
+
type: "button",
|
|
82
|
+
onClick: x,
|
|
83
|
+
className: "shrink-0 text-slate-500 hover:text-slate-600 dark:hover:text-slate-300 cursor-pointer transition-colors",
|
|
84
|
+
children: /* @__PURE__ */ h(v, {})
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/components/autocomplete/multi-trigger.tsx
|
|
91
|
+
function S({ inputRef: t, inputId: r, listId: i, open: a, activeIdx: o, inputText: s, prefix: c, placeholder: l, disabled: u, error: d, loading: f, showClear: p, selected: m, onContainerClick: _, onInputChange: b, onFocus: x, onKeyDown: S, onRemove: C, onClearAll: w, messageId: T, inputProps: E }) {
|
|
92
|
+
return /* @__PURE__ */ g("div", {
|
|
93
|
+
onClick: _,
|
|
94
|
+
className: e("flex min-h-9 w-full flex-wrap items-center gap-1.5 rounded-[var(--radius-md)] px-2.5 py-1.5 cursor-text", n, d && "border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20", u && "opacity-50 cursor-not-allowed"),
|
|
95
|
+
children: [
|
|
96
|
+
c && /* @__PURE__ */ h("span", {
|
|
97
|
+
className: "text-slate-500 shrink-0 text-sm",
|
|
98
|
+
children: c
|
|
99
|
+
}),
|
|
100
|
+
m.map((e) => /* @__PURE__ */ g("span", {
|
|
101
|
+
className: "inline-flex max-w-[200px] items-center gap-1 rounded-md border border-border bg-surface-muted px-2 py-0.5 text-xs font-medium text-foreground",
|
|
102
|
+
children: [
|
|
103
|
+
e.icon && /* @__PURE__ */ h("span", {
|
|
104
|
+
className: "shrink-0 text-slate-500 dark:text-slate-400",
|
|
105
|
+
children: e.icon
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ h("span", {
|
|
108
|
+
className: "truncate",
|
|
109
|
+
children: e.label
|
|
110
|
+
}),
|
|
111
|
+
/* @__PURE__ */ h("button", {
|
|
112
|
+
type: "button",
|
|
113
|
+
tabIndex: -1,
|
|
114
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
115
|
+
onClick: (t) => {
|
|
116
|
+
t.stopPropagation(), C(e);
|
|
117
|
+
},
|
|
118
|
+
disabled: u,
|
|
119
|
+
className: "shrink-0 text-slate-500 dark:text-slate-400 hover:text-gray-900 dark:hover:text-white transition-colors cursor-pointer ml-0.5",
|
|
120
|
+
"aria-label": `Remove ${e.label}`,
|
|
121
|
+
children: /* @__PURE__ */ h(v, { size: 10 })
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
}, String(e.value))),
|
|
125
|
+
/* @__PURE__ */ h("input", {
|
|
126
|
+
...E,
|
|
127
|
+
ref: t,
|
|
128
|
+
id: r,
|
|
129
|
+
role: "combobox",
|
|
130
|
+
"aria-autocomplete": "list",
|
|
131
|
+
"aria-expanded": a,
|
|
132
|
+
"aria-controls": i,
|
|
133
|
+
"aria-activedescendant": o >= 0 ? `${i}-opt-${o}` : void 0,
|
|
134
|
+
"aria-invalid": d ? !0 : void 0,
|
|
135
|
+
"aria-describedby": T,
|
|
136
|
+
autoComplete: "off",
|
|
137
|
+
value: s,
|
|
138
|
+
onChange: b,
|
|
139
|
+
onFocus: x,
|
|
140
|
+
onKeyDown: S,
|
|
141
|
+
placeholder: m.length === 0 ? l : void 0,
|
|
142
|
+
disabled: u,
|
|
143
|
+
className: "flex-1 min-w-[80px] bg-transparent text-sm text-foreground placeholder:text-muted-foreground outline-none disabled:cursor-not-allowed py-0.5"
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ g("span", {
|
|
146
|
+
className: "ml-auto flex items-center gap-1.5 shrink-0",
|
|
147
|
+
children: [
|
|
148
|
+
f && /* @__PURE__ */ h(y, {}),
|
|
149
|
+
p && !f && /* @__PURE__ */ h("button", {
|
|
150
|
+
type: "button",
|
|
151
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
152
|
+
onClick: (e) => {
|
|
153
|
+
e.stopPropagation(), w();
|
|
154
|
+
},
|
|
155
|
+
className: "text-slate-500 hover:text-slate-600 dark:hover:text-slate-300 transition-colors",
|
|
156
|
+
"aria-label": "Clear all",
|
|
157
|
+
children: /* @__PURE__ */ h(v, {})
|
|
158
|
+
}),
|
|
159
|
+
m.length > 0 && /* @__PURE__ */ h("span", {
|
|
160
|
+
className: "text-[10px] font-medium text-slate-500 tabular-nums",
|
|
161
|
+
children: m.length
|
|
162
|
+
})
|
|
163
|
+
]
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/components/autocomplete/dropdown.tsx
|
|
170
|
+
function C({ listRef: t, listId: n, open: r, pos: i, multiple: s, loading: c, filtered: l, emptyMessage: u, activeIdx: d, setActiveIdx: f, inputText: p, selectedValues: m, singleValue: v, onSelectSingle: x, onToggleMulti: S, className: C }) {
|
|
171
|
+
return typeof document > "u" ? null : _(/* @__PURE__ */ h(a, { children: r && i && /* @__PURE__ */ h(o.ul, {
|
|
172
|
+
ref: t,
|
|
173
|
+
id: n,
|
|
174
|
+
role: "listbox",
|
|
175
|
+
"aria-multiselectable": s,
|
|
176
|
+
initial: {
|
|
177
|
+
opacity: 0,
|
|
178
|
+
y: i.placement === "bottom" ? -4 : 4
|
|
179
|
+
},
|
|
180
|
+
animate: {
|
|
181
|
+
opacity: 1,
|
|
182
|
+
y: 0
|
|
183
|
+
},
|
|
184
|
+
exit: {
|
|
185
|
+
opacity: 0,
|
|
186
|
+
y: i.placement === "bottom" ? -4 : 4
|
|
187
|
+
},
|
|
188
|
+
transition: { duration: .13 },
|
|
189
|
+
style: {
|
|
190
|
+
position: "fixed",
|
|
191
|
+
top: i.top,
|
|
192
|
+
left: i.left,
|
|
193
|
+
width: i.width,
|
|
194
|
+
maxHeight: i.maxHeight
|
|
195
|
+
},
|
|
196
|
+
className: e("z-[110] overflow-y-auto rounded-[var(--radius-lg)] border border-border bg-surface-raised py-1 shadow-floating", C),
|
|
197
|
+
children: c ? /* @__PURE__ */ g("li", {
|
|
198
|
+
className: "px-4 py-3 text-sm text-slate-600 flex items-center gap-2",
|
|
199
|
+
children: [/* @__PURE__ */ h(y, {}), "Loading…"]
|
|
200
|
+
}) : l.length === 0 ? /* @__PURE__ */ h("li", {
|
|
201
|
+
className: "px-4 py-3 text-sm text-slate-600",
|
|
202
|
+
children: u
|
|
203
|
+
}) : l.map((t, r) => {
|
|
204
|
+
let i = r === d, a = s ? m.includes(t.value) : t.value === v;
|
|
205
|
+
return /* @__PURE__ */ g("li", {
|
|
206
|
+
id: `${n}-opt-${r}`,
|
|
207
|
+
role: "option",
|
|
208
|
+
"aria-selected": a,
|
|
209
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
210
|
+
onClick: () => s ? S(t) : x(t),
|
|
211
|
+
onMouseEnter: () => f(r),
|
|
212
|
+
className: e("flex min-h-9 items-center gap-3 px-3 py-2 cursor-pointer transition-colors", i && "bg-surface-muted", a && !i && "bg-accent-50 dark:bg-accent-500/10"),
|
|
213
|
+
children: [
|
|
214
|
+
t.icon && /* @__PURE__ */ h("span", {
|
|
215
|
+
className: "shrink-0 text-slate-500 dark:text-slate-400",
|
|
216
|
+
children: t.icon
|
|
217
|
+
}),
|
|
218
|
+
/* @__PURE__ */ g("div", {
|
|
219
|
+
className: "min-w-0 flex-1",
|
|
220
|
+
children: [/* @__PURE__ */ h("p", {
|
|
221
|
+
className: e("text-sm", a ? "text-accent-700 dark:text-accent-300 font-medium" : "text-foreground"),
|
|
222
|
+
children: /* @__PURE__ */ h(b, {
|
|
223
|
+
text: t.label,
|
|
224
|
+
query: p
|
|
225
|
+
})
|
|
226
|
+
}), t.description && /* @__PURE__ */ h("p", {
|
|
227
|
+
className: "text-xs text-slate-500 mt-0.5 truncate",
|
|
228
|
+
children: t.description
|
|
229
|
+
})]
|
|
230
|
+
}),
|
|
231
|
+
a && /* @__PURE__ */ h("svg", {
|
|
232
|
+
"aria-hidden": "true",
|
|
233
|
+
width: "14",
|
|
234
|
+
height: "14",
|
|
235
|
+
viewBox: "0 0 24 24",
|
|
236
|
+
fill: "none",
|
|
237
|
+
stroke: "currentColor",
|
|
238
|
+
strokeWidth: "2.5",
|
|
239
|
+
strokeLinecap: "round",
|
|
240
|
+
strokeLinejoin: "round",
|
|
241
|
+
className: "text-accent-600 shrink-0",
|
|
242
|
+
children: /* @__PURE__ */ h("path", { d: "m20 6-11 11-5-5" })
|
|
243
|
+
})
|
|
244
|
+
]
|
|
245
|
+
}, String(t.value));
|
|
246
|
+
})
|
|
247
|
+
}) }), document.body);
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/components/autocomplete.tsx
|
|
251
|
+
function w(n, a) {
|
|
252
|
+
let { options: o, inputValue: s, onInputChange: _, label: v, hint: y, error: b, prefix: w, clearable: T = !0, loading: E = !1, emptyMessage: ee = "No results", maxVisible: te = 8, className: ne, wrapperClassName: re, listClassName: ie, placeholder: D, disabled: O, id: ae, multiple: k, unstyled: oe = !1, ...A } = n, { value: se, onSelect: ce, onDeselect: le, ...j } = A, ue = u(), M = ae ?? ue, N = `${M}-list`, P = `${M}-message`, [de, fe] = p(""), F = s === void 0 ? de : s, pe = i((e) => _?.(e)), I = c((e) => {
|
|
253
|
+
s === void 0 ? fe(e) : pe(e);
|
|
254
|
+
}, [s, pe]), [me, L] = p([]), R = d(() => {
|
|
255
|
+
if (!k) return [];
|
|
256
|
+
let e = n;
|
|
257
|
+
return e.value === void 0 ? me : o.filter((t) => e.value.includes(t.value));
|
|
258
|
+
}, [
|
|
259
|
+
k,
|
|
260
|
+
o,
|
|
261
|
+
n,
|
|
262
|
+
me
|
|
263
|
+
]), z = d(() => R.map((e) => e.value), [R]), [B, V] = p(!1), [H, U] = p(-1), W = f(null), G = f(null), K = f(null), [q, J] = p(""), Y = d(() => {
|
|
264
|
+
let e = q.trim().toLowerCase();
|
|
265
|
+
return o.filter((t) => !t.disabled && t.label.toLowerCase().includes(e)).slice(0, te);
|
|
266
|
+
}, [
|
|
267
|
+
o,
|
|
268
|
+
q,
|
|
269
|
+
te
|
|
270
|
+
]), X = c((e) => {
|
|
271
|
+
n.onSelect?.(e), I(e.label), V(!1), U(-1);
|
|
272
|
+
}, [n, I]), he = c((e) => {
|
|
273
|
+
let t = n, r = [...R, e];
|
|
274
|
+
t.value === void 0 && L(r), t.onSelect?.(e, r), I(""), U(-1), G.current?.focus();
|
|
275
|
+
}, [
|
|
276
|
+
R,
|
|
277
|
+
n,
|
|
278
|
+
I
|
|
279
|
+
]), Z = c((e) => {
|
|
280
|
+
let t = n, r = R.filter((t) => t.value !== e.value);
|
|
281
|
+
t.value === void 0 && L(r), t.onDeselect?.(e, r);
|
|
282
|
+
}, [R, n]), Q = c((e) => {
|
|
283
|
+
z.includes(e.value) ? Z(e) : he(e);
|
|
284
|
+
}, [
|
|
285
|
+
z,
|
|
286
|
+
Z,
|
|
287
|
+
he
|
|
288
|
+
]), ge = c(() => {
|
|
289
|
+
I(""), n.onSelect?.({
|
|
290
|
+
value: "",
|
|
291
|
+
label: ""
|
|
292
|
+
}), V(!1);
|
|
293
|
+
}, [n, I]), _e = c(() => {
|
|
294
|
+
n.value === void 0 && L([]), I("");
|
|
295
|
+
}, [n, I]), ve = c((e) => {
|
|
296
|
+
if (k && e.key === "Backspace" && F === "" && R.length > 0) {
|
|
297
|
+
Z(R[R.length - 1]);
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
if (!B) {
|
|
301
|
+
(e.key === "ArrowDown" || e.key === "ArrowUp") && (V(!0), J(""));
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
if (e.key === "ArrowDown") e.preventDefault(), U((e) => Math.min(e + 1, Y.length - 1));
|
|
305
|
+
else if (e.key === "ArrowUp") e.preventDefault(), U((e) => Math.max(e - 1, 0));
|
|
306
|
+
else if (e.key === "Enter") {
|
|
307
|
+
e.preventDefault();
|
|
308
|
+
let t = Y[H];
|
|
309
|
+
if (!t) return;
|
|
310
|
+
k ? Q(t) : X(t);
|
|
311
|
+
} else e.key === "Escape" && (V(!1), U(-1));
|
|
312
|
+
}, [
|
|
313
|
+
k,
|
|
314
|
+
F,
|
|
315
|
+
R,
|
|
316
|
+
B,
|
|
317
|
+
Y,
|
|
318
|
+
H,
|
|
319
|
+
Q,
|
|
320
|
+
X,
|
|
321
|
+
Z
|
|
322
|
+
]);
|
|
323
|
+
l(() => {
|
|
324
|
+
H < 0 || !K.current || K.current.children[H]?.scrollIntoView({ block: "nearest" });
|
|
325
|
+
}, [H]), l(() => {
|
|
326
|
+
function e(e) {
|
|
327
|
+
let t = e.target;
|
|
328
|
+
!W.current?.contains(t) && !K.current?.contains(t) && V(!1);
|
|
329
|
+
}
|
|
330
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
331
|
+
}, []);
|
|
332
|
+
let ye = k ? void 0 : n.value, be = !!(!k && T && F.length > 0 && !O), xe = !!(k && T && (R.length > 0 || F.length > 0) && !O), Se = r(B, W), $ = c((e) => {
|
|
333
|
+
I(e.target.value), J(e.target.value), V(!0), U(-1);
|
|
334
|
+
}, [I]), Ce = c(() => {
|
|
335
|
+
V(!0), J("");
|
|
336
|
+
}, []);
|
|
337
|
+
return oe ? /* @__PURE__ */ g("div", {
|
|
338
|
+
ref: W,
|
|
339
|
+
className: e(ne, re),
|
|
340
|
+
children: [/* @__PURE__ */ h("input", {
|
|
341
|
+
ref: a,
|
|
342
|
+
id: M,
|
|
343
|
+
value: F,
|
|
344
|
+
onChange: $,
|
|
345
|
+
placeholder: D,
|
|
346
|
+
disabled: O
|
|
347
|
+
}), B && /* @__PURE__ */ h("ul", {
|
|
348
|
+
ref: K,
|
|
349
|
+
id: N,
|
|
350
|
+
className: ie,
|
|
351
|
+
children: Y.map((e) => /* @__PURE__ */ h("li", {
|
|
352
|
+
onClick: () => k ? Q(e) : X(e),
|
|
353
|
+
children: e.label
|
|
354
|
+
}, String(e.value)))
|
|
355
|
+
})]
|
|
356
|
+
}) : /* @__PURE__ */ g("div", {
|
|
357
|
+
ref: W,
|
|
358
|
+
className: e("relative", t, re, ne),
|
|
359
|
+
children: [
|
|
360
|
+
v && /* @__PURE__ */ g("label", {
|
|
361
|
+
htmlFor: M,
|
|
362
|
+
className: "text-sm font-medium leading-5 text-foreground",
|
|
363
|
+
children: [v, A.required && /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h("span", {
|
|
364
|
+
"aria-hidden": "true",
|
|
365
|
+
className: "ml-1 text-destructive",
|
|
366
|
+
children: "*"
|
|
367
|
+
}), /* @__PURE__ */ h("span", {
|
|
368
|
+
className: "sr-only",
|
|
369
|
+
children: " (required)"
|
|
370
|
+
})] })]
|
|
371
|
+
}),
|
|
372
|
+
!k && /* @__PURE__ */ h(x, {
|
|
373
|
+
inputRef: a,
|
|
374
|
+
inputId: M,
|
|
375
|
+
listId: N,
|
|
376
|
+
open: B,
|
|
377
|
+
activeIdx: H,
|
|
378
|
+
inputText: F,
|
|
379
|
+
prefix: w,
|
|
380
|
+
placeholder: D,
|
|
381
|
+
disabled: O,
|
|
382
|
+
error: b,
|
|
383
|
+
loading: E,
|
|
384
|
+
showClear: be,
|
|
385
|
+
onInputChange: $,
|
|
386
|
+
onFocus: Ce,
|
|
387
|
+
onKeyDown: ve,
|
|
388
|
+
onClear: ge,
|
|
389
|
+
messageId: b || y ? P : void 0,
|
|
390
|
+
inputProps: j
|
|
391
|
+
}),
|
|
392
|
+
k && /* @__PURE__ */ h(S, {
|
|
393
|
+
inputRef: (e) => {
|
|
394
|
+
G.current = e, typeof a == "function" ? a(e) : a && (a.current = e);
|
|
395
|
+
},
|
|
396
|
+
inputId: M,
|
|
397
|
+
listId: N,
|
|
398
|
+
open: B,
|
|
399
|
+
activeIdx: H,
|
|
400
|
+
inputText: F,
|
|
401
|
+
prefix: w,
|
|
402
|
+
placeholder: D,
|
|
403
|
+
disabled: O,
|
|
404
|
+
error: b,
|
|
405
|
+
loading: E,
|
|
406
|
+
showClear: xe,
|
|
407
|
+
selected: R,
|
|
408
|
+
onContainerClick: () => {
|
|
409
|
+
O || (G.current?.focus(), V(!0), J(""));
|
|
410
|
+
},
|
|
411
|
+
onInputChange: $,
|
|
412
|
+
onFocus: Ce,
|
|
413
|
+
onKeyDown: ve,
|
|
414
|
+
onRemove: Z,
|
|
415
|
+
onClearAll: _e,
|
|
416
|
+
messageId: b || y ? P : void 0,
|
|
417
|
+
inputProps: j
|
|
418
|
+
}),
|
|
419
|
+
/* @__PURE__ */ h(C, {
|
|
420
|
+
listRef: K,
|
|
421
|
+
listId: N,
|
|
422
|
+
open: B,
|
|
423
|
+
pos: Se,
|
|
424
|
+
multiple: k,
|
|
425
|
+
loading: E,
|
|
426
|
+
filtered: Y,
|
|
427
|
+
emptyMessage: ee,
|
|
428
|
+
activeIdx: H,
|
|
429
|
+
setActiveIdx: U,
|
|
430
|
+
inputText: q,
|
|
431
|
+
selectedValues: z,
|
|
432
|
+
singleValue: ye,
|
|
433
|
+
onSelectSingle: X,
|
|
434
|
+
onToggleMulti: Q,
|
|
435
|
+
className: ie
|
|
436
|
+
}),
|
|
437
|
+
b && /* @__PURE__ */ h("p", {
|
|
438
|
+
id: P,
|
|
439
|
+
"aria-live": "polite",
|
|
440
|
+
className: "text-xs leading-5 text-destructive",
|
|
441
|
+
children: b
|
|
442
|
+
}),
|
|
443
|
+
y && !b && /* @__PURE__ */ h("p", {
|
|
444
|
+
id: P,
|
|
445
|
+
className: "text-xs leading-5 text-muted-foreground",
|
|
446
|
+
children: y
|
|
447
|
+
})
|
|
448
|
+
]
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
var T = s(w);
|
|
452
|
+
//#endregion
|
|
453
|
+
export { T as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./cn-BdjraxxU.cjs"),t=require("./component-styles-TkZ7v6Ef.cjs");let n=require("framer-motion"),r=require("react"),i=require("react/jsx-runtime");var a=[`Su`,`Mo`,`Tu`,`We`,`Th`,`Fr`,`Sa`],o=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],s=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],c={blue:`bg-blue-500/12 text-blue-400 border-blue-500/20`,green:`bg-emerald-500/12 text-emerald-400 border-emerald-500/20`,red:`bg-red-500/12 text-red-400 border-red-500/20`,yellow:`bg-amber-500/12 text-amber-400 border-amber-500/20`,purple:`bg-violet-500/12 text-violet-400 border-violet-500/20`,orange:`bg-orange-500/12 text-orange-400 border-orange-500/20`};function l(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function u(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function d(e){let t=new Date(e);return t.setDate(t.getDate()-t.getDay()),t}var f={enter:e=>({opacity:0,x:e*16}),center:{opacity:1,x:0},exit:e=>({opacity:0,x:e*-16})};function p({viewDate:t,today:n,value:r,events:o,onSelect:s,onEventClick:u,isDateDisabled:d,onEventCreate:f,onEventDelete:p,editingId:m,onEditToggle:h,onUpdateTitle:g}){let _=t.getFullYear(),v=t.getMonth(),y=new Date(_,v+1,0).getDate(),b=new Date(_,v,1).getDay(),x=[...Array(b).fill(null),...Array.from({length:y},(e,t)=>new Date(_,v,t+1))];for(;x.length%7!=0;)x.push(null);function S(e){return o.filter(t=>l(t.date,e))}return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`div`,{role:`row`,className:`grid grid-cols-7 border-b border-border`,children:a.map(e=>(0,i.jsx)(`div`,{role:`columnheader`,className:`py-2.5 text-center text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:e},e))}),(0,i.jsx)(`div`,{role:`grid`,className:`grid grid-cols-7`,style:{gridTemplateRows:`repeat(${x.length/7}, minmax(80px, 1fr))`},children:x.map((t,a)=>{let o=a%7==6,h=a>=x.length-7;if(!t)return(0,i.jsx)(`div`,{role:`gridcell`,className:e.t(`border-black/6 dark:border-white/6 bg-black/[0.015] dark:bg-white/[0.015]`,!o&&`border-r`,!h&&`border-b`)},`e${a}`);let g=S(t),_=n?l(t,n):!1,y=r?l(t,r):!1,b=t.getMonth()===v,C=d?.(t)??!1;return(0,i.jsxs)(`div`,{role:`gridcell`,tabIndex:C?void 0:0,"aria-label":t.toLocaleDateString(void 0,{dateStyle:`full`}),"aria-disabled":C||void 0,"aria-selected":y,onClick:()=>!C&&s(t),onKeyDown:e=>{!C&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(t))},className:e.t(`p-1.5 transition-colors group/cell`,`border-border focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-ring/35`,!o&&`border-r`,!h&&`border-b`,!b&&`bg-black/[0.015] dark:bg-white/[0.015]`,C?`cursor-not-allowed opacity-40`:`cursor-pointer hover:bg-surface-muted`),children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,i.jsx)(`span`,{className:e.t(`w-6 h-6 rounded-full flex items-center justify-center text-xs font-medium`,y?`bg-primary text-primary-foreground`:_?`border border-accent-500/50 text-accent-600 dark:text-accent-300`:b?`text-slate-700 dark:text-slate-200`:`text-slate-400 dark:text-slate-600`),children:t.getDate()}),f&&!C&&(0,i.jsx)(`button`,{type:`button`,"aria-label":`Add event on ${t.toLocaleDateString()}`,onClick:e=>{e.stopPropagation(),f(t)},className:`opacity-0 group-hover/cell:opacity-100 focus:opacity-100 w-5 h-5 rounded-md bg-primary text-primary-foreground flex items-center justify-center text-[10px] hover:bg-primary-hover transition-opacity`,children:`+`})]}),(0,i.jsxs)(`div`,{className:`space-y-0.5`,children:[g.slice(0,2).map(t=>{let n=m===t.id;return(0,i.jsxs)(`div`,{className:e.t(`group/ev flex items-center gap-0.5 rounded border px-1 py-0.5`,c[t.color??`blue`],n&&`ring-1 ring-focus-ring`),children:[(0,i.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u?.(t)},className:`min-w-0 flex-1 truncate text-left text-[10px] font-medium`,children:[t.time&&(0,i.jsx)(`span`,{className:`opacity-60 mr-1`,children:t.time}),t.title]}),p&&(0,i.jsx)(`button`,{type:`button`,"aria-label":`Delete ${t.title}`,onClick:e=>{e.stopPropagation(),p(t.id)},className:`flex size-4 shrink-0 items-center justify-center rounded text-[10px] leading-none opacity-60 hover:bg-muted hover:opacity-100`,children:`×`})]},t.id)}),g.length>2&&(0,i.jsxs)(`p`,{className:`text-[10px] text-slate-500 px-1`,children:[`+`,g.length-2,` more`]})]})]},t.toISOString())})})]})}function m({viewDate:t,today:n,value:r,events:a,onSelect:s,onEventClick:f,isDateDisabled:p,onEventCreate:m,onEventDelete:h,editingId:g,onEditToggle:_,onUpdateTitle:v}){let y=d(t),b=Array.from({length:7},(e,t)=>u(y,t));function x(e){return a.filter(t=>l(t.date,e))}return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`div`,{role:`row`,className:`grid grid-cols-7 border-b border-border`,children:b.map(t=>{let a=n?l(t,n):!1,c=r?l(t,r):!1,u=p?.(t)??!1;return(0,i.jsxs)(`div`,{role:`gridcell`,tabIndex:u?void 0:0,"aria-selected":c,"aria-disabled":u||void 0,"aria-label":t.toLocaleDateString(void 0,{dateStyle:`full`}),onClick:()=>!u&&s(t),onKeyDown:e=>{!u&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(t))},className:e.t(`group/whead flex flex-col items-center gap-1 py-3 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-ring/35`,u?`cursor-not-allowed opacity-40`:`cursor-pointer hover:bg-surface-muted`),children:[(0,i.jsx)(`span`,{className:`text-[10px] font-semibold text-slate-400 dark:text-slate-500 uppercase tracking-wide`,children:o[t.getDay()]}),(0,i.jsx)(`span`,{className:e.t(`w-8 h-8 rounded-full flex items-center justify-center text-sm font-semibold transition-colors`,c?`bg-primary text-primary-foreground`:a?`border border-accent-500/50 text-accent-600 dark:text-accent-300`:`text-slate-700 dark:text-slate-200`),children:t.getDate()}),m&&!u&&(0,i.jsx)(`button`,{type:`button`,"aria-label":`Add event on ${t.toLocaleDateString()}`,onClick:e=>{e.stopPropagation(),m(t)},className:`opacity-0 group-hover/whead:opacity-100 focus:opacity-100 h-5 px-1.5 rounded-md bg-primary text-primary-foreground text-[10px] hover:bg-primary-hover`,children:`+ Add`})]},t.toISOString())})}),(0,i.jsx)(`div`,{className:`grid grid-cols-7 min-h-[200px]`,children:b.map((t,n)=>{let r=x(t),a=n===6,o=p?.(t)??!1;return(0,i.jsx)(`div`,{role:`gridcell`,tabIndex:o?void 0:0,"aria-disabled":o||void 0,"aria-label":`${t.toLocaleDateString(void 0,{dateStyle:`full`})} events`,onClick:()=>!o&&s(t),onKeyDown:e=>{!o&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(t))},className:e.t(`space-y-1.5 p-2 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-ring/35`,!a&&`border-r border-border`,o?`cursor-not-allowed opacity-40`:`cursor-pointer hover:bg-surface-muted/70`),children:r.map(t=>(0,i.jsxs)(`div`,{className:e.t(`group/wev flex items-start gap-1 rounded-[var(--radius-md)] border px-2 py-1.5`,c[t.color??`blue`],g===t.id&&`ring-1 ring-focus-ring`),children:[(0,i.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),f?.(t)},className:`min-w-0 flex-1 text-left`,children:[t.time&&(0,i.jsx)(`div`,{className:`text-[10px] opacity-60 mb-0.5`,children:t.time}),(0,i.jsx)(`div`,{className:`text-xs font-medium truncate`,children:t.title})]}),h&&(0,i.jsx)(`button`,{type:`button`,"aria-label":`Delete ${t.title}`,onClick:e=>{e.stopPropagation(),h(t.id)},className:`flex size-5 shrink-0 items-center justify-center rounded text-xs opacity-60 hover:bg-muted hover:opacity-100`,children:`×`})]},t.id))},t.toISOString())})})]})}function h({value:a,defaultValue:o=null,onChange:c,events:l,defaultEvents:h=[],onEventsChange:g,onEventClick:_,onEventCreate:v,onEventUpdate:y,onEventDelete:b,editable:x=!1,view:S,defaultView:C=`month`,onViewChange:ee,viewDate:w,defaultViewDate:T,onViewDateChange:te,minDate:E,maxDate:D,disabledDates:O,className:ne}){let[re,ie]=(0,r.useState)(null),[ae,oe]=(0,r.useState)(o),[se,ce]=(0,r.useState)(C),[k,A]=(0,r.useState)(T??null),[le,ue]=(0,r.useState)(()=>l??h),[j,M]=(0,r.useState)(1),[N,P]=(0,r.useState)(null),[F,I]=(0,r.useState)(``),[L,de]=(0,r.useState)(`blue`),[R,z]=(0,r.useState)(`09:00`),[B,V]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=new Date;ie(e),T===void 0&&w===void 0&&A(new Date(e.getFullYear(),e.getMonth(),1))},[]),(0,r.useEffect)(()=>{w===void 0&&T!==void 0&&k===null&&A(T?new Date(T):null)},[T]);let fe=a===void 0?ae:a,H=S===void 0?se:S,U=w===void 0?k:w,W=l!==void 0,G=W?l:le;function K(e){return!!(E&&e<new Date(E.getFullYear(),E.getMonth(),E.getDate())||D&&e>new Date(D.getFullYear(),D.getMonth(),D.getDate(),23,59,59,999)||O?.(e))}function pe(e){S===void 0&&ce(e),ee?.(e)}function q(e){e!==null&&(w===void 0&&A(e),te?.(e))}function J(e){K(e)||(a===void 0&&oe(e),c?.(e))}function me(e){return e&&(H===`month`?new Date(e.getFullYear(),e.getMonth()-1,1):u(e,-7))}function he(e){return e&&(H===`month`?new Date(e.getFullYear(),e.getMonth()+1,1):u(e,7))}function ge(){M(-1),q(me(U))}function _e(){M(1),q(he(U))}function ve(){let e=new Date;M(0),q(new Date(e.getFullYear(),e.getMonth(),1)),J(e)}function Y(e){W||ue(e),g?.(e)}function X(e,t){if(K(e))return;let n={id:typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():String(Date.now()+Math.random()),title:t?.trim()||F.trim()||`New event`,date:new Date(e),color:L,time:R||void 0};Y([...G,n]),v?.(n),P(null),I(``),z(`09:00`)}function Z(e){Y(G.filter(t=>t.id!==e)),b?.(e),B===e&&V(null)}function Q(e){Y(G.map(t=>t.id===e.id?e:t)),y?.(e),V(null)}function ye(e){x&&V(t=>t===e.id?null:e.id),_?.(e)}let $=``;if(U){if(H===`month`)$=`${s[U.getMonth()]} ${U.getFullYear()}`;else{let e=d(U),t=u(e,6);$=e.getMonth()===t.getMonth()?`${s[e.getMonth()].slice(0,3)} ${e.getDate()} \u2013 ${t.getDate()}, ${e.getFullYear()}`:`${s[e.getMonth()].slice(0,3)} ${e.getDate()} \u2013 ${s[t.getMonth()].slice(0,3)} ${t.getDate()}, ${e.getFullYear()}`}}let be=x||!!v||!!y||!!b||!!g,xe={today:re,value:fe,events:G,onSelect:J,onEventClick:ye,onEventCreate:be?e=>P(e):void 0,onEventDelete:be||b?Z:void 0,onEventUpdate:y,editingId:B,onEditToggle:e=>V(t=>t===e?null:e),onUpdateTitle:(e,t)=>{let n=G.find(t=>t.id===e);n&&Q({...n,title:t})},minDate:E,maxDate:D,disabledDates:O,isDateDisabled:K},Se=U?`${H}-${U.toISOString()}`:null;return(0,i.jsxs)(`div`,{className:e.t(`flex flex-col overflow-hidden rounded-[var(--radius-lg)] border border-border bg-surface`,ne),children:[(0,i.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border px-3 py-3 sm:px-4`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,i.jsx)(`button`,{type:`button`,onClick:ge,"aria-label":`Previous ${H}`,className:e.t(t.c,`size-8`),children:(0,i.jsx)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,i.jsx)(`path`,{d:`m15 18-6-6 6-6`})})}),(0,i.jsx)(`button`,{type:`button`,onClick:_e,"aria-label":`Next ${H}`,className:e.t(t.c,`size-8`),children:(0,i.jsx)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,i.jsx)(`path`,{d:`m9 18 6-6-6-6`})})})]}),(0,i.jsx)(`span`,{"aria-live":`polite`,className:`min-w-[9rem] flex-1 select-none text-sm font-semibold text-foreground`,children:$}),(0,i.jsx)(`button`,{type:`button`,onClick:ve,className:e.t(`h-8 rounded-[var(--radius-md)] border border-border px-3 text-xs font-medium text-muted-foreground transition-colors hover:border-border-strong hover:bg-muted hover:text-foreground`,t.s),children:`Today`}),(0,i.jsx)(`div`,{role:`group`,"aria-label":`Calendar view`,className:`flex overflow-hidden rounded-[var(--radius-md)] border border-border`,children:[`month`,`week`].map(n=>(0,i.jsx)(`button`,{type:`button`,onClick:()=>pe(n),"aria-pressed":H===n,className:e.t(`h-8 px-3 text-xs capitalize transition-colors focus-visible:z-10`,t.s,H===n?`bg-muted text-foreground font-medium`:`text-muted-foreground hover:bg-surface-muted hover:text-foreground`),children:n},n))})]}),N&&(0,i.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border bg-warning/8 px-3 py-3 sm:px-4`,children:[(0,i.jsxs)(`span`,{className:`text-xs font-medium text-foreground`,children:[`New event on `,N.toLocaleDateString(),`:`]}),(0,i.jsx)(`input`,{autoFocus:!0,value:F,onChange:e=>I(e.target.value),onKeyDown:e=>{e.key===`Enter`&&X(N),e.key===`Escape`&&(P(null),I(``),z(`09:00`))},placeholder:`Event title`,className:`h-7 flex-1 min-w-[140px] rounded-md border border-border bg-surface px-2 text-xs text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-focus-ring/25`}),(0,i.jsx)(`input`,{type:`time`,value:R,onChange:e=>z(e.target.value),className:`h-7 w-[110px] rounded-md border border-border bg-surface px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-focus-ring/25`}),(0,i.jsxs)(`select`,{"aria-label":`Event color`,value:L,onChange:e=>de(e.target.value),className:`h-7 rounded-[var(--radius-md)] border border-border bg-surface px-2 text-xs text-foreground`,children:[(0,i.jsx)(`option`,{value:`blue`,children:`Blue`}),(0,i.jsx)(`option`,{value:`green`,children:`Green`}),(0,i.jsx)(`option`,{value:`red`,children:`Red`}),(0,i.jsx)(`option`,{value:`yellow`,children:`Yellow`}),(0,i.jsx)(`option`,{value:`purple`,children:`Purple`}),(0,i.jsx)(`option`,{value:`orange`,children:`Orange`})]}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>X(N),className:`h-7 px-3 rounded-md bg-primary text-xs font-medium text-primary-foreground hover:bg-primary-hover`,children:`Add`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>{P(null),I(``),z(`09:00`)},className:`h-7 rounded-[var(--radius-md)] border border-border bg-surface px-2.5 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:`Cancel`})]}),B&&(()=>{let e=G.find(e=>e.id===B);return e?(0,i.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border bg-surface-muted px-3 py-3 sm:px-4`,children:[(0,i.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Edit event:`}),(0,i.jsx)(`input`,{autoFocus:!0,defaultValue:e.title,onKeyDown:t=>{if(t.key===`Enter`){let n=t.target.value,r=document.getElementById(`cal-edit-time-${e.id}`)?.value??e.time??``;n.trim()&&Q({...e,title:n.trim(),time:r||void 0})}t.key===`Escape`&&V(null)},id:`cal-edit-${e.id}`,placeholder:`Title`,className:`h-7 flex-1 min-w-[140px] rounded-md border border-border bg-surface px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-focus-ring/25`}),(0,i.jsx)(`input`,{type:`time`,defaultValue:e.time??``,id:`cal-edit-time-${e.id}`,className:`h-7 w-[110px] rounded-md border border-border bg-surface px-2 text-xs text-foreground focus:outline-none focus:ring-2 focus:ring-focus-ring/25`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>{let t=document.getElementById(`cal-edit-${e.id}`),n=document.getElementById(`cal-edit-time-${e.id}`),r=t?.value??e.title,i=n?.value??``;r.trim()&&Q({...e,title:r.trim(),time:i||void 0})},className:`h-7 px-3 rounded-md bg-primary text-xs font-medium text-primary-foreground hover:bg-primary-hover`,children:`Save`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>Z(e.id),className:`h-7 rounded-[var(--radius-md)] bg-destructive px-2.5 text-xs font-medium text-destructive-foreground hover:bg-destructive-hover`,children:`Delete`}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>V(null),className:`h-7 rounded-[var(--radius-md)] border border-border bg-surface px-2.5 text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:`Cancel`})]}):null})(),(0,i.jsx)(`div`,{className:`relative flex-1 overflow-x-auto`,children:(0,i.jsx)(`div`,{className:`min-w-[42rem]`,children:(0,i.jsx)(n.AnimatePresence,{mode:`popLayout`,initial:!1,custom:j,children:Se!==null&&U!==null&&(0,i.jsx)(n.motion.div,{custom:j,variants:f,initial:`enter`,animate:`center`,exit:`exit`,transition:{duration:.18,ease:`easeInOut`},children:H===`month`?(0,i.jsx)(p,{viewDate:U,...xe}):(0,i.jsx)(m,{viewDate:U,...xe})},Se)})})})]})}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}});
|