plass-ui 1.0.0 → 1.0.2
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 +165 -0
- package/dist/components/accordion/PlAccordion.js +1 -131
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/alert/PlAlert.js +1 -109
- package/dist/components/alert/index.js +1 -1
- package/dist/components/animate-appear/PlAnimateAppear.js +1 -71
- package/dist/components/animate-appear/index.js +1 -1
- package/dist/components/animate-blink/PlAnimateBlink.js +1 -47
- package/dist/components/animate-blink/index.js +1 -1
- package/dist/components/animate-fade/PlAnimateFade.js +1 -48
- package/dist/components/animate-fade/index.js +1 -1
- package/dist/components/animate-grow/PlAnimateGrow.js +1 -49
- package/dist/components/animate-grow/index.js +1 -1
- package/dist/components/animate-headline/PlAnimateHeadline.js +1 -120
- package/dist/components/animate-headline/index.js +1 -1
- package/dist/components/animate-lighting/PlAnimateLighting.js +1 -65
- package/dist/components/animate-lighting/index.js +1 -1
- package/dist/components/animate-marquee/PlAnimateMarquee.js +1 -94
- package/dist/components/animate-marquee/index.js +1 -1
- package/dist/components/animate-rotate/PlAnimateRotate.js +1 -50
- package/dist/components/animate-rotate/index.js +1 -1
- package/dist/components/animate-slide/PlAnimateSlide.js +1 -49
- package/dist/components/animate-slide/index.js +1 -1
- package/dist/components/animate-typing/PlAnimateTyping.js +1 -177
- package/dist/components/animate-typing/index.js +1 -1
- package/dist/components/animate-zoom/PlAnimateZoom.js +1 -45
- package/dist/components/animate-zoom/index.js +1 -1
- package/dist/components/aspect-ratio/PlAspectRatio.js +1 -58
- package/dist/components/aspect-ratio/index.js +1 -1
- package/dist/components/avatar/PlAvatar.js +1 -121
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/badge/PlBadge.js +1 -168
- package/dist/components/badge/index.js +1 -1
- package/dist/components/blockquote/PlBlockquote.js +1 -112
- package/dist/components/blockquote/index.js +1 -1
- package/dist/components/bottom-navigation/PlBottomNavigation.js +1 -141
- package/dist/components/bottom-navigation/index.js +1 -1
- package/dist/components/box/PlBox.js +1 -46
- package/dist/components/box/index.js +1 -1
- package/dist/components/breadcrumb/PlBreadcrumb.js +1 -201
- package/dist/components/breadcrumb/index.js +1 -1
- package/dist/components/button/PlButton.js +1 -196
- package/dist/components/button/index.js +1 -1
- package/dist/components/button-group/PlButtonGroup.js +1 -64
- package/dist/components/button-group/index.js +1 -1
- package/dist/components/card/PlCard.js +1 -102
- package/dist/components/card/index.js +1 -1
- package/dist/components/carousel/PlCarousel.js +1 -177
- package/dist/components/carousel/index.js +1 -1
- package/dist/components/chat-bubble/PlChatBubble.js +1 -206
- package/dist/components/chat-bubble/index.js +1 -1
- package/dist/components/checkbox/PlCheckbox.js +1 -100
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/chip/PlChip.js +1 -144
- package/dist/components/chip/index.js +1 -1
- package/dist/components/collapsible/PlCollapsible.js +1 -65
- package/dist/components/collapsible/index.js +1 -1
- package/dist/components/combobox/PlCombobox.js +1 -199
- package/dist/components/combobox/index.js +1 -1
- package/dist/components/container/PlContainer.js +1 -47
- package/dist/components/container/index.js +1 -1
- package/dist/components/date-picker/PlDatePicker.js +1 -87
- package/dist/components/date-picker/index.js +1 -1
- package/dist/components/date-range-picker/PlDateRangePicker.js +1 -152
- package/dist/components/date-range-picker/index.js +1 -1
- package/dist/components/date-time-picker/PlDateTimePicker.js +1 -106
- package/dist/components/date-time-picker/index.js +1 -1
- package/dist/components/divider/PlDivider.js +1 -107
- package/dist/components/divider/index.js +1 -1
- package/dist/components/drawer/PlDrawer.js +1 -190
- package/dist/components/drawer/index.js +1 -1
- package/dist/components/file-picker/PlFilePicker.js +1 -274
- package/dist/components/file-picker/index.js +1 -1
- package/dist/components/floating-bottom-navigation/PlFloatingBottomNavigation.js +1 -291
- package/dist/components/floating-bottom-navigation/index.js +1 -1
- package/dist/components/grid/PlGrid.js +1 -51
- package/dist/components/grid/PlGridItem.js +1 -34
- package/dist/components/grid/index.js +1 -2
- package/dist/components/highlight/PlHighlight.js +1 -185
- package/dist/components/highlight/index.js +1 -1
- package/dist/components/hot-keys/PlHotKeys.js +1 -294
- package/dist/components/hot-keys/index.js +1 -1
- package/dist/components/icon/PlIcon.js +1 -58
- package/dist/components/icon/index.js +1 -1
- package/dist/components/icon-button/PlIconButton.js +1 -37
- package/dist/components/icon-button/index.js +1 -1
- package/dist/components/list/PlList.js +1 -160
- package/dist/components/list/index.js +1 -1
- package/dist/components/menu/PlMenu.js +1 -209
- package/dist/components/menu/index.js +1 -1
- package/dist/components/modal/PlModal.js +1 -150
- package/dist/components/modal/index.js +1 -1
- package/dist/components/number-field/PlNumberField.js +1 -111
- package/dist/components/number-field/index.js +1 -1
- package/dist/components/otp-field/PlOtpField.js +1 -109
- package/dist/components/otp-field/index.js +1 -1
- package/dist/components/overlay/PlOverlay.js +1 -77
- package/dist/components/overlay/index.js +1 -1
- package/dist/components/pagination/PlPagination.js +1 -159
- package/dist/components/pagination/index.js +1 -1
- package/dist/components/panes/PlPanes.js +1 -324
- package/dist/components/panes/index.js +1 -1
- package/dist/components/pill/PlPill.js +1 -154
- package/dist/components/pill/index.js +1 -1
- package/dist/components/popover/PlPopover.js +1 -113
- package/dist/components/popover/index.js +1 -1
- package/dist/components/progress-box/PlProgressBox.js +1 -34
- package/dist/components/progress-box/index.js +1 -1
- package/dist/components/progress-circular/PlProgressCircular.js +1 -47
- package/dist/components/progress-circular/index.js +1 -1
- package/dist/components/progress-linear/PlProgressLinear.js +1 -40
- package/dist/components/progress-linear/index.js +1 -1
- package/dist/components/radio-group/PlRadioGroup.js +1 -99
- package/dist/components/radio-group/index.js +1 -1
- package/dist/components/rating/PlRating.js +1 -101
- package/dist/components/rating/index.js +1 -1
- package/dist/components/scroll-zone/PlScrollZone.js +1 -411
- package/dist/components/scroll-zone/index.js +1 -1
- package/dist/components/segmented-button/PlSegmentedButton.js +1 -206
- package/dist/components/segmented-button/index.js +1 -1
- package/dist/components/select/PlSelect.js +1 -115
- package/dist/components/select/index.js +1 -1
- package/dist/components/skeleton/PlSkeleton.js +1 -142
- package/dist/components/skeleton/index.js +1 -1
- package/dist/components/slider/PlSlider.js +1 -132
- package/dist/components/slider/index.js +1 -1
- package/dist/components/spoiler/PlSpoiler.js +1 -74
- package/dist/components/spoiler/index.js +1 -1
- package/dist/components/switch/PlSwitch.js +1 -131
- package/dist/components/switch/index.js +1 -1
- package/dist/components/table/PlTable.js +1 -210
- package/dist/components/table/index.js +1 -1
- package/dist/components/tabs/PlTabs.js +1 -182
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/text-field/PlTextField.js +1 -126
- package/dist/components/text-field/index.js +1 -1
- package/dist/components/text-link/PlTextLink.js +1 -136
- package/dist/components/text-link/index.js +1 -1
- package/dist/components/time-picker/PlTimePicker.js +1 -97
- package/dist/components/time-picker/index.js +1 -1
- package/dist/components/timeline/PlTimeline.js +1 -207
- package/dist/components/timeline/index.js +1 -1
- package/dist/components/toast/PlToast.js +1 -174
- package/dist/components/toast/index.js +1 -1
- package/dist/components/toolbar/PlToolbar.js +1 -65
- package/dist/components/toolbar/index.js +1 -1
- package/dist/components/tooltip/PlTooltip.js +1 -117
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/typography/PlTypography.js +1 -143
- package/dist/components/typography/index.js +1 -1
- package/dist/index.js +1 -75
- package/dist/internal/animate.js +1 -318
- package/dist/internal/button-group.js +2 -19
- package/dist/internal/calendar.js +1 -501
- package/dist/internal/date.js +1 -353
- package/dist/internal/format.js +1 -41
- package/dist/internal/grid.js +1 -143
- package/dist/internal/icons.js +1 -138
- package/dist/internal/menu.js +1 -18
- package/dist/internal/picker.js +1 -139
- package/dist/internal/progress.js +1 -167
- package/dist/internal/sizer.js +1 -35
- package/dist/internal/styles.js +1 -636
- package/dist/types.js +0 -8
- package/package.json +5 -3
package/dist/internal/date.js
CHANGED
|
@@ -1,353 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* The arithmetic and the naming the four pickers share.
|
|
3
|
-
*
|
|
4
|
-
* No date library under it, deliberately. Plass has one runtime dependency —
|
|
5
|
-
* Base UI — and a component library that quietly adds `date-fns`, or worse
|
|
6
|
-
* picks a side in the dayjs/luxon/Temporal argument on its consumer's behalf,
|
|
7
|
-
* has made a decision that was not its to make. Everything here is either
|
|
8
|
-
* `Date` arithmetic, which is a dozen lines, or `Intl`, which the platform
|
|
9
|
-
* already ships and which knows more about month names in more languages than
|
|
10
|
-
* any bundled table ever will.
|
|
11
|
-
*
|
|
12
|
-
* **That is also the whole of the localisation story.** There is no table of
|
|
13
|
-
* translated month names to import and no per-language module to register: the
|
|
14
|
-
* only strings a picker says that `Intl` has no opinion about are the labels on
|
|
15
|
-
* its own buttons, and those are one `labels` prop with English defaults. A
|
|
16
|
-
* project that ships in twelve languages pays nothing for eleven of them.
|
|
17
|
-
*
|
|
18
|
-
* Two rules hold everywhere below:
|
|
19
|
-
*
|
|
20
|
-
* - **Local time, always.** A calendar day is a thing a person is looking at on
|
|
21
|
-
* a wall, not an instant on a line. `makeDate(2026, 6, 27)` is midnight local
|
|
22
|
-
* and every comparison here is made on the local Y/M/D triple, so a picker in
|
|
23
|
-
* Seoul and a picker in São Paulo both light up the cell that says 27.
|
|
24
|
-
* - **Nothing is mutated.** `Date` is mutable and every method on it that
|
|
25
|
-
* sounds like a question is actually a command. Each function here copies
|
|
26
|
-
* first, so a `value` handed in by a caller is never the object that comes
|
|
27
|
-
* back out.
|
|
28
|
-
*/
|
|
29
|
-
import { dateFormatter } from './format.js';
|
|
30
|
-
/** How many years one page of the year grid holds. Four columns of three. */
|
|
31
|
-
export const YEAR_PAGE_SIZE = 12;
|
|
32
|
-
/* ---------------------------------------------------------------------------
|
|
33
|
-
* Construction
|
|
34
|
-
* ------------------------------------------------------------------------- */
|
|
35
|
-
/**
|
|
36
|
-
* A local midnight on the given Y/M/D, with out-of-range parts normalised —
|
|
37
|
-
* month `12` rolls into January, day `0` into the last day of the month before.
|
|
38
|
-
*
|
|
39
|
-
* Built through `setFullYear` rather than `new Date(year, month, day)` because
|
|
40
|
-
* the multi-argument constructor maps years 0–99 onto 1900–1999. Nobody is
|
|
41
|
-
* going to pick a date in the year 47, but a component that silently rewrites
|
|
42
|
-
* the year it was handed is a component that will eventually be blamed for
|
|
43
|
-
* something else.
|
|
44
|
-
*/
|
|
45
|
-
export function makeDate(year, month, day) {
|
|
46
|
-
const date = new Date(0);
|
|
47
|
-
date.setFullYear(year, month, day);
|
|
48
|
-
date.setHours(0, 0, 0, 0);
|
|
49
|
-
return date;
|
|
50
|
-
}
|
|
51
|
-
/** Is this a `Date` that stands for a real instant? `new Date('nope')` is not. */
|
|
52
|
-
export function isValidDate(value) {
|
|
53
|
-
return value instanceof Date && !Number.isNaN(value.getTime());
|
|
54
|
-
}
|
|
55
|
-
/** The same day with the clock wound back to midnight. */
|
|
56
|
-
export function startOfDay(date) {
|
|
57
|
-
const next = new Date(date.getTime());
|
|
58
|
-
next.setHours(0, 0, 0, 0);
|
|
59
|
-
return next;
|
|
60
|
-
}
|
|
61
|
-
/** The first day of the month this date is in, at midnight. */
|
|
62
|
-
export function startOfMonth(date) {
|
|
63
|
-
return makeDate(date.getFullYear(), date.getMonth(), 1);
|
|
64
|
-
}
|
|
65
|
-
/** How many days a month has, leap years included. */
|
|
66
|
-
export function daysInMonth(year, month) {
|
|
67
|
-
return makeDate(year, month + 1, 0).getDate();
|
|
68
|
-
}
|
|
69
|
-
/** Today, at midnight. The one place the pickers read the clock for a *date*. */
|
|
70
|
-
export function today() {
|
|
71
|
-
return startOfDay(new Date());
|
|
72
|
-
}
|
|
73
|
-
/* ---------------------------------------------------------------------------
|
|
74
|
-
* Arithmetic
|
|
75
|
-
* ------------------------------------------------------------------------- */
|
|
76
|
-
export function addDays(date, amount) {
|
|
77
|
-
const next = new Date(date.getTime());
|
|
78
|
-
next.setDate(next.getDate() + amount);
|
|
79
|
-
return next;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Months, with the day of the month clamped rather than allowed to overflow.
|
|
83
|
-
*
|
|
84
|
-
* 31 January plus one month is 28 February, not 3 March. The naive
|
|
85
|
-
* `setMonth(getMonth() + 1)` gives the second answer, which is why stepping a
|
|
86
|
-
* calendar forward from a 31st with it skips February entirely.
|
|
87
|
-
*/
|
|
88
|
-
export function addMonths(date, amount) {
|
|
89
|
-
const next = new Date(date.getTime());
|
|
90
|
-
// Normalised through a first-of-month so the day never carries the overflow.
|
|
91
|
-
const target = makeDate(date.getFullYear(), date.getMonth() + amount, 1);
|
|
92
|
-
next.setFullYear(target.getFullYear(), target.getMonth(), Math.min(date.getDate(), daysInMonth(target.getFullYear(), target.getMonth())));
|
|
93
|
-
return next;
|
|
94
|
-
}
|
|
95
|
-
export function addYears(date, amount) {
|
|
96
|
-
return addMonths(date, amount * 12);
|
|
97
|
-
}
|
|
98
|
-
/* ---------------------------------------------------------------------------
|
|
99
|
-
* Comparison
|
|
100
|
-
*
|
|
101
|
-
* All of it on the local Y/M/D triple, never on `getTime()`. Two `Date`s that
|
|
102
|
-
* are the same calendar day differ by milliseconds far more often than not — a
|
|
103
|
-
* value carrying a time of day, a `min` built at noon — and every one of those
|
|
104
|
-
* comparisons has to come out `true`.
|
|
105
|
-
* ------------------------------------------------------------------------- */
|
|
106
|
-
/** Negative, zero or positive, the way a sort comparator wants it. */
|
|
107
|
-
export function compareDay(a, b) {
|
|
108
|
-
return startOfDay(a).getTime() - startOfDay(b).getTime();
|
|
109
|
-
}
|
|
110
|
-
export function isSameDay(a, b) {
|
|
111
|
-
return isValidDate(a) && isValidDate(b) && compareDay(a, b) === 0;
|
|
112
|
-
}
|
|
113
|
-
export function isSameMonth(a, b) {
|
|
114
|
-
return (isValidDate(a) &&
|
|
115
|
-
isValidDate(b) &&
|
|
116
|
-
a.getFullYear() === b.getFullYear() &&
|
|
117
|
-
a.getMonth() === b.getMonth());
|
|
118
|
-
}
|
|
119
|
-
/** Holds a date inside `[min, max]`, at whatever precision the bounds carry. */
|
|
120
|
-
export function clampDate(date, min, max) {
|
|
121
|
-
if (isValidDate(min) && date.getTime() < min.getTime()) {
|
|
122
|
-
return new Date(min.getTime());
|
|
123
|
-
}
|
|
124
|
-
if (isValidDate(max) && date.getTime() > max.getTime()) {
|
|
125
|
-
return new Date(max.getTime());
|
|
126
|
-
}
|
|
127
|
-
return date;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Is this calendar *day* outside the allowed span?
|
|
131
|
-
*
|
|
132
|
-
* Day-granular on purpose. A `maxDate` of 27 July at 09:00 still leaves the
|
|
133
|
-
* 27th pickable — the bound is about which days exist, and the time of day is
|
|
134
|
-
* the time picker's problem. `PlDateTimePicker` re-checks at full precision
|
|
135
|
-
* once an hour has been chosen.
|
|
136
|
-
*/
|
|
137
|
-
export function isDayOutside(date, min, max) {
|
|
138
|
-
if (isValidDate(min) && compareDay(date, min) < 0) {
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
return isValidDate(max) && compareDay(date, max) > 0;
|
|
142
|
-
}
|
|
143
|
-
/* ---------------------------------------------------------------------------
|
|
144
|
-
* Time of day
|
|
145
|
-
* ------------------------------------------------------------------------- */
|
|
146
|
-
/** Seconds since local midnight — what `minTime`/`maxTime` are compared on. */
|
|
147
|
-
export function secondsOfDay(date) {
|
|
148
|
-
return date.getHours() * 3600 + date.getMinutes() * 60 + date.getSeconds();
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* The span of the day one row of one column covers, in seconds since midnight.
|
|
152
|
-
*
|
|
153
|
-
* This is the detail that separates a working time picker from a frustrating
|
|
154
|
-
* one. A bound has to be checked against the *span* a row stands for, not
|
|
155
|
-
* against one instant inside it: with a `minTime` of 09:30, the hour `9` covers
|
|
156
|
-
* 09:00:00–09:59:59, which overlaps what is allowed, so it stays available and
|
|
157
|
-
* the minute column is where `00` through `25` grey out. Comparing the whole
|
|
158
|
-
* candidate instead hides the 9 and makes half past nine unreachable.
|
|
159
|
-
*/
|
|
160
|
-
export function timeUnitSpan(unit, at) {
|
|
161
|
-
const seconds = secondsOfDay(at);
|
|
162
|
-
if (unit === 'hour') {
|
|
163
|
-
const start = Math.floor(seconds / 3600) * 3600;
|
|
164
|
-
return [start, start + 3599];
|
|
165
|
-
}
|
|
166
|
-
if (unit === 'minute') {
|
|
167
|
-
const start = Math.floor(seconds / 60) * 60;
|
|
168
|
-
return [start, start + 59];
|
|
169
|
-
}
|
|
170
|
-
if (unit === 'second') {
|
|
171
|
-
return [seconds, seconds];
|
|
172
|
-
}
|
|
173
|
-
const start = at.getHours() < 12 ? 0 : 12 * 3600;
|
|
174
|
-
return [start, start + 12 * 3600 - 1];
|
|
175
|
-
}
|
|
176
|
-
/** The same instant with one or more clock fields replaced. */
|
|
177
|
-
export function withTime(date, parts) {
|
|
178
|
-
const next = new Date(date.getTime());
|
|
179
|
-
next.setHours(parts.hours ?? next.getHours(), parts.minutes ?? next.getMinutes(), parts.seconds ?? next.getSeconds(), 0);
|
|
180
|
-
return next;
|
|
181
|
-
}
|
|
182
|
-
/** `date`'s calendar day wearing `time`'s clock. */
|
|
183
|
-
export function mergeDateAndTime(date, time) {
|
|
184
|
-
return withTime(startOfDay(date), {
|
|
185
|
-
hours: time.getHours(),
|
|
186
|
-
minutes: time.getMinutes(),
|
|
187
|
-
seconds: time.getSeconds()
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
/* ---------------------------------------------------------------------------
|
|
191
|
-
* The grid
|
|
192
|
-
* ------------------------------------------------------------------------- */
|
|
193
|
-
/**
|
|
194
|
-
* Six weeks of seven days, always — including the leading and trailing days
|
|
195
|
-
* that belong to the neighbouring months.
|
|
196
|
-
*
|
|
197
|
-
* Six rows whatever the month, and that is the whole point. A February that
|
|
198
|
-
* starts on a Sunday needs four rows and a 31-day month starting on a Saturday
|
|
199
|
-
* needs six; a grid that renders only the rows it needs is a grid that changes
|
|
200
|
-
* height when you step a month forward, moving every cell out from under the
|
|
201
|
-
* pointer that just pressed one. The same reason `PlPagination` pins its slot
|
|
202
|
-
* count.
|
|
203
|
-
*/
|
|
204
|
-
export function calendarWeeks(month, weekStartsOn) {
|
|
205
|
-
const first = startOfMonth(month);
|
|
206
|
-
const lead = (first.getDay() - weekStartsOn + 7) % 7;
|
|
207
|
-
const origin = addDays(first, -lead);
|
|
208
|
-
return Array.from({ length: 6 }, (_, week) => Array.from({ length: 7 }, (_, day) => addDays(origin, week * 7 + day)));
|
|
209
|
-
}
|
|
210
|
-
/** The first year on the page a given year falls on. 2026 becomes 2016 at 12 a page. */
|
|
211
|
-
export function yearPageStart(year) {
|
|
212
|
-
return year - (((year % YEAR_PAGE_SIZE) + YEAR_PAGE_SIZE) % YEAR_PAGE_SIZE);
|
|
213
|
-
}
|
|
214
|
-
/* ---------------------------------------------------------------------------
|
|
215
|
-
* Naming
|
|
216
|
-
*
|
|
217
|
-
* Every string a picker draws that is not a number comes from `Intl`, through
|
|
218
|
-
* the memoised formatters in `internal/format.ts` — constructing one is the
|
|
219
|
-
* expensive half of using one, and a calendar builds seven weekday names and
|
|
220
|
-
* twelve month names on every render of the month view.
|
|
221
|
-
* ------------------------------------------------------------------------- */
|
|
222
|
-
/** Formats a date, tolerating the `null` a cleared picker holds. */
|
|
223
|
-
export function formatDate(date, locale, options) {
|
|
224
|
-
return isValidDate(date) ? dateFormatter(locale, options).format(date) : '';
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Twenty-four instants that between them exercise everything a picker's display
|
|
228
|
-
* can vary by: all twelve month names, all seven weekday names, a two-digit
|
|
229
|
-
* day, every hour of the clock and a two-digit minute and second.
|
|
230
|
-
*
|
|
231
|
-
* They exist to be measured, not read. A picker's trigger is sized by its
|
|
232
|
-
* content, so `Jul 1, 2026` and `Sep 28, 2026` are different widths and the
|
|
233
|
-
* field would jump every time a date was chosen — with the whole row of
|
|
234
|
-
* controls beside it shuffling along. Rendering all of these invisibly pins the
|
|
235
|
-
* trigger to the widest thing it could ever say.
|
|
236
|
-
*
|
|
237
|
-
* Both cycles are prime to twelve in the right way — `i % 12` walks the months
|
|
238
|
-
* and `i % 7` walks the days 21…27 — so every name appears without the two
|
|
239
|
-
* being multiplied out into eighty-four samples.
|
|
240
|
-
*/
|
|
241
|
-
const DISPLAY_SAMPLES = /* @__PURE__ */ Array.from({ length: 24 }, (_, index) => new Date(2027, index % 12, 21 + (index % 7), index, 58, 58));
|
|
242
|
-
/**
|
|
243
|
-
* Every distinct string those instants format to. Deduplicated, because a
|
|
244
|
-
* date-only format collapses twenty-four of them into a handful.
|
|
245
|
-
*/
|
|
246
|
-
export function displaySamples(locale, options) {
|
|
247
|
-
const formatter = dateFormatter(locale, options);
|
|
248
|
-
return [...new Set(DISPLAY_SAMPLES.map((date) => formatter.format(date)))];
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* The samples plus the placeholder, when the placeholder is a string.
|
|
252
|
-
*
|
|
253
|
-
* An empty picker shows the placeholder, which can easily be longer than any
|
|
254
|
-
* date — "Pick a departure date" against "3 Aug 2026" — and a trigger that
|
|
255
|
-
* shrinks the moment the first date is chosen is the same jump from the other
|
|
256
|
-
* direction. A `ReactNode` placeholder is left out: there is nothing to measure
|
|
257
|
-
* without rendering it twice.
|
|
258
|
-
*/
|
|
259
|
-
export function withPlaceholder(samples, placeholder) {
|
|
260
|
-
return typeof placeholder === 'string' && placeholder !== ''
|
|
261
|
-
? [...samples, placeholder]
|
|
262
|
-
: samples;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* The three machine-readable spellings, for the hidden input that makes a
|
|
266
|
-
* picker submit with a form.
|
|
267
|
-
*
|
|
268
|
-
* Local, not UTC, and that is the whole point: `toISOString()` on a `Date`
|
|
269
|
-
* standing for 27 July in Seoul gives `2026-07-26T15:00:00Z`, and a form field
|
|
270
|
-
* that quietly reports the day before the one on screen is the single most
|
|
271
|
-
* expensive bug a date picker can ship. The shapes are the ones the native
|
|
272
|
-
* `<input type="date">`, `type="time"` and `type="datetime-local"` submit, so a
|
|
273
|
-
* server that already parses those needs no new code.
|
|
274
|
-
*/
|
|
275
|
-
export function toISODate(date) {
|
|
276
|
-
const pad = (value) => String(value).padStart(2, '0');
|
|
277
|
-
return `${String(date.getFullYear()).padStart(4, '0')}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
278
|
-
}
|
|
279
|
-
export function toISOTime(date, withSeconds = false) {
|
|
280
|
-
const pad = (value) => String(value).padStart(2, '0');
|
|
281
|
-
const base = `${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
282
|
-
return withSeconds ? `${base}:${pad(date.getSeconds())}` : base;
|
|
283
|
-
}
|
|
284
|
-
export function toISODateTime(date, withSeconds = false) {
|
|
285
|
-
return `${toISODate(date)}T${toISOTime(date, withSeconds)}`;
|
|
286
|
-
}
|
|
287
|
-
/** A Sunday, used as the origin for every weekday name below. 1 Aug 2021. */
|
|
288
|
-
const WEEKDAY_ORIGIN = /* @__PURE__ */ makeDate(2021, 7, 1);
|
|
289
|
-
/**
|
|
290
|
-
* The seven column headers, rotated so the first one is `weekStartsOn`.
|
|
291
|
-
*
|
|
292
|
-
* `short` rather than `narrow`: narrow gives `S`, `M`, `T`, `W`, `T`, `F`, `S`
|
|
293
|
-
* in English, where two pairs are indistinguishable. The full name goes on the
|
|
294
|
-
* header's `aria-label` so a screen reader hears "Monday" rather than "Mon".
|
|
295
|
-
*/
|
|
296
|
-
export function weekdayLabels(locale, weekStartsOn, weekday = 'short') {
|
|
297
|
-
const formatter = dateFormatter(locale, { weekday });
|
|
298
|
-
return Array.from({ length: 7 }, (_, index) => formatter.format(addDays(WEEKDAY_ORIGIN, (weekStartsOn + index) % 7)));
|
|
299
|
-
}
|
|
300
|
-
/** The twelve month names, January first, in the locale's own words. */
|
|
301
|
-
export function monthLabels(locale, month = 'short') {
|
|
302
|
-
const formatter = dateFormatter(locale, { month });
|
|
303
|
-
return Array.from({ length: 12 }, (_, index) => formatter.format(makeDate(2021, index, 1)));
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* Does this locale write the month before the year?
|
|
307
|
-
*
|
|
308
|
-
* The calendar's header is two separate buttons — one that opens the month grid
|
|
309
|
-
* and one that opens the year grid — so it cannot just print what `Intl` gives
|
|
310
|
-
* it. Asking `formatToParts` which part came first is how the two buttons end
|
|
311
|
-
* up in the order the reader expects: `July 2026` in English, `2026년 7월` in
|
|
312
|
-
* Korean. Getting this wrong is subtle and reads as broken to exactly the
|
|
313
|
-
* people it is wrong for.
|
|
314
|
-
*/
|
|
315
|
-
export function isMonthBeforeYear(locale) {
|
|
316
|
-
const parts = dateFormatter(locale, { year: 'numeric', month: 'long' }).formatToParts(WEEKDAY_ORIGIN);
|
|
317
|
-
return (parts.findIndex((part) => part.type === 'month') <
|
|
318
|
-
parts.findIndex((part) => part.type === 'year'));
|
|
319
|
-
}
|
|
320
|
-
/** Does this locale put a clock on a 12-hour dial? */
|
|
321
|
-
export function isHour12(locale) {
|
|
322
|
-
const resolved = dateFormatter(locale, { hour: 'numeric' }).resolvedOptions();
|
|
323
|
-
if (resolved.hourCycle) {
|
|
324
|
-
return resolved.hourCycle === 'h11' || resolved.hourCycle === 'h12';
|
|
325
|
-
}
|
|
326
|
-
return resolved.hour12 === true;
|
|
327
|
-
}
|
|
328
|
-
/** What this locale calls AM and PM. */
|
|
329
|
-
export function meridiemLabels(locale) {
|
|
330
|
-
const formatter = dateFormatter(locale, { hour: 'numeric', hour12: true });
|
|
331
|
-
const read = (hours) => {
|
|
332
|
-
const part = formatter
|
|
333
|
-
.formatToParts(withTime(WEEKDAY_ORIGIN, { hours }))
|
|
334
|
-
.find((entry) => entry.type === 'dayPeriod');
|
|
335
|
-
return part?.value ?? (hours < 12 ? 'AM' : 'PM');
|
|
336
|
-
};
|
|
337
|
-
return [read(9), read(21)];
|
|
338
|
-
}
|
|
339
|
-
export function localeWeekStart(locale) {
|
|
340
|
-
try {
|
|
341
|
-
const resolved = locale ?? new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
342
|
-
const info = new Intl.Locale(resolved);
|
|
343
|
-
const week = typeof info.getWeekInfo === 'function' ? info.getWeekInfo() : info.weekInfo;
|
|
344
|
-
// CLDR counts Monday as 1 through Sunday as 7; `getDay` counts Sunday as 0.
|
|
345
|
-
if (typeof week?.firstDay === 'number') {
|
|
346
|
-
return (week.firstDay % 7);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
catch {
|
|
350
|
-
// An unparseable locale tag. Not worth taking the calendar down over.
|
|
351
|
-
}
|
|
352
|
-
return 0;
|
|
353
|
-
}
|
|
1
|
+
import{dateFormatter as t}from"./format.js";export const YEAR_PAGE_SIZE=12;export function makeDate(t,e,r){const n=new Date(0);return n.setFullYear(t,e,r),n.setHours(0,0,0,0),n}export function isValidDate(t){return t instanceof Date&&!Number.isNaN(t.getTime())}export function startOfDay(t){const e=new Date(t.getTime());return e.setHours(0,0,0,0),e}export function startOfMonth(t){return makeDate(t.getFullYear(),t.getMonth(),1)}export function daysInMonth(t,e){return makeDate(t,e+1,0).getDate()}export function today(){return startOfDay(new Date)}export function addDays(t,e){const r=new Date(t.getTime());return r.setDate(r.getDate()+e),r}export function addMonths(t,e){const r=new Date(t.getTime()),n=makeDate(t.getFullYear(),t.getMonth()+e,1);return r.setFullYear(n.getFullYear(),n.getMonth(),Math.min(t.getDate(),daysInMonth(n.getFullYear(),n.getMonth()))),r}export function addYears(t,e){return addMonths(t,12*e)}export function compareDay(t,e){return startOfDay(t).getTime()-startOfDay(e).getTime()}export function isSameDay(t,e){return isValidDate(t)&&isValidDate(e)&&0===compareDay(t,e)}export function isSameMonth(t,e){return isValidDate(t)&&isValidDate(e)&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()}export function clampDate(t,e,r){return isValidDate(e)&&t.getTime()<e.getTime()?new Date(e.getTime()):isValidDate(r)&&t.getTime()>r.getTime()?new Date(r.getTime()):t}export function isDayOutside(t,e,r){return!!(isValidDate(e)&&compareDay(t,e)<0)||isValidDate(r)&&compareDay(t,r)>0}export function secondsOfDay(t){return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}export function timeUnitSpan(t,e){const r=secondsOfDay(e);if("hour"===t){const t=3600*Math.floor(r/3600);return[t,t+3599]}if("minute"===t){const t=60*Math.floor(r/60);return[t,t+59]}if("second"===t)return[r,r];const n=e.getHours()<12?0:43200;return[n,n+43200-1]}export function withTime(t,e){const r=new Date(t.getTime());return r.setHours(e.hours??r.getHours(),e.minutes??r.getMinutes(),e.seconds??r.getSeconds(),0),r}export function mergeDateAndTime(t,e){return withTime(startOfDay(t),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()})}export function calendarWeeks(t,e){const r=startOfMonth(t),n=(r.getDay()-e+7)%7,o=addDays(r,-n);return Array.from({length:6},(t,e)=>Array.from({length:7},(t,r)=>addDays(o,7*e+r)))}export function yearPageStart(t){return t-(t%12+12)%12}export function formatDate(e,r,n){return isValidDate(e)?t(r,n).format(e):""}const e=/* @__PURE__ */Array.from({length:24},(t,e)=>new Date(2027,e%12,21+e%7,e,58,58));export function displaySamples(r,n){const o=t(r,n);return[...new Set(e.map(t=>o.format(t)))]}export function withPlaceholder(t,e){return"string"==typeof e&&""!==e?[...t,e]:t}export function toISODate(t){const pad=t=>String(t).padStart(2,"0");return`${String(t.getFullYear()).padStart(4,"0")}-${pad(t.getMonth()+1)}-${pad(t.getDate())}`}export function toISOTime(t,e=!1){const pad=t=>String(t).padStart(2,"0"),r=`${pad(t.getHours())}:${pad(t.getMinutes())}`;return e?`${r}:${pad(t.getSeconds())}`:r}export function toISODateTime(t,e=!1){return`${toISODate(t)}T${toISOTime(t,e)}`}const r=/* @__PURE__ */makeDate(2021,7,1);export function weekdayLabels(e,n,o="short"){const a=t(e,{weekday:o});return Array.from({length:7},(t,e)=>a.format(addDays(r,(n+e)%7)))}export function monthLabels(e,r="short"){const n=t(e,{month:r});return Array.from({length:12},(t,e)=>n.format(makeDate(2021,e,1)))}export function isMonthBeforeYear(e){const n=t(e,{year:"numeric",month:"long"}).formatToParts(r);return n.findIndex(t=>"month"===t.type)<n.findIndex(t=>"year"===t.type)}export function isHour12(e){const r=t(e,{hour:"numeric"}).resolvedOptions();return r.hourCycle?"h11"===r.hourCycle||"h12"===r.hourCycle:!0===r.hour12}export function meridiemLabels(e){const n=t(e,{hour:"numeric",hour12:!0}),read=t=>{const e=n.formatToParts(withTime(r,{hours:t})).find(t=>"dayPeriod"===t.type);return e?.value??(t<12?"AM":"PM")};return[read(9),read(21)]}export function localeWeekStart(t){try{const e=t??(new Intl.DateTimeFormat).resolvedOptions().locale,r=new Intl.Locale(e),n="function"==typeof r.getWeekInfo?r.getWeekInfo():r.weekInfo;if("number"==typeof n?.firstDay)return n.firstDay%7}catch{}return 0}
|
package/dist/internal/format.js
CHANGED
|
@@ -1,41 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* The `Intl` formatters, memoised.
|
|
3
|
-
*
|
|
4
|
-
* Here rather than inline for one reason: constructing a formatter is the
|
|
5
|
-
* expensive half of using one. On V8, `new Intl.DateTimeFormat(...).format(d)`
|
|
6
|
-
* costs about 16us and `format(d)` on a formatter that already exists costs
|
|
7
|
-
* about 0.3us — fifty-five times the work for the same string.
|
|
8
|
-
*
|
|
9
|
-
* That ratio only matters where the call is in a loop or in a render, and in the
|
|
10
|
-
* pickers it is both: a calendar builds seven weekday names and twelve month
|
|
11
|
-
* names for a 42-cell month view, and it builds them again on every step, every
|
|
12
|
-
* hover and every keystroke.
|
|
13
|
-
*
|
|
14
|
-
* The cache is unbounded on purpose. The keys are not user data — they come from
|
|
15
|
-
* a component's own option objects, of which any one page has a handful — so
|
|
16
|
-
* there is nothing here that grows with the size of anything.
|
|
17
|
-
*
|
|
18
|
-
* The options object is deliberately **not** part of the key by identity. A
|
|
19
|
-
* caller writing `format={{ dateStyle: 'medium' }}` inline hands over a new
|
|
20
|
-
* object on every render, which is the ordinary way that prop gets written, and
|
|
21
|
-
* keying on identity would miss every time and cache nothing but garbage.
|
|
22
|
-
*/
|
|
23
|
-
/**
|
|
24
|
-
* `undefined` locale means the runtime's own, and is a key of its own. The two
|
|
25
|
-
* halves are parted by a NUL, which no locale tag and no option name can
|
|
26
|
-
* contain, so no two different pairs of inputs can spell the same key.
|
|
27
|
-
*/
|
|
28
|
-
function cacheKey(locale, options) {
|
|
29
|
-
return `${locale ?? ''}\u0000${options ? JSON.stringify(options) : ''}`;
|
|
30
|
-
}
|
|
31
|
-
const dateFormatters = new Map();
|
|
32
|
-
/** A memoised `Intl.DateTimeFormat`. */
|
|
33
|
-
export function dateFormatter(locale, options) {
|
|
34
|
-
const key = cacheKey(locale, options);
|
|
35
|
-
let formatter = dateFormatters.get(key);
|
|
36
|
-
if (!formatter) {
|
|
37
|
-
formatter = new Intl.DateTimeFormat(locale, options);
|
|
38
|
-
dateFormatters.set(key, formatter);
|
|
39
|
-
}
|
|
40
|
-
return formatter;
|
|
41
|
-
}
|
|
1
|
+
const t=new Map;export function dateFormatter(e,n){const r=function cacheKey(t,e){return`${t??""}\0${e?JSON.stringify(e):""}`}(e,n);let o=t.get(r);return o||(o=new Intl.DateTimeFormat(e,n),t.set(r,o)),o}
|
package/dist/internal/grid.js
CHANGED
|
@@ -1,143 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* The arithmetic and the vocabulary `PlGrid` and `PlGridItem` share.
|
|
3
|
-
*
|
|
4
|
-
* Like `internal/styles.ts` this is the library talking to itself, and it lives
|
|
5
|
-
* here rather than in either component's folder for one reason: the two are one
|
|
6
|
-
* system in two elements, and neither should have to import the other.
|
|
7
|
-
*
|
|
8
|
-
* What is *not* here is the layout itself. A column width is
|
|
9
|
-
* `(100% + gap) * span / columns - gap`, it has to change at four breakpoints,
|
|
10
|
-
* and it is the width of an element whose column count is declared on its
|
|
11
|
-
* parent — none of which Tailwind can spell, because Tailwind only ever sees
|
|
12
|
-
* class names written out literally and `columns` is a number a caller picks.
|
|
13
|
-
* So the widths are real CSS in `styles.css`, driven by the `--p-*` slots this
|
|
14
|
-
* file generates. That is the same split the rest of the library makes:
|
|
15
|
-
* per-instance values go in inline custom properties, never in class names.
|
|
16
|
-
*/
|
|
17
|
-
/** Smallest first, which is also the order the media queries have to be in. */
|
|
18
|
-
export const breakpoints = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
19
|
-
/**
|
|
20
|
-
* One step of `spacing`, in `rem`.
|
|
21
|
-
*
|
|
22
|
-
* This is Tailwind's spacing scale and not Material's 8px one: `spacing={4}` is
|
|
23
|
-
* `1rem`, exactly what `gap-4` already means and what `p-4` in the sheet
|
|
24
|
-
* padding tables already is. Every other number in this library is on that
|
|
25
|
-
* ladder, and a grid that measured its gutters differently from the card around
|
|
26
|
-
* it would be the one place a caller has to stop and convert.
|
|
27
|
-
*/
|
|
28
|
-
const SPACING_STEP = 0.25;
|
|
29
|
-
/** A bare value means "from `xs` up"; a map is already per-breakpoint. */
|
|
30
|
-
function breakpointMap(value) {
|
|
31
|
-
if (value === undefined || value === null)
|
|
32
|
-
return {};
|
|
33
|
-
if (typeof value === 'object')
|
|
34
|
-
return value;
|
|
35
|
-
return { xs: value };
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Turns a responsive value into the `--p-{name}-{breakpoint}` slots the CSS
|
|
39
|
-
* reads, emitting only the breakpoints the caller actually named.
|
|
40
|
-
*
|
|
41
|
-
* The gaps are filled in by CSS rather than here: each breakpoint's rule falls
|
|
42
|
-
* back through the ones below it, so `{ md: 6 }` needs one slot and not five.
|
|
43
|
-
* That keeps the inline style on a grid item down to what was asked for.
|
|
44
|
-
*/
|
|
45
|
-
export function responsiveSlots(name, value, toCss) {
|
|
46
|
-
const map = breakpointMap(value);
|
|
47
|
-
const slots = {};
|
|
48
|
-
for (const breakpoint of breakpoints) {
|
|
49
|
-
const entry = map[breakpoint];
|
|
50
|
-
if (entry !== undefined)
|
|
51
|
-
slots[`--p-${name}-${breakpoint}`] = toCss(entry);
|
|
52
|
-
}
|
|
53
|
-
return slots;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Fills in the `xs` entry of a partial map with the prop's own default.
|
|
57
|
-
*
|
|
58
|
-
* Without this, `spacing={{ md: 4 }}` would be a grid with no gutter at all
|
|
59
|
-
* below 48rem — the CSS fallback rather than the documented default — and a
|
|
60
|
-
* caller who narrowed one breakpoint would silently lose every other one. A map
|
|
61
|
-
* says "from here up, use this instead"; it does not say "and nothing below".
|
|
62
|
-
*/
|
|
63
|
-
export function withBaseline(value, baseline) {
|
|
64
|
-
if (value === undefined || value === null)
|
|
65
|
-
return baseline;
|
|
66
|
-
if (typeof value === 'object') {
|
|
67
|
-
return { xs: baseline, ...value };
|
|
68
|
-
}
|
|
69
|
-
return value;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* A count of columns, as a plain number for `calc()` to divide by.
|
|
73
|
-
*
|
|
74
|
-
* Rounded and floored at 1 because the value ends up as a divisor: a grid of
|
|
75
|
-
* 2.5 columns is not a thing anybody meant, and a grid of 0 is a division by
|
|
76
|
-
* zero that would take the width declaration down with it.
|
|
77
|
-
*/
|
|
78
|
-
export function columnCount(value) {
|
|
79
|
-
return String(Math.max(1, Math.round(value)));
|
|
80
|
-
}
|
|
81
|
-
/** A span or an offset. Same rounding; an offset of 0 is meaningful. */
|
|
82
|
-
export function columnUnits(value, min) {
|
|
83
|
-
return String(Math.max(min, Math.round(value)));
|
|
84
|
-
}
|
|
85
|
-
export const spanValue = (value) => columnUnits(value, 1);
|
|
86
|
-
export const offsetValue = (value) => columnUnits(value, 0);
|
|
87
|
-
/**
|
|
88
|
-
* A gutter, as a length.
|
|
89
|
-
*
|
|
90
|
-
* Fractions are the point — `spacing={1.5}` is `0.375rem`, the same step
|
|
91
|
-
* `gap-1.5` is — so the multiplication is rounded to five places rather than
|
|
92
|
-
* left to print `0.30000000000000004rem` into the DOM.
|
|
93
|
-
*/
|
|
94
|
-
export function spacingValue(units) {
|
|
95
|
-
const rem = Math.max(0, units) * SPACING_STEP;
|
|
96
|
-
return `${Number(rem.toFixed(5))}rem`;
|
|
97
|
-
}
|
|
98
|
-
/* ---------------------------------------------------------------------------
|
|
99
|
-
* Alignment
|
|
100
|
-
*
|
|
101
|
-
* These *are* literal class names, so they stay in Tailwind. The positional
|
|
102
|
-
* values map onto `flex-start`/`flex-end` rather than the logical `start`/`end`
|
|
103
|
-
* because a flex container is what is underneath, and the bare logical keywords
|
|
104
|
-
* are the newer spelling of the two.
|
|
105
|
-
* ------------------------------------------------------------------------- */
|
|
106
|
-
export const justifyClasses = {
|
|
107
|
-
start: 'justify-start',
|
|
108
|
-
center: 'justify-center',
|
|
109
|
-
end: 'justify-end',
|
|
110
|
-
'space-between': 'justify-between',
|
|
111
|
-
'space-around': 'justify-around',
|
|
112
|
-
'space-evenly': 'justify-evenly',
|
|
113
|
-
stretch: 'justify-stretch'
|
|
114
|
-
};
|
|
115
|
-
export const alignItemsClasses = {
|
|
116
|
-
start: 'items-start',
|
|
117
|
-
center: 'items-center',
|
|
118
|
-
end: 'items-end',
|
|
119
|
-
stretch: 'items-stretch',
|
|
120
|
-
baseline: 'items-baseline'
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Where the *rows* sit when the grid is shorter than the box holding it. Only
|
|
124
|
-
* ever visible on a grid with a height of its own, which is why it takes the
|
|
125
|
-
* full distribution vocabulary and `alignItems` does not.
|
|
126
|
-
*/
|
|
127
|
-
export const alignContentClasses = {
|
|
128
|
-
start: 'content-start',
|
|
129
|
-
center: 'content-center',
|
|
130
|
-
end: 'content-end',
|
|
131
|
-
'space-between': 'content-between',
|
|
132
|
-
'space-around': 'content-around',
|
|
133
|
-
'space-evenly': 'content-evenly',
|
|
134
|
-
stretch: 'content-stretch'
|
|
135
|
-
};
|
|
136
|
-
export const alignSelfClasses = {
|
|
137
|
-
auto: 'self-auto',
|
|
138
|
-
start: 'self-start',
|
|
139
|
-
center: 'self-center',
|
|
140
|
-
end: 'self-end',
|
|
141
|
-
stretch: 'self-stretch',
|
|
142
|
-
baseline: 'self-baseline'
|
|
143
|
-
};
|
|
1
|
+
export const breakpoints=["xs","sm","md","lg","xl"];export function responsiveSlots(t,e,n){const s=function breakpointMap(t){return null==t?{}:"object"==typeof t?t:{xs:t}}(e),o={};for(const e of breakpoints){const r=s[e];void 0!==r&&(o[`--p-${t}-${e}`]=n(r))}return o}export function withBaseline(t,e){return null==t?e:"object"==typeof t?{xs:e,...t}:t}export function columnCount(t){return String(Math.max(1,Math.round(t)))}export function columnUnits(t,e){return String(Math.max(e,Math.round(t)))}export const spanValue=t=>columnUnits(t,1);export const offsetValue=t=>columnUnits(t,0);export function spacingValue(t){const e=.25*Math.max(0,t);return`${Number(e.toFixed(5))}rem`}export const justifyClasses={start:"justify-start",center:"justify-center",end:"justify-end","space-between":"justify-between","space-around":"justify-around","space-evenly":"justify-evenly",stretch:"justify-stretch"};export const alignItemsClasses={start:"items-start",center:"items-center",end:"items-end",stretch:"items-stretch",baseline:"items-baseline"};export const alignContentClasses={start:"content-start",center:"content-center",end:"content-end","space-between":"content-between","space-around":"content-around","space-evenly":"content-evenly",stretch:"content-stretch"};export const alignSelfClasses={auto:"self-auto",start:"self-start",center:"self-center",end:"self-end",stretch:"self-stretch",baseline:"self-baseline"};
|