@selectwin/kit 0.1.258 → 0.1.260

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.
Files changed (46) hide show
  1. package/README.md +47 -0
  2. package/dist/SelectActionBar.d.ts +29 -0
  3. package/dist/SelectActionBar.js +101 -0
  4. package/dist/SelectBadge.d.ts +9 -0
  5. package/dist/SelectBadge.js +26 -12
  6. package/dist/SelectBulkBar.d.ts +21 -0
  7. package/dist/SelectBulkBar.js +40 -0
  8. package/dist/SelectChannelPreview.d.ts +21 -1
  9. package/dist/SelectChannelPreview.js +100 -73
  10. package/dist/SelectColorField.d.ts +1 -5
  11. package/dist/SelectColorField.js +83 -101
  12. package/dist/SelectCombobox.d.ts +5 -0
  13. package/dist/SelectCombobox.js +52 -49
  14. package/dist/SelectComposerNotice.d.ts +14 -0
  15. package/dist/SelectComposerNotice.js +37 -0
  16. package/dist/SelectDataTable.d.ts +17 -1
  17. package/dist/SelectDataTable.js +100 -90
  18. package/dist/SelectDeadlineBadge.d.ts +32 -0
  19. package/dist/SelectDeadlineBadge.js +73 -0
  20. package/dist/SelectFilterBar.js +5 -5
  21. package/dist/SelectListCard.d.ts +27 -1
  22. package/dist/SelectListCard.js +47 -22
  23. package/dist/SelectLocale.d.ts +62 -0
  24. package/dist/SelectLocale.js +173 -0
  25. package/dist/SelectMail.d.ts +52 -8
  26. package/dist/SelectMail.js +315 -242
  27. package/dist/SelectSection.d.ts +4 -4
  28. package/dist/SelectSection.js +77 -8
  29. package/dist/SelectSegmented.d.ts +11 -0
  30. package/dist/SelectSegmented.js +87 -68
  31. package/dist/SelectTable.d.ts +13 -1
  32. package/dist/SelectTable.js +88 -79
  33. package/dist/SelectTabs.d.ts +7 -0
  34. package/dist/SelectTabs.js +47 -40
  35. package/dist/SelectWeekHours.d.ts +64 -0
  36. package/dist/SelectWeekHours.js +338 -0
  37. package/dist/index.d.ts +14 -2
  38. package/dist/index.js +189 -183
  39. package/dist/internal/color.d.ts +15 -0
  40. package/dist/internal/color.js +40 -0
  41. package/dist/internal/safeHref.d.ts +7 -0
  42. package/dist/internal/safeHref.js +12 -1
  43. package/dist/internal/scrollReveal.d.ts +19 -0
  44. package/dist/internal/scrollReveal.js +38 -0
  45. package/dist/style.css +1 -1
  46. package/package.json +1 -1
