@sprawlify/react 0.0.105 → 0.0.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{alert-dialog-anatomy-Bhjic8B3.d.mts → alert-dialog-anatomy-Jf75lz9b.d.mts} +1 -1
- package/dist/{alert-dialog-anatomy-CmS0HzWk.d.cts → alert-dialog-anatomy-TKcT7l5b.d.cts} +1 -1
- package/dist/{anatomy-D0EGQD9G.d.cts → anatomy-Bp37tNqs.d.cts} +9 -9
- package/dist/{anatomy-BHkusD_O.d.mts → anatomy-D7ejjpDx.d.mts} +9 -9
- package/dist/{carousel-anatomy-Bx57uqeE.d.cts → carousel-anatomy-B9cQNolB.d.mts} +1 -1
- package/dist/{carousel-anatomy-Cw0YIsPP.d.mts → carousel-anatomy-DdNhuLfJ.d.cts} +1 -1
- package/dist/{checkbox-anatomy-B3UgGmJ5.d.mts → checkbox-anatomy-8Vf0VCHG.d.cts} +1 -1
- package/dist/{checkbox-anatomy-BuDM7LQO.d.cts → checkbox-anatomy-_OLisOer.d.mts} +1 -1
- package/dist/{collapsible-BQYUN_eV.cjs → collapsible-BCma5-fq.cjs} +2 -2
- package/dist/{collapsible-DmgD6PQY.mjs → collapsible-DcnLTV0k.mjs} +2 -2
- package/dist/{collection-DX1e_ZEq.mjs → collection-9ORmr4hT.mjs} +1 -1
- package/dist/{collection-xMr2Xl5X.cjs → collection-D-H1Ib2v.cjs} +1 -1
- package/dist/{color-picker-anatomy-CDfQfWnH.d.mts → color-picker-anatomy--NJVbmTS.d.cts} +1 -1
- package/dist/{color-picker-anatomy-RfXHYnWo.d.cts → color-picker-anatomy-D4WKuLMN.d.mts} +1 -1
- package/dist/{combobox-anatomy-7Utq4FMb.d.cts → combobox-anatomy-8FahQpQ3.d.cts} +1 -1
- package/dist/{combobox-anatomy-Dzkzt6wx.d.mts → combobox-anatomy-BlQq-b8P.d.mts} +1 -1
- package/dist/components/accordion/index.cjs +3 -3
- package/dist/components/accordion/index.mjs +3 -3
- package/dist/components/alert-dialog/index.cjs +3 -3
- package/dist/components/alert-dialog/index.d.cts +1 -1
- package/dist/components/alert-dialog/index.d.mts +1 -1
- package/dist/components/alert-dialog/index.mjs +3 -3
- package/dist/components/anatomy.d.cts +10 -10
- package/dist/components/anatomy.d.mts +10 -10
- package/dist/components/angle-slider/index.cjs +2 -2
- package/dist/components/angle-slider/index.mjs +2 -2
- package/dist/components/aspect-ratio/index.cjs +2 -2
- package/dist/components/aspect-ratio/index.mjs +2 -2
- package/dist/components/avatar/index.cjs +2 -2
- package/dist/components/avatar/index.mjs +2 -2
- package/dist/components/bottom-sheet/index.cjs +3 -3
- package/dist/components/bottom-sheet/index.mjs +3 -3
- package/dist/components/carousel/index.cjs +2 -2
- package/dist/components/carousel/index.d.cts +1 -1
- package/dist/components/carousel/index.d.mts +1 -1
- package/dist/components/carousel/index.mjs +2 -2
- package/dist/components/checkbox/index.cjs +2 -2
- package/dist/components/checkbox/index.d.cts +1 -1
- package/dist/components/checkbox/index.d.mts +1 -1
- package/dist/components/checkbox/index.mjs +4 -4
- package/dist/components/clipboard/index.cjs +1 -1
- package/dist/components/clipboard/index.mjs +1 -1
- package/dist/components/collapsible/index.cjs +3 -3
- package/dist/components/collapsible/index.mjs +3 -3
- package/dist/components/collection/index.cjs +2 -2
- package/dist/components/collection/index.mjs +2 -2
- package/dist/components/color-picker/index.cjs +3 -3
- package/dist/components/color-picker/index.d.cts +1 -1
- package/dist/components/color-picker/index.d.mts +1 -1
- package/dist/components/color-picker/index.mjs +4 -4
- package/dist/components/combobox/index.cjs +4 -4
- package/dist/components/combobox/index.d.cts +1 -1
- package/dist/components/combobox/index.d.mts +1 -1
- package/dist/components/combobox/index.mjs +5 -5
- package/dist/components/date-picker/index.cjs +3 -3
- package/dist/components/date-picker/index.d.cts +1 -1
- package/dist/components/date-picker/index.d.mts +1 -1
- package/dist/components/date-picker/index.mjs +3 -3
- package/dist/components/dialog/index.cjs +3 -3
- package/dist/components/dialog/index.mjs +3 -3
- package/dist/components/download-trigger/index.cjs +1 -1
- package/dist/components/download-trigger/index.mjs +1 -1
- package/dist/components/dropdown-menu/index.cjs +3 -3
- package/dist/components/dropdown-menu/index.d.cts +1 -1
- package/dist/components/dropdown-menu/index.d.mts +1 -1
- package/dist/components/dropdown-menu/index.mjs +3 -3
- package/dist/components/editable/index.cjs +2 -2
- package/dist/components/editable/index.mjs +3 -3
- package/dist/components/field/index.cjs +2 -2
- package/dist/components/field/index.mjs +3 -3
- package/dist/components/fieldset/index.cjs +2 -2
- package/dist/components/fieldset/index.mjs +3 -3
- package/dist/components/file-upload/index.cjs +2 -2
- package/dist/components/file-upload/index.mjs +3 -3
- package/dist/components/floating-panel/index.cjs +3 -3
- package/dist/components/floating-panel/index.mjs +3 -3
- package/dist/components/format/index.cjs +1 -1
- package/dist/components/format/index.mjs +1 -1
- package/dist/components/frame/index.cjs +1 -1
- package/dist/components/frame/index.mjs +1 -1
- package/dist/components/hover-card/index.cjs +3 -3
- package/dist/components/hover-card/index.mjs +3 -3
- package/dist/components/image-cropper/index.cjs +2 -2
- package/dist/components/image-cropper/index.mjs +2 -2
- package/dist/components/json-tree-view/index.cjs +5 -5
- package/dist/components/json-tree-view/index.mjs +5 -6
- package/dist/components/listbox/index.cjs +3 -3
- package/dist/components/listbox/index.d.cts +1 -1
- package/dist/components/listbox/index.d.mts +1 -1
- package/dist/components/listbox/index.mjs +3 -3
- package/dist/components/marquee/index.cjs +2 -2
- package/dist/components/marquee/index.mjs +2 -2
- package/dist/components/navigation-menu/index.cjs +3 -3
- package/dist/components/navigation-menu/index.mjs +3 -3
- package/dist/components/number-input/index.cjs +2 -2
- package/dist/components/number-input/index.mjs +3 -3
- package/dist/components/pagination/index.cjs +2 -2
- package/dist/components/pagination/index.mjs +2 -2
- package/dist/components/password-input/index.cjs +2 -2
- package/dist/components/password-input/index.mjs +3 -3
- package/dist/components/pin-input/index.cjs +2 -2
- package/dist/components/pin-input/index.mjs +3 -3
- package/dist/components/popover/index.cjs +3 -3
- package/dist/components/popover/index.mjs +3 -3
- package/dist/components/portal/index.cjs +1 -1
- package/dist/components/portal/index.mjs +1 -1
- package/dist/components/presence/index.cjs +2 -2
- package/dist/components/presence/index.mjs +2 -2
- package/dist/components/progress/index.cjs +2 -2
- package/dist/components/progress/index.mjs +2 -2
- package/dist/components/qr-code/index.cjs +2 -2
- package/dist/components/qr-code/index.mjs +2 -2
- package/dist/components/radio-group/index.cjs +2 -2
- package/dist/components/radio-group/index.mjs +3 -3
- package/dist/components/rating-group/index.cjs +2 -2
- package/dist/components/rating-group/index.mjs +3 -3
- package/dist/components/scroll-area/index.cjs +2 -2
- package/dist/components/scroll-area/index.mjs +2 -2
- package/dist/components/segment-group/index.cjs +2 -2
- package/dist/components/segment-group/index.d.cts +1 -1
- package/dist/components/segment-group/index.d.mts +1 -1
- package/dist/components/segment-group/index.mjs +2 -2
- package/dist/components/select/index.cjs +4 -4
- package/dist/components/select/index.mjs +5 -5
- package/dist/components/separator/index.cjs +2 -2
- package/dist/components/separator/index.mjs +2 -2
- package/dist/components/signature-pad/index.cjs +2 -2
- package/dist/components/signature-pad/index.mjs +3 -3
- package/dist/components/slider/index.cjs +2 -2
- package/dist/components/slider/index.mjs +2 -2
- package/dist/components/splitter/index.cjs +2 -2
- package/dist/components/splitter/index.mjs +2 -2
- package/dist/components/steps/index.cjs +2 -2
- package/dist/components/steps/index.mjs +2 -2
- package/dist/components/switch/index.cjs +2 -2
- package/dist/components/switch/index.mjs +3 -3
- package/dist/components/tabs/index.cjs +3 -3
- package/dist/components/tabs/index.mjs +3 -3
- package/dist/components/tags-input/index.cjs +2 -2
- package/dist/components/tags-input/index.mjs +3 -3
- package/dist/components/timer/index.cjs +2 -2
- package/dist/components/timer/index.mjs +2 -2
- package/dist/components/toast/index.cjs +2 -2
- package/dist/components/toast/index.mjs +2 -2
- package/dist/components/toggle/index.cjs +1 -1
- package/dist/components/toggle/index.mjs +1 -1
- package/dist/components/toggle-group/index.cjs +2 -2
- package/dist/components/toggle-group/index.mjs +2 -2
- package/dist/components/tooltip/index.cjs +3 -3
- package/dist/components/tooltip/index.mjs +3 -3
- package/dist/components/tour/index.cjs +3 -3
- package/dist/components/tour/index.d.cts +1 -1
- package/dist/components/tour/index.d.mts +1 -1
- package/dist/components/tour/index.mjs +3 -3
- package/dist/components/tree-view/index.cjs +5 -5
- package/dist/components/tree-view/index.mjs +5 -5
- package/dist/{core-B2xe_H5d.cjs → core-D3VWpaVw.cjs} +1 -1
- package/dist/{core-C1rldtMa.mjs → core-Ds_Jbvzw.mjs} +1 -1
- package/dist/{date-picker-anatomy-DKdD3Jj1.d.cts → date-picker-anatomy-CR-zf9Uu.d.cts} +1 -1
- package/dist/{date-picker-anatomy-Drzv4o8X.d.mts → date-picker-anatomy-dyI6XVYb.d.mts} +1 -1
- package/dist/{field-Bbi9izVu.mjs → field-D0DgA3nE.mjs} +1 -1
- package/dist/{fieldset-DlUDLf8o.mjs → fieldset-BTum5ZBg.mjs} +1 -1
- package/dist/{index-BYbG07Qs.d.mts → index-CRJn4i7D.d.mts} +37 -12
- package/dist/{index-CgJDVhnI.d.cts → index-ys7B7svO.d.cts} +37 -12
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +12 -12
- package/dist/index.d.mts +12 -12
- package/dist/index.mjs +3 -3
- package/dist/{listbox-anatomy-C3cnB6RV.d.cts → listbox-anatomy-DHCNIr_E.d.cts} +1 -1
- package/dist/{listbox-anatomy-CP_PUvXM.d.mts → listbox-anatomy-DhG9XXxL.d.mts} +1 -1
- package/dist/locale-BOA439G-.mjs +160 -0
- package/dist/locale-Dc2Fyoa-.cjs +190 -0
- package/dist/{presence-DjN_fQcB.cjs → presence-W-p0Vh_B.cjs} +1 -1
- package/dist/{presence-Dj3TqYzy.mjs → presence-s8pNuusP.mjs} +1 -1
- package/dist/{segment-group-anatomy-BO-oXNAU.d.cts → segment-group-anatomy-BxkiJHLF.d.cts} +1 -1
- package/dist/{segment-group-anatomy-BUdXtMrR.d.mts → segment-group-anatomy-uVSRVyur.d.mts} +1 -1
- package/dist/{tour-anatomy-CMLhRe_3.d.mts → tour-anatomy-W3ivVKHh.d.mts} +1 -1
- package/dist/{tour-anatomy-CuoAItcP.d.cts → tour-anatomy-Yp290aAw.d.cts} +1 -1
- package/dist/{tree-view-C5sDOTFF.cjs → tree-view-CPza4iz0.cjs} +3 -3
- package/dist/{tree-view-BLSdhcfd.mjs → tree-view-dbAqFgCx.mjs} +3 -3
- package/package.json +9 -8
- package/dist/locale-DenY029U.cjs +0 -73
- package/dist/locale-yswfGSTu.mjs +0 -49
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { t as createContext$1 } from "./create-context-vbKnbgU_.mjs";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { createCollator, createFilter, isRTL } from "@sprawlify/primitives/i18n-utils";
|
|
5
|
+
//#region src/providers/locale/use-locale-context.ts
|
|
6
|
+
const [LocaleContextProvider, useLocaleContext] = createContext$1({
|
|
7
|
+
name: "LocaleContext",
|
|
8
|
+
hookName: "useLocaleContext",
|
|
9
|
+
providerName: "<LocaleProvider />",
|
|
10
|
+
strict: false,
|
|
11
|
+
defaultValue: {
|
|
12
|
+
dir: "ltr",
|
|
13
|
+
locale: "en-US"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/providers/locale/locale-provider.tsx
|
|
18
|
+
const LocaleProvider = (props) => {
|
|
19
|
+
const { children, locale } = props;
|
|
20
|
+
return /* @__PURE__ */ jsx(LocaleContextProvider, {
|
|
21
|
+
value: {
|
|
22
|
+
locale,
|
|
23
|
+
dir: isRTL(locale) ? "rtl" : "ltr"
|
|
24
|
+
},
|
|
25
|
+
children
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/providers/locale/use-collator.ts
|
|
30
|
+
function useCollator(props = {}) {
|
|
31
|
+
const env = useLocaleContext();
|
|
32
|
+
const locale = props.locale ?? env.locale;
|
|
33
|
+
return useMemo(() => {
|
|
34
|
+
const { locale: _, ...options } = props;
|
|
35
|
+
return createCollator(locale, options);
|
|
36
|
+
}, [locale, props]);
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region ../../node_modules/.pnpm/@internationalized+date@3.12.0/node_modules/@internationalized/date/dist/DateFormatter.mjs
|
|
40
|
+
let $fb18d541ea1ad717$var$formatterCache = /* @__PURE__ */ new Map();
|
|
41
|
+
var $fb18d541ea1ad717$export$ad991b66133851cf = class {
|
|
42
|
+
/** Formats a date as a string according to the locale and format options passed to the constructor. */ format(value) {
|
|
43
|
+
return this.formatter.format(value);
|
|
44
|
+
}
|
|
45
|
+
/** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */ formatToParts(value) {
|
|
46
|
+
return this.formatter.formatToParts(value);
|
|
47
|
+
}
|
|
48
|
+
/** Formats a date range as a string. */ formatRange(start, end) {
|
|
49
|
+
if (typeof this.formatter.formatRange === "function") return this.formatter.formatRange(start, end);
|
|
50
|
+
if (end < start) throw new RangeError("End date must be >= start date");
|
|
51
|
+
return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`;
|
|
52
|
+
}
|
|
53
|
+
/** Formats a date range as an array of parts. */ formatRangeToParts(start, end) {
|
|
54
|
+
if (typeof this.formatter.formatRangeToParts === "function") return this.formatter.formatRangeToParts(start, end);
|
|
55
|
+
if (end < start) throw new RangeError("End date must be >= start date");
|
|
56
|
+
let startParts = this.formatter.formatToParts(start);
|
|
57
|
+
let endParts = this.formatter.formatToParts(end);
|
|
58
|
+
return [
|
|
59
|
+
...startParts.map((p) => ({
|
|
60
|
+
...p,
|
|
61
|
+
source: "startRange"
|
|
62
|
+
})),
|
|
63
|
+
{
|
|
64
|
+
type: "literal",
|
|
65
|
+
value: " – ",
|
|
66
|
+
source: "shared"
|
|
67
|
+
},
|
|
68
|
+
...endParts.map((p) => ({
|
|
69
|
+
...p,
|
|
70
|
+
source: "endRange"
|
|
71
|
+
}))
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
/** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() {
|
|
75
|
+
let resolvedOptions = this.formatter.resolvedOptions();
|
|
76
|
+
if ($fb18d541ea1ad717$var$hasBuggyResolvedHourCycle()) {
|
|
77
|
+
if (!this.resolvedHourCycle) this.resolvedHourCycle = $fb18d541ea1ad717$var$getResolvedHourCycle(resolvedOptions.locale, this.options);
|
|
78
|
+
resolvedOptions.hourCycle = this.resolvedHourCycle;
|
|
79
|
+
resolvedOptions.hour12 = this.resolvedHourCycle === "h11" || this.resolvedHourCycle === "h12";
|
|
80
|
+
}
|
|
81
|
+
if (resolvedOptions.calendar === "ethiopic-amete-alem") resolvedOptions.calendar = "ethioaa";
|
|
82
|
+
return resolvedOptions;
|
|
83
|
+
}
|
|
84
|
+
constructor(locale, options = {}) {
|
|
85
|
+
this.formatter = $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options);
|
|
86
|
+
this.options = options;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const $fb18d541ea1ad717$var$hour12Preferences = {
|
|
90
|
+
true: { ja: "h11" },
|
|
91
|
+
false: {}
|
|
92
|
+
};
|
|
93
|
+
function $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options = {}) {
|
|
94
|
+
if (typeof options.hour12 === "boolean" && $fb18d541ea1ad717$var$hasBuggyHour12Behavior()) {
|
|
95
|
+
options = { ...options };
|
|
96
|
+
let pref = $fb18d541ea1ad717$var$hour12Preferences[String(options.hour12)][locale.split("-")[0]];
|
|
97
|
+
let defaultHourCycle = options.hour12 ? "h12" : "h23";
|
|
98
|
+
options.hourCycle = pref !== null && pref !== void 0 ? pref : defaultHourCycle;
|
|
99
|
+
delete options.hour12;
|
|
100
|
+
}
|
|
101
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : "");
|
|
102
|
+
if ($fb18d541ea1ad717$var$formatterCache.has(cacheKey)) return $fb18d541ea1ad717$var$formatterCache.get(cacheKey);
|
|
103
|
+
let numberFormatter = new Intl.DateTimeFormat(locale, options);
|
|
104
|
+
$fb18d541ea1ad717$var$formatterCache.set(cacheKey, numberFormatter);
|
|
105
|
+
return numberFormatter;
|
|
106
|
+
}
|
|
107
|
+
let $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = null;
|
|
108
|
+
function $fb18d541ea1ad717$var$hasBuggyHour12Behavior() {
|
|
109
|
+
if ($fb18d541ea1ad717$var$_hasBuggyHour12Behavior == null) $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat("en-US", {
|
|
110
|
+
hour: "numeric",
|
|
111
|
+
hour12: false
|
|
112
|
+
}).format(new Date(2020, 2, 3, 0)) === "24";
|
|
113
|
+
return $fb18d541ea1ad717$var$_hasBuggyHour12Behavior;
|
|
114
|
+
}
|
|
115
|
+
let $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = null;
|
|
116
|
+
function $fb18d541ea1ad717$var$hasBuggyResolvedHourCycle() {
|
|
117
|
+
if ($fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle == null) $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat("fr", {
|
|
118
|
+
hour: "numeric",
|
|
119
|
+
hour12: false
|
|
120
|
+
}).resolvedOptions().hourCycle === "h12";
|
|
121
|
+
return $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle;
|
|
122
|
+
}
|
|
123
|
+
function $fb18d541ea1ad717$var$getResolvedHourCycle(locale, options) {
|
|
124
|
+
if (!options.timeStyle && !options.hour) return void 0;
|
|
125
|
+
locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, "");
|
|
126
|
+
locale += (locale.includes("-u-") ? "" : "-u") + "-nu-latn";
|
|
127
|
+
let formatter = $fb18d541ea1ad717$var$getCachedDateFormatter(locale, {
|
|
128
|
+
...options,
|
|
129
|
+
timeZone: void 0
|
|
130
|
+
});
|
|
131
|
+
let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p) => p.type === "hour").value, 10);
|
|
132
|
+
let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p) => p.type === "hour").value, 10);
|
|
133
|
+
if (min === 0 && max === 23) return "h23";
|
|
134
|
+
if (min === 24 && max === 23) return "h24";
|
|
135
|
+
if (min === 0 && max === 11) return "h11";
|
|
136
|
+
if (min === 12 && max === 11) return "h12";
|
|
137
|
+
throw new Error("Unexpected hour cycle result");
|
|
138
|
+
}
|
|
139
|
+
//#endregion
|
|
140
|
+
//#region src/providers/locale/use-date-formatter.ts
|
|
141
|
+
function useDateFormatter(props = {}) {
|
|
142
|
+
const env = useLocaleContext();
|
|
143
|
+
const locale = props.locale ?? env.locale;
|
|
144
|
+
return useMemo(() => {
|
|
145
|
+
const { locale: _, ...options } = props;
|
|
146
|
+
return new $fb18d541ea1ad717$export$ad991b66133851cf(locale, options);
|
|
147
|
+
}, [locale, props]);
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/providers/locale/use-filter.ts
|
|
151
|
+
function useFilter(props) {
|
|
152
|
+
const env = useLocaleContext();
|
|
153
|
+
const locale = props.locale ?? env.locale;
|
|
154
|
+
return useMemo(() => createFilter({
|
|
155
|
+
...props,
|
|
156
|
+
locale
|
|
157
|
+
}), [locale, props]);
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
export { useLocaleContext as a, LocaleProvider as i, useDateFormatter as n, useCollator as r, useFilter as t };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
require("./chunk-DIRhrrdE.cjs");
|
|
2
|
+
const require_create_context = require("./create-context-DVfXoZgh.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
+
let _sprawlify_primitives_i18n_utils = require("@sprawlify/primitives/i18n-utils");
|
|
6
|
+
//#region src/providers/locale/use-locale-context.ts
|
|
7
|
+
const [LocaleContextProvider, useLocaleContext] = require_create_context.createContext({
|
|
8
|
+
name: "LocaleContext",
|
|
9
|
+
hookName: "useLocaleContext",
|
|
10
|
+
providerName: "<LocaleProvider />",
|
|
11
|
+
strict: false,
|
|
12
|
+
defaultValue: {
|
|
13
|
+
dir: "ltr",
|
|
14
|
+
locale: "en-US"
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/providers/locale/locale-provider.tsx
|
|
19
|
+
const LocaleProvider = (props) => {
|
|
20
|
+
const { children, locale } = props;
|
|
21
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LocaleContextProvider, {
|
|
22
|
+
value: {
|
|
23
|
+
locale,
|
|
24
|
+
dir: (0, _sprawlify_primitives_i18n_utils.isRTL)(locale) ? "rtl" : "ltr"
|
|
25
|
+
},
|
|
26
|
+
children
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/providers/locale/use-collator.ts
|
|
31
|
+
function useCollator(props = {}) {
|
|
32
|
+
const env = useLocaleContext();
|
|
33
|
+
const locale = props.locale ?? env.locale;
|
|
34
|
+
return (0, react.useMemo)(() => {
|
|
35
|
+
const { locale: _, ...options } = props;
|
|
36
|
+
return (0, _sprawlify_primitives_i18n_utils.createCollator)(locale, options);
|
|
37
|
+
}, [locale, props]);
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region ../../node_modules/.pnpm/@internationalized+date@3.12.0/node_modules/@internationalized/date/dist/DateFormatter.mjs
|
|
41
|
+
let $fb18d541ea1ad717$var$formatterCache = /* @__PURE__ */ new Map();
|
|
42
|
+
var $fb18d541ea1ad717$export$ad991b66133851cf = class {
|
|
43
|
+
/** Formats a date as a string according to the locale and format options passed to the constructor. */ format(value) {
|
|
44
|
+
return this.formatter.format(value);
|
|
45
|
+
}
|
|
46
|
+
/** Formats a date to an array of parts such as separators, numbers, punctuation, and more. */ formatToParts(value) {
|
|
47
|
+
return this.formatter.formatToParts(value);
|
|
48
|
+
}
|
|
49
|
+
/** Formats a date range as a string. */ formatRange(start, end) {
|
|
50
|
+
if (typeof this.formatter.formatRange === "function") return this.formatter.formatRange(start, end);
|
|
51
|
+
if (end < start) throw new RangeError("End date must be >= start date");
|
|
52
|
+
return `${this.formatter.format(start)} \u{2013} ${this.formatter.format(end)}`;
|
|
53
|
+
}
|
|
54
|
+
/** Formats a date range as an array of parts. */ formatRangeToParts(start, end) {
|
|
55
|
+
if (typeof this.formatter.formatRangeToParts === "function") return this.formatter.formatRangeToParts(start, end);
|
|
56
|
+
if (end < start) throw new RangeError("End date must be >= start date");
|
|
57
|
+
let startParts = this.formatter.formatToParts(start);
|
|
58
|
+
let endParts = this.formatter.formatToParts(end);
|
|
59
|
+
return [
|
|
60
|
+
...startParts.map((p) => ({
|
|
61
|
+
...p,
|
|
62
|
+
source: "startRange"
|
|
63
|
+
})),
|
|
64
|
+
{
|
|
65
|
+
type: "literal",
|
|
66
|
+
value: " – ",
|
|
67
|
+
source: "shared"
|
|
68
|
+
},
|
|
69
|
+
...endParts.map((p) => ({
|
|
70
|
+
...p,
|
|
71
|
+
source: "endRange"
|
|
72
|
+
}))
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
/** Returns the resolved formatting options based on the values passed to the constructor. */ resolvedOptions() {
|
|
76
|
+
let resolvedOptions = this.formatter.resolvedOptions();
|
|
77
|
+
if ($fb18d541ea1ad717$var$hasBuggyResolvedHourCycle()) {
|
|
78
|
+
if (!this.resolvedHourCycle) this.resolvedHourCycle = $fb18d541ea1ad717$var$getResolvedHourCycle(resolvedOptions.locale, this.options);
|
|
79
|
+
resolvedOptions.hourCycle = this.resolvedHourCycle;
|
|
80
|
+
resolvedOptions.hour12 = this.resolvedHourCycle === "h11" || this.resolvedHourCycle === "h12";
|
|
81
|
+
}
|
|
82
|
+
if (resolvedOptions.calendar === "ethiopic-amete-alem") resolvedOptions.calendar = "ethioaa";
|
|
83
|
+
return resolvedOptions;
|
|
84
|
+
}
|
|
85
|
+
constructor(locale, options = {}) {
|
|
86
|
+
this.formatter = $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options);
|
|
87
|
+
this.options = options;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const $fb18d541ea1ad717$var$hour12Preferences = {
|
|
91
|
+
true: { ja: "h11" },
|
|
92
|
+
false: {}
|
|
93
|
+
};
|
|
94
|
+
function $fb18d541ea1ad717$var$getCachedDateFormatter(locale, options = {}) {
|
|
95
|
+
if (typeof options.hour12 === "boolean" && $fb18d541ea1ad717$var$hasBuggyHour12Behavior()) {
|
|
96
|
+
options = { ...options };
|
|
97
|
+
let pref = $fb18d541ea1ad717$var$hour12Preferences[String(options.hour12)][locale.split("-")[0]];
|
|
98
|
+
let defaultHourCycle = options.hour12 ? "h12" : "h23";
|
|
99
|
+
options.hourCycle = pref !== null && pref !== void 0 ? pref : defaultHourCycle;
|
|
100
|
+
delete options.hour12;
|
|
101
|
+
}
|
|
102
|
+
let cacheKey = locale + (options ? Object.entries(options).sort((a, b) => a[0] < b[0] ? -1 : 1).join() : "");
|
|
103
|
+
if ($fb18d541ea1ad717$var$formatterCache.has(cacheKey)) return $fb18d541ea1ad717$var$formatterCache.get(cacheKey);
|
|
104
|
+
let numberFormatter = new Intl.DateTimeFormat(locale, options);
|
|
105
|
+
$fb18d541ea1ad717$var$formatterCache.set(cacheKey, numberFormatter);
|
|
106
|
+
return numberFormatter;
|
|
107
|
+
}
|
|
108
|
+
let $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = null;
|
|
109
|
+
function $fb18d541ea1ad717$var$hasBuggyHour12Behavior() {
|
|
110
|
+
if ($fb18d541ea1ad717$var$_hasBuggyHour12Behavior == null) $fb18d541ea1ad717$var$_hasBuggyHour12Behavior = new Intl.DateTimeFormat("en-US", {
|
|
111
|
+
hour: "numeric",
|
|
112
|
+
hour12: false
|
|
113
|
+
}).format(new Date(2020, 2, 3, 0)) === "24";
|
|
114
|
+
return $fb18d541ea1ad717$var$_hasBuggyHour12Behavior;
|
|
115
|
+
}
|
|
116
|
+
let $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = null;
|
|
117
|
+
function $fb18d541ea1ad717$var$hasBuggyResolvedHourCycle() {
|
|
118
|
+
if ($fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle == null) $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle = new Intl.DateTimeFormat("fr", {
|
|
119
|
+
hour: "numeric",
|
|
120
|
+
hour12: false
|
|
121
|
+
}).resolvedOptions().hourCycle === "h12";
|
|
122
|
+
return $fb18d541ea1ad717$var$_hasBuggyResolvedHourCycle;
|
|
123
|
+
}
|
|
124
|
+
function $fb18d541ea1ad717$var$getResolvedHourCycle(locale, options) {
|
|
125
|
+
if (!options.timeStyle && !options.hour) return void 0;
|
|
126
|
+
locale = locale.replace(/(-u-)?-nu-[a-zA-Z0-9]+/, "");
|
|
127
|
+
locale += (locale.includes("-u-") ? "" : "-u") + "-nu-latn";
|
|
128
|
+
let formatter = $fb18d541ea1ad717$var$getCachedDateFormatter(locale, {
|
|
129
|
+
...options,
|
|
130
|
+
timeZone: void 0
|
|
131
|
+
});
|
|
132
|
+
let min = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 0)).find((p) => p.type === "hour").value, 10);
|
|
133
|
+
let max = parseInt(formatter.formatToParts(new Date(2020, 2, 3, 23)).find((p) => p.type === "hour").value, 10);
|
|
134
|
+
if (min === 0 && max === 23) return "h23";
|
|
135
|
+
if (min === 24 && max === 23) return "h24";
|
|
136
|
+
if (min === 0 && max === 11) return "h11";
|
|
137
|
+
if (min === 12 && max === 11) return "h12";
|
|
138
|
+
throw new Error("Unexpected hour cycle result");
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/providers/locale/use-date-formatter.ts
|
|
142
|
+
function useDateFormatter(props = {}) {
|
|
143
|
+
const env = useLocaleContext();
|
|
144
|
+
const locale = props.locale ?? env.locale;
|
|
145
|
+
return (0, react.useMemo)(() => {
|
|
146
|
+
const { locale: _, ...options } = props;
|
|
147
|
+
return new $fb18d541ea1ad717$export$ad991b66133851cf(locale, options);
|
|
148
|
+
}, [locale, props]);
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/providers/locale/use-filter.ts
|
|
152
|
+
function useFilter(props) {
|
|
153
|
+
const env = useLocaleContext();
|
|
154
|
+
const locale = props.locale ?? env.locale;
|
|
155
|
+
return (0, react.useMemo)(() => (0, _sprawlify_primitives_i18n_utils.createFilter)({
|
|
156
|
+
...props,
|
|
157
|
+
locale
|
|
158
|
+
}), [locale, props]);
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
Object.defineProperty(exports, "LocaleProvider", {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
get: function() {
|
|
164
|
+
return LocaleProvider;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
Object.defineProperty(exports, "useCollator", {
|
|
168
|
+
enumerable: true,
|
|
169
|
+
get: function() {
|
|
170
|
+
return useCollator;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
Object.defineProperty(exports, "useDateFormatter", {
|
|
174
|
+
enumerable: true,
|
|
175
|
+
get: function() {
|
|
176
|
+
return useDateFormatter;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
Object.defineProperty(exports, "useFilter", {
|
|
180
|
+
enumerable: true,
|
|
181
|
+
get: function() {
|
|
182
|
+
return useFilter;
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
Object.defineProperty(exports, "useLocaleContext", {
|
|
186
|
+
enumerable: true,
|
|
187
|
+
get: function() {
|
|
188
|
+
return useLocaleContext;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-DIRhrrdE.cjs");
|
|
2
|
-
const require_core = require("./core-
|
|
2
|
+
const require_core = require("./core-D3VWpaVw.cjs");
|
|
3
3
|
const require_create_context = require("./create-context-DVfXoZgh.cjs");
|
|
4
4
|
const require_compose_refs = require("./compose-refs-CUN-PodG.cjs");
|
|
5
5
|
const require_factory = require("./factory-DNpyR-JO.cjs");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as useMachine, r as normalizeProps } from "./core-
|
|
1
|
+
import { i as useMachine, r as normalizeProps } from "./core-Ds_Jbvzw.mjs";
|
|
2
2
|
import { t as createContext$1 } from "./create-context-vbKnbgU_.mjs";
|
|
3
3
|
import { t as composeRefs } from "./compose-refs-C1ZNInvv.mjs";
|
|
4
4
|
import { n as sprawlify } from "./factory-B2jnWWga.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _sprawlify_primitives_anatomy0 from "@sprawlify/primitives/anatomy";
|
|
2
2
|
|
|
3
3
|
//#region src/components/segment-group/segment-group-anatomy.d.ts
|
|
4
|
-
declare const segmentGroupAnatomy: _sprawlify_primitives_anatomy0.Anatomy<"label" | "
|
|
4
|
+
declare const segmentGroupAnatomy: _sprawlify_primitives_anatomy0.Anatomy<"label" | "root" | "indicator" | "item" | "itemText" | "itemControl">;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { segmentGroupAnatomy as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _sprawlify_primitives_anatomy0 from "@sprawlify/primitives/anatomy";
|
|
2
2
|
|
|
3
3
|
//#region src/components/segment-group/segment-group-anatomy.d.ts
|
|
4
|
-
declare const segmentGroupAnatomy: _sprawlify_primitives_anatomy0.Anatomy<"label" | "
|
|
4
|
+
declare const segmentGroupAnatomy: _sprawlify_primitives_anatomy0.Anatomy<"label" | "root" | "indicator" | "item" | "itemText" | "itemControl">;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { segmentGroupAnatomy as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _sprawlify_primitives_anatomy0 from "@sprawlify/primitives/anatomy";
|
|
2
2
|
|
|
3
3
|
//#region src/components/tour/tour-anatomy.d.ts
|
|
4
|
-
declare const tourAnatomy: _sprawlify_primitives_anatomy0.AnatomyInstance<"title" | "content" | "
|
|
4
|
+
declare const tourAnatomy: _sprawlify_primitives_anatomy0.AnatomyInstance<"title" | "content" | "arrow" | "control" | "positioner" | "backdrop" | "description" | "closeTrigger" | "progressText" | "arrowTip" | "actionTrigger" | "spotlight">;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { tourAnatomy as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _sprawlify_primitives_anatomy0 from "@sprawlify/primitives/anatomy";
|
|
2
2
|
|
|
3
3
|
//#region src/components/tour/tour-anatomy.d.ts
|
|
4
|
-
declare const tourAnatomy: _sprawlify_primitives_anatomy0.AnatomyInstance<"title" | "content" | "
|
|
4
|
+
declare const tourAnatomy: _sprawlify_primitives_anatomy0.AnatomyInstance<"title" | "content" | "arrow" | "control" | "positioner" | "backdrop" | "description" | "closeTrigger" | "progressText" | "arrowTip" | "actionTrigger" | "spotlight">;
|
|
5
5
|
//#endregion
|
|
6
6
|
export { tourAnatomy as t };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-DIRhrrdE.cjs");
|
|
2
|
-
const require_core = require("./core-
|
|
2
|
+
const require_core = require("./core-D3VWpaVw.cjs");
|
|
3
3
|
const require_create_context = require("./create-context-DVfXoZgh.cjs");
|
|
4
4
|
const require_environment = require("./environment-DkPPGx5U.cjs");
|
|
5
|
-
const require_locale = require("./locale-
|
|
5
|
+
const require_locale = require("./locale-Dc2Fyoa-.cjs");
|
|
6
6
|
const require_factory = require("./factory-DNpyR-JO.cjs");
|
|
7
|
-
const require_collapsible = require("./collapsible-
|
|
7
|
+
const require_collapsible = require("./collapsible-BCma5-fq.cjs");
|
|
8
8
|
const require_create_split_props = require("./create-split-props-CUjqut2D.cjs");
|
|
9
9
|
const require_render_strategy = require("./render-strategy-C63iNoUN.cjs");
|
|
10
10
|
let react = require("react");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-D1SwGrFN.mjs";
|
|
2
|
-
import { i as useMachine, r as normalizeProps, t as mergeProps } from "./core-
|
|
2
|
+
import { i as useMachine, r as normalizeProps, t as mergeProps } from "./core-Ds_Jbvzw.mjs";
|
|
3
3
|
import { t as createContext$1 } from "./create-context-vbKnbgU_.mjs";
|
|
4
4
|
import { n as useEnvironmentContext } from "./environment-B_ip8ub2.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { a as useLocaleContext } from "./locale-BOA439G-.mjs";
|
|
6
6
|
import { n as sprawlify } from "./factory-B2jnWWga.mjs";
|
|
7
|
-
import { c as CollapsibleContent, i as CollapsibleRoot } from "./collapsible-
|
|
7
|
+
import { c as CollapsibleContent, i as CollapsibleRoot } from "./collapsible-DcnLTV0k.mjs";
|
|
8
8
|
import { t as createSplitProps } from "./create-split-props-B38DMyhW.mjs";
|
|
9
9
|
import { n as splitRenderStrategyProps, r as useRenderStrategyPropsContext, t as RenderStrategyPropsProvider } from "./render-strategy-BWa8NoRy.mjs";
|
|
10
10
|
import { forwardRef, useId } from "react";
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sprawlify/react",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.0.107",
|
|
5
4
|
"description": "React wrapper for primitives.",
|
|
5
|
+
"license": "MIT",
|
|
6
6
|
"author": "sprawlify <npm@sprawlify.com>",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
7
11
|
"main": "./dist/index.cjs",
|
|
8
12
|
"module": "./dist/index.mjs",
|
|
9
13
|
"types": "./dist/index.d.mts",
|
|
@@ -649,14 +653,11 @@
|
|
|
649
653
|
}
|
|
650
654
|
}
|
|
651
655
|
},
|
|
652
|
-
"files": [
|
|
653
|
-
"dist"
|
|
654
|
-
],
|
|
655
656
|
"publishConfig": {
|
|
656
657
|
"access": "public"
|
|
657
658
|
},
|
|
658
659
|
"dependencies": {
|
|
659
|
-
"@sprawlify/primitives": "0.0.
|
|
660
|
+
"@sprawlify/primitives": "0.0.107"
|
|
660
661
|
},
|
|
661
662
|
"peerDependencies": {
|
|
662
663
|
"react": ">=19.0.0",
|
|
@@ -665,10 +666,10 @@
|
|
|
665
666
|
"engines": {
|
|
666
667
|
"node": ">=24"
|
|
667
668
|
},
|
|
668
|
-
"license": "MIT",
|
|
669
669
|
"scripts": {
|
|
670
670
|
"build": "tsdown",
|
|
671
671
|
"typecheck": "tsc --noEmit",
|
|
672
|
-
"lint": "
|
|
672
|
+
"lint": "oxlint --fix",
|
|
673
|
+
"format": "oxfmt"
|
|
673
674
|
}
|
|
674
675
|
}
|
package/dist/locale-DenY029U.cjs
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
require("./chunk-DIRhrrdE.cjs");
|
|
2
|
-
const require_create_context = require("./create-context-DVfXoZgh.cjs");
|
|
3
|
-
let react = require("react");
|
|
4
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
5
|
-
let _sprawlify_primitives_i18n_utils = require("@sprawlify/primitives/i18n-utils");
|
|
6
|
-
//#region src/providers/locale/use-locale-context.ts
|
|
7
|
-
const [LocaleContextProvider, useLocaleContext] = require_create_context.createContext({
|
|
8
|
-
name: "LocaleContext",
|
|
9
|
-
hookName: "useLocaleContext",
|
|
10
|
-
providerName: "<LocaleProvider />",
|
|
11
|
-
strict: false,
|
|
12
|
-
defaultValue: {
|
|
13
|
-
dir: "ltr",
|
|
14
|
-
locale: "en-US"
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
//#endregion
|
|
18
|
-
//#region src/providers/locale/locale-provider.tsx
|
|
19
|
-
const LocaleProvider = (props) => {
|
|
20
|
-
const { children, locale } = props;
|
|
21
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LocaleContextProvider, {
|
|
22
|
-
value: {
|
|
23
|
-
locale,
|
|
24
|
-
dir: (0, _sprawlify_primitives_i18n_utils.isRTL)(locale) ? "rtl" : "ltr"
|
|
25
|
-
},
|
|
26
|
-
children
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/providers/locale/use-collator.ts
|
|
31
|
-
function useCollator(props = {}) {
|
|
32
|
-
const env = useLocaleContext();
|
|
33
|
-
const locale = props.locale ?? env.locale;
|
|
34
|
-
return (0, react.useMemo)(() => {
|
|
35
|
-
const { locale: _, ...options } = props;
|
|
36
|
-
return (0, _sprawlify_primitives_i18n_utils.createCollator)(locale, options);
|
|
37
|
-
}, [locale, props]);
|
|
38
|
-
}
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/providers/locale/use-filter.ts
|
|
41
|
-
function useFilter(props) {
|
|
42
|
-
const env = useLocaleContext();
|
|
43
|
-
const locale = props.locale ?? env.locale;
|
|
44
|
-
return (0, react.useMemo)(() => (0, _sprawlify_primitives_i18n_utils.createFilter)({
|
|
45
|
-
...props,
|
|
46
|
-
locale
|
|
47
|
-
}), [locale, props]);
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
Object.defineProperty(exports, "LocaleProvider", {
|
|
51
|
-
enumerable: true,
|
|
52
|
-
get: function() {
|
|
53
|
-
return LocaleProvider;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
Object.defineProperty(exports, "useCollator", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
get: function() {
|
|
59
|
-
return useCollator;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(exports, "useFilter", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: function() {
|
|
65
|
-
return useFilter;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(exports, "useLocaleContext", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
get: function() {
|
|
71
|
-
return useLocaleContext;
|
|
72
|
-
}
|
|
73
|
-
});
|
package/dist/locale-yswfGSTu.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { t as createContext$1 } from "./create-context-vbKnbgU_.mjs";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { createCollator, createFilter, isRTL } from "@sprawlify/primitives/i18n-utils";
|
|
5
|
-
//#region src/providers/locale/use-locale-context.ts
|
|
6
|
-
const [LocaleContextProvider, useLocaleContext] = createContext$1({
|
|
7
|
-
name: "LocaleContext",
|
|
8
|
-
hookName: "useLocaleContext",
|
|
9
|
-
providerName: "<LocaleProvider />",
|
|
10
|
-
strict: false,
|
|
11
|
-
defaultValue: {
|
|
12
|
-
dir: "ltr",
|
|
13
|
-
locale: "en-US"
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region src/providers/locale/locale-provider.tsx
|
|
18
|
-
const LocaleProvider = (props) => {
|
|
19
|
-
const { children, locale } = props;
|
|
20
|
-
return /* @__PURE__ */ jsx(LocaleContextProvider, {
|
|
21
|
-
value: {
|
|
22
|
-
locale,
|
|
23
|
-
dir: isRTL(locale) ? "rtl" : "ltr"
|
|
24
|
-
},
|
|
25
|
-
children
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/providers/locale/use-collator.ts
|
|
30
|
-
function useCollator(props = {}) {
|
|
31
|
-
const env = useLocaleContext();
|
|
32
|
-
const locale = props.locale ?? env.locale;
|
|
33
|
-
return useMemo(() => {
|
|
34
|
-
const { locale: _, ...options } = props;
|
|
35
|
-
return createCollator(locale, options);
|
|
36
|
-
}, [locale, props]);
|
|
37
|
-
}
|
|
38
|
-
//#endregion
|
|
39
|
-
//#region src/providers/locale/use-filter.ts
|
|
40
|
-
function useFilter(props) {
|
|
41
|
-
const env = useLocaleContext();
|
|
42
|
-
const locale = props.locale ?? env.locale;
|
|
43
|
-
return useMemo(() => createFilter({
|
|
44
|
-
...props,
|
|
45
|
-
locale
|
|
46
|
-
}), [locale, props]);
|
|
47
|
-
}
|
|
48
|
-
//#endregion
|
|
49
|
-
export { useLocaleContext as i, useCollator as n, LocaleProvider as r, useFilter as t };
|