@handijitcom/ui 2.0.1 → 3.0.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/README.md +67 -62
- package/build/calendar.cjs +1 -1
- package/build/calendar.cjs.map +1 -1
- package/build/calendar.css +1 -1
- package/build/calendar.js +109 -111
- package/build/calendar.js.map +1 -1
- package/build/chat.cjs +1 -1
- package/build/chat.cjs.map +1 -1
- package/build/chat.css +1 -1
- package/build/chat.js +2 -2
- package/build/chat.js.map +1 -1
- package/build/components/Alert/style.css +1 -1
- package/build/components/Avatar/index.cjs.map +1 -1
- package/build/components/Avatar/index.d.cts +1 -1
- package/build/components/Avatar/index.d.ts +1 -1
- package/build/components/Avatar/index.js.map +1 -1
- package/build/components/Avatar/style.css +1 -1
- package/build/components/Badge/index.cjs +1 -1
- package/build/components/Badge/index.cjs.map +1 -1
- package/build/components/Badge/index.d.cts +4 -2
- package/build/components/Badge/index.d.ts +4 -2
- package/build/components/Badge/index.js +1 -1
- package/build/components/Badge/index.js.map +1 -1
- package/build/components/Badge/style.css +1 -1
- package/build/components/BrandSurface/index.cjs +2 -0
- package/build/components/BrandSurface/index.cjs.map +1 -0
- package/build/components/BrandSurface/index.d.cts +46 -0
- package/build/components/BrandSurface/index.d.ts +46 -0
- package/build/components/BrandSurface/index.js +128 -0
- package/build/components/BrandSurface/index.js.map +1 -0
- package/build/components/BrandSurface/style.css +1 -0
- package/build/components/Button/index.cjs +1 -1
- package/build/components/Button/index.js +1 -1
- package/build/components/Button/style.css +1 -1
- package/build/components/CodeBadge/style.css +1 -1
- package/build/components/CopyField/style.css +1 -1
- package/build/components/DataTable/style.css +1 -1
- package/build/components/Eyebrow/index.cjs.map +1 -1
- package/build/components/Eyebrow/index.d.cts +1 -1
- package/build/components/Eyebrow/index.d.ts +1 -1
- package/build/components/Eyebrow/index.js.map +1 -1
- package/build/components/Eyebrow/style.css +1 -1
- package/build/components/Modal/style.css +1 -1
- package/build/components/Progress/index.cjs +1 -1
- package/build/components/Progress/index.cjs.map +1 -1
- package/build/components/Progress/index.d.cts +2 -2
- package/build/components/Progress/index.d.ts +2 -2
- package/build/components/Progress/index.js +1 -1
- package/build/components/Progress/index.js.map +1 -1
- package/build/components/Progress/style.css +1 -1
- package/build/components/Rating/style.css +1 -1
- package/build/components/RatingInput/style.css +1 -1
- package/build/components/Stat/style.css +1 -1
- package/build/components/StatStrip/index.cjs +1 -1
- package/build/components/StatStrip/index.cjs.map +1 -1
- package/build/components/StatStrip/index.d.cts +3 -3
- package/build/components/StatStrip/index.d.ts +3 -3
- package/build/components/StatStrip/index.js +1 -1
- package/build/components/StatStrip/index.js.map +1 -1
- package/build/components/StatStrip/style.css +1 -1
- package/build/components/StatusDot/index.cjs +1 -1
- package/build/components/StatusDot/index.cjs.map +1 -1
- package/build/components/StatusDot/index.d.cts +5 -3
- package/build/components/StatusDot/index.d.ts +5 -3
- package/build/components/StatusDot/index.js +1 -1
- package/build/components/StatusDot/index.js.map +1 -1
- package/build/components/StatusDot/style.css +1 -1
- package/build/components/TagInput/style.css +1 -1
- package/build/components/Textarea/style.css +1 -1
- package/build/components/Timeline/style.css +1 -1
- package/build/components/Toast/style.css +1 -1
- package/build/design/index.cjs +84 -178
- package/build/design/index.cjs.map +1 -1
- package/build/design/index.d.cts +72 -63
- package/build/design/index.d.mts +72 -63
- package/build/design/index.mjs +84 -178
- package/build/design/index.mjs.map +1 -1
- package/build/design/index.umd.cjs +1 -1
- package/build/design/index.umd.cjs.map +1 -1
- package/build/design/tokens.css +62 -177
- package/build/design/tokens.json +66 -168
- package/build/design/tokens.scss +48 -178
- package/build/enums/ui-variant.enum.cjs +1 -1
- package/build/enums/ui-variant.enum.cjs.map +1 -1
- package/build/enums/ui-variant.enum.d.cts +2 -2
- package/build/enums/ui-variant.enum.d.ts +2 -2
- package/build/enums/ui-variant.enum.js +1 -1
- package/build/enums/ui-variant.enum.js.map +1 -1
- package/build/index.cjs +1 -1
- package/build/index.d.cts +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.js +11 -11
- package/build/scss/_mixins.scss +8 -10
- package/build/scss/_variables.scss +19 -39
- package/build/styles.css +21 -21
- package/build/types/calendar/Calendar/index.d.cts +1 -1
- package/build/types/calendar/Calendar/index.d.ts +1 -1
- package/build/types/calendar/core/types.d.cts +3 -2
- package/build/types/calendar/core/types.d.ts +3 -2
- package/package.json +11 -11
- package/build/components/Band/index.cjs +0 -2
- package/build/components/Band/index.cjs.map +0 -1
- package/build/components/Band/index.d.cts +0 -45
- package/build/components/Band/index.d.ts +0 -45
- package/build/components/Band/index.js +0 -126
- package/build/components/Band/index.js.map +0 -1
- package/build/components/Band/style.css +0 -1
package/README.md
CHANGED
|
@@ -384,7 +384,7 @@ and changes when an announcement strip appears.
|
|
|
384
384
|
| Input | `Input` · `PasswordInput` · `Textarea` · `TagInput` · `DateField` (+ `DateRange`) · `FileUpload` · `Field` · `ScaledInput` · `MoneyInput` · `QuantityInput` · `RateInput` · `PercentInput` |
|
|
385
385
|
| Surface | `Card` (+ `CardMedia`, `CardOverlay`, `CardBody`, `CardFooter`) · `SummaryCard` · `Panel` (+ `PanelForm`, `PanelRow`) · `PageHeader` · `SectionHeader` · `Tile` · `Directory` (+ `DirectoryGroup`, `DirectoryRow`, `DirectoryJump`) · `Carousel` · `ScrollArea` · `Disclosure` · `Accordion` · `Tabs` |
|
|
386
386
|
| Feedback | `Alert` · `Badge` · `StatusDot` · `CodeBadge` · `Kbd` · `EmptyState` · `Skeleton` (+ `SkeletonCard`, `SkeletonRows`, `SkeletonTable`) · `Spinner` · `Progress` · `Steps` · `Divider` · `Avatar` · `Rating` · `Price` · `Stat` · `CopyField` · `Breadcrumb` · `ToastHub` (+ `ToastPortal`) |
|
|
387
|
-
| Brand
|
|
387
|
+
| Brand surface (3.0) | `BrandSurface` (+ `BrandBlueprint`) · `Eyebrow` · `StatStrip` |
|
|
388
388
|
| Modal | `Modal` · `Drawer` · `BottomSheet` · `ConfirmDialog` · `PromptDialog` · `CommandPalette` |
|
|
389
389
|
| Data | `Table` (+ `TableScroller`) · `DataTable` (+ `DataTableRow`) · `FilterBar` (+ `FilterBarField`) · `Pagination` · `Timeline` |
|
|
390
390
|
| Theme and hooks | `UiProvider` · `UiThemeScript` · `useUi` · `useUiTheme` · `useUiTokens` · `useAnnounce` · `useStickToBottom` · `usePositioning` · `useVirtualList` · `useListboxNavigation` · `hasOpenSurface` |
|
|
@@ -394,16 +394,16 @@ and changes when an announcement strip appears.
|
|
|
394
394
|
|
|
395
395
|
### Variants and sizes
|
|
396
396
|
|
|
397
|
-
| `UIVariant` | Use
|
|
398
|
-
| ----------- |
|
|
399
|
-
| `PRIMARY` | the one expected action of the screen: cobalt fill
|
|
400
|
-
| `ACCENT` | the conversion action (download, try, subscribe): coral fill, only that; on the
|
|
401
|
-
| `SECONDARY` | a neutral second action: grey border, body text
|
|
402
|
-
| `OUTLINE` | a cobalt frame: an encouraged navigation that is not the primary action
|
|
403
|
-
| `SOFT` | a neutral fill: a secondary action inside a card
|
|
404
|
-
| `GHOST` | no surface: toolbar and inline secondary actions, in the link colour
|
|
405
|
-
| `DANGER` | a destructive action
|
|
406
|
-
| `
|
|
397
|
+
| `UIVariant` | Use |
|
|
398
|
+
| ----------- | --------------------------------------------------------------------------------------------------- |
|
|
399
|
+
| `PRIMARY` | the one expected action of the screen: cobalt fill |
|
|
400
|
+
| `ACCENT` | the conversion action (download, try, subscribe): coral fill, only that; glows on the brand surface |
|
|
401
|
+
| `SECONDARY` | a neutral second action: grey border, body text |
|
|
402
|
+
| `OUTLINE` | a cobalt frame: an encouraged navigation that is not the primary action |
|
|
403
|
+
| `SOFT` | a neutral fill: a secondary action inside a card |
|
|
404
|
+
| `GHOST` | no surface: toolbar and inline secondary actions, in the link colour |
|
|
405
|
+
| `DANGER` | a destructive action |
|
|
406
|
+
| `ON_BRAND` | a second action on the brand surface (cobalt in both themes): white frame, white label |
|
|
407
407
|
|
|
408
408
|
`UISize`: `XSMALL` 28px · `SMALL` 32px · `MEDIUM` 40px · `LARGE` 48px. Fields
|
|
409
409
|
are 40px with 15px text on desktop and 44px with 16px text on a narrow or touch
|
|
@@ -413,9 +413,11 @@ screen (no iOS zoom, a full touch target).
|
|
|
413
413
|
`danger`. `secondary` and `outline` are drawn exactly like the `Button` variants
|
|
414
414
|
of the same name: the neutral frame and the cobalt frame. (Until 2.1 `outline`
|
|
415
415
|
was the neutral frame; use `secondary` for that look.)
|
|
416
|
-
`Badge tone`: `neutral` · `
|
|
417
|
-
`
|
|
418
|
-
a
|
|
416
|
+
`Badge tone`: `neutral` · `ink` · `info` · `danger`, each as `soft`, `solid` or
|
|
417
|
+
`outline`. The palette has one status hue, red (3.0): a good state is `info`
|
|
418
|
+
(cobalt), one that needs a look `ink` (the emphatic neutral). `StatusDot` and
|
|
419
|
+
`Calendar` tones follow the same names; `Alert`, `Toast` and `Modal` keep
|
|
420
|
+
`success` and `warning`, drawn in cobalt and ink and told apart by their icon.
|
|
419
421
|
|
|
420
422
|
### The number of options picks the element
|
|
421
423
|
|
|
@@ -586,28 +588,37 @@ the build with `skipLibCheck` off.
|
|
|
586
588
|
|
|
587
589
|
## Decisions the system carries
|
|
588
590
|
|
|
589
|
-
**Cobalt
|
|
590
|
-
primary action, the link, the selection
|
|
591
|
-
conversion button (`UIVariant.ACCENT` on `Button`,
|
|
592
|
-
`IconButton`) and appears nowhere else but the dot of the
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
591
|
+
**Cobalt, coral, ink.** The palette is three colours plus red for danger:
|
|
592
|
+
cobalt is the primary action, the link, the selection, the focus ring and the
|
|
593
|
+
brand surface; coral is the conversion button (`UIVariant.ACCENT` on `Button`,
|
|
594
|
+
`variant="accent"` on `IconButton`) and appears nowhere else but the dot of the
|
|
595
|
+
brand mark and code strings; ink (`#091122`) and its lightness steps are every
|
|
596
|
+
neutral. There is no green, amber, violet, cyan or navy (3.0); a design test
|
|
597
|
+
fails on any other hue. A success is cobalt and a warning ink, each with its
|
|
598
|
+
icon and text. `colour-footprint.test.ts` turns a coral or brand-surface token
|
|
599
|
+
in any other component's stylesheet into a failing test.
|
|
596
600
|
|
|
597
|
-
**The brand
|
|
598
|
-
a sign-in side or a footer
|
|
599
|
-
|
|
601
|
+
**The brand surface (3.0).** `BrandSurface` is the cobalt surface of a hero, a
|
|
602
|
+
closing call, a sign-in side or a footer: `primary` with white on it, the same
|
|
603
|
+
in both themes, needing no edge on either page:
|
|
600
604
|
|
|
601
605
|
```tsx
|
|
602
|
-
import {
|
|
606
|
+
import {
|
|
607
|
+
BrandBlueprint,
|
|
608
|
+
BrandSurface,
|
|
609
|
+
Button,
|
|
610
|
+
Eyebrow,
|
|
611
|
+
StatStrip,
|
|
612
|
+
UIVariant,
|
|
613
|
+
} from '@handijitcom/ui';
|
|
603
614
|
import { logos } from '@handijitcom/ui/design';
|
|
604
615
|
|
|
605
|
-
<
|
|
616
|
+
<BrandSurface
|
|
606
617
|
aria-labelledby="cta-title"
|
|
607
|
-
glow="both" // soft
|
|
608
|
-
dots="end" // the faded dot grid: 'start' · 'end' (default) · 'both' · 'none'
|
|
609
|
-
artwork={<
|
|
610
|
-
footer={<StatStrip variant="
|
|
618
|
+
glow="both" // soft white sheens: 'start' · 'end' · 'both' (default) · 'none'
|
|
619
|
+
dots="end" // the faded white dot grid: 'start' · 'end' (default) · 'both' · 'none'
|
|
620
|
+
artwork={<BrandBlueprint shape={logos.mark} />} // decorative, from the tablet width up
|
|
621
|
+
footer={<StatStrip variant="brand" items={[{ value: '2 saat', label: 'yanıt süresi' }]} />}
|
|
611
622
|
>
|
|
612
623
|
<Eyebrow>Teklif</Eyebrow>
|
|
613
624
|
<h2 id="cta-title">
|
|
@@ -615,25 +626,26 @@ import { logos } from '@handijitcom/ui/design';
|
|
|
615
626
|
{/* .full-stop: color var(--hd-accent) */}
|
|
616
627
|
</h2>
|
|
617
628
|
<Button variant={UIVariant.ACCENT}>Teklif alın</Button>
|
|
618
|
-
<Button variant={UIVariant.
|
|
619
|
-
</
|
|
629
|
+
<Button variant={UIVariant.ON_BRAND}>WhatsApp</Button>
|
|
630
|
+
</BrandSurface>;
|
|
620
631
|
```
|
|
621
632
|
|
|
622
|
-
- The gradient,
|
|
623
|
-
with ids from `useId`; nothing is
|
|
624
|
-
|
|
625
|
-
imagery is dropped and the
|
|
626
|
-
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
633
|
+
- The gradient (cobalt into `brand-surface-deep`), sheens, dot grid and
|
|
634
|
+
blueprint are **inline SVG**, `aria-hidden`, with ids from `useId`; nothing is
|
|
635
|
+
a CSS gradient. The component renders on the server. In forced colours the
|
|
636
|
+
imagery is dropped and the surface is a framed region.
|
|
637
|
+
- **Text on it is white only**: white on cobalt is 5.03:1, and white at 92% is
|
|
638
|
+
already 4.50:1, so there is no secondary text colour; use size and weight.
|
|
639
|
+
The white sheen stays at 6% so that white text over it is still 4.58:1.
|
|
640
|
+
- Inside it every focus ring is white: `BrandSurface` sets the `--ui-ring-color`
|
|
641
|
+
hook that `$focus` reads. `Eyebrow` and the `ACCENT` button read the surface
|
|
642
|
+
from `data-ui-brand-surface` (an application's own surface may carry it too).
|
|
643
|
+
- **Coral once per view as an action:** the surface's one action is the
|
|
644
|
+
`ACCENT` button, which glows softly there (`brand-surface-accent-glow`) and
|
|
645
|
+
nowhere else; coral on cobalt is 1.64:1, so its label (6.15:1) identifies it.
|
|
646
|
+
A second action is `ON_BRAND`. The coral full stop and the mark's dot are the
|
|
647
|
+
brand's punctuation. Opacity lives only in the surface's imagery.
|
|
648
|
+
- `StatStrip` (`page` or `brand`) is a list of value and label facts with thin
|
|
637
649
|
dividers; `Eyebrow` is the mono capital label with its rules (`start` or
|
|
638
650
|
`center`). The text is set in capitals by CSS, so give the page a `lang`.
|
|
639
651
|
|
|
@@ -679,7 +691,7 @@ smaller; an invisible overlay keeps the area.
|
|
|
679
691
|
## Next.js App Router
|
|
680
692
|
|
|
681
693
|
The package draws the `'use client'` boundary **inside itself, per file**:
|
|
682
|
-
components without hooks (`Alert`, `Badge`, `
|
|
694
|
+
components without hooks (`Alert`, `Badge`, `BrandSurface`, `Button`, `Card`, `Chip`,
|
|
683
695
|
`Divider`, `EmptyState`, `IconButton`, `Kbd`, `PageHeader`, `Panel`,
|
|
684
696
|
`Progress`, `SectionHeader`, `Skeleton`, `StatusDot`, `SummaryCard`,
|
|
685
697
|
`TextLink`, `Tile`) render as server components and send no JavaScript; the
|
|
@@ -797,7 +809,7 @@ JSON is re-indented with two spaces (values are kept as text: large numbers are
|
|
|
797
809
|
not rounded) and blank lines at the edges are dropped; other languages keep
|
|
798
810
|
their indentation. More than 30 languages are recognised; an unknown one is
|
|
799
811
|
drawn plain. The token colours are design tokens (keyword `primary-text`,
|
|
800
|
-
string
|
|
812
|
+
string and number `accent-text`, type `text` at medium weight), so they
|
|
801
813
|
follow the theme and stay inside the measured text pairs. For Shiki-grade
|
|
802
814
|
accuracy pass pre-highlighted HTML as `html` (its safety is yours).
|
|
803
815
|
|
|
@@ -864,7 +876,7 @@ import { Calendar, type CalendarEvent } from '@handijitcom/ui/calendar';
|
|
|
864
876
|
<Calendar
|
|
865
877
|
label="Ders planı"
|
|
866
878
|
days={week} // [{ date: '2026-11-09', label: 'Pazartesi 9 Kasım', shortLabel: 'Pzt 9', isToday, isOff }]
|
|
867
|
-
resources={rooms} // optional: [{ id: 'r1', label: 'Derslik 1', detail: '7 / 8', tone: '
|
|
879
|
+
resources={rooms} // optional: [{ id: 'r1', label: 'Derslik 1', detail: '7 / 8', tone: 'ink' }]
|
|
868
880
|
bands={[{ label: 'Sabah', start: '08:00', end: '12:00' }]} // optional, 2.5
|
|
869
881
|
events={lessons} // [{ id, title, start: '2026-11-09T09:00', end: '2026-11-09T10:30', resourceId, tone, isCancelled, isLocked }]
|
|
870
882
|
startTime="08:00"
|
|
@@ -898,7 +910,7 @@ import { Calendar, type CalendarEvent } from '@handijitcom/ui/calendar';
|
|
|
898
910
|
a day or a week), ⌘/Ctrl ⇧ ↑ ↓ shorten or lengthen it. The new place is
|
|
899
911
|
announced (`labels.calendar.moved`) and the focus follows the event.
|
|
900
912
|
- **Resource headers and bands (2.5).** A resource's `detail` is a second
|
|
901
|
-
header line and its `tone` tints the header (Teknik Servis: `
|
|
913
|
+
header line and its `tone` tints the header (Teknik Servis: `ink` at 80%
|
|
902
914
|
of the day's capacity — the percentage goes in `detail`, colour is never
|
|
903
915
|
alone); `renderResource` draws the header instead. `bands` (`CalendarBand`:
|
|
904
916
|
`{ label, start, end }`, `HH:MM`) draws named stretches of the day ("Sabah",
|
|
@@ -991,10 +1003,10 @@ npm run playground # component gallery → http://localhost:5273
|
|
|
991
1003
|
TypeScript sources exists in the tokens of `src/design`; breakpoints
|
|
992
1004
|
and layers match it; no stylesheet declares an `--hd-*` property or carries
|
|
993
1005
|
a literal colour.
|
|
994
|
-
- **Colour footprint** (`colour-footprint.test.ts`): coral and
|
|
995
|
-
used only by the components on a justified allow-list, and the
|
|
996
|
-
roles
|
|
997
|
-
and
|
|
1006
|
+
- **Colour footprint** (`colour-footprint.test.ts`): coral and brand-surface
|
|
1007
|
+
tokens are used only by the components on a justified allow-list, and the
|
|
1008
|
+
removed roles (turquoise, success, warning, band, slate) cannot come back. A
|
|
1009
|
+
design test fails on any hue outside cobalt, coral and danger red.
|
|
998
1010
|
- **Contrast**: text ≥ 4.5:1, icons and the focus ring ≥ 3:1, measured on the
|
|
999
1011
|
values of the installed design package for every pair a component draws.
|
|
1000
1012
|
- **Accessibility scan** (`__tests__/components/a11y.test.tsx`): every exported
|
|
@@ -1051,13 +1063,6 @@ on npm yet**; otherwise it skips. A published version gets a `vX.Y.Z` tag and a
|
|
|
1051
1063
|
GitHub Release whose notes are that version's section of `CHANGELOG.md`, so the
|
|
1052
1064
|
section must exist before the push.
|
|
1053
1065
|
|
|
1054
|
-
⚠ **2.0.0 and the old tags.** The 2.x line of the previous package name
|
|
1055
|
-
(`@handijit/ui`) left the tags `v2.0.0`, `v2.1.0`, `v2.1.1` and `v2.2.0` on the
|
|
1056
|
-
origin. The workflow refuses to release onto an existing tag ("Tag v2.0.0
|
|
1057
|
-
already exists"), so before pushing 2.0.0 those four tags are renamed (for
|
|
1058
|
-
example to `handijit-ui-v2.0.0`) or deleted on the origin; otherwise the run
|
|
1059
|
-
fails after `verify`, before `npm publish`.
|
|
1060
|
-
|
|
1061
1066
|
## Design contract
|
|
1062
1067
|
|
|
1063
1068
|
Which element to use when, the surface ladder, colour roles, typography roles,
|
package/build/calendar.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),y=require("react"),me=require("@handijitcom/ui"),L=(...e)=>{let t="";for(const n of e)n&&(t=t===""?n:`${t} ${n}`);return t},we=(e,t)=>Object.assign(e,{displayName:t}),ge=new Set,re=(e,...t)=>{for(const n of t)if(n!==void 0)return n;return process.env.NODE_ENV!=="production"&&!ge.has(e)&&(ge.add(e),console.error(`[@handijitcom/ui] Eksik metin: ${e}. Prop olarak geçin ya da <UiProvider labels={…}> içinde bir kez tanımlayın. Metinsiz bırakılan öğe ekran okuyucuda adsız kalır.`)),""},ve=(e,t,...n)=>t?t(...n):re(e),ke=1440,W=e=>{const[t,n]=e.split(":");return Number(t)*60+Number(n??0)},Q=e=>`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`,F=e=>e.slice(0,10),U=e=>W(e.slice(11,16)),ee=(e,t)=>`${e}T${Q(t)}`,oe=(e,t)=>`${Q(e)}–${Q(t)}`,q=(e,t,n)=>Math.min(Math.max(e,t),n),Me=(e,t)=>`${e}|${t??""}`,je=(e,t)=>t&&t.length>0?e.flatMap((n,r)=>t.map((a,o)=>({index:r*t.length+o,day:n,resource:a,label:`${n.label}, ${a.label}`}))):e.map((n,r)=>({index:r,day:n,label:n.label})),pe=(e,t)=>{const n=F(e.start),r=F(e.end);return n<=t&&(t<r||t===r&&U(e.end)>0)},te=e=>F(e.start)===F(e.end),Ne=e=>{e.sort((o,s)=>o.startMin-s.startMin||s.endMin-o.endMin);let t=[],n=[],r=-1;const a=()=>{for(const o of t)o.lanes=n.length;t=[],n=[]};for(const o of e){o.startMin>=r&&a();const s=n.findIndex(_=>_<=o.startMin);o.lane=s===-1?n.length:s;const l=Math.max(o.endMin,o.startMin+1);n[o.lane]=l,r=Math.max(r,l),t.push(o)}a()},Ce=(e,t,n,r,a)=>{var k;const o=new Map(t.map(f=>{var c;return[Me(f.day.date,(c=f.resource)==null?void 0:c.id),f]})),s=t.some(f=>f.resource),l=t.map(()=>[]),_=(f,c)=>{const p=c.day.date,i=F(f.start)===p?U(f.start):0,m=F(f.end)===p?U(f.end):ke;m<=n||i>=r||l[c.index].push({key:`${f.id}@${c.index}`,event:f,column:c.index,startMin:Math.max(i,n),endMin:Math.min(m,r),lane:0,lanes:1,isMovable:a&&!f.isLocked&&te(f)&&i>=n&&m<=r})};for(const f of e){const c=s?f.resourceId:void 0;if(!(s&&c===void 0)){if(te(f)){const p=o.get(Me(F(f.start),c));p&&_(f,p);continue}for(const p of t)((k=p.resource)==null?void 0:k.id)===c&&pe(f,p.day.date)&&_(f,p)}}for(const f of l)Ne(f);return l},De=(e,t,n)=>{const r=new Map(t.map((s,l)=>[s.date,l])),a=t.map(()=>[]),o=(s,l)=>a[l].push({key:`${s.id}@${l}`,event:s,column:l,startMin:U(s.start),endMin:U(s.end),lane:0,lanes:1,isMovable:n&&!s.isLocked&&te(s)});for(const s of e){if(te(s)){const l=r.get(F(s.start));l!==void 0&&o(s,l);continue}t.forEach((l,_)=>{pe(s,l.date)&&o(s,_)})}for(const s of a)s.sort((l,_)=>l.event.start<_.event.start?-1:l.event.start>_.event.start?1:0);return a},$e=(e,t,n)=>(e??[]).flatMap((r,a)=>{const o=Math.max(W(r.start),t),s=Math.min(W(r.end),n);return s>o?[{key:`${a}`,label:r.label,startMin:o,endMin:s}]:[]}),V=(e,t,n,r,a)=>{if(a.view==="month")return r<0||r>=a.columnCount?void 0:{column:r,startMin:e.startMin,endMin:e.endMin};if(t){const l=Math.min(e.startMin+a.slotMinutes,a.rangeEnd);return{column:e.column,startMin:e.startMin,endMin:q(e.endMin+n,l,a.rangeEnd)}}const o=e.endMin-e.startMin,s=q(e.startMin+n,a.rangeStart,a.rangeEnd-o);return{column:q(r,0,a.columnCount-1),startMin:s,endMin:s+o}},Ee=(e,t,n,r,a)=>{var _;if(t.column===e.column&&t.startMin===e.startMin&&t.endMin===e.endMin)return;const s=n==="time"?r[t.column]:void 0,l=s?s.day.date:a[t.column].date;return{id:e.event.id,start:ee(l,t.startMin),end:ee(l,t.endMin),resourceId:((_=s==null?void 0:s.resource)==null?void 0:_.id)??e.event.resourceId}},Ae=e=>e==="ArrowUp"||e==="ArrowDown"||e==="ArrowLeft"||e==="ArrowRight",Re=(e,t,n)=>{if(n==="ArrowUp"||n==="ArrowDown"){const a=e[t.column],o=a.findIndex(s=>s.key===t.key);return a[o+(n==="ArrowDown"?1:-1)]}const r=n==="ArrowRight"?1:-1;for(let a=t.column+r;a>=0&&a<e.length;a+=r){const o=e[a];if(o.length!==0)return o.reduce((s,l)=>Math.abs(l.startMin-t.startMin)<Math.abs(s.startMin-t.startMin)?l:s)}},Te=(e,t,n,r)=>{const a=t==="ArrowUp"||t==="ArrowDown",o=t==="ArrowDown"||t==="ArrowRight"?1:-1;if(r.view==="month")return n?void 0:V(e,!1,0,e.column+o*(a?7:1),r);if(!(n&&!a))return a?V(e,n,o*r.slotMinutes,e.column,r):V(e,!1,0,e.column+o,r)},Le=4,Z=7,Oe=({bodyRef:e,bounds:t,onDrop:n})=>{const[r,a]=y.useState(null),o=y.useRef(null),s=y.useRef(!1),l=y.useRef({bounds:t,onDrop:n});l.current={bounds:t,onDrop:n};const _=(c,p)=>{var E;const i=(E=e.current)==null?void 0:E.getBoundingClientRect(),{bounds:m}=l.current;if(!i||i.width===0||i.height===0)return;if(m.view==="time"){const R=(m.rangeEnd-m.rangeStart)/i.height,$=(c.clientY-p.y)*R,x=Math.round($/m.slotMinutes)*m.slotMinutes,w=Math.floor((c.clientX-i.left)/i.width*m.columnCount);return V(p.item,p.isResize,x,w,m)}const j=Math.ceil(m.columnCount/Z),C=Math.floor((c.clientX-i.left)/i.width*Z),N=Math.floor((c.clientY-i.top)/i.height*j);if(!(C<0||C>=Z||N<0||N>=j))return V(p.item,!1,0,N*Z+C,m)},k=y.useCallback((c,p,i)=>{var x;if(s.current=!1,p.button!==0||!c.isMovable)return;(x=o.current)==null||x.call(o);const m={item:c,isResize:i,x:p.clientX,y:p.clientY,isStarted:!1},j=()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",R),window.removeEventListener("keydown",$,!0),o.current=null,a(null)},C=()=>{s.current=!0,window.setTimeout(()=>{s.current=!1},0)},N=w=>{const O=Math.hypot(w.clientX-m.x,w.clientY-m.y);if(!m.isStarted&&O<Le)return;m.isStarted=!0;const S=_(w,m);a(S?{key:m.item.key,isResize:m.isResize,target:S}:null)},E=w=>{if(j(),!m.isStarted)return;C();const O=_(w,m);O&&l.current.onDrop(m.item,O)},R=()=>j(),$=w=>{w.key!=="Escape"||!m.isStarted||(w.preventDefault(),w.stopPropagation(),C(),j())};window.addEventListener("pointermove",N),window.addEventListener("pointerup",E),window.addEventListener("pointercancel",R),window.addEventListener("keydown",$,!0),o.current=j},[]);y.useEffect(()=>()=>{var c;return(c=o.current)==null?void 0:c.call(o)},[]);const f=y.useCallback(()=>s.current,[]);return{preview:r,begin:k,isClickSwallowed:f}},Se="ui-calendar-YEgbk",Ke="ui-srOnly-6NUr9",Ie="ui-scroller-IkPuv",Pe="ui-time-DPj2K",Ye="ui-corner-7ggOq",Fe="ui-headers-c6s18",Ue="ui-header-vuk-c",Xe="ui-resource-i6zVF",ze="ui-resource__detail-ssEve",Be="ui-gutter-YjM1s",Ge="ui-gutter__hour-oyYrg",Je="ui-gutter__band-D6P6s",He="ui-band-GkAex",qe="ui-columns-aXu-3",Ve="ui-column-BsLn7",We="ui-event-uQH1A",Qe="ui-event__body-jClWr",Ze="ui-event__time-8Nt0z",et="ui-event__handle-cXUkS",tt="ui-preview-FsJaC",nt="ui-preview__title-GkNhx",st="ui-month-aEknN",rt="ui-weekdays-VJ6EQ",ot="ui-cells-jQJ7X",at="ui-cell-c3itR",ct="ui-cell__day-40ADs",it="ui-cell__more-e3wMw",u={calendar:Se,srOnly:Ke,scroller:Ie,time:Pe,"time--bands":"ui-time--bands-7Kndf",corner:Ye,headers:Fe,header:Ue,resource:Xe,"header--today":"ui-header--today-eLJzT",resource__detail:ze,"resource--primary":"ui-resource--primary--iCwp","resource--neutral":"ui-resource--neutral-cxIaY","resource--success":"ui-resource--success-qhCEv","resource--warning":"ui-resource--warning-GR4eo","resource--danger":"ui-resource--danger-S8dwG","resource--info":"ui-resource--info-hZjna",gutter:Be,gutter__hour:Ge,gutter__band:Je,band:He,"band--alternate":"ui-band--alternate-5aeTI",columns:qe,column:Ve,"column--off":"ui-column--off-4yR85",event:We,"event--primary":"ui-event--primary-ykXcJ","event--neutral":"ui-event--neutral-uTBTX","event--success":"ui-event--success-vosp6","event--warning":"ui-event--warning-scg6H","event--danger":"ui-event--danger-UY-OD","event--info":"ui-event--info-SHlJD","event--time":"ui-event--time-cg0iK","event--month":"ui-event--month-7wAJO","event--movable":"ui-event--movable-1n8nf","event--dragging":"ui-event--dragging-E2r9s","event--cancelled":"ui-event--cancelled-eG-x9",event__body:Qe,event__time:Ze,event__handle:et,preview:tt,preview__title:nt,month:st,weekdays:rt,cells:ot,cell:at,"cell--off":"ui-cell--off-TIR0O","cell--outside":"ui-cell--outside-F23oJ",cell__day:ct,"cell--target":"ui-cell--target-utfa-","cell__day--today":"ui-cell__day--today-2i28S",cell__more:it},lt=(e,t,n)=>({"--ui-calendar-top":`${(e.startMin-t)/n*100}%`,"--ui-calendar-height":`${(e.endMin-e.startMin)/n*100}%`,"--ui-calendar-lane":e.lane,"--ui-calendar-lanes":e.lanes}),ut=({item:e,view:t,isActive:n,isDragSource:r,isResizable:a,rangeStart:o,rangeLength:s,columnLabel:l,cancelledLabel:_,renderEvent:k,handlers:f})=>{const{event:c}=e,p=t==="time"?oe(U(c.start),U(c.end)):Q(U(c.start));return d.jsxs("button",{type:"button",className:L(u.event,u[`event--${t}`],u[`event--${c.tone??"primary"}`],c.isCancelled&&u["event--cancelled"],e.isMovable&&u["event--movable"],r&&u["event--dragging"]),style:t==="time"?lt(e,o,s):void 0,tabIndex:n?0:-1,"data-key":e.key,onPointerDown:i=>f.onPointerDown(e,i,!1),onClick:i=>f.onClick(e,i),onKeyDown:i=>f.onKeyDown(e,i),onFocus:()=>f.onFocus(e),children:[c.isCancelled&&d.jsx("span",{className:u.srOnly,children:`${_}: `}),d.jsx("span",{className:u.event__time,children:p}),d.jsx("span",{className:u.event__body,children:k?k(c):c.title}),d.jsx("span",{className:u.srOnly,children:`, ${l}`}),a&&d.jsx("span",{className:u.event__handle,"aria-hidden":!0,onPointerDown:i=>{i.stopPropagation(),f.onPointerDown(e,i,!0)}})]})},_e=y.memo(ut),dt=7,ht=({days:e,shown:t,hiddenCounts:n,weekdays:r,selectedDate:a,bodyRef:o,activeKey:s,preview:l,cancelledLabel:_,formatMore:k,renderEvent:f,handlers:c,onDaySelect:p})=>d.jsxs("div",{className:u.month,style:{"--ui-calendar-rows":Math.ceil(e.length/dt)},children:[r&&d.jsx("div",{className:u.weekdays,"aria-hidden":!0,children:r.map(i=>d.jsx("span",{children:i},i))}),d.jsx("div",{ref:o,className:u.cells,children:e.map((i,m)=>{const j=n[m],C=i.shortLabel??i.label;return d.jsxs("div",{role:"group","aria-label":i.label,className:L(u.cell,i.isOff&&u["cell--off"],i.isOutside&&u["cell--outside"],(l==null?void 0:l.target.column)===m&&u["cell--target"]),children:[p?d.jsx("button",{type:"button",className:L(u.cell__day,i.isToday&&u["cell__day--today"]),"aria-label":i.label,"aria-current":i.isToday?"date":void 0,"aria-pressed":a===void 0?void 0:i.date===a,onClick:()=>p(i.date),children:C}):d.jsx("span",{className:L(u.cell__day,i.isToday&&u["cell__day--today"]),"aria-hidden":!0,children:C}),t[m].map(N=>d.jsx(_e,{item:N,view:"month",isActive:N.key===s,isDragSource:N.key===(l==null?void 0:l.key),isResizable:!1,rangeStart:0,rangeLength:1,columnLabel:i.label,cancelledLabel:_,renderEvent:f,handlers:c},N.key)),j>0&&(p?d.jsx("button",{type:"button",className:u.cell__more,onClick:()=>p(i.date),children:k(j)}):d.jsx("span",{className:u.cell__more,children:k(j)}))]},i.date)})})]}),ft=({day:e,span:t})=>d.jsx("div",{className:L(u.header,e.isToday&&u["header--today"]),style:{gridColumn:`span ${t}`},"aria-current":e.isToday?"date":void 0,children:e.shortLabel?d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,children:e.shortLabel}),d.jsx("span",{className:u.srOnly,children:e.label})]}):e.label}),mt=({resource:e,renderResource:t})=>d.jsx("div",{className:L(u.resource,e.tone&&u[`resource--${e.tone}`]),"data-tone":e.tone,children:t?t(e):d.jsxs(d.Fragment,{children:[e.label,e.detail&&d.jsx("span",{className:u.resource__detail,children:e.detail})]})}),gt=({label:e,days:t,resources:n,columns:r,bands:a,placed:o,rangeStart:s,rangeEnd:l,slotMinutes:_,bodyRef:k,activeKey:f,preview:c,isEditable:p,cancelledLabel:i,renderEvent:m,renderResource:j,handlers:C,isClickSwallowed:N,onSlotSelect:E,onExternalDrop:R})=>{const $=l-s,x=(n==null?void 0:n.length)??0,w=x>0,O=Array.from({length:Math.floor((l-1)/60)-Math.ceil(s/60)+1},(h,g)=>(Math.ceil(s/60)+g)*60),S=h=>`${h/$*100}%`,K=h=>S(h-s),G=c?o.flat().find(h=>h.key===c.key):void 0,X=(h,g,T)=>{var z;const A=g.getBoundingClientRect(),ne=A.height>0?q((T-A.top)/A.height,0,1):0,P=Math.floor(ne*$/_)*_,Y=q(s+P,s,l-_);return{start:ee(h.day.date,Y),end:ee(h.day.date,Y+_),resourceId:(z=h.resource)==null?void 0:z.id}},I={"--ui-calendar-columns":r.length,"--ui-calendar-hours":$/60,"--ui-calendar-slot-ratio":_/60};return d.jsx("div",{className:u.scroller,...o.some(h=>h.length>0)?{}:{tabIndex:0,role:"region","aria-label":e},children:d.jsxs("div",{className:L(u.time,a.length>0&&u["time--bands"]),style:I,children:[d.jsx("div",{className:u.corner}),d.jsxs("div",{className:u.headers,children:[t.map(h=>d.jsx(ft,{day:h,span:w?x:1},h.date)),w&&r.map(h=>d.jsx(mt,{resource:h.resource,renderResource:j},h.index))]}),d.jsxs("div",{className:u.gutter,"aria-hidden":!0,children:[O.map(h=>d.jsx("span",{className:u.gutter__hour,style:{top:K(h)},children:Q(h)},h)),a.map(h=>d.jsx("span",{className:u.gutter__band,style:{top:K(h.startMin),height:S(h.endMin-h.startMin)},children:h.label},h.key))]}),d.jsx("div",{ref:k,className:u.columns,children:r.map(h=>d.jsxs("div",{role:"group","aria-label":h.label,className:L(u.column,h.day.isOff&&u["column--off"]),onClick:E?g=>{g.target!==g.currentTarget||N()||E(X(h,g.currentTarget,g.clientY))}:void 0,onDragOver:R?g=>{g.preventDefault(),g.dataTransfer.dropEffect="move"}:void 0,onDrop:R?g=>{g.preventDefault(),R({...X(h,g.currentTarget,g.clientY),data:g.dataTransfer.getData("text/plain")})}:void 0,children:[a.map((g,T)=>d.jsx("div",{className:L(u.band,T%2===1&&u["band--alternate"]),style:{top:K(g.startMin),height:S(g.endMin-g.startMin)},"aria-hidden":!0},g.key)),o[h.index].map(g=>d.jsx(_e,{item:g,view:"time",isActive:g.key===f,isDragSource:g.key===(c==null?void 0:c.key),isResizable:p&&g.isMovable,rangeStart:s,rangeLength:$,columnLabel:h.label,cancelledLabel:i,renderEvent:m,handlers:C},g.key)),c&&G&&c.target.column===h.index&&d.jsxs("div",{className:u.preview,style:{"--ui-calendar-top":K(c.target.startMin),"--ui-calendar-height":`${(c.target.endMin-c.target.startMin)/$*100}%`},"aria-hidden":!0,children:[oe(c.target.startMin,c.target.endMin),d.jsx("span",{className:u.preview__title,children:G.event.title})]})]},h.index))})]})})},vt=3,Mt=({label:e,days:t,events:n,view:r="time",resources:a,renderResource:o,bands:s,startTime:l="08:00",endTime:_="20:00",slotMinutes:k=30,weekdays:f,maxEventsPerDay:c=vt,selectedDate:p,onEventChange:i,onEventOpen:m,onSlotSelect:j,onDaySelect:C,onExternalDrop:N,renderEvent:E,className:R,testId:$})=>{var de,he,fe;const{labels:x}=me.useUi(),w=me.useAnnounce(),O=y.useId(),S=y.useRef(null),K=y.useRef(null),[G,X]=y.useState(),I=y.useRef(null),h=!!i,g=W(l),T=W(_),A=y.useMemo(()=>je(t,a),[t,a]),ne=y.useMemo(()=>$e(s,g,T),[s,g,T]),P=y.useMemo(()=>r==="time"?Ce(n,A,g,T,h):De(n,t,h),[r,n,A,t,g,T,h]),Y=y.useMemo(()=>r==="month"?P.map(v=>v.slice(0,c)):P,[r,P,c]),z={view:r,columnCount:r==="time"?A.length:t.length,rangeStart:g,rangeEnd:T,slotMinutes:k},ae=Y.flat(),ce=ae.some(v=>v.key===G)?G:(de=ae[0])==null?void 0:de.key,ye=v=>r==="time"?A[v.column].label:t[v.column].label,J=y.useRef({view:r,columns:A,days:t,onEventChange:i,onEventOpen:m,focusable:Y,bounds:z});J.current={view:r,columns:A,days:t,onEventChange:i,onEventOpen:m,focusable:Y,bounds:z};const se=y.useCallback((v,M)=>{const b=J.current,D=Ee(v,M,b.view,b.columns,b.days);if(!(!D||!b.onEventChange))return b.onEventChange(D),D},[]),H=Oe({bodyRef:K,bounds:z,onDrop:se}),ie=v=>{const b=[...S.current.querySelectorAll("[data-key]")].find(D=>D.dataset.key===v);b==null||b.focus()},le=y.useMemo(()=>({onPointerDown:(v,M,b)=>{I.current=null,J.current.onEventChange&&H.begin(v,M,b)},onClick:(v,M)=>{var b,D;H.isClickSwallowed()||(D=(b=J.current).onEventOpen)==null||D.call(b,v.event.id)},onFocus:v=>X(v.key),onKeyDown:(v,M)=>{if(I.current=null,!Ae(M.key))return;const b=J.current;if(M.metaKey||M.ctrlKey){if(M.preventDefault(),!v.isMovable)return;const B=Te(v,M.key,M.shiftKey,b.bounds);if(!B)return;I.current={key:`${v.event.id}@${B.column}`,before:v.event},se(v,B)||(I.current=null);return}const D=Re(b.focusable,v,M.key);D&&(M.preventDefault(),X(D.key),ie(D.key))}}),[se]);y.useEffect(()=>{var B;const v=I.current;if(!v)return;const M=P.flat().find(xe=>xe.key===v.key),{before:b}=v;M!==void 0&&(M.event.start!==b.start||M.event.end!==b.end||M.event.resourceId!==b.resourceId)&&(I.current=null,X(M.key),ie(M.key),w(ve("Calendar.moved",(B=x==null?void 0:x.calendar)==null?void 0:B.moved,M.event.title,`${ye(M)}, ${oe(M.startMin,M.endMin)}`)))},[n]);const ue=re("Calendar.cancelled",(he=x==null?void 0:x.calendar)==null?void 0:he.cancelled),be=re("Calendar.instructions",(fe=x==null?void 0:x.calendar)==null?void 0:fe.instructions);return d.jsxs("div",{ref:S,className:L(u.calendar,R),role:"group","aria-label":e,"aria-describedby":O,"data-testid":$,children:[d.jsx("span",{id:O,className:u.srOnly,children:be}),r==="time"?d.jsx(gt,{label:e,days:t,resources:a,columns:A,bands:ne,placed:P,rangeStart:g,rangeEnd:T,slotMinutes:k,bodyRef:K,activeKey:ce,preview:H.preview,isEditable:h,cancelledLabel:ue,renderEvent:E,renderResource:o,handlers:le,isClickSwallowed:H.isClickSwallowed,onSlotSelect:j,onExternalDrop:N}):d.jsx(ht,{days:t,shown:Y,hiddenCounts:P.map((v,M)=>v.length-Y[M].length),weekdays:f,selectedDate:p,bodyRef:K,activeKey:ce,preview:H.preview,cancelledLabel:ue,formatMore:v=>{var M;return ve("Calendar.more",(M=x==null?void 0:x.calendar)==null?void 0:M.more,v)},renderEvent:E,handlers:le,onDaySelect:C})]})},pt=y.memo(we(Mt,"Calendar"));exports.Calendar=pt;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),y=require("react"),me=require("@handijitcom/ui"),L=(...e)=>{let t="";for(const n of e)n&&(t=t===""?n:`${t} ${n}`);return t},ke=(e,t)=>Object.assign(e,{displayName:t}),ge=new Set,se=(e,...t)=>{for(const n of t)if(n!==void 0)return n;return process.env.NODE_ENV!=="production"&&!ge.has(e)&&(ge.add(e),console.error(`[@handijitcom/ui] Eksik metin: ${e}. Prop olarak geçin ya da <UiProvider labels={…}> içinde bir kez tanımlayın. Metinsiz bırakılan öğe ekran okuyucuda adsız kalır.`)),""},Me=(e,t,...n)=>t?t(...n):se(e),we=1440,W=e=>{const[t,n]=e.split(":");return Number(t)*60+Number(n??0)},Q=e=>`${String(Math.floor(e/60)).padStart(2,"0")}:${String(e%60).padStart(2,"0")}`,F=e=>e.slice(0,10),U=e=>W(e.slice(11,16)),ee=(e,t)=>`${e}T${Q(t)}`,oe=(e,t)=>`${Q(e)}–${Q(t)}`,q=(e,t,n)=>Math.min(Math.max(e,t),n),pe=(e,t)=>`${e}|${t??""}`,je=(e,t)=>t&&t.length>0?e.flatMap((n,s)=>t.map((a,o)=>({index:s*t.length+o,day:n,resource:a,label:`${n.label}, ${a.label}`}))):e.map((n,s)=>({index:s,day:n,label:n.label})),ve=(e,t)=>{const n=F(e.start),s=F(e.end);return n<=t&&(t<s||t===s&&U(e.end)>0)},te=e=>F(e.start)===F(e.end),Ne=e=>{e.sort((o,r)=>o.startMin-r.startMin||r.endMin-o.endMin);let t=[],n=[],s=-1;const a=()=>{for(const o of t)o.lanes=n.length;t=[],n=[]};for(const o of e){o.startMin>=s&&a();const r=n.findIndex(_=>_<=o.startMin);o.lane=r===-1?n.length:r;const l=Math.max(o.endMin,o.startMin+1);n[o.lane]=l,s=Math.max(s,l),t.push(o)}a()},Ce=(e,t,n,s,a)=>{var w;const o=new Map(t.map(f=>{var c;return[pe(f.day.date,(c=f.resource)==null?void 0:c.id),f]})),r=t.some(f=>f.resource),l=t.map(()=>[]),_=(f,c)=>{const v=c.day.date,i=F(f.start)===v?U(f.start):0,m=F(f.end)===v?U(f.end):we;m<=n||i>=s||l[c.index].push({key:`${f.id}@${c.index}`,event:f,column:c.index,startMin:Math.max(i,n),endMin:Math.min(m,s),lane:0,lanes:1,isMovable:a&&!f.isLocked&&te(f)&&i>=n&&m<=s})};for(const f of e){const c=r?f.resourceId:void 0;if(!(r&&c===void 0)){if(te(f)){const v=o.get(pe(F(f.start),c));v&&_(f,v);continue}for(const v of t)((w=v.resource)==null?void 0:w.id)===c&&ve(f,v.day.date)&&_(f,v)}}for(const f of l)Ne(f);return l},De=(e,t,n)=>{const s=new Map(t.map((r,l)=>[r.date,l])),a=t.map(()=>[]),o=(r,l)=>a[l].push({key:`${r.id}@${l}`,event:r,column:l,startMin:U(r.start),endMin:U(r.end),lane:0,lanes:1,isMovable:n&&!r.isLocked&&te(r)});for(const r of e){if(te(r)){const l=s.get(F(r.start));l!==void 0&&o(r,l);continue}t.forEach((l,_)=>{ve(r,l.date)&&o(r,_)})}for(const r of a)r.sort((l,_)=>l.event.start<_.event.start?-1:l.event.start>_.event.start?1:0);return a},$e=(e,t,n)=>(e??[]).flatMap((s,a)=>{const o=Math.max(W(s.start),t),r=Math.min(W(s.end),n);return r>o?[{key:`${a}`,label:s.label,startMin:o,endMin:r}]:[]}),V=(e,t,n,s,a)=>{if(a.view==="month")return s<0||s>=a.columnCount?void 0:{column:s,startMin:e.startMin,endMin:e.endMin};if(t){const l=Math.min(e.startMin+a.slotMinutes,a.rangeEnd);return{column:e.column,startMin:e.startMin,endMin:q(e.endMin+n,l,a.rangeEnd)}}const o=e.endMin-e.startMin,r=q(e.startMin+n,a.rangeStart,a.rangeEnd-o);return{column:q(s,0,a.columnCount-1),startMin:r,endMin:r+o}},Ae=(e,t,n,s,a)=>{var _;if(t.column===e.column&&t.startMin===e.startMin&&t.endMin===e.endMin)return;const r=n==="time"?s[t.column]:void 0,l=r?r.day.date:a[t.column].date;return{id:e.event.id,start:ee(l,t.startMin),end:ee(l,t.endMin),resourceId:((_=r==null?void 0:r.resource)==null?void 0:_.id)??e.event.resourceId}},Ee=e=>e==="ArrowUp"||e==="ArrowDown"||e==="ArrowLeft"||e==="ArrowRight",Re=(e,t,n)=>{if(n==="ArrowUp"||n==="ArrowDown"){const a=e[t.column],o=a.findIndex(r=>r.key===t.key);return a[o+(n==="ArrowDown"?1:-1)]}const s=n==="ArrowRight"?1:-1;for(let a=t.column+s;a>=0&&a<e.length;a+=s){const o=e[a];if(o.length!==0)return o.reduce((r,l)=>Math.abs(l.startMin-t.startMin)<Math.abs(r.startMin-t.startMin)?l:r)}},Te=(e,t,n,s)=>{const a=t==="ArrowUp"||t==="ArrowDown",o=t==="ArrowDown"||t==="ArrowRight"?1:-1;if(s.view==="month")return n?void 0:V(e,!1,0,e.column+o*(a?7:1),s);if(!(n&&!a))return a?V(e,n,o*s.slotMinutes,e.column,s):V(e,!1,0,e.column+o,s)},Le=4,Z=7,Oe=({bodyRef:e,bounds:t,onDrop:n})=>{const[s,a]=y.useState(null),o=y.useRef(null),r=y.useRef(!1),l=y.useRef({bounds:t,onDrop:n});l.current={bounds:t,onDrop:n};const _=(c,v)=>{var A;const i=(A=e.current)==null?void 0:A.getBoundingClientRect(),{bounds:m}=l.current;if(!i||i.width===0||i.height===0)return;if(m.view==="time"){const R=(m.rangeEnd-m.rangeStart)/i.height,$=(c.clientY-v.y)*R,x=Math.round($/m.slotMinutes)*m.slotMinutes,k=Math.floor((c.clientX-i.left)/i.width*m.columnCount);return V(v.item,v.isResize,x,k,m)}const j=Math.ceil(m.columnCount/Z),C=Math.floor((c.clientX-i.left)/i.width*Z),N=Math.floor((c.clientY-i.top)/i.height*j);if(!(C<0||C>=Z||N<0||N>=j))return V(v.item,!1,0,N*Z+C,m)},w=y.useCallback((c,v,i)=>{var x;if(r.current=!1,v.button!==0||!c.isMovable)return;(x=o.current)==null||x.call(o);const m={item:c,isResize:i,x:v.clientX,y:v.clientY,isStarted:!1},j=()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",A),window.removeEventListener("pointercancel",R),window.removeEventListener("keydown",$,!0),o.current=null,a(null)},C=()=>{r.current=!0,window.setTimeout(()=>{r.current=!1},0)},N=k=>{const O=Math.hypot(k.clientX-m.x,k.clientY-m.y);if(!m.isStarted&&O<Le)return;m.isStarted=!0;const S=_(k,m);a(S?{key:m.item.key,isResize:m.isResize,target:S}:null)},A=k=>{if(j(),!m.isStarted)return;C();const O=_(k,m);O&&l.current.onDrop(m.item,O)},R=()=>j(),$=k=>{k.key!=="Escape"||!m.isStarted||(k.preventDefault(),k.stopPropagation(),C(),j())};window.addEventListener("pointermove",N),window.addEventListener("pointerup",A),window.addEventListener("pointercancel",R),window.addEventListener("keydown",$,!0),o.current=j},[]);y.useEffect(()=>()=>{var c;return(c=o.current)==null?void 0:c.call(o)},[]);const f=y.useCallback(()=>r.current,[]);return{preview:s,begin:w,isClickSwallowed:f}},Se="ui-calendar-YEgbk",Ke="ui-srOnly-6NUr9",Ie="ui-scroller-IkPuv",Pe="ui-time-DPj2K",Ye="ui-corner-7ggOq",Fe="ui-headers-c6s18",Ue="ui-header-vuk-c",Xe="ui-resource-i6zVF",ze="ui-resource__detail-ssEve",Be="ui-gutter-YjM1s",Je="ui-gutter__hour-oyYrg",Ge="ui-gutter__band-D6P6s",He="ui-band-GkAex",qe="ui-columns-aXu-3",Ve="ui-column-BsLn7",We="ui-event-uQH1A",Qe="ui-event__body-jClWr",Ze="ui-event__time-8Nt0z",et="ui-event__handle-cXUkS",tt="ui-preview-FsJaC",nt="ui-preview__title-GkNhx",rt="ui-month-aEknN",st="ui-weekdays-VJ6EQ",ot="ui-cells-jQJ7X",at="ui-cell-c3itR",ct="ui-cell__day-40ADs",it="ui-cell__more-e3wMw",u={calendar:Se,srOnly:Ke,scroller:Ie,time:Pe,"time--bands":"ui-time--bands-7Kndf",corner:Ye,headers:Fe,header:Ue,resource:Xe,"header--today":"ui-header--today-eLJzT",resource__detail:ze,"resource--primary":"ui-resource--primary--iCwp","resource--neutral":"ui-resource--neutral-cxIaY","resource--ink":"ui-resource--ink-uNsDF","resource--danger":"ui-resource--danger-S8dwG","resource--info":"ui-resource--info-hZjna",gutter:Be,gutter__hour:Je,gutter__band:Ge,band:He,"band--alternate":"ui-band--alternate-5aeTI",columns:qe,column:Ve,"column--off":"ui-column--off-4yR85",event:We,"event--primary":"ui-event--primary-ykXcJ","event--neutral":"ui-event--neutral-uTBTX","event--ink":"ui-event--ink-bChwl","event--danger":"ui-event--danger-UY-OD","event--info":"ui-event--info-SHlJD","event--time":"ui-event--time-cg0iK","event--month":"ui-event--month-7wAJO","event--movable":"ui-event--movable-1n8nf","event--dragging":"ui-event--dragging-E2r9s","event--cancelled":"ui-event--cancelled-eG-x9",event__body:Qe,event__time:Ze,event__handle:et,preview:tt,preview__title:nt,month:rt,weekdays:st,cells:ot,cell:at,"cell--off":"ui-cell--off-TIR0O","cell--outside":"ui-cell--outside-F23oJ",cell__day:ct,"cell--target":"ui-cell--target-utfa-","cell__day--today":"ui-cell__day--today-2i28S",cell__more:it},lt=(e,t,n)=>({"--ui-calendar-top":`${(e.startMin-t)/n*100}%`,"--ui-calendar-height":`${(e.endMin-e.startMin)/n*100}%`,"--ui-calendar-lane":e.lane,"--ui-calendar-lanes":e.lanes}),ut=({item:e,view:t,isActive:n,isDragSource:s,isResizable:a,rangeStart:o,rangeLength:r,columnLabel:l,cancelledLabel:_,renderEvent:w,handlers:f})=>{const{event:c}=e,v=t==="time"?oe(U(c.start),U(c.end)):Q(U(c.start));return d.jsxs("button",{type:"button",className:L(u.event,u[`event--${t}`],u[`event--${c.tone??"primary"}`],c.isCancelled&&u["event--cancelled"],e.isMovable&&u["event--movable"],s&&u["event--dragging"]),style:t==="time"?lt(e,o,r):void 0,tabIndex:n?0:-1,"data-key":e.key,onPointerDown:i=>f.onPointerDown(e,i,!1),onClick:i=>f.onClick(e,i),onKeyDown:i=>f.onKeyDown(e,i),onFocus:()=>f.onFocus(e),children:[c.isCancelled&&d.jsx("span",{className:u.srOnly,children:`${_}: `}),d.jsx("span",{className:u.event__time,children:v}),d.jsx("span",{className:u.event__body,children:w?w(c):c.title}),d.jsx("span",{className:u.srOnly,children:`, ${l}`}),a&&d.jsx("span",{className:u.event__handle,"aria-hidden":!0,onPointerDown:i=>{i.stopPropagation(),f.onPointerDown(e,i,!0)}})]})},_e=y.memo(ut),dt=7,ht=({days:e,shown:t,hiddenCounts:n,weekdays:s,selectedDate:a,bodyRef:o,activeKey:r,preview:l,cancelledLabel:_,formatMore:w,renderEvent:f,handlers:c,onDaySelect:v})=>d.jsxs("div",{className:u.month,style:{"--ui-calendar-rows":Math.ceil(e.length/dt)},children:[s&&d.jsx("div",{className:u.weekdays,"aria-hidden":!0,children:s.map(i=>d.jsx("span",{children:i},i))}),d.jsx("div",{ref:o,className:u.cells,children:e.map((i,m)=>{const j=n[m],C=i.shortLabel??i.label;return d.jsxs("div",{role:"group","aria-label":i.label,className:L(u.cell,i.isOff&&u["cell--off"],i.isOutside&&u["cell--outside"],(l==null?void 0:l.target.column)===m&&u["cell--target"]),children:[v?d.jsx("button",{type:"button",className:L(u.cell__day,i.isToday&&u["cell__day--today"]),"aria-label":i.label,"aria-current":i.isToday?"date":void 0,"aria-pressed":a===void 0?void 0:i.date===a,onClick:()=>v(i.date),children:C}):d.jsx("span",{className:L(u.cell__day,i.isToday&&u["cell__day--today"]),"aria-hidden":!0,children:C}),t[m].map(N=>d.jsx(_e,{item:N,view:"month",isActive:N.key===r,isDragSource:N.key===(l==null?void 0:l.key),isResizable:!1,rangeStart:0,rangeLength:1,columnLabel:i.label,cancelledLabel:_,renderEvent:f,handlers:c},N.key)),j>0&&(v?d.jsx("button",{type:"button",className:u.cell__more,onClick:()=>v(i.date),children:w(j)}):d.jsx("span",{className:u.cell__more,children:w(j)}))]},i.date)})})]}),ft=({day:e,span:t})=>d.jsx("div",{className:L(u.header,e.isToday&&u["header--today"]),style:{gridColumn:`span ${t}`},"aria-current":e.isToday?"date":void 0,children:e.shortLabel?d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,children:e.shortLabel}),d.jsx("span",{className:u.srOnly,children:e.label})]}):e.label}),mt=({resource:e,renderResource:t})=>d.jsx("div",{className:L(u.resource,e.tone&&u[`resource--${e.tone}`]),"data-tone":e.tone,children:t?t(e):d.jsxs(d.Fragment,{children:[e.label,e.detail&&d.jsx("span",{className:u.resource__detail,children:e.detail})]})}),gt=({label:e,days:t,resources:n,columns:s,bands:a,placed:o,rangeStart:r,rangeEnd:l,slotMinutes:_,bodyRef:w,activeKey:f,preview:c,isEditable:v,cancelledLabel:i,renderEvent:m,renderResource:j,handlers:C,isClickSwallowed:N,onSlotSelect:A,onExternalDrop:R})=>{const $=l-r,x=(n==null?void 0:n.length)??0,k=x>0,O=Array.from({length:Math.floor((l-1)/60)-Math.ceil(r/60)+1},(h,g)=>(Math.ceil(r/60)+g)*60),S=h=>`${h/$*100}%`,K=h=>S(h-r),J=c?o.flat().find(h=>h.key===c.key):void 0,X=(h,g,T)=>{var z;const E=g.getBoundingClientRect(),ne=E.height>0?q((T-E.top)/E.height,0,1):0,P=Math.floor(ne*$/_)*_,Y=q(r+P,r,l-_);return{start:ee(h.day.date,Y),end:ee(h.day.date,Y+_),resourceId:(z=h.resource)==null?void 0:z.id}},I={"--ui-calendar-columns":s.length,"--ui-calendar-hours":$/60,"--ui-calendar-slot-ratio":_/60};return d.jsx("div",{className:u.scroller,...o.some(h=>h.length>0)?{}:{tabIndex:0,role:"region","aria-label":e},children:d.jsxs("div",{className:L(u.time,a.length>0&&u["time--bands"]),style:I,children:[d.jsx("div",{className:u.corner}),d.jsxs("div",{className:u.headers,children:[t.map(h=>d.jsx(ft,{day:h,span:k?x:1},h.date)),k&&s.map(h=>d.jsx(mt,{resource:h.resource,renderResource:j},h.index))]}),d.jsxs("div",{className:u.gutter,"aria-hidden":!0,children:[O.map(h=>d.jsx("span",{className:u.gutter__hour,style:{top:K(h)},children:Q(h)},h)),a.map(h=>d.jsx("span",{className:u.gutter__band,style:{top:K(h.startMin),height:S(h.endMin-h.startMin)},children:h.label},h.key))]}),d.jsx("div",{ref:w,className:u.columns,children:s.map(h=>d.jsxs("div",{role:"group","aria-label":h.label,className:L(u.column,h.day.isOff&&u["column--off"]),onClick:A?g=>{g.target!==g.currentTarget||N()||A(X(h,g.currentTarget,g.clientY))}:void 0,onDragOver:R?g=>{g.preventDefault(),g.dataTransfer.dropEffect="move"}:void 0,onDrop:R?g=>{g.preventDefault(),R({...X(h,g.currentTarget,g.clientY),data:g.dataTransfer.getData("text/plain")})}:void 0,children:[a.map((g,T)=>d.jsx("div",{className:L(u.band,T%2===1&&u["band--alternate"]),style:{top:K(g.startMin),height:S(g.endMin-g.startMin)},"aria-hidden":!0},g.key)),o[h.index].map(g=>d.jsx(_e,{item:g,view:"time",isActive:g.key===f,isDragSource:g.key===(c==null?void 0:c.key),isResizable:v&&g.isMovable,rangeStart:r,rangeLength:$,columnLabel:h.label,cancelledLabel:i,renderEvent:m,handlers:C},g.key)),c&&J&&c.target.column===h.index&&d.jsxs("div",{className:u.preview,style:{"--ui-calendar-top":K(c.target.startMin),"--ui-calendar-height":`${(c.target.endMin-c.target.startMin)/$*100}%`},"aria-hidden":!0,children:[oe(c.target.startMin,c.target.endMin),d.jsx("span",{className:u.preview__title,children:J.event.title})]})]},h.index))})]})})},Mt=3,pt=({label:e,days:t,events:n,view:s="time",resources:a,renderResource:o,bands:r,startTime:l="08:00",endTime:_="20:00",slotMinutes:w=30,weekdays:f,maxEventsPerDay:c=Mt,selectedDate:v,onEventChange:i,onEventOpen:m,onSlotSelect:j,onDaySelect:C,onExternalDrop:N,renderEvent:A,className:R,testId:$})=>{var de,he,fe;const{labels:x}=me.useUi(),k=me.useAnnounce(),O=y.useId(),S=y.useRef(null),K=y.useRef(null),[J,X]=y.useState(),I=y.useRef(null),h=!!i,g=W(l),T=W(_),E=y.useMemo(()=>je(t,a),[t,a]),ne=y.useMemo(()=>$e(r,g,T),[r,g,T]),P=y.useMemo(()=>s==="time"?Ce(n,E,g,T,h):De(n,t,h),[s,n,E,t,g,T,h]),Y=y.useMemo(()=>s==="month"?P.map(M=>M.slice(0,c)):P,[s,P,c]),z={view:s,columnCount:s==="time"?E.length:t.length,rangeStart:g,rangeEnd:T,slotMinutes:w},ae=Y.flat(),ce=ae.some(M=>M.key===J)?J:(de=ae[0])==null?void 0:de.key,ye=M=>s==="time"?E[M.column].label:t[M.column].label,G=y.useRef({view:s,columns:E,days:t,onEventChange:i,onEventOpen:m,focusable:Y,bounds:z});G.current={view:s,columns:E,days:t,onEventChange:i,onEventOpen:m,focusable:Y,bounds:z};const re=y.useCallback((M,p)=>{const b=G.current,D=Ae(M,p,b.view,b.columns,b.days);if(!(!D||!b.onEventChange))return b.onEventChange(D),D},[]),H=Oe({bodyRef:K,bounds:z,onDrop:re}),ie=M=>{const b=[...S.current.querySelectorAll("[data-key]")].find(D=>D.dataset.key===M);b==null||b.focus()},le=y.useMemo(()=>({onPointerDown:(M,p,b)=>{I.current=null,G.current.onEventChange&&H.begin(M,p,b)},onClick:(M,p)=>{var b,D;H.isClickSwallowed()||(D=(b=G.current).onEventOpen)==null||D.call(b,M.event.id)},onFocus:M=>X(M.key),onKeyDown:(M,p)=>{if(I.current=null,!Ee(p.key))return;const b=G.current;if(p.metaKey||p.ctrlKey){if(p.preventDefault(),!M.isMovable)return;const B=Te(M,p.key,p.shiftKey,b.bounds);if(!B)return;I.current={key:`${M.event.id}@${B.column}`,before:M.event},re(M,B)||(I.current=null);return}const D=Re(b.focusable,M,p.key);D&&(p.preventDefault(),X(D.key),ie(D.key))}}),[re]);y.useEffect(()=>{var B;const M=I.current;if(!M)return;const p=P.flat().find(xe=>xe.key===M.key),{before:b}=M;p!==void 0&&(p.event.start!==b.start||p.event.end!==b.end||p.event.resourceId!==b.resourceId)&&(I.current=null,X(p.key),ie(p.key),k(Me("Calendar.moved",(B=x==null?void 0:x.calendar)==null?void 0:B.moved,p.event.title,`${ye(p)}, ${oe(p.startMin,p.endMin)}`)))},[n]);const ue=se("Calendar.cancelled",(he=x==null?void 0:x.calendar)==null?void 0:he.cancelled),be=se("Calendar.instructions",(fe=x==null?void 0:x.calendar)==null?void 0:fe.instructions);return d.jsxs("div",{ref:S,className:L(u.calendar,R),role:"group","aria-label":e,"aria-describedby":O,"data-testid":$,children:[d.jsx("span",{id:O,className:u.srOnly,children:be}),s==="time"?d.jsx(gt,{label:e,days:t,resources:a,columns:E,bands:ne,placed:P,rangeStart:g,rangeEnd:T,slotMinutes:w,bodyRef:K,activeKey:ce,preview:H.preview,isEditable:h,cancelledLabel:ue,renderEvent:A,renderResource:o,handlers:le,isClickSwallowed:H.isClickSwallowed,onSlotSelect:j,onExternalDrop:N}):d.jsx(ht,{days:t,shown:Y,hiddenCounts:P.map((M,p)=>M.length-Y[p].length),weekdays:f,selectedDate:v,bodyRef:K,activeKey:ce,preview:H.preview,cancelledLabel:ue,formatMore:M=>{var p;return Me("Calendar.more",(p=x==null?void 0:x.calendar)==null?void 0:p.more,M)},renderEvent:A,handlers:le,onDaySelect:C})]})},vt=y.memo(ke(pt,"Calendar"));exports.Calendar=vt;
|
|
2
2
|
//# sourceMappingURL=calendar.cjs.map
|