bruh 1.13.0 → 2.0.0-beta.1
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/browser/jsx-runtime.mjs +2 -0
- package/dist/browser/jsx-runtime.mjs.map +1 -0
- package/dist/browser.mjs +174 -0
- package/dist/browser.mjs.map +1 -0
- package/dist/cli/node.mjs +16 -0
- package/dist/cli/node.mjs.map +1 -0
- package/dist/components/aside-toc.mjs +162 -0
- package/dist/components/aside-toc.mjs.map +1 -0
- package/dist/components/custom-elements.mjs +52 -0
- package/dist/components/custom-elements.mjs.map +1 -0
- package/dist/components/intl/date-time.mjs +219 -0
- package/dist/components/intl/date-time.mjs.map +1 -0
- package/dist/components/intl/display-name.mjs +71 -0
- package/dist/components/intl/display-name.mjs.map +1 -0
- package/dist/components/intl/language-picker.mjs +102 -0
- package/dist/components/intl/language-picker.mjs.map +1 -0
- package/dist/components/intl/list.mjs +80 -0
- package/dist/components/intl/list.mjs.map +1 -0
- package/dist/components/intl/number.mjs +118 -0
- package/dist/components/intl/number.mjs.map +1 -0
- package/dist/components/intl/plural.mjs +82 -0
- package/dist/components/intl/plural.mjs.map +1 -0
- package/dist/components/intl/utils.mjs +197 -0
- package/dist/components/intl/utils.mjs.map +1 -0
- package/dist/components/optimized-picture/hydrate.mjs +10 -0
- package/dist/components/optimized-picture/hydrate.mjs.map +1 -0
- package/dist/components/optimized-picture/server.mjs +28 -0
- package/dist/components/optimized-picture/server.mjs.map +1 -0
- package/dist/components/utils.mjs +4 -0
- package/dist/components/utils.mjs.map +1 -0
- package/dist/media/images/node.mjs +41 -0
- package/dist/media/images/node.mjs.map +1 -0
- package/dist/polyfills/weakref.mjs +16 -0
- package/dist/polyfills/weakref.mjs.map +1 -0
- package/dist/reactive/sync/transport/websocket/browser.mjs +52 -0
- package/dist/reactive/sync/transport/websocket/browser.mjs.map +1 -0
- package/dist/reactive.mjs +160 -0
- package/dist/reactive.mjs.map +1 -0
- package/dist/server/jsx-runtime.mjs +2 -0
- package/dist/server/jsx-runtime.mjs.map +1 -0
- package/dist/server.mjs +346 -0
- package/dist/server.mjs.map +1 -0
- package/dist/types/cli/index.d.mts +2 -0
- package/dist/types/components/aside-toc/index.d.ts +45 -0
- package/dist/types/components/custom-elements.d.mts +83 -0
- package/dist/types/components/intl/date-time.d.ts +138 -0
- package/dist/types/components/intl/display-name.d.ts +45 -0
- package/dist/types/components/intl/language-picker.d.ts +35 -0
- package/dist/types/components/intl/list.d.ts +41 -0
- package/dist/types/components/intl/number.d.ts +81 -0
- package/dist/types/components/intl/plural.d.ts +60 -0
- package/dist/types/components/intl/utils.d.mts +30 -0
- package/dist/types/components/optimized-picture/hydrate.d.mts +2 -0
- package/dist/types/components/optimized-picture/server.d.ts +8 -0
- package/dist/types/components/utils.d.mts +5 -0
- package/dist/types/dom/browser/jsx-runtime.d.mts +3 -0
- package/dist/types/dom/index.browser.d.mts +127 -0
- package/dist/types/dom/index.server.d.mts +174 -0
- package/dist/types/dom/server/jsx-runtime.d.mts +3 -0
- package/dist/types/dom/types.d.mts +9 -0
- package/dist/types/media/images.node.d.mts +1 -0
- package/dist/types/polyfills/weakref.d.mts +4 -0
- package/dist/types/reactive/index.d.mts +91 -0
- package/dist/types/reactive/sync/transport/websocket/browser.d.mts +11 -0
- package/dist/types/utils/browser.d.mts +2 -0
- package/dist/types/utils/index.d.mts +122 -0
- package/dist/utils/browser.mjs +27 -0
- package/dist/utils/browser.mjs.map +1 -0
- package/dist/utils.mjs +287 -0
- package/dist/utils.mjs.map +1 -0
- package/package.json +125 -18
- package/mod.mjs +0 -3
- package/src/cli/index.mjs +0 -19
- package/src/components/optimized-picture/hydrate.mjs +0 -10
- package/src/components/optimized-picture/render.mjs +0 -26
- package/src/dom/index.browser.mjs +0 -270
- package/src/dom/index.server.mjs +0 -280
- package/src/index.browser.mjs +0 -3
- package/src/media/images.node.mjs +0 -70
- package/src/reactive/index.mjs +0 -160
- package/src/util/index.mjs +0 -42
- package/vite.config.mjs +0 -12
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { jsx, bruhChildrenToNodes } from '../../browser.mjs';
|
|
2
|
+
import { r } from '../../reactive.mjs';
|
|
3
|
+
import { mapObject, attempt } from '../../utils.mjs';
|
|
4
|
+
import { spaceSeparated } from '../utils.mjs';
|
|
5
|
+
import { BruhCustomElementBase } from '../custom-elements.mjs';
|
|
6
|
+
import { parseLocales, userLanguages, inferDirection } from './utils.mjs';
|
|
7
|
+
|
|
8
|
+
const getTimeZoneOffset = (timeZone) => {
|
|
9
|
+
if (timeZone === void 0)
|
|
10
|
+
return (/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
11
|
+
const longOffset = new Intl.DateTimeFormat("en", {
|
|
12
|
+
timeZone,
|
|
13
|
+
timeZoneName: "longOffset"
|
|
14
|
+
}).formatToParts(/* @__PURE__ */ new Date()).find((part) => part.type === "timeZoneName")?.value;
|
|
15
|
+
if (!longOffset)
|
|
16
|
+
return;
|
|
17
|
+
if (longOffset === "GMT" || longOffset === "UTC")
|
|
18
|
+
return 0;
|
|
19
|
+
const [hoursUnparsed, minutesUnparsed] = longOffset.replace(/^(GMT|UTC)/, "").split(":");
|
|
20
|
+
const hoursParsed = parseInt(hoursUnparsed);
|
|
21
|
+
const minutesParsed = minutesUnparsed !== void 0 ? Math.sign(hoursParsed) * parseInt(minutesUnparsed) : 0;
|
|
22
|
+
const inMinutes = -1 * (hoursParsed * 60 + minutesParsed);
|
|
23
|
+
if (isFinite(inMinutes))
|
|
24
|
+
return inMinutes;
|
|
25
|
+
};
|
|
26
|
+
const currentTimeZone = () => new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
27
|
+
const localDateInUTC = (date, timeZone) => {
|
|
28
|
+
const offset = getTimeZoneOffset(timeZone);
|
|
29
|
+
if (offset === void 0)
|
|
30
|
+
return void 0;
|
|
31
|
+
return new Date(date - offset * 60 * 1e3);
|
|
32
|
+
};
|
|
33
|
+
const hideRedundantOptions = (originalFormatter, {
|
|
34
|
+
date,
|
|
35
|
+
endDate,
|
|
36
|
+
now = /* @__PURE__ */ new Date()
|
|
37
|
+
}) => {
|
|
38
|
+
const resolvedOptions = originalFormatter.resolvedOptions();
|
|
39
|
+
const minimizedOptions = { ...resolvedOptions };
|
|
40
|
+
if (resolvedOptions.timeZone === currentTimeZone() || getTimeZoneOffset(resolvedOptions.timeZone) === getTimeZoneOffset())
|
|
41
|
+
delete minimizedOptions.timeZoneName;
|
|
42
|
+
if (resolvedOptions.calendar === "gregory") {
|
|
43
|
+
const timeZonedDate = localDateInUTC(date, resolvedOptions.timeZone);
|
|
44
|
+
if (timeZonedDate !== void 0) {
|
|
45
|
+
const dateYear = timeZonedDate.getUTCFullYear();
|
|
46
|
+
const dateMonth = timeZonedDate.getUTCMonth();
|
|
47
|
+
const dateDate = timeZonedDate.getUTCDate();
|
|
48
|
+
const timeZonedEndDate = endDate !== void 0 ? localDateInUTC(endDate, resolvedOptions.timeZone) : void 0;
|
|
49
|
+
const missingEndDate = timeZonedEndDate === void 0;
|
|
50
|
+
if (missingEndDate === (endDate === void 0)) {
|
|
51
|
+
const endDateYear = timeZonedEndDate?.getUTCFullYear();
|
|
52
|
+
const endDateMonth = timeZonedEndDate?.getUTCMonth();
|
|
53
|
+
const endDateDate = timeZonedEndDate?.getUTCDate();
|
|
54
|
+
const currentYear = now.getFullYear();
|
|
55
|
+
const currentMonth = now.getMonth();
|
|
56
|
+
const currentDate = now.getDate();
|
|
57
|
+
const dateSameEra = dateYear < 1 === currentYear < 1;
|
|
58
|
+
const endDateSameEra = missingEndDate || endDateYear < 1 === currentYear < 1;
|
|
59
|
+
if (dateSameEra && endDateSameEra) {
|
|
60
|
+
delete minimizedOptions.era;
|
|
61
|
+
const dateSameYear = dateYear === currentYear;
|
|
62
|
+
const endDateSameYear = missingEndDate || endDateYear === currentYear;
|
|
63
|
+
if (dateSameYear && endDateSameYear) {
|
|
64
|
+
delete minimizedOptions.year;
|
|
65
|
+
const dateSameMonthAndDate = dateMonth === currentMonth && dateDate === currentDate;
|
|
66
|
+
const endDateSameMonthAndDate = missingEndDate || endDateMonth === currentMonth && endDateDate === currentDate;
|
|
67
|
+
if (dateSameMonthAndDate && endDateSameMonthAndDate) {
|
|
68
|
+
delete minimizedOptions.month;
|
|
69
|
+
delete minimizedOptions.day;
|
|
70
|
+
delete minimizedOptions.weekday;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return new Intl.DateTimeFormat(resolvedOptions.locale, minimizedOptions);
|
|
78
|
+
};
|
|
79
|
+
const parseDate = (unparsed) => {
|
|
80
|
+
if (unparsed == void 0)
|
|
81
|
+
return;
|
|
82
|
+
if (unparsed === "")
|
|
83
|
+
return { type: "now" };
|
|
84
|
+
const date = new Date(unparsed);
|
|
85
|
+
if (isFinite(date))
|
|
86
|
+
return { type: "date", date };
|
|
87
|
+
const numberThenDate = new Date(Number(unparsed));
|
|
88
|
+
if (isFinite(numberThenDate))
|
|
89
|
+
return { type: "date", date: numberThenDate };
|
|
90
|
+
return { type: "unparsed", unparsed };
|
|
91
|
+
};
|
|
92
|
+
const optionToAttribute = {
|
|
93
|
+
// locale options
|
|
94
|
+
"localeMatcher": "locale-matcher",
|
|
95
|
+
"calendar": "calendar",
|
|
96
|
+
"numberingSystem": "numbering-system",
|
|
97
|
+
"hour12": "hour12",
|
|
98
|
+
"hourCycle": "hour-cycle",
|
|
99
|
+
"timeZone": "time-zone",
|
|
100
|
+
// style options
|
|
101
|
+
"weekday": "weekday",
|
|
102
|
+
"era": "era",
|
|
103
|
+
"year": "year",
|
|
104
|
+
"month": "month",
|
|
105
|
+
"day": "day",
|
|
106
|
+
"dayPeriod": "day-period",
|
|
107
|
+
"hour": "hour",
|
|
108
|
+
"minute": "minute",
|
|
109
|
+
"second": "second",
|
|
110
|
+
"fractionalSecondDigits": "fractional-second-digits",
|
|
111
|
+
"timeZoneName": "time-zone-name",
|
|
112
|
+
"formatMatcher": "format-matcher",
|
|
113
|
+
// style shortcuts
|
|
114
|
+
"dateStyle": "date-style",
|
|
115
|
+
"timeStyle": "time-style"
|
|
116
|
+
};
|
|
117
|
+
class BruhDateTime extends BruhCustomElementBase {
|
|
118
|
+
static observedAttributes = [
|
|
119
|
+
"date",
|
|
120
|
+
"end-date",
|
|
121
|
+
"locales",
|
|
122
|
+
"hide-redundant-options",
|
|
123
|
+
...Object.values(optionToAttribute)
|
|
124
|
+
];
|
|
125
|
+
static bruh = {
|
|
126
|
+
parseAttributes: {
|
|
127
|
+
date: parseDate,
|
|
128
|
+
"end-date": parseDate,
|
|
129
|
+
locales: spaceSeparated,
|
|
130
|
+
"hide-redundant-options": (v) => v != void 0
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
#locales;
|
|
134
|
+
#options;
|
|
135
|
+
#formatter;
|
|
136
|
+
#formatted;
|
|
137
|
+
constructor() {
|
|
138
|
+
super();
|
|
139
|
+
this.#locales = r(
|
|
140
|
+
[this.bruh.attributes.locales, userLanguages],
|
|
141
|
+
() => parseLocales([
|
|
142
|
+
...this.bruh.attributes.locales.value ?? [],
|
|
143
|
+
...userLanguages.value
|
|
144
|
+
])
|
|
145
|
+
);
|
|
146
|
+
const optionToReactiveAttribute = mapObject(
|
|
147
|
+
optionToAttribute,
|
|
148
|
+
([option, attribute]) => [option, this.bruh.attributes[attribute]]
|
|
149
|
+
);
|
|
150
|
+
this.#options = r(
|
|
151
|
+
Object.values(optionToReactiveAttribute),
|
|
152
|
+
() => mapObject(optionToReactiveAttribute, ([option, attribute]) => [option, attribute.value || void 0])
|
|
153
|
+
);
|
|
154
|
+
this.#formatter = r(
|
|
155
|
+
[this.#locales, this.#options],
|
|
156
|
+
() => attempt(() => new Intl.DateTimeFormat(this.#locales.value, this.#options.value)) ?? new Intl.DateTimeFormat(this.#locales.value)
|
|
157
|
+
);
|
|
158
|
+
const dateToFormat = this.bruh.attributes.date;
|
|
159
|
+
const rangeEndDateToFormat = this.bruh.attributes["end-date"];
|
|
160
|
+
const renderParts = (parts) => parts.map(
|
|
161
|
+
(part) => /* @__PURE__ */ jsx("span", { class: `bruh-date-time-part bruh-date-time-part--${part.type}`, children: part.value })
|
|
162
|
+
);
|
|
163
|
+
const renderSingle = (date, attributes) => {
|
|
164
|
+
if (date.type === "unparsed")
|
|
165
|
+
return /* @__PURE__ */ jsx("time", { ...attributes, datetime: date.unparsed, children: date.unparsed });
|
|
166
|
+
const value = date.type === "now" ? /* @__PURE__ */ new Date() : date.date;
|
|
167
|
+
const formatter = this.bruh.attributes["hide-redundant-options"].value ? hideRedundantOptions(this.#formatter.value, { date: value }) : this.#formatter.value;
|
|
168
|
+
const rendered = renderParts(formatter.formatToParts(value));
|
|
169
|
+
return /* @__PURE__ */ jsx("time", { ...attributes, datetime: value.toISOString(), children: rendered });
|
|
170
|
+
};
|
|
171
|
+
const renderRange = (start, end) => {
|
|
172
|
+
const canRenderRangeDirectly = "formatRangeToParts" in this.#formatter.value && start.type !== "unparsed" && end.type !== "unparsed";
|
|
173
|
+
if (!canRenderRangeDirectly)
|
|
174
|
+
return [
|
|
175
|
+
renderSingle(start, { class: "bruh-date-time-source bruh-date-time-source--startRange" }),
|
|
176
|
+
/* @__PURE__ */ jsx("span", { class: "bruh-date-time-source bruh-date-time-source--shared", children: /* @__PURE__ */ jsx("span", { class: "bruh-date-time-part bruh-date-time-part--literal", children: " – " }) }),
|
|
177
|
+
renderSingle(end, { class: "bruh-date-time-source bruh-date-time-source--endRange" })
|
|
178
|
+
];
|
|
179
|
+
const startValue = start.type === "now" ? /* @__PURE__ */ new Date() : start.date;
|
|
180
|
+
const endValue = end.type === "now" ? /* @__PURE__ */ new Date() : end.date;
|
|
181
|
+
const formatter = this.bruh.attributes["hide-redundant-options"].value ? hideRedundantOptions(this.#formatter.value, { date: startValue, endDate: endValue }) : this.#formatter.value;
|
|
182
|
+
const parts = formatter.formatRangeToParts(startValue, endValue);
|
|
183
|
+
const bySource = parts.reduce((bySource2, part, i) => {
|
|
184
|
+
if (!i || parts[i - 1].source !== part.source)
|
|
185
|
+
bySource2.push([]);
|
|
186
|
+
bySource2[bySource2.length - 1].push(part);
|
|
187
|
+
return bySource2;
|
|
188
|
+
}, []);
|
|
189
|
+
return bySource.map((parts2) => {
|
|
190
|
+
const source = parts2[0].source;
|
|
191
|
+
const className = `bruh-date-time-source bruh-date-time-source--${source}`;
|
|
192
|
+
const rendered = renderParts(parts2);
|
|
193
|
+
if (source === "startRange" || source === "endRange" || source === "shared" && bySource.length === 1) {
|
|
194
|
+
const dateTime = source === "startRange" ? startValue : endValue;
|
|
195
|
+
return /* @__PURE__ */ jsx("time", { class: className, datetime: dateTime.toISOString(), children: rendered });
|
|
196
|
+
} else {
|
|
197
|
+
return /* @__PURE__ */ jsx("span", { class: className, children: rendered });
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
};
|
|
201
|
+
this.#formatted = r([this.#formatter, dateToFormat, rangeEndDateToFormat], () => {
|
|
202
|
+
if (!dateToFormat.value)
|
|
203
|
+
return;
|
|
204
|
+
const formatter = this.#formatter.value;
|
|
205
|
+
const { locale } = formatter.resolvedOptions();
|
|
206
|
+
const direction = inferDirection(locale);
|
|
207
|
+
const result = rangeEndDateToFormat.value ? renderRange(dateToFormat.value, rangeEndDateToFormat.value) : renderSingle(dateToFormat.value);
|
|
208
|
+
return /* @__PURE__ */ jsx("bdi", { lang: locale, dir: direction, children: result });
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
mountedCallback() {
|
|
212
|
+
const children = bruhChildrenToNodes([this.#formatted]);
|
|
213
|
+
this.replaceChildren(...children);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
customElements.define("bruh-date-time", BruhDateTime);
|
|
217
|
+
|
|
218
|
+
export { BruhDateTime, currentTimeZone, getTimeZoneOffset, hideRedundantOptions, localDateInUTC, parseDate };
|
|
219
|
+
//# sourceMappingURL=date-time.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-time.mjs","sources":["../../../src/components/intl/date-time.tsx"],"sourcesContent":["/** @jsxImportSource bruh/browser */\nimport { bruhChildrenToNodes, type BruhProps } from \"bruh/browser\"\nimport { r } from \"../../reactive/index.mts\"\nimport { attempt, mapObject } from \"../../utils/index.mts\"\nimport { spaceSeparated } from \"../utils.mts\"\nimport { BruhCustomElementBase } from \"../custom-elements.mts\"\nimport { inferDirection, parseLocales, userLanguages } from \"./utils.mts\"\n\n// todo: reactive updating times / responding to current time using found setTimeout or requestAnimationFrame\n\n/**\n * In minutes from UTC/GMT, same as `new Date().getTimezoneOffset()`, but for any time zone\n *\n * `undefined` if unknown\n */\nexport const getTimeZoneOffset = (timeZone?: string) => {\n if (timeZone === undefined)\n return new Date().getTimezoneOffset()\n\n const longOffset = new Intl.DateTimeFormat(\"en\", {\n timeZone,\n timeZoneName: \"longOffset\"\n })\n .formatToParts(new Date())\n .find(part => part.type === \"timeZoneName\")?.value\n\n if (!longOffset)\n return\n\n if (longOffset === \"GMT\" || longOffset === \"UTC\")\n return 0\n\n const [hoursUnparsed, minutesUnparsed] = longOffset.replace(/^(GMT|UTC)/, \"\").split(\":\")\n const hoursParsed = parseInt(hoursUnparsed)\n const minutesParsed =\n minutesUnparsed !== undefined\n ? Math.sign(hoursParsed) * parseInt(minutesUnparsed)\n : 0\n\n const inMinutes = -1 * (hoursParsed * 60 + minutesParsed)\n if (isFinite(inMinutes))\n return inMinutes\n}\n\nexport const currentTimeZone = () =>\n new Intl.DateTimeFormat().resolvedOptions().timeZone\n\n/**\n * Makes a date that has a UTC time set to the input date's local time in the given time zone\n */\nexport const localDateInUTC = (date: Date | number, timeZone: string) => {\n const offset = getTimeZoneOffset(timeZone)\n if (offset === undefined)\n return undefined\n\n return new Date((date as number) - offset * 60 * 1_000)\n}\n\nexport const hideRedundantOptions = (\n originalFormatter: Intl.DateTimeFormat,\n {\n date,\n endDate,\n now = new Date()\n }: {\n date: Date,\n endDate?: Date,\n now?: Date\n }\n) => {\n const resolvedOptions = originalFormatter.resolvedOptions() as Intl.ResolvedDateTimeFormatOptions & Intl.DateTimeFormatOptions\n const minimizedOptions = { ...resolvedOptions }\n\n if (resolvedOptions.timeZone === currentTimeZone() || getTimeZoneOffset(resolvedOptions.timeZone) === getTimeZoneOffset())\n delete minimizedOptions.timeZoneName\n\n // https://tc39.es/ecma402/#table-datetimeformat-tolocaltime-record\n if (resolvedOptions.calendar === \"gregory\") {\n const timeZonedDate = localDateInUTC(date, resolvedOptions.timeZone)\n if (timeZonedDate !== undefined) {\n const dateYear = timeZonedDate.getUTCFullYear()\n const dateMonth = timeZonedDate.getUTCMonth()\n const dateDate = timeZonedDate.getUTCDate()\n\n const timeZonedEndDate =\n endDate !== undefined\n ? localDateInUTC(endDate, resolvedOptions.timeZone)\n : undefined\n const missingEndDate = timeZonedEndDate === undefined\n if (missingEndDate === (endDate === undefined)) {\n const endDateYear = timeZonedEndDate?.getUTCFullYear()\n const endDateMonth = timeZonedEndDate?.getUTCMonth()\n const endDateDate = timeZonedEndDate?.getUTCDate()\n\n const currentYear = now.getFullYear()\n const currentMonth = now.getMonth()\n const currentDate = now.getDate()\n\n const dateSameEra = dateYear < 1 === currentYear < 1\n const endDateSameEra = missingEndDate || (endDateYear! < 1 === currentYear < 1)\n if (dateSameEra && endDateSameEra) {\n delete minimizedOptions.era\n\n const dateSameYear = dateYear === currentYear\n const endDateSameYear = missingEndDate || (endDateYear! === currentYear)\n if (dateSameYear && endDateSameYear) {\n delete minimizedOptions.year\n\n const dateSameMonthAndDate = dateMonth === currentMonth && dateDate === currentDate\n const endDateSameMonthAndDate = missingEndDate || (endDateMonth! === currentMonth && endDateDate! === currentDate)\n if (dateSameMonthAndDate && endDateSameMonthAndDate) {\n delete minimizedOptions.month\n delete minimizedOptions.day\n delete minimizedOptions.weekday\n }\n }\n }\n }\n }\n }\n\n return new Intl.DateTimeFormat(resolvedOptions.locale, minimizedOptions)\n}\n\nexport const parseDate = (unparsed?: string | null) => {\n if (unparsed == undefined)\n return\n\n if (unparsed === \"\")\n return { type: \"now\" } as const\n\n const date = new Date(unparsed)\n if (isFinite(date as any as number))\n return { type: \"date\", date } as const\n\n const numberThenDate = new Date(Number(unparsed))\n if (isFinite(numberThenDate as any as number))\n return { type: \"date\", date: numberThenDate } as const\n\n return { type: \"unparsed\", unparsed } as const\n}\n\nexport type ParsedDate = ReturnType<typeof parseDate>\n\nconst optionToAttribute = {\n // locale options\n \"localeMatcher\": \"locale-matcher\",\n \"calendar\": \"calendar\",\n \"numberingSystem\": \"numbering-system\",\n \"hour12\": \"hour12\",\n \"hourCycle\": \"hour-cycle\",\n \"timeZone\": \"time-zone\",\n // style options\n \"weekday\": \"weekday\",\n \"era\": \"era\",\n \"year\": \"year\",\n \"month\": \"month\",\n \"day\": \"day\",\n \"dayPeriod\": \"day-period\",\n \"hour\": \"hour\",\n \"minute\": \"minute\",\n \"second\": \"second\",\n \"fractionalSecondDigits\": \"fractional-second-digits\",\n \"timeZoneName\": \"time-zone-name\",\n \"formatMatcher\": \"format-matcher\",\n // style shortcuts\n \"dateStyle\": \"date-style\",\n \"timeStyle\": \"time-style\"\n} as const\n\ntype BruhDateTimeAttributes = {\n \"date\"?: ParsedDate,\n \"end-date\"?: ParsedDate,\n \"locales\"?: ReadonlyArray<Intl.UnicodeBCP47LocaleIdentifier>,\n \"hide-redundant-options\"?: boolean,\n \"locale-matcher\"?: Intl.DateTimeFormatOptions[\"localeMatcher\"],\n \"calendar\"?: Intl.DateTimeFormatOptions[\"calendar\"],\n \"numbering-system\"?: Intl.DateTimeFormatOptions[\"numberingSystem\"],\n \"hour12\"?: Intl.DateTimeFormatOptions[\"hour12\"],\n \"hour-cycle\"?: Intl.DateTimeFormatOptions[\"hourCycle\"],\n \"time-zone\"?: Intl.DateTimeFormatOptions[\"timeZone\"],\n \"weekday\"?: Intl.DateTimeFormatOptions[\"weekday\"],\n \"era\"?: Intl.DateTimeFormatOptions[\"era\"],\n \"year\"?: Intl.DateTimeFormatOptions[\"year\"],\n \"month\"?: Intl.DateTimeFormatOptions[\"month\"],\n \"day\"?: Intl.DateTimeFormatOptions[\"day\"],\n \"day-period\"?: Intl.DateTimeFormatOptions[\"dayPeriod\"],\n \"hour\"?: Intl.DateTimeFormatOptions[\"hour\"],\n \"minute\"?: Intl.DateTimeFormatOptions[\"minute\"],\n \"second\"?: Intl.DateTimeFormatOptions[\"second\"],\n \"fractional-second-digits\"?: Intl.DateTimeFormatOptions[\"fractionalSecondDigits\"],\n \"time-zone-name\"?: Intl.DateTimeFormatOptions[\"timeZoneName\"],\n \"format-matcher\"?: Intl.DateTimeFormatOptions[\"formatMatcher\"],\n \"date-style\"?: Intl.DateTimeFormatOptions[\"dateStyle\"],\n \"time-style\"?: Intl.DateTimeFormatOptions[\"timeStyle\"]\n}\n\nexport class BruhDateTime extends BruhCustomElementBase<BruhDateTimeAttributes> {\n static observedAttributes = [\n \"date\",\n \"end-date\",\n \"locales\",\n \"hide-redundant-options\",\n ...Object.values(optionToAttribute)\n ]\n\n static bruh = {\n parseAttributes: {\n date: parseDate,\n \"end-date\": parseDate,\n locales: spaceSeparated,\n \"hide-redundant-options\": (v?: string | null) => v != undefined\n }\n }\n\n #locales\n #options\n #formatter\n #formatted\n\n constructor() {\n super()\n\n this.#locales = r([this.bruh.attributes.locales, userLanguages], () =>\n parseLocales([\n ...this.bruh.attributes.locales.value ?? [],\n ...userLanguages.value\n ])\n )\n\n const optionToReactiveAttribute = mapObject(optionToAttribute,\n ([option, attribute]) => [option, this.bruh.attributes[attribute]]\n )\n this.#options = r(Object.values(optionToReactiveAttribute), () =>\n mapObject(optionToReactiveAttribute, ([option, attribute]) => [option, attribute.value || undefined]) as Partial<Intl.DateTimeFormatOptions>\n )\n\n this.#formatter = r([this.#locales, this.#options], () =>\n attempt(() => new Intl.DateTimeFormat(this.#locales.value, this.#options.value))\n ?? new Intl.DateTimeFormat(this.#locales.value)\n )\n\n const dateToFormat = this.bruh.attributes.date\n const rangeEndDateToFormat = this.bruh.attributes[\"end-date\"]\n\n const renderParts = (parts: ReadonlyArray<Intl.DateTimeFormatPart>) =>\n parts.map(part =>\n <span class={`bruh-date-time-part bruh-date-time-part--${part.type}`}>{part.value}</span> as HTMLSpanElement\n )\n\n const renderSingle = (\n date: NonNullable<ParsedDate>,\n attributes?: BruhProps<\"time\">\n ) => {\n if (date.type === \"unparsed\")\n return <time {...attributes} datetime={date.unparsed}>{date.unparsed}</time> as HTMLTimeElement\n\n const value =\n date.type === \"now\"\n ? new Date()\n : date.date\n\n const formatter =\n this.bruh.attributes[\"hide-redundant-options\"].value\n ? hideRedundantOptions(this.#formatter.value, { date: value })\n : this.#formatter.value\n\n const rendered = renderParts(formatter.formatToParts(value))\n return <time {...attributes} datetime={value.toISOString()}>{rendered}</time> as HTMLTimeElement\n }\n\n const renderRange = (start: NonNullable<ParsedDate>, end: NonNullable<ParsedDate>) => {\n const canRenderRangeDirectly =\n \"formatRangeToParts\" in this.#formatter.value\n && start.type !== \"unparsed\"\n && end.type !== \"unparsed\"\n if (!canRenderRangeDirectly)\n return [\n renderSingle(start, { class: \"bruh-date-time-source bruh-date-time-source--startRange\" }),\n <span class=\"bruh-date-time-source bruh-date-time-source--shared\">\n <span class=\"bruh-date-time-part bruh-date-time-part--literal\"> – </span>\n </span> as HTMLSpanElement,\n renderSingle(end, { class: \"bruh-date-time-source bruh-date-time-source--endRange\" })\n ]\n\n const startValue =\n start.type === \"now\"\n ? new Date()\n : start.date\n const endValue =\n end.type === \"now\"\n ? new Date()\n : end.date\n\n const formatter =\n this.bruh.attributes[\"hide-redundant-options\"].value\n ? hideRedundantOptions(this.#formatter.value, { date: startValue, endDate: endValue })\n : this.#formatter.value\n\n const parts = formatter.formatRangeToParts(startValue, endValue)\n const bySource = parts.reduce<Intl.DateTimeRangeFormatPart[][]>((bySource, part, i) => {\n if (!i || parts[i - 1].source !== part.source)\n bySource.push([])\n bySource[bySource.length - 1].push(part)\n return bySource\n }, [])\n return bySource.map(parts => {\n const source = parts[0].source\n const className = `bruh-date-time-source bruh-date-time-source--${source}`\n const rendered = renderParts(parts)\n if (source === \"startRange\" || source === \"endRange\" || (source === \"shared\" && bySource.length === 1)) {\n const dateTime =\n source === \"startRange\"\n ? startValue\n : endValue\n return <time class={className} datetime={dateTime.toISOString()}>{rendered}</time> as HTMLTimeElement\n }\n else {\n return <span class={className}>{rendered}</span> as HTMLSpanElement\n }\n })\n }\n\n this.#formatted = r([this.#formatter, dateToFormat, rangeEndDateToFormat], () => {\n if (!dateToFormat.value)\n return\n\n const formatter = this.#formatter.value\n const { locale } = formatter.resolvedOptions()\n const direction = inferDirection(locale)\n\n const result =\n rangeEndDateToFormat.value\n ? renderRange(dateToFormat.value, rangeEndDateToFormat.value)\n : renderSingle(dateToFormat.value)\n\n return <bdi lang={locale} dir={direction}>{result}</bdi> as HTMLElement\n })\n }\n\n mountedCallback() {\n const children = bruhChildrenToNodes([this.#formatted])\n this.replaceChildren(...children)\n }\n}\n\ncustomElements.define(\"bruh-date-time\", BruhDateTime)\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bruh-date-time\": BruhDateTime\n }\n}\ndeclare module \"html-info\" {\n interface HTMLTagToAttributes {\n \"bruh-date-time\": {\n \"date\"?: string\n \"end-date\"?: string\n /**\n * Space separated list of locales\n */\n \"locales\"?: string,\n \"hide-redundant-options\"?: boolean,\n \"locale-matcher\"?: Intl.DateTimeFormatOptions[\"localeMatcher\"],\n \"calendar\"?: Intl.DateTimeFormatOptions[\"calendar\"],\n \"numbering-system\"?: Intl.DateTimeFormatOptions[\"numberingSystem\"],\n \"hour12\"?: Intl.DateTimeFormatOptions[\"hour12\"],\n \"hour-cycle\"?: Intl.DateTimeFormatOptions[\"hourCycle\"],\n \"time-zone\"?: Intl.DateTimeFormatOptions[\"timeZone\"],\n \"weekday\"?: Intl.DateTimeFormatOptions[\"weekday\"],\n \"era\"?: Intl.DateTimeFormatOptions[\"era\"],\n \"year\"?: Intl.DateTimeFormatOptions[\"year\"],\n \"month\"?: Intl.DateTimeFormatOptions[\"month\"],\n \"day\"?: Intl.DateTimeFormatOptions[\"day\"],\n \"day-period\"?: Intl.DateTimeFormatOptions[\"dayPeriod\"],\n \"hour\"?: Intl.DateTimeFormatOptions[\"hour\"],\n \"minute\"?: Intl.DateTimeFormatOptions[\"minute\"],\n \"second\"?: Intl.DateTimeFormatOptions[\"second\"],\n \"fractional-second-digits\"?: Intl.DateTimeFormatOptions[\"fractionalSecondDigits\"] | `${Intl.DateTimeFormatOptions[\"fractionalSecondDigits\"]}`,\n \"time-zone-name\"?: Intl.DateTimeFormatOptions[\"timeZoneName\"],\n \"format-matcher\"?: Intl.DateTimeFormatOptions[\"formatMatcher\"],\n \"date-style\"?: Intl.DateTimeFormatOptions[\"dateStyle\"],\n \"time-style\"?: Intl.DateTimeFormatOptions[\"timeStyle\"]\n }\n }\n}\n"],"names":["bySource","parts"],"mappings":";;;;;;;AAea,MAAA,iBAAA,GAAoB,CAAC,QAAsB,KAAA;AACtD,EAAA,IAAI,QAAa,KAAA,MAAA;AACf,IAAO,OAAA,iBAAA,IAAI,IAAK,EAAA,EAAE,iBAAkB,EAAA;AAEtC,EAAA,MAAM,UAAa,GAAA,IAAI,IAAK,CAAA,cAAA,CAAe,IAAM,EAAA;AAAA,IAC/C,QAAA;AAAA,IACA,YAAc,EAAA;AAAA,GACf,CAAA,CACE,aAAc,iBAAA,IAAI,IAAK,EAAC,CACxB,CAAA,IAAA,CAAK,CAAQ,IAAA,KAAA,IAAA,CAAK,IAAS,KAAA,cAAc,CAAG,EAAA,KAAA;AAE/C,EAAA,IAAI,CAAC,UAAA;AACH,IAAA;AAEF,EAAI,IAAA,UAAA,KAAe,SAAS,UAAe,KAAA,KAAA;AACzC,IAAO,OAAA,CAAA;AAET,EAAM,MAAA,CAAC,aAAe,EAAA,eAAe,CAAI,GAAA,UAAA,CAAW,QAAQ,YAAc,EAAA,EAAE,CAAE,CAAA,KAAA,CAAM,GAAG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EAAA,QAAA,EAAA,CAAA;AAAA;AAC3C,OACD,CAAA;AAAA,KACH;AAEA,IAAK,IAAA,CAAA,UAAA,GAAa,EAAE,CAAC,IAAA,CAAK,YAAY,YAAc,EAAA,oBAAoB,GAAG,MAAM;AAC/E,MAAA,IAAI,CAAC,YAAa,CAAA,KAAA;AAChB,QAAA;AAEF,MAAM,MAAA,SAAA,GAAY,KAAK,UAAW,CAAA,KAAA;AAClC,MAAA,MAAM,EAAE,MAAA,EAAW,GAAA,SAAA,CAAU,eAAgB,EAAA;AAC7C,MAAM,MAAA,SAAA,GAAY,eAAe,MAAM,CAAA;AAEvC,MAAM,MAAA,MAAA,GACJ,oBAAqB,CAAA,KAAA,GACjB,WAAY,CAAA,YAAA,CAAa,KAAO,EAAA,oBAAA,CAAqB,KAAK,CAAA,GAC1D,YAAa,CAAA,YAAA,CAAa,KAAK,CAAA;AAErC,MAAA,2BAAQ,KAAI,EAAA,EAAA,IAAA,EAAM,MAAQ,EAAA,GAAA,EAAK,WAAY,QAAO,EAAA,MAAA,EAAA,CAAA;AAAA,KACnD,CAAA;AAAA;AACH,EAEA,eAAkB,GAAA;AAChB,IAAA,MAAM,QAAW,GAAA,mBAAA,CAAoB,CAAC,IAAA,CAAK,UAAU,CAAC,CAAA;AACtD,IAAK,IAAA,CAAA,eAAA,CAAgB,GAAG,QAAQ,CAAA;AAAA;AAEpC;AAEA,cAAe,CAAA,MAAA,CAAO,kBAAkB,YAAY,CAAA;;;;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx, bruhChildrenToNodes } from '../../browser.mjs';
|
|
2
|
+
import { r } from '../../reactive.mjs';
|
|
3
|
+
import { mapObject, attempt } from '../../utils.mjs';
|
|
4
|
+
import { spaceSeparated } from '../utils.mjs';
|
|
5
|
+
import { BruhCustomElementBase } from '../custom-elements.mjs';
|
|
6
|
+
import { parseLocales, userLanguages, inferDirection, languageDisplayName } from './utils.mjs';
|
|
7
|
+
|
|
8
|
+
const optionToAttribute = {
|
|
9
|
+
localeMatcher: "locale-matcher",
|
|
10
|
+
style: "format-style",
|
|
11
|
+
type: "type",
|
|
12
|
+
languageDisplay: "language-display"
|
|
13
|
+
};
|
|
14
|
+
class BruhDisplayName extends BruhCustomElementBase {
|
|
15
|
+
static observedAttributes = [
|
|
16
|
+
"code",
|
|
17
|
+
"locales",
|
|
18
|
+
...Object.values(optionToAttribute)
|
|
19
|
+
];
|
|
20
|
+
static bruh = {
|
|
21
|
+
parseAttributes: {
|
|
22
|
+
locales: spaceSeparated
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
#locales;
|
|
26
|
+
#options;
|
|
27
|
+
#formatter;
|
|
28
|
+
#formatted;
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
this.#locales = r(
|
|
32
|
+
[this.bruh.attributes.locales, userLanguages],
|
|
33
|
+
() => parseLocales([
|
|
34
|
+
...this.bruh.attributes.locales.value ?? [],
|
|
35
|
+
...userLanguages.value
|
|
36
|
+
])
|
|
37
|
+
);
|
|
38
|
+
const optionToReactiveAttribute = mapObject(
|
|
39
|
+
optionToAttribute,
|
|
40
|
+
([option, attribute]) => [option, this.bruh.attributes[attribute]]
|
|
41
|
+
);
|
|
42
|
+
this.#options = r(
|
|
43
|
+
Object.values(optionToReactiveAttribute),
|
|
44
|
+
() => mapObject(optionToReactiveAttribute, ([option, attribute]) => [option, attribute.value || void 0])
|
|
45
|
+
);
|
|
46
|
+
this.#formatter = r(
|
|
47
|
+
[this.#locales, this.#options],
|
|
48
|
+
() => attempt(
|
|
49
|
+
() => new Intl.DisplayNames(this.#locales.value, this.#options.value)
|
|
50
|
+
)
|
|
51
|
+
);
|
|
52
|
+
this.#formatted = r([this.#formatter, this.bruh.attributes.code], () => {
|
|
53
|
+
const formatter = this.#formatter.value;
|
|
54
|
+
const code = this.bruh.attributes.code.value;
|
|
55
|
+
if (!formatter || !code)
|
|
56
|
+
return;
|
|
57
|
+
const { locale, type } = formatter.resolvedOptions();
|
|
58
|
+
const direction = inferDirection(locale);
|
|
59
|
+
const value = type === "language" ? languageDisplayName(formatter, code) : attempt(() => formatter.of(code)) ?? code;
|
|
60
|
+
return /* @__PURE__ */ jsx("bdi", { lang: locale, dir: direction, children: value });
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
mountedCallback() {
|
|
64
|
+
const children = bruhChildrenToNodes([this.#formatted]);
|
|
65
|
+
this.replaceChildren(...children);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
customElements.define("bruh-display-name", BruhDisplayName);
|
|
69
|
+
|
|
70
|
+
export { BruhDisplayName };
|
|
71
|
+
//# sourceMappingURL=display-name.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display-name.mjs","sources":["../../../src/components/intl/display-name.tsx"],"sourcesContent":["/** @jsxImportSource bruh/browser */\nimport { bruhChildrenToNodes } from \"bruh/browser\"\nimport { r } from \"../../reactive/index.mts\"\nimport { attempt, mapObject } from \"../../utils/index.mts\"\nimport { spaceSeparated } from \"../utils.mts\"\nimport { BruhCustomElementBase } from \"../custom-elements.mts\"\nimport { inferDirection, languageDisplayName, parseLocales, userLanguages } from \"./utils.mts\"\n\nconst optionToAttribute = {\n localeMatcher: \"locale-matcher\",\n style: \"format-style\",\n type: \"type\",\n languageDisplay: \"language-display\"\n} as const\n\ntype BruhDisplayNameAttributes = {\n \"code\"?: string,\n \"locales\"?: ReadonlyArray<Intl.UnicodeBCP47LocaleIdentifier>,\n \"locale-matcher\"?: Intl.DisplayNamesOptions[\"localeMatcher\"],\n \"format-style\"?: Intl.DisplayNamesOptions[\"style\"],\n \"type\"?: Intl.DisplayNamesOptions[\"type\"],\n \"language-display\"?: Intl.DisplayNamesOptions[\"languageDisplay\"]\n}\n\nexport class BruhDisplayName extends BruhCustomElementBase<BruhDisplayNameAttributes> {\n static observedAttributes = [\n \"code\",\n \"locales\",\n ...Object.values(optionToAttribute)\n ] as const\n\n static bruh = {\n parseAttributes: {\n locales: spaceSeparated\n }\n }\n\n #locales\n #options\n #formatter\n #formatted\n\n constructor() {\n super()\n\n this.#locales = r([this.bruh.attributes.locales, userLanguages], () =>\n parseLocales([\n ...this.bruh.attributes.locales.value ?? [],\n ...userLanguages.value\n ])\n )\n\n const optionToReactiveAttribute = mapObject(optionToAttribute,\n ([option, attribute]) => [option, this.bruh.attributes[attribute]]\n )\n this.#options = r(Object.values(optionToReactiveAttribute), () =>\n mapObject(optionToReactiveAttribute, ([option, attribute]) => [option, attribute.value || undefined]) as Partial<Intl.DisplayNamesOptions>\n )\n\n this.#formatter = r([this.#locales, this.#options], () =>\n attempt(() =>\n new Intl.DisplayNames(this.#locales.value, this.#options.value as any)\n )\n )\n\n this.#formatted = r([this.#formatter, this.bruh.attributes.code], () => {\n const formatter = this.#formatter.value\n const code = this.bruh.attributes.code.value\n if (!formatter || !code)\n return\n\n const { locale, type } = formatter.resolvedOptions()\n const direction = inferDirection(locale)\n\n const value =\n type === \"language\"\n ? languageDisplayName(formatter, code)\n : attempt(() => formatter.of(code)) ?? code\n\n return <bdi lang={locale} dir={direction}>{value}</bdi> as HTMLElement\n })\n }\n\n mountedCallback() {\n const children = bruhChildrenToNodes([this.#formatted])\n this.replaceChildren(...children)\n }\n}\n\ncustomElements.define(\"bruh-display-name\", BruhDisplayName)\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bruh-display-name\": BruhDisplayName\n }\n}\ndeclare module \"html-info\" {\n interface HTMLTagToAttributes {\n \"bruh-display-name\": {\n \"code\": string,\n /**\n * Space separated list of locales\n */\n \"locales\"?: string,\n \"locale-matcher\"?: Intl.DisplayNamesOptions[\"localeMatcher\"],\n \"format-style\"?: Intl.DisplayNamesOptions[\"style\"],\n \"type\": Intl.DisplayNamesOptions[\"type\"],\n \"language-display\"?: Intl.DisplayNamesOptions[\"languageDisplay\"]\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;AAQA,MAAM,iBAAoB,GAAA;AAAA,EACxB,aAAe,EA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
|
|
|
1
|
+
import { jsx, Fragment } from '../../browser.mjs';
|
|
2
|
+
import { r } from '../../reactive.mjs';
|
|
3
|
+
import { spaceSeparated } from '../utils.mjs';
|
|
4
|
+
import { BruhCustomElementBase } from '../custom-elements.mjs';
|
|
5
|
+
import { userLanguages, parseLocales, languagePickerLanguages, inferDirection, bestAvailableLocales, languageDisplayName } from './utils.mjs';
|
|
6
|
+
|
|
7
|
+
const userLanguageDisplayNames = r(
|
|
8
|
+
[userLanguages],
|
|
9
|
+
() => new Intl.DisplayNames(userLanguages.value, { type: "language" })
|
|
10
|
+
);
|
|
11
|
+
const SelectLanguage = ({
|
|
12
|
+
languages,
|
|
13
|
+
name = "language"
|
|
14
|
+
}) => {
|
|
15
|
+
const options = r([languages, userLanguages, userLanguageDisplayNames], () => {
|
|
16
|
+
const currentLanguage = userLanguageDisplayNames.value.resolvedOptions().locale;
|
|
17
|
+
const currentDirection = inferDirection(currentLanguage);
|
|
18
|
+
const { matches, alsoAvailable } = bestAvailableLocales(languages.value, userLanguages.value);
|
|
19
|
+
const makeOption = (language) => {
|
|
20
|
+
const nativeNameSupported = Intl.DisplayNames.supportedLocalesOf(language).length > 0;
|
|
21
|
+
return {
|
|
22
|
+
native: {
|
|
23
|
+
name: nativeNameSupported ? languageDisplayName(new Intl.DisplayNames(language, { type: "language" }), language) : void 0,
|
|
24
|
+
language: language + "",
|
|
25
|
+
direction: inferDirection(language)
|
|
26
|
+
},
|
|
27
|
+
current: {
|
|
28
|
+
name: languageDisplayName(userLanguageDisplayNames.value, language),
|
|
29
|
+
language: currentLanguage,
|
|
30
|
+
direction: currentDirection
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
const { compare } = new Intl.Collator(userLanguages.value, { usage: "sort" });
|
|
35
|
+
return {
|
|
36
|
+
matches: matches.map(makeOption),
|
|
37
|
+
alsoAvailable: alsoAvailable.map(makeOption).sort((a, b) => {
|
|
38
|
+
const aName = a.native.name ?? a.current.name;
|
|
39
|
+
const bName = b.native.name ?? b.current.name;
|
|
40
|
+
return compare(aName, bName);
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
const selectOptions = r([options], () => {
|
|
45
|
+
const makeOptionElement = ({ native, current }) => {
|
|
46
|
+
const currentElement = /* @__PURE__ */ jsx("bdi", { lang: current.language, dir: current.direction, children: current.name });
|
|
47
|
+
let friendly;
|
|
48
|
+
if (native.name === void 0 || native.name === current.name)
|
|
49
|
+
friendly = currentElement;
|
|
50
|
+
else {
|
|
51
|
+
const nativeElement = /* @__PURE__ */ jsx("bdi", { lang: native.language, dir: native.direction, children: native.name });
|
|
52
|
+
friendly = /* @__PURE__ */ jsx(Fragment, { children: [
|
|
53
|
+
nativeElement,
|
|
54
|
+
" — ",
|
|
55
|
+
currentElement
|
|
56
|
+
] });
|
|
57
|
+
}
|
|
58
|
+
const isSelected = r([userLanguages], () => native.language === userLanguages.value[0] + "" || void 0);
|
|
59
|
+
const directionOverride = native.name && native.direction !== current.direction ? native.direction : void 0;
|
|
60
|
+
const option = /* @__PURE__ */ jsx("option", { value: native.language, selected: isSelected, dir: directionOverride, children: friendly });
|
|
61
|
+
return option;
|
|
62
|
+
};
|
|
63
|
+
const matches = options.value.matches.map(makeOptionElement);
|
|
64
|
+
const alsoAvailable = options.value.alsoAvailable.map(makeOptionElement);
|
|
65
|
+
if (matches.length && alsoAvailable.length)
|
|
66
|
+
return [...matches, /* @__PURE__ */ jsx("hr", {}), ...alsoAvailable];
|
|
67
|
+
else
|
|
68
|
+
return [...matches, ...alsoAvailable];
|
|
69
|
+
});
|
|
70
|
+
const select = /* @__PURE__ */ jsx("select", { name, children: selectOptions });
|
|
71
|
+
return select;
|
|
72
|
+
};
|
|
73
|
+
class BruhLanguagePicker extends BruhCustomElementBase {
|
|
74
|
+
static observedAttributes = ["languages"];
|
|
75
|
+
static bruh = {
|
|
76
|
+
parseAttributes: {
|
|
77
|
+
languages: spaceSeparated
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
#languages = r([this.bruh.attributes.languages], () => parseLocales(this.bruh.attributes.languages.value));
|
|
81
|
+
#select;
|
|
82
|
+
constructor() {
|
|
83
|
+
super();
|
|
84
|
+
this.#select = /* @__PURE__ */ jsx(SelectLanguage, { languages: this.#languages });
|
|
85
|
+
this.#select.addEventListener("change", () => {
|
|
86
|
+
languagePickerLanguages.value = parseLocales([this.#select.value]);
|
|
87
|
+
localStorage.setItem(
|
|
88
|
+
"bruh-language-picker-languages",
|
|
89
|
+
JSON.stringify(
|
|
90
|
+
languagePickerLanguages.value.map((language) => language + "")
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
mountedCallback() {
|
|
96
|
+
this.replaceChildren(this.#select);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
customElements.define("bruh-language-picker", BruhLanguagePicker);
|
|
100
|
+
|
|
101
|
+
export { BruhLanguagePicker };
|
|
102
|
+
//# sourceMappingURL=language-picker.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-picker.mjs","sources":["../../../src/components/intl/language-picker.tsx"],"sourcesContent":["/** @jsxImportSource bruh/browser */\nimport type { BruhChild } from \"bruh/browser\"\nimport { r, type FunctionalReactive } from \"../../reactive/index.mts\"\nimport { spaceSeparated } from \"../utils.mts\"\nimport { BruhCustomElementBase } from \"../custom-elements.mts\"\nimport { inferDirection, languageDisplayName, bestAvailableLocales, parseLocales, userLanguages, languagePickerLanguages, type InputLocale } from \"./utils.mts\"\n\nconst userLanguageDisplayNames = r([userLanguages], () =>\n new Intl.DisplayNames(userLanguages.value, { type: \"language\" })\n)\n\ntype Option = {\n native: {\n name: string | undefined,\n language: string,\n direction: \"ltr\" | \"rtl\" | undefined\n },\n current: {\n name: string,\n language: string,\n direction: \"ltr\" | \"rtl\" | undefined\n }\n}\n\nconst SelectLanguage = (\n {\n languages,\n name = \"language\"\n }: {\n languages: FunctionalReactive<ReadonlyArray<InputLocale>>,\n name?: string\n }\n) => {\n const options = r([languages, userLanguages, userLanguageDisplayNames], () => {\n const currentLanguage = userLanguageDisplayNames.value.resolvedOptions().locale\n const currentDirection = inferDirection(currentLanguage)\n\n const { matches, alsoAvailable } = bestAvailableLocales(languages.value, userLanguages.value)\n\n const makeOption = (language: Intl.Locale): Option => {\n const nativeNameSupported = Intl.DisplayNames.supportedLocalesOf(language).length > 0\n return {\n native: {\n name:\n nativeNameSupported\n ? languageDisplayName(new Intl.DisplayNames(language, { type: \"language\" }), language)\n : undefined,\n language: language + \"\",\n direction: inferDirection(language)\n },\n current: {\n name: languageDisplayName(userLanguageDisplayNames.value, language),\n language: currentLanguage,\n direction: currentDirection\n }\n }\n }\n\n const { compare } = new Intl.Collator(userLanguages.value, { usage: \"sort\" })\n\n return {\n matches: matches.map(makeOption),\n alsoAvailable: alsoAvailable.map(makeOption)\n .sort((a, b) => {\n const aName = a.native.name ?? a.current.name\n const bName = b.native.name ?? b.current.name\n return compare(aName, bName)\n })\n }\n })\n\n const selectOptions = r([options], () => {\n const makeOptionElement = ({ native, current }: Option) => {\n const currentElement = <bdi lang={current.language} dir={current.direction}>{current.name}</bdi> as HTMLElement\n\n let friendly: BruhChild\n if (native.name === undefined || native.name === current.name)\n friendly = currentElement\n else {\n const nativeElement = <bdi lang={native.language} dir={native.direction}>{native.name}</bdi> as HTMLElement\n friendly = <>{nativeElement} — {currentElement}</>\n }\n\n const isSelected = r([userLanguages], () => native.language === userLanguages.value[0] + \"\" || undefined)\n\n const directionOverride =\n native.name && native.direction !== current.direction\n ? native.direction\n : undefined\n\n const option =\n <option value={native.language} selected={isSelected} dir={directionOverride}>\n {friendly}\n </option> as HTMLOptionElement\n\n return option\n }\n\n const matches = options.value.matches.map(makeOptionElement)\n const alsoAvailable = options.value.alsoAvailable.map(makeOptionElement)\n\n if (matches.length && alsoAvailable.length)\n return [...matches, <hr /> as HTMLHRElement, ...alsoAvailable]\n else\n return [...matches, ...alsoAvailable]\n })\n\n const select =\n <select name={name}>\n {selectOptions}\n </select>\n\n return select\n}\n\ntype BruhLanguagePickerAttributes = {\n \"languages\": ReadonlyArray<Intl.Locale>\n}\n\nexport class BruhLanguagePicker extends BruhCustomElementBase<BruhLanguagePickerAttributes> {\n static observedAttributes = [\"languages\"]\n\n static bruh = {\n parseAttributes: {\n languages: spaceSeparated\n }\n }\n\n #languages = r([this.bruh.attributes.languages], () => parseLocales(this.bruh.attributes.languages.value))\n\n #select\n\n constructor() {\n super()\n\n this.#select = <SelectLanguage languages={this.#languages} />\n this.#select.addEventListener(\"change\", () => {\n languagePickerLanguages.value = parseLocales([this.#select.value])\n localStorage.setItem(\n \"bruh-language-picker-languages\",\n JSON.stringify(\n languagePickerLanguages.value\n .map(language => language + \"\")\n )\n )\n })\n }\n\n mountedCallback() {\n this.replaceChildren(this.#select)\n }\n}\n\ncustomElements.define(\"bruh-language-picker\", BruhLanguagePicker)\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bruh-language-picker\": BruhLanguagePicker\n }\n}\ndeclare module \"html-info\" {\n interface HTMLTagToAttributes {\n \"bruh-language-picker\": {\n /**\n * Space separated list of locales\n */\n \"languages\": string\n }\n }\n}\n"],"names":["jsxs"],"mappings":";;;;;;AAOA,MAAM,wBAA2B,GAAA,CAAA;AAAA,EAAE,CAAC,aAAa,CAAA;AAAA,EAAG,MAClD,IAAI,IAAK,CAAA,YAAA,CAAa,cAAc,KAAO,EAAA,EAAE,IAAM,EAAA,UAAA,EAAY;AACjE,CAAA;AAeA,MAAM,iBAAiB,CACrB;AAAA,EACE,SAAA;AAAA,EACA,IAAO,GAAA;AACT,CAIG,KAAA;AACH,EAAA,MAAM,UAAU,CAAE,CAAA,CAAC,WAAW,aAAe,EAAA,wBAAwB,GAAG,MAAM;AAC5E,IAAA,MAAM,eAAkB,GAAA,wBAAA,CAAyB,KAAM,CAAA,eAAA,EAAkB,CAAA,MAAA;AACzE,IAAM,MAAA,gBAAA,GAAm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,QAAA,EAAU,MAAM;AAC5C,MAAA,uBAAA,CAAwB,QAAQ,YAAa,CAAA,CAAC,IAAK,CAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AACjE,MAAa,YAAA,CAAA,OAAA;AAAA,QACX,gCAAA;AAAA,QACA,IAAK,CAAA,SAAA;AAAA,UACH,uBAAwB,CAAA,KAAA,CACrB,GAAI,CAAA,CAAA,QAAA,KAAY,WAAW,EAAE;AAAA;AAClC,OACF;AAAA,KACD,CAAA;AAAA;AACH,EAEA,eAAkB,GAAA;AAChB,IAAK,IAAA,CAAA,eAAA,CAAgB,KAAK,OAAO,CAAA;AAAA;AAErC;AAEA,cAAe,CAAA,MAAA,CAAO,wBAAwB,kBAAkB,CAAA;;;;"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { jsx, bruhChildrenToNodes } from '../../browser.mjs';
|
|
2
|
+
import { r } from '../../reactive.mjs';
|
|
3
|
+
import { mapObject, attempt } from '../../utils.mjs';
|
|
4
|
+
import { spaceSeparated } from '../utils.mjs';
|
|
5
|
+
import { BruhCustomElementBase } from '../custom-elements.mjs';
|
|
6
|
+
import { parseLocales, userLanguages, inferDirection } from './utils.mjs';
|
|
7
|
+
|
|
8
|
+
const optionToAttribute = {
|
|
9
|
+
"locale-matcher": "locale-matcher",
|
|
10
|
+
"type": "type",
|
|
11
|
+
"style": "format-style"
|
|
12
|
+
};
|
|
13
|
+
class BruhList extends BruhCustomElementBase {
|
|
14
|
+
static observedAttributes = [
|
|
15
|
+
"locales",
|
|
16
|
+
...Object.values(optionToAttribute)
|
|
17
|
+
];
|
|
18
|
+
static bruh = {
|
|
19
|
+
parseAttributes: {
|
|
20
|
+
locales: spaceSeparated
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
#locales;
|
|
24
|
+
#options;
|
|
25
|
+
#formatter;
|
|
26
|
+
#itemSlotNames = r();
|
|
27
|
+
#formatted;
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
this.#locales = r(
|
|
31
|
+
[this.bruh.attributes.locales, userLanguages],
|
|
32
|
+
() => parseLocales([
|
|
33
|
+
...this.bruh.attributes.locales.value ?? [],
|
|
34
|
+
...userLanguages.value
|
|
35
|
+
])
|
|
36
|
+
);
|
|
37
|
+
const optionToReactiveAttribute = mapObject(
|
|
38
|
+
optionToAttribute,
|
|
39
|
+
([option, attribute]) => [option, this.bruh.attributes[attribute]]
|
|
40
|
+
);
|
|
41
|
+
this.#options = r(
|
|
42
|
+
Object.values(optionToReactiveAttribute),
|
|
43
|
+
() => mapObject(optionToReactiveAttribute, ([option, attribute]) => [option, attribute.value || void 0])
|
|
44
|
+
);
|
|
45
|
+
this.#formatter = r(
|
|
46
|
+
[this.#locales, this.#options],
|
|
47
|
+
() => attempt(() => new Intl.ListFormat(this.#locales.value, this.#options.value)) ?? new Intl.ListFormat(this.#locales.value)
|
|
48
|
+
);
|
|
49
|
+
const renderParts = (parts) => parts.map((part) => {
|
|
50
|
+
const partAttribute = `part ${part.type}`;
|
|
51
|
+
return part.type === "element" ? /* @__PURE__ */ jsx("bdi", { part: partAttribute, role: "listitem", children: /* @__PURE__ */ jsx("slot", { name: part.value }) }) : /* @__PURE__ */ jsx("span", { part: partAttribute, children: part.value });
|
|
52
|
+
});
|
|
53
|
+
this.#formatted = r([this.#formatter, this.#itemSlotNames], () => {
|
|
54
|
+
if (!this.#itemSlotNames.value)
|
|
55
|
+
return;
|
|
56
|
+
const formatter = this.#formatter.value;
|
|
57
|
+
const { locale } = formatter.resolvedOptions();
|
|
58
|
+
const direction = inferDirection(locale);
|
|
59
|
+
const result = renderParts(formatter.formatToParts(this.#itemSlotNames.value));
|
|
60
|
+
return /* @__PURE__ */ jsx("bdi", { lang: locale, dir: direction, role: "list", children: result });
|
|
61
|
+
});
|
|
62
|
+
const shadowContent = bruhChildrenToNodes([this.#formatted]);
|
|
63
|
+
this.attachShadow({ mode: "open" }).append(...shadowContent);
|
|
64
|
+
}
|
|
65
|
+
mountedCallback() {
|
|
66
|
+
const assignSlots = () => {
|
|
67
|
+
this.#itemSlotNames.value = [...this.children].map((child, i) => {
|
|
68
|
+
const slot = "" + (i + 1);
|
|
69
|
+
child.slot = slot;
|
|
70
|
+
return slot;
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
assignSlots();
|
|
74
|
+
new MutationObserver(assignSlots).observe(this, { childList: true });
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
customElements.define("bruh-list", BruhList);
|
|
78
|
+
|
|
79
|
+
export { BruhList };
|
|
80
|
+
//# sourceMappingURL=list.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.mjs","sources":["../../../src/components/intl/list.tsx"],"sourcesContent":["/** @jsxImportSource bruh/browser */\nimport { bruhChildrenToNodes } from \"bruh/browser\"\nimport { r } from \"../../reactive/index.mts\"\nimport { attempt, mapObject } from \"../../utils/index.mts\"\nimport { spaceSeparated } from \"../utils.mts\"\nimport { BruhCustomElementBase } from \"../custom-elements.mts\"\nimport { inferDirection, parseLocales, userLanguages } from \"./utils.mts\"\n\nconst optionToAttribute = {\n \"locale-matcher\": \"locale-matcher\",\n \"type\": \"type\",\n \"style\": \"format-style\"\n} as const\n\ntype BruhListAttributes = {\n \"locales\"?: ReadonlyArray<Intl.UnicodeBCP47LocaleIdentifier>,\n \"locale-matcher\"?: Intl.ListFormatOptions[\"localeMatcher\"],\n \"type\"?: Intl.ListFormatOptions[\"type\"],\n \"format-style\"?: Intl.ListFormatOptions[\"style\"]\n}\n\nexport class BruhList extends BruhCustomElementBase<BruhListAttributes> {\n static observedAttributes = [\n \"locales\",\n ...Object.values(optionToAttribute)\n ]\n\n static bruh = {\n parseAttributes: {\n locales: spaceSeparated\n }\n }\n\n #locales\n #options\n #formatter\n #itemSlotNames = r<ReadonlyArray<`${number}`>>()\n #formatted\n\n constructor() {\n super()\n\n this.#locales = r([this.bruh.attributes.locales, userLanguages], () =>\n parseLocales([\n ...this.bruh.attributes.locales.value ?? [],\n ...userLanguages.value\n ])\n )\n\n const optionToReactiveAttribute = mapObject(optionToAttribute,\n ([option, attribute]) => [option, this.bruh.attributes[attribute]]\n )\n this.#options = r(Object.values(optionToReactiveAttribute), () =>\n mapObject(optionToReactiveAttribute, ([option, attribute]) => [option, attribute.value || undefined]) as Partial<Intl.ListFormatOptions>\n )\n\n this.#formatter = r([this.#locales, this.#options], () =>\n attempt(() => new Intl.ListFormat(this.#locales.value, this.#options.value))\n ?? new Intl.ListFormat(this.#locales.value)\n )\n\n type ListFormatPart = ReturnType<Intl.ListFormat[\"formatToParts\"]>[number]\n const renderParts = (parts: ReadonlyArray<ListFormatPart>) =>\n parts.map(part => {\n const partAttribute = `part ${part.type}`\n return part.type === \"element\"\n ? <bdi part={partAttribute} role=\"listitem\"><slot name={part.value} /></bdi> as HTMLElement\n : <span part={partAttribute}>{part.value}</span> as HTMLSpanElement\n })\n\n this.#formatted = r([this.#formatter, this.#itemSlotNames], () => {\n if (!this.#itemSlotNames.value)\n return\n\n const formatter = this.#formatter.value\n const { locale } = formatter.resolvedOptions()\n const direction = inferDirection(locale)\n\n const result = renderParts(formatter.formatToParts(this.#itemSlotNames.value))\n\n return <bdi lang={locale} dir={direction} role=\"list\">{result}</bdi> as HTMLElement\n })\n\n const shadowContent = bruhChildrenToNodes([this.#formatted])\n this\n .attachShadow({ mode: \"open\" })\n .append(...shadowContent)\n }\n\n mountedCallback() {\n const assignSlots = () => {\n this.#itemSlotNames.value = [...this.children].map((child, i) => {\n const slot = \"\" + (i + 1) as `${number}`\n child.slot = slot\n return slot\n })\n }\n assignSlots()\n new MutationObserver(assignSlots).observe(this, { childList: true })\n }\n}\n\ncustomElements.define(\"bruh-list\", BruhList)\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"bruh-list\": BruhList\n }\n}\ndeclare module \"html-info\" {\n interface HTMLTagToAttributes {\n \"bruh-list\": {\n /**\n * Space separated list of locales\n */\n \"locales\"?: string,\n \"locale-matcher\"?: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