@@ -0,0 +1,338 @@
1
+ import { SelectButton as e } from "./SelectButton.js";
2
+ import { CloseIcon as t, PlusIcon as n } from "./icons.js";
3
+ import { selectIntlLocale as r, selectKitMessages as i, useSelectLocale as a, useSelectMessages as o } from "./SelectLocale.js";
4
+ import { SelectField as s } from "./SelectField.js";
5
+ import { SelectSwitch as c } from "./SelectSwitch.js";
6
+ import { SelectBadge as l } from "./SelectBadge.js";
7
+ import { SelectIconButton as u } from "./SelectIconButton.js";
8
+ import { SelectDateField as d } from "./SelectDateField.js";
9
+ import { SelectRowActions as f } from "./SelectRowActions.js";
10
+ import { useId as p, useRef as m, useState as h } from "react";
11
+ import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
12
+ //#region src/SelectWeekHours.tsx
13
+ var y = [
14
+ "mon",
15
+ "tue",
16
+ "wed",
17
+ "thu",
18
+ "fri",
19
+ "sat",
20
+ "sun"
21
+ ], b = [
22
+ "mon",
23
+ "tue",
24
+ "wed",
25
+ "thu",
26
+ "fri"
27
+ ], x = /^([01]\d|2[0-3]):([0-5]\d)$|^24:00$/;
28
+ function S(e) {
29
+ return x.test(e) ? Number(e.slice(0, 2)) * 60 + Number(e.slice(3, 5)) : null;
30
+ }
31
+ var C = (e) => `${String(Math.floor(e / 60)).padStart(2, "0")}:${String(e % 60).padStart(2, "0")}`;
32
+ function w(e = "mon") {
33
+ return e === "sun" ? ["sun", ...y.slice(0, 6)] : [...y];
34
+ }
35
+ function T(e, t = 6) {
36
+ let n = {};
37
+ for (let r of y) {
38
+ let i = e[r] ?? [];
39
+ if (i.length > t) {
40
+ n[r] = "many";
41
+ continue;
42
+ }
43
+ let a = i.map((e) => [S(e.from), S(e.to)]);
44
+ if (a.some(([e, t]) => e === null || t === null)) {
45
+ n[r] = "empty";
46
+ continue;
47
+ }
48
+ if (a.some(([e, t]) => t <= e)) {
49
+ n[r] = "order";
50
+ continue;
51
+ }
52
+ let o = [...a].sort((e, t) => e[0] - t[0]);
53
+ o.some(([e], t) => t > 0 && e < o[t - 1][1]) && (n[r] = "overlap");
54
+ }
55
+ return n;
56
+ }
57
+ function E(e, t, n) {
58
+ let r = e[t] ?? [], i = { ...e };
59
+ for (let e of n) e !== t && (r.length ? i[e] = r.map((e) => ({ ...e })) : delete i[e]);
60
+ return i;
61
+ }
62
+ function D(e, t) {
63
+ if (!e.length) return { ...t };
64
+ let n = e.map((e) => S(e.to)).filter((e) => e !== null), r = n.length ? Math.max(...n) : 0, i = Math.min(r + 60, 1380);
65
+ return i <= r ? null : {
66
+ from: C(i),
67
+ to: C(Math.min(i + 240, 1439))
68
+ };
69
+ }
70
+ function O(e, t) {
71
+ let n = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
72
+ return n ? new Intl.DateTimeFormat(r(t), {
73
+ day: "2-digit",
74
+ month: "2-digit",
75
+ year: "numeric",
76
+ timeZone: "UTC"
77
+ }).format(new Date(Date.UTC(Number(n[1]), Number(n[2]) - 1, Number(n[3])))) : e;
78
+ }
79
+ function k(e, t = "pt-BR", n = "mon") {
80
+ let r = i[t].weekHours, a = (t) => (e[t] ?? []).map((e) => `${e.from}-${e.to}`).join(","), o = w(n), s = [];
81
+ for (let e of o) {
82
+ let t = s[s.length - 1];
83
+ t && a(t[0]) === a(e) ? t.push(e) : s.push([e]);
84
+ }
85
+ return s.map((t) => {
86
+ let n = t[0], i = t[t.length - 1], a = t.length === 1 ? r.days[n] : t.length === 2 ? r.pair(r.span[n], r.span[i]) : r.through(r.span[n], r.span[i]), o = e[n] ?? [];
87
+ return {
88
+ days: a,
89
+ hours: o.length ? o.map((e) => r.range(e.from, e.to)).join(", ") : r.closed
90
+ };
91
+ });
92
+ }
93
+ function A({ value: r, onChange: i, holidays: s = [], onHolidaysChange: l, holidaysNote: d, weekStart: x = "mon", defaultRange: S = {
94
+ from: "08:00",
95
+ to: "18:00"
96
+ }, maxRanges: C = 6, readOnly: A = !1, disabled: M = !1, label: N, className: P }) {
97
+ let F = a(), I = o().weekHours, L = p(), R = m({}), [z, B] = h(""), V = w(x), H = T(r, C), U = `select-weekhours${A ? " select-weekhours--readonly" : ""}${P ? " " + P : ""}`;
98
+ if (A) {
99
+ let e = k(r, F, x);
100
+ return /* @__PURE__ */ v("div", {
101
+ className: U,
102
+ role: "group",
103
+ "aria-label": N ?? I.label,
104
+ children: [/* @__PURE__ */ _("dl", {
105
+ className: "select-weekhours__summary",
106
+ children: e.map((e) => /* @__PURE__ */ v("div", {
107
+ className: "select-weekhours__line",
108
+ children: [/* @__PURE__ */ _("dt", { children: e.days }), /* @__PURE__ */ _("dd", {
109
+ className: e.hours === I.closed ? "is-closed" : void 0,
110
+ children: e.hours
111
+ })]
112
+ }, e.days))
113
+ }), d || s.length ? /* @__PURE__ */ v("div", {
114
+ className: "select-weekhours__holidays",
115
+ children: [
116
+ /* @__PURE__ */ _("span", {
117
+ className: "select-weekhours__subtitle",
118
+ children: I.holidays
119
+ }),
120
+ d ? /* @__PURE__ */ _("div", {
121
+ className: "select-weekhours__note",
122
+ children: d
123
+ }) : null,
124
+ s.length ? /* @__PURE__ */ _("ul", {
125
+ className: "select-weekhours__dates",
126
+ children: [...s].sort((e, t) => e.date.localeCompare(t.date)).map((e) => /* @__PURE__ */ _("li", { children: I.holiday(O(e.date, F), e.name) }, e.date))
127
+ }) : null
128
+ ]
129
+ }) : null]
130
+ });
131
+ }
132
+ let W = (e, t) => {
133
+ let n = { ...r };
134
+ t.length ? n[e] = t : delete n[e], i(n);
135
+ }, G = (e, t) => {
136
+ let n = r[e] ?? [];
137
+ if (t) {
138
+ let t = R.current[e];
139
+ W(e, t && t.length ? t : [{ ...S }]);
140
+ } else R.current[e] = n, W(e, []);
141
+ }, K = (e, t, n) => {
142
+ i(E(r, e, t)), B(I.copied(I.days[e], n));
143
+ };
144
+ return /* @__PURE__ */ v("fieldset", {
145
+ className: U,
146
+ disabled: M,
147
+ children: [
148
+ /* @__PURE__ */ _("legend", {
149
+ className: "select-visually-hidden",
150
+ children: N ?? I.label
151
+ }),
152
+ /* @__PURE__ */ _("div", {
153
+ className: "select-weekhours__days",
154
+ children: V.map((i) => {
155
+ let a = r[i] ?? [], o = a.length > 0, s = H[i], l = `${L}-${i}-error`, d = I.days[i], p = D(a, S);
156
+ return /* @__PURE__ */ v("div", {
157
+ className: `select-weekhours__day${o ? "" : " is-closed"}`,
158
+ role: "group",
159
+ "aria-labelledby": `${L}-${i}`,
160
+ children: [
161
+ /* @__PURE__ */ v("div", {
162
+ className: "select-weekhours__dayhead",
163
+ children: [/* @__PURE__ */ _(c, {
164
+ checked: o,
165
+ onChange: (e) => G(i, e),
166
+ label: I.openOn(i),
167
+ disabled: M
168
+ }), /* @__PURE__ */ _("span", {
169
+ className: "select-weekhours__dayname",
170
+ id: `${L}-${i}`,
171
+ children: d
172
+ })]
173
+ }),
174
+ /* @__PURE__ */ _("div", {
175
+ className: "select-weekhours__ranges",
176
+ children: o ? /* @__PURE__ */ v(g, { children: [
177
+ a.map((e, n) => /* @__PURE__ */ v("div", {
178
+ className: "select-weekhours__range",
179
+ role: "group",
180
+ "aria-label": I.rangeLabel(d, n + 1),
181
+ children: [
182
+ /* @__PURE__ */ _("input", {
183
+ type: "time",
184
+ className: `select-input select-weekhours__time${s ? " select-input--error" : ""}`,
185
+ "aria-label": I.from,
186
+ value: e.from,
187
+ "aria-invalid": s ? !0 : void 0,
188
+ "aria-describedby": s ? l : void 0,
189
+ onChange: (e) => W(i, a.map((t, r) => r === n ? {
190
+ ...t,
191
+ from: e.target.value
192
+ } : t))
193
+ }),
194
+ /* @__PURE__ */ _("span", {
195
+ className: "select-weekhours__to",
196
+ "aria-hidden": "true",
197
+ children: I.until
198
+ }),
199
+ /* @__PURE__ */ _("input", {
200
+ type: "time",
201
+ className: `select-input select-weekhours__time${s ? " select-input--error" : ""}`,
202
+ "aria-label": I.to,
203
+ value: e.to === "24:00" ? "23:59" : e.to,
204
+ "aria-invalid": s ? !0 : void 0,
205
+ "aria-describedby": s ? l : void 0,
206
+ onChange: (e) => W(i, a.map((t, r) => r === n ? {
207
+ ...t,
208
+ to: e.target.value
209
+ } : t))
210
+ }),
211
+ /* @__PURE__ */ _(u, {
212
+ icon: /* @__PURE__ */ _(t, {}),
213
+ size: "sm",
214
+ label: I.removeRange(e.from, e.to),
215
+ disabled: M,
216
+ onClick: () => W(i, a.filter((e, t) => t !== n))
217
+ })
218
+ ]
219
+ }, n)),
220
+ s ? /* @__PURE__ */ _("p", {
221
+ id: l,
222
+ className: "select-weekhours__error",
223
+ children: I.problems[s]
224
+ }) : null,
225
+ a.length < C && p ? /* @__PURE__ */ _(e, {
226
+ variant: "ghost",
227
+ size: "sm",
228
+ inline: !0,
229
+ icon: /* @__PURE__ */ _(n, {}),
230
+ disabled: M,
231
+ onClick: () => W(i, [...a, p]),
232
+ children: I.addRange
233
+ }) : null
234
+ ] }) : /* @__PURE__ */ _("span", {
235
+ className: "select-weekhours__closed",
236
+ children: I.closed
237
+ })
238
+ }),
239
+ /* @__PURE__ */ _("div", {
240
+ className: "select-weekhours__menu",
241
+ children: /* @__PURE__ */ _(f, {
242
+ label: I.copyMenu(d),
243
+ actions: [{
244
+ content: I.copyWorkdays,
245
+ onAction: () => K(i, b, I.workdays)
246
+ }, {
247
+ content: I.copyAll,
248
+ onAction: () => K(i, y, I.everyDay)
249
+ }]
250
+ })
251
+ })
252
+ ]
253
+ }, i);
254
+ })
255
+ }),
256
+ l ? /* @__PURE__ */ _(j, {
257
+ holidays: s,
258
+ onChange: l,
259
+ note: d
260
+ }) : null,
261
+ /* @__PURE__ */ _("span", {
262
+ className: "select-visually-hidden",
263
+ role: "status",
264
+ "aria-live": "polite",
265
+ children: z
266
+ })
267
+ ]
268
+ });
269
+ }
270
+ function j({ holidays: t, onChange: n, note: r }) {
271
+ let i = a(), c = o().weekHours, u = p(), [f, m] = h(""), [g, y] = h(""), b = [...t].sort((e, t) => e.date.localeCompare(t.date)), x = /^\d{4}-\d{2}-\d{2}$/.test(f) && g.trim() !== "", S = () => {
272
+ x && (n([...t.filter((e) => e.date !== f), {
273
+ date: f,
274
+ name: g.trim()
275
+ }].sort((e, t) => e.date.localeCompare(t.date))), m(""), y(""));
276
+ };
277
+ return /* @__PURE__ */ v("div", {
278
+ className: "select-weekhours__holidays",
279
+ role: "group",
280
+ "aria-labelledby": `${u}-title`,
281
+ children: [
282
+ /* @__PURE__ */ _("span", {
283
+ className: "select-weekhours__subtitle",
284
+ id: `${u}-title`,
285
+ children: c.holidays
286
+ }),
287
+ r ? /* @__PURE__ */ _("div", {
288
+ className: "select-weekhours__note",
289
+ children: r
290
+ }) : null,
291
+ b.length ? /* @__PURE__ */ _("ul", {
292
+ className: "select-weekhours__dates",
293
+ children: b.map((e) => {
294
+ let r = c.holiday(O(e.date, i), e.name);
295
+ return /* @__PURE__ */ _("li", { children: /* @__PURE__ */ _(l, {
296
+ onRemove: () => n(t.filter((t) => t.date !== e.date)),
297
+ removeLabel: c.removeHoliday(r),
298
+ children: r
299
+ }) }, e.date);
300
+ })
301
+ }) : /* @__PURE__ */ _("p", {
302
+ className: "select-weekhours__none",
303
+ children: c.noHolidays
304
+ }),
305
+ /* @__PURE__ */ v("div", {
306
+ className: "select-weekhours__adddate",
307
+ children: [
308
+ /* @__PURE__ */ _(d, {
309
+ label: c.date,
310
+ value: f,
311
+ onChange: m,
312
+ clearable: !1
313
+ }),
314
+ /* @__PURE__ */ _(s, {
315
+ label: c.name,
316
+ value: g,
317
+ onChange: (e) => y(e),
318
+ maxLength: 80,
319
+ onKeyDown: (e) => {
320
+ e.key === "Enter" && (e.preventDefault(), S());
321
+ }
322
+ }),
323
+ /* @__PURE__ */ _(e, {
324
+ variant: "secondary",
325
+ inline: !0,
326
+ disabled: !x,
327
+ onClick: S,
328
+ children: c.addHoliday
329
+ })
330
+ ]
331
+ })
332
+ ]
333
+ });
334
+ }
335
+ //#endregion
336
+ export { y as SELECT_WEEKDAYS, A as SelectWeekHours, E as selectCopyDay, D as selectNextRange, S as selectTimeMinutes, k as selectWeekHoursLines, T as selectWeekHoursProblems, w as selectWeekOrder };
337
+
338
+ //# sourceMappingURL=SelectWeekHours.js.map
package/dist/index.d.ts CHANGED
@@ -64,6 +64,18 @@ export type { SelectFieldsetProps } from './SelectFieldset';
64
64
  export type { SelectNavCount } from './internal/navCount';
