@krizaka/ui 3.70.0 → 3.72.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account-menu.d.ts +1 -1
- package/dist/account-menu.js +1 -1
- package/dist/account-settings.d.ts +1 -1
- package/dist/account-settings.js +1 -1
- package/dist/avatar/defaults.d.ts +22 -2
- package/dist/avatar/defaults.js +20 -7
- package/dist/avatar/defaults.js.map +1 -1
- package/dist/{avatar-BdZcfkWR.d.ts → avatar-B_na7r1U.d.ts} +16 -0
- package/dist/avatar.d.ts +22 -2
- package/dist/avatar.js +20 -7
- package/dist/avatar.js.map +1 -1
- package/dist/blocks.css +37 -0
- package/dist/chat.js +1 -1
- package/dist/chunk-3PRYL2LS.js +2 -0
- package/dist/chunk-3PRYL2LS.js.map +1 -0
- package/dist/{chunk-HK525THY.js → chunk-5MPPIGCB.js} +18 -7
- package/dist/chunk-5MPPIGCB.js.map +1 -0
- package/dist/{chunk-CSRKYZ53.js → chunk-CZHPWLNW.js} +1 -1
- package/dist/{chunk-PZ4FJOD5.js → chunk-HLEBSAGC.js} +5 -1
- package/dist/{chunk-PZ4FJOD5.js.map → chunk-HLEBSAGC.js.map} +1 -1
- package/dist/chunk-M3T5RQYV.js +34 -0
- package/dist/chunk-M3T5RQYV.js.map +1 -0
- package/dist/{chunk-EUJ7337V.js → chunk-TISDOZH3.js} +18 -7
- package/dist/chunk-TISDOZH3.js.map +1 -0
- package/dist/chunk-W64RAX4N.js +79 -0
- package/dist/chunk-W64RAX4N.js.map +1 -0
- package/dist/chunk-ZFR6ZNXD.js +203 -0
- package/dist/chunk-ZFR6ZNXD.js.map +1 -0
- package/dist/collection-switcher.d.ts +1 -1
- package/dist/{default-avatar-D9kiSFNB.d.ts → default-avatar-BL0nJFti.d.ts} +16 -0
- package/dist/entity-header.d.ts +1 -1
- package/dist/{frame-D6Xv83t8.d.ts → frame-CNZ5VgDD.d.ts} +11 -4
- package/dist/index.js +7 -7
- package/dist/kind-config-editor.js +3 -2
- package/dist/kind-config-editor.js.map +1 -1
- package/dist/map.d.ts +6 -6
- package/dist/match-dialog.js +1 -1
- package/dist/media-grid.d.ts +16 -0
- package/dist/media-grid.js +1 -1
- package/dist/money-input.js +6 -70
- package/dist/money-input.js.map +1 -1
- package/dist/native.d.ts +16 -0
- package/dist/native.js +17 -6
- package/dist/native.js.map +1 -1
- package/dist/nav-bar.d.ts +13 -2
- package/dist/nav-bar.js +71 -54
- package/dist/nav-bar.js.map +1 -1
- package/dist/notification-preferences.js +2 -1
- package/dist/notification-preferences.js.map +1 -1
- package/dist/price-catalogue-editor.d.ts +117 -0
- package/dist/price-catalogue-editor.js +194 -0
- package/dist/price-catalogue-editor.js.map +1 -0
- package/dist/promo-code-field.js +1 -1
- package/dist/schema-DgjBz7-8.d.ts +242 -0
- package/dist/schema-form.d.ts +106 -0
- package/dist/schema-form.js +268 -0
- package/dist/schema-form.js.map +1 -0
- package/dist/shop/booking.d.ts +2 -2
- package/dist/shop/booking.js +1 -1
- package/dist/shop/booking.js.map +1 -1
- package/dist/shop/bulletin.js +1 -1
- package/dist/shop/faq.d.ts +2 -1
- package/dist/shop/faq.js +1 -1
- package/dist/shop/faq.js.map +1 -1
- package/dist/shop/gallery.js +1 -1
- package/dist/shop/look.d.ts +43 -0
- package/dist/shop/look.js +52 -0
- package/dist/shop/look.js.map +1 -0
- package/dist/shop/policies.d.ts +2 -1
- package/dist/shop/policies.js +1 -1
- package/dist/shop/policies.js.map +1 -1
- package/dist/shop/reviews.d.ts +2 -1
- package/dist/shop/reviews.js +1 -1
- package/dist/shop/reviews.js.map +1 -1
- package/dist/shop/services.js +1 -1
- package/dist/shop/social.js +1 -1
- package/dist/shop/story.d.ts +2 -1
- package/dist/shop/story.js +1 -1
- package/dist/shop/story.js.map +1 -1
- package/dist/shop/team.js +1 -1
- package/dist/shop/video.js +1 -1
- package/dist/shop/visit.js +1 -1
- package/dist/shop-composer.d.ts +29 -0
- package/dist/shop-composer.js +156 -89
- package/dist/shop-composer.js.map +1 -1
- package/dist/shop.d.ts +6 -240
- package/dist/shop.js +24 -212
- package/dist/shop.js.map +1 -1
- package/dist/switch.js +2 -1
- package/dist/vertical-video.js +1 -1
- package/dist/wall.d.ts +7 -1
- package/dist/wall.js +5 -4
- package/dist/wall.js.map +1 -1
- package/package.json +59 -9
- package/registry/account-menu.json +1 -1
- package/registry/account-settings.json +1 -1
- package/registry/achievement.json +1 -1
- package/registry/action-bar.json +1 -1
- package/registry/activity-feed.json +1 -1
- package/registry/agenda.json +1 -1
- package/registry/alert.json +1 -1
- package/registry/analysis-report.json +1 -1
- package/registry/anatomy-plate.json +1 -1
- package/registry/app-frame.json +2 -2
- package/registry/app-header.json +1 -1
- package/registry/app-shell.json +1 -1
- package/registry/argument-card.json +1 -1
- package/registry/audio-player.json +1 -1
- package/registry/auth-layout.json +1 -1
- package/registry/avatar.json +4 -4
- package/registry/badge.json +1 -1
- package/registry/bird-plate.json +1 -1
- package/registry/button.json +1 -1
- package/registry/captcha.json +1 -1
- package/registry/card-grid.json +1 -1
- package/registry/card.json +1 -1
- package/registry/catalogue-page.json +1 -1
- package/registry/changelog-page.json +1 -1
- package/registry/chapter.json +1 -1
- package/registry/chat.json +1 -1
- package/registry/checkbox.json +1 -1
- package/registry/chip-link.json +1 -1
- package/registry/chip-row.json +1 -1
- package/registry/chip.json +1 -1
- package/registry/choice-grid.json +1 -1
- package/registry/code-block.json +1 -1
- package/registry/collection-switcher.json +1 -1
- package/registry/combobox.json +1 -1
- package/registry/command.json +1 -1
- package/registry/comparison-table.json +1 -1
- package/registry/component-page.json +1 -1
- package/registry/confirm-button.json +1 -1
- package/registry/contact-page.json +1 -1
- package/registry/continue-prompt.json +1 -1
- package/registry/copy-button.json +1 -1
- package/registry/countdown.json +1 -1
- package/registry/cover-hero.json +1 -1
- package/registry/cta-panel.json +1 -1
- package/registry/dashboard-layout.json +1 -1
- package/registry/data-table.json +1 -1
- package/registry/date-picker.json +1 -1
- package/registry/decision-list.json +1 -1
- package/registry/description-list.json +1 -1
- package/registry/desktop-window.json +1 -1
- package/registry/detail-layout.json +1 -1
- package/registry/dialog.json +1 -1
- package/registry/docs-article-page.json +1 -1
- package/registry/docs-hub-page.json +1 -1
- package/registry/docs-layout.json +1 -1
- package/registry/docs-nav.json +1 -1
- package/registry/document-viewer.json +1 -1
- package/registry/doodle.json +1 -1
- package/registry/drop-overlay.json +1 -1
- package/registry/dropdown-menu.json +1 -1
- package/registry/elephant.json +2 -2
- package/registry/embed-facade.json +1 -1
- package/registry/empty-state.json +1 -1
- package/registry/engine-flow.json +1 -1
- package/registry/entity-header.json +1 -1
- package/registry/environment-notice.json +1 -1
- package/registry/error-page.json +1 -1
- package/registry/examples/price-catalogue-editor/default.d.ts +4 -0
- package/registry/examples/price-catalogue-editor/default.js +47 -0
- package/registry/examples/price-catalogue-editor/default.tsx +25 -0
- package/registry/examples/schema-form/default.d.ts +4 -0
- package/registry/examples/schema-form/default.js +29 -0
- package/registry/examples/schema-form/default.tsx +27 -0
- package/registry/examples/wall/pinned-note.js +2 -1
- package/registry/examples/wall/pinned-note.tsx +2 -1
- package/registry/field.json +1 -1
- package/registry/file-upload.json +1 -1
- package/registry/filter-bar.json +1 -1
- package/registry/flock.json +1 -1
- package/registry/footnote.json +1 -1
- package/registry/force-update-screen.json +1 -1
- package/registry/form.json +1 -1
- package/registry/gallery-page.json +1 -1
- package/registry/genui.json +1 -1
- package/registry/glossary-term.json +1 -1
- package/registry/glossary.json +1 -1
- package/registry/glow-card.json +1 -1
- package/registry/goal-gauge.json +1 -1
- package/registry/grade-stamp.json +1 -1
- package/registry/how-it-works-page.json +1 -1
- package/registry/image-cropper.json +1 -1
- package/registry/index.json +81 -8
- package/registry/iso.json +1 -1
- package/registry/kanban.json +1 -1
- package/registry/kbd.json +1 -1
- package/registry/kind-config-editor.json +1 -1
- package/registry/kpi-explained.json +1 -1
- package/registry/landing-page.json +1 -1
- package/registry/landscape.json +1 -1
- package/registry/language-switch.json +1 -1
- package/registry/legal-page.json +1 -1
- package/registry/link-card.json +1 -1
- package/registry/list.json +1 -1
- package/registry/loader.json +1 -1
- package/registry/longform-page.json +1 -1
- package/registry/maintenance-screen.json +1 -1
- package/registry/map.json +2 -2
- package/registry/margin-layout.json +1 -1
- package/registry/markdown.json +1 -1
- package/registry/marketing-layout.json +1 -1
- package/registry/marquee.json +1 -1
- package/registry/mascot-quote.json +1 -1
- package/registry/mascot-state.json +1 -1
- package/registry/mascots.json +1 -1
- package/registry/match-dialog.json +1 -1
- package/registry/media-capture.json +1 -1
- package/registry/media-gallery.json +1 -1
- package/registry/media-grid.json +1 -1
- package/registry/meta-row.json +1 -1
- package/registry/meter.json +1 -1
- package/registry/money-input.json +1 -1
- package/registry/nav-bar.json +30 -6
- package/registry/next-actions.json +1 -1
- package/registry/notification-preferences.json +1 -1
- package/registry/number-ticker.json +1 -1
- package/registry/opening-hours.json +1 -1
- package/registry/page-header.json +1 -1
- package/registry/page-hero.json +1 -1
- package/registry/page-index.json +1 -1
- package/registry/page.json +1 -1
- package/registry/pagination.json +1 -1
- package/registry/photo-grid.json +1 -1
- package/registry/pointer-light.json +1 -1
- package/registry/popover.json +1 -1
- package/registry/price-catalogue-editor.json +228 -0
- package/registry/pricing-page.json +1 -1
- package/registry/product-page.json +1 -1
- package/registry/profile-card.json +1 -1
- package/registry/progress.json +1 -1
- package/registry/promise-card.json +1 -1
- package/registry/promo-code-field.json +1 -1
- package/registry/proposal.json +1 -1
- package/registry/qr-code.json +1 -1
- package/registry/quota-meter.json +1 -1
- package/registry/radio-group.json +1 -1
- package/registry/rail-nav.json +2 -2
- package/registry/recipes.json +1 -1
- package/registry/retro-tv.json +1 -1
- package/registry/reviews.json +1 -1
- package/registry/router.json +1 -1
- package/registry/schema-form.json +253 -0
- package/registry/scroll-stage.json +1 -1
- package/registry/search-field.json +1 -1
- package/registry/section-backdrop.json +1 -1
- package/registry/separator.json +1 -1
- package/registry/service-card.json +1 -1
- package/registry/settings-layout.json +1 -1
- package/registry/shop-composer.json +10 -6
- package/registry/shop-gallery.json +1 -1
- package/registry/shop.json +51 -10
- package/registry/showcase.json +1 -1
- package/registry/signature.json +1 -1
- package/registry/site-cahier.json +1 -1
- package/registry/site-footer.json +2 -2
- package/registry/sites.json +1 -1
- package/registry/skeleton.json +1 -1
- package/registry/skip-link.json +1 -1
- package/registry/slider.json +1 -1
- package/registry/slot-picker.json +1 -1
- package/registry/slot.json +1 -1
- package/registry/specimen-tag.json +1 -1
- package/registry/speed-lines.json +1 -1
- package/registry/spinner.json +1 -1
- package/registry/split-view.json +1 -1
- package/registry/stage-banner.json +1 -1
- package/registry/stat.json +1 -1
- package/registry/status-chip.json +1 -1
- package/registry/status-page.json +1 -1
- package/registry/step-progress.json +1 -1
- package/registry/step-showcase.json +1 -1
- package/registry/stepper.json +1 -1
- package/registry/sticky-action.json +1 -1
- package/registry/stuck.json +1 -1
- package/registry/swipe-deck.json +1 -1
- package/registry/switch.json +1 -1
- package/registry/tabs.json +1 -1
- package/registry/tag-input.json +1 -1
- package/registry/tag-selector.json +1 -1
- package/registry/taped-photo.json +1 -1
- package/registry/terminal-replay.json +1 -1
- package/registry/text-style.json +1 -1
- package/registry/theme.json +1 -1
- package/registry/toast.json +1 -1
- package/registry/toc.json +1 -1
- package/registry/tooltip.json +1 -1
- package/registry/tree-view.json +1 -1
- package/registry/update-prompt.json +1 -1
- package/registry/upload-queue.json +1 -1
- package/registry/usage.json +1 -1
- package/registry/verified-badge.json +1 -1
- package/registry/versus-card.json +1 -1
- package/registry/vertical-video.json +1 -1
- package/registry/video-player.json +1 -1
- package/registry/video-trimmer.json +1 -1
- package/registry/virtual.json +1 -1
- package/registry/wall.json +47 -4
- package/registry/waveform.json +1 -1
- package/dist/chunk-A7MQPIEG.js +0 -31
- package/dist/chunk-A7MQPIEG.js.map +0 -1
- package/dist/chunk-EUJ7337V.js.map +0 -1
- package/dist/chunk-HK525THY.js.map +0 -1
- /package/dist/{chunk-CSRKYZ53.js.map → chunk-CZHPWLNW.js.map} +0 -0
package/dist/media-grid.d.ts
CHANGED
|
@@ -90,6 +90,22 @@ interface DefaultAvatar {
|
|
|
90
90
|
* @default "person"
|
|
91
91
|
*/
|
|
92
92
|
kind?: DefaultAvatarKind;
|
|
93
|
+
/**
|
|
94
|
+
* The family's central set (`listDefaults("person")` of `@krizaka/org`): when given with a `seed`, the avatar is the set's picture for that seed —
|
|
95
|
+
* the same person has the same picture in every product — instead of the brand's silhouette. An empty set, or no seed, draws the silhouette.
|
|
96
|
+
*/
|
|
97
|
+
set?: readonly DefaultAvatarPicture[];
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* One picture of the family's central set, as `@krizaka/org` lists it (`listDefaults("person")` items fit as they are): the sizes it is served in.
|
|
101
|
+
* `disabled` pictures are never picked.
|
|
102
|
+
*/
|
|
103
|
+
interface DefaultAvatarPicture {
|
|
104
|
+
id: string;
|
|
105
|
+
disabled?: boolean;
|
|
106
|
+
urls: {
|
|
107
|
+
webp: Readonly<Record<string, string>>;
|
|
108
|
+
};
|
|
93
109
|
}
|
|
94
110
|
|
|
95
111
|
type VideoCardAspect = "landscape" | "portrait";
|
package/dist/media-grid.js
CHANGED
package/dist/money-input.js
CHANGED
|
@@ -1,75 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// src/money-input/money-input.tsx
|
|
11
|
-
import { currencyDigits } from "@krizaka/intl";
|
|
12
|
-
import * as React from "react";
|
|
13
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
var separators = (locale) => {
|
|
15
|
-
const parts = new Intl.NumberFormat(locale, { useGrouping: true, minimumFractionDigits: 1 }).formatToParts(12345671e-1);
|
|
16
|
-
return { decimal: parts.find((p) => p.type === "decimal")?.value ?? ".", group: parts.find((p) => p.type === "group")?.value ?? "," };
|
|
17
|
-
};
|
|
18
|
-
function parseMinorUnits(text, locale, digits) {
|
|
19
|
-
const { decimal } = separators(locale);
|
|
20
|
-
const cleaned = text.replace(/\s/g, "");
|
|
21
|
-
if (cleaned === "") return null;
|
|
22
|
-
const marks = [...cleaned].filter((c) => c === "." || c === "," || c === decimal);
|
|
23
|
-
if (!/^[\d.,]+$/.test(cleaned.replaceAll(decimal, ""))) return void 0;
|
|
24
|
-
const last = marks.length ? Math.max(cleaned.lastIndexOf("."), cleaned.lastIndexOf(","), cleaned.lastIndexOf(decimal)) : -1;
|
|
25
|
-
const whole = (last >= 0 ? cleaned.slice(0, last) : cleaned).replace(/\D/g, "");
|
|
26
|
-
const fraction = last >= 0 ? cleaned.slice(last + 1) : "";
|
|
27
|
-
if (!/^\d*$/.test(fraction) || fraction.length > digits || digits === 0 && last >= 0) return void 0;
|
|
28
|
-
const minor = Number(`${whole || "0"}${fraction.padEnd(digits, "0")}`);
|
|
29
|
-
return Number.isSafeInteger(minor) ? minor : void 0;
|
|
30
|
-
}
|
|
31
|
-
function formatMinorUnits(minor, locale, digits) {
|
|
32
|
-
const { decimal } = separators(locale);
|
|
33
|
-
const abs = BigInt(Math.abs(minor)).toString().padStart(digits + 1, "0");
|
|
34
|
-
const whole = new Intl.NumberFormat(locale).format(BigInt(digits ? abs.slice(0, -digits) : abs));
|
|
35
|
-
return `${minor < 0 ? "-" : ""}${whole}${digits ? decimal + abs.slice(-digits) : ""}`;
|
|
36
|
-
}
|
|
37
|
-
function MoneyInput({ value, onValueChange, currency, locale, currencies, onCurrencyChange, currencyLabel, invalid, className, onBlur, disabled, ...props }) {
|
|
38
|
-
const digits = currencyDigits(currency);
|
|
39
|
-
const [text, setText] = React.useState(() => value === null ? "" : formatMinorUnits(value, locale, digits));
|
|
40
|
-
const typed = React.useRef(value);
|
|
41
|
-
React.useEffect(() => {
|
|
42
|
-
if (typed.current !== value) setText(value === null ? "" : formatMinorUnits(value, locale, digits));
|
|
43
|
-
typed.current = value;
|
|
44
|
-
}, [value, locale, digits]);
|
|
45
|
-
return /* @__PURE__ */ jsxs("span", { className: cn("flex w-full items-stretch gap-2", className), children: [
|
|
46
|
-
/* @__PURE__ */ jsx(
|
|
47
|
-
Input,
|
|
48
|
-
{
|
|
49
|
-
...props,
|
|
50
|
-
type: "text",
|
|
51
|
-
inputMode: digits ? "decimal" : "numeric",
|
|
52
|
-
autoComplete: "off",
|
|
53
|
-
disabled,
|
|
54
|
-
invalid,
|
|
55
|
-
"data-currency": currency,
|
|
56
|
-
value: text,
|
|
57
|
-
onChange: (event) => {
|
|
58
|
-
const parsed = parseMinorUnits(event.target.value, locale, digits);
|
|
59
|
-
if (parsed === void 0) return;
|
|
60
|
-
setText(event.target.value);
|
|
61
|
-
typed.current = parsed;
|
|
62
|
-
onValueChange(parsed);
|
|
63
|
-
},
|
|
64
|
-
onBlur: (event) => {
|
|
65
|
-
onBlur?.(event);
|
|
66
|
-
if (value !== null) setText(formatMinorUnits(value, locale, digits));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
),
|
|
70
|
-
currencies ? /* @__PURE__ */ jsx(Select, { "aria-label": currencyLabel, disabled, value: currency, onChange: (event) => onCurrencyChange?.(event.target.value), className: "w-28", children: currencies.map((code) => /* @__PURE__ */ jsx("option", { value: code, children: code }, code)) }) : /* @__PURE__ */ jsx("span", { className: "flex items-center text-sm font-medium text-fg-secondary", children: currency })
|
|
71
|
-
] });
|
|
72
|
-
}
|
|
3
|
+
MoneyInput,
|
|
4
|
+
formatMinorUnits,
|
|
5
|
+
parseMinorUnits
|
|
6
|
+
} from "./chunk-W64RAX4N.js";
|
|
7
|
+
import "./chunk-HLEBSAGC.js";
|
|
8
|
+
import "./chunk-NSLXEDIS.js";
|
|
73
9
|
export {
|
|
74
10
|
MoneyInput,
|
|
75
11
|
formatMinorUnits,
|
package/dist/money-input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/native.d.ts
CHANGED
|
@@ -25,6 +25,22 @@ interface DefaultAvatar {
|
|
|
25
25
|
* @default "person"
|
|
26
26
|
*/
|
|
27
27
|
kind?: DefaultAvatarKind;
|
|
28
|
+
/**
|
|
29
|
+
* The family's central set (`listDefaults("person")` of `@krizaka/org`): when given with a `seed`, the avatar is the set's picture for that seed —
|
|
30
|
+
* the same person has the same picture in every product — instead of the brand's silhouette. An empty set, or no seed, draws the silhouette.
|
|
31
|
+
*/
|
|
32
|
+
set?: readonly DefaultAvatarPicture[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* One picture of the family's central set, as `@krizaka/org` lists it (`listDefaults("person")` items fit as they are): the sizes it is served in.
|
|
36
|
+
* `disabled` pictures are never picked.
|
|
37
|
+
*/
|
|
38
|
+
interface DefaultAvatarPicture {
|
|
39
|
+
id: string;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
urls: {
|
|
42
|
+
webp: Readonly<Record<string, string>>;
|
|
43
|
+
};
|
|
28
44
|
}
|
|
29
45
|
/**
|
|
30
46
|
* The URL of a default avatar: `defaultAvatarUrl({ brand: "orazaka", seed: user.id })`.
|
package/dist/native.js
CHANGED
|
@@ -18,7 +18,7 @@ function hslToHex([h, s, l]) {
|
|
|
18
18
|
const light = l / 100;
|
|
19
19
|
const k = (n) => (n + (h % 360 + 360) % 360 / 30) % 12;
|
|
20
20
|
const a = sat * Math.min(light, 1 - light);
|
|
21
|
-
const channel = (n) => Math.round(255 * (light - a * Math.max(-1, Math.min(k(n) - 3,
|
|
21
|
+
const channel = (n) => Math.round(255 * (light - a * Math.max(-1, Math.min(k(n) - 3, 9 - k(n), 1))));
|
|
22
22
|
return `#${[0, 8, 4].map((n) => channel(n).toString(16).padStart(2, "0")).join("")}`;
|
|
23
23
|
}
|
|
24
24
|
var channelLuminance = (v) => v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
@@ -37,14 +37,21 @@ function defaultAvatarTone(brand, tone3) {
|
|
|
37
37
|
return [readable([b.from[0] + o, b.from[1], b.from[2]]), readable([b.to[0] + o, b.to[1], b.to[2]])];
|
|
38
38
|
}
|
|
39
39
|
var clampTone = (tone3) => Math.min(DEFAULT_AVATAR_TONES, Math.max(1, Math.round(tone3)));
|
|
40
|
-
function
|
|
41
|
-
if (seed === void 0) return 1;
|
|
40
|
+
function defaultAvatarSeedHash(seed) {
|
|
42
41
|
let h = 2166136261;
|
|
43
42
|
for (const ch of String(seed)) {
|
|
44
|
-
h ^= ch.codePointAt(0)
|
|
43
|
+
h ^= ch.codePointAt(0);
|
|
45
44
|
h = Math.imul(h, 16777619) >>> 0;
|
|
46
45
|
}
|
|
47
|
-
return h
|
|
46
|
+
return h;
|
|
47
|
+
}
|
|
48
|
+
function defaultAvatarToneOf(seed) {
|
|
49
|
+
if (seed === void 0) return 1;
|
|
50
|
+
return defaultAvatarSeedHash(seed) % DEFAULT_AVATAR_TONES + 1;
|
|
51
|
+
}
|
|
52
|
+
function pickDefaultPicture(set, seed) {
|
|
53
|
+
const usable = set.filter((picture) => !picture.disabled);
|
|
54
|
+
return usable[defaultAvatarSeedHash(seed) % usable.length];
|
|
48
55
|
}
|
|
49
56
|
var resolveTone = (a) => a.tone === void 0 ? defaultAvatarToneOf(a.seed) : clampTone(a.tone);
|
|
50
57
|
function defaultAvatarFile(kind, tone3, size) {
|
|
@@ -52,11 +59,15 @@ function defaultAvatarFile(kind, tone3, size) {
|
|
|
52
59
|
}
|
|
53
60
|
function trimTrailingSlashes(value) {
|
|
54
61
|
let end = value.length;
|
|
55
|
-
while (end > 0 && value
|
|
62
|
+
while (end > 0 && value[end - 1] === "/") end--;
|
|
56
63
|
return value.slice(0, end);
|
|
57
64
|
}
|
|
58
65
|
function defaultAvatarUrl(avatar, { size = 256, base = DEFAULT_AVATAR_BASE } = {}) {
|
|
59
66
|
if (isGlyphKind(avatar.kind)) return defaultAvatarDataUrl(avatar);
|
|
67
|
+
if (avatar.set && avatar.seed !== void 0) {
|
|
68
|
+
const picked = pickDefaultPicture(avatar.set, avatar.seed)?.urls.webp[size];
|
|
69
|
+
if (picked) return picked;
|
|
70
|
+
}
|
|
60
71
|
return `${trimTrailingSlashes(base)}/${avatar.brand}/${defaultAvatarFile(avatar.kind ?? "person", resolveTone(avatar), size)}`;
|
|
61
72
|
}
|
|
62
73
|
var GLYPHS = {
|