65
65
  export { useSelectSortable, selectSortableOrder } from './SelectSortable';
66
66
  export type { SelectSortable, SelectSortableOptions, SelectSortableHandleProps, SelectSortableItemBinding } from './SelectSortable';
67
+ export type { SelectListRowColumn } from './SelectListCard';
68
+ export type { SelectDeviceFrameBrand } from './SelectChannelPreview';
69
+ export { SelectWeekHours, SELECT_WEEKDAYS, selectWeekHoursProblems, selectWeekHoursLines, selectCopyDay, selectNextRange, selectTimeMinutes, selectWeekOrder, } from './SelectWeekHours';
70
+ export type { SelectWeekHoursProps, SelectWeekHoursValue, SelectWeekHoursProblem, SelectWeekday, SelectTimeRange, SelectHoliday, } from './SelectWeekHours';
71
+ export { SelectActionBar, selectActionBarFit } from './SelectActionBar';
72
+ export type { SelectActionBarProps, SelectActionBarItem } from './SelectActionBar';
73
+ export { SelectDeadlineBadge, selectDeadlineText, selectDurationText } from './SelectDeadlineBadge';
74
+ export type { SelectDeadlineBadgeProps, SelectDeadlineState } from './SelectDeadlineBadge';
75
+ export { SelectBulkBar } from './SelectBulkBar';
76
+ export type { SelectBulkBarProps } from './SelectBulkBar';
77
+ export { SelectComposerNotice } from './SelectComposerNotice';
78
+ export type { SelectComposerNoticeProps } from './SelectComposerNotice';
67
79
  export { SelectPage, SelectPageBackProvider, SelectPageHeader } from './SelectPage';
68
80
  export { SelectFormLayout } from './SelectFormLayout';
69
81
  export { SelectSkeleton } from './SelectSkeleton';
@@ -160,7 +172,7 @@ export { SelectRowActions } from './SelectRowActions';
160
172
  export { SelectConfirmModal } from './SelectConfirmModal';
161
173
  export { SelectFormModal } from './SelectFormModal';
162
174
  export { detectSelectTheme } from './detectSelectTheme';
163
- export { SelectDataTable, SELECT_COL_DATETIME, SELECT_COL_ID, useSelectPageSize } from './SelectDataTable';
175
+ export { SelectDataTable, SELECT_COL_DATETIME, SELECT_COL_TIMEAGO, SELECT_COL_ID, useSelectPageSize } from './SelectDataTable';
164
176
  export { SelectCardGrid } from './SelectCardGrid';
165
177
  export { SelectRecordCard, SelectLayoutThumb, SelectFactList } from './SelectRecordCard';
166
178
  export { SelectBreadcrumb } from './SelectBreadcrumb';
@@ -330,7 +342,7 @@ export type { SelectRadioOption } from './SelectRadioGroup';
330
342
  export type { SegmentedOption } from './SelectSegmented';
331
343
  export type { SelectTab } from './SelectTabs';
332
344
  export type { SideNavItem, SideNavSection } from './SelectSideNav';
333
- export type { SelectColumn } from './SelectTable';
345
+ export type { SelectColumn, SelectTableRowTone } from './SelectTable';
334
346
  export type { ComboboxOption } from './SelectCombobox';
335
347
  export type { SelectTheme } from './SelectThemeSwitcher';
336
348
  export type { SelectToastApi, SelectToastAction, SelectToastVariant } from './SelectToast';