@krizaka/ui 3.63.0 → 3.64.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 +61 -4
- package/dist/account-settings.js +207 -45
- package/dist/account-settings.js.map +1 -1
- package/dist/action-bar.js +4 -4
- package/dist/analysis-report.d.ts +274 -0
- package/dist/analysis-report.js +207 -0
- package/dist/analysis-report.js.map +1 -0
- package/dist/app-header.d.ts +3 -3
- package/dist/argument-card.d.ts +1 -1
- package/dist/argument-card.js +5 -5
- package/dist/avatar/defaults.d.ts +16 -5
- package/dist/avatar/defaults.js +15 -1
- package/dist/avatar/defaults.js.map +1 -1
- package/dist/{avatar-BL2iG_Js.d.ts → avatar-BdZcfkWR.d.ts} +11 -4
- package/dist/avatar.d.ts +16 -5
- package/dist/avatar.js +15 -1
- package/dist/avatar.js.map +1 -1
- package/dist/badge.js +4 -34
- package/dist/badge.js.map +1 -1
- package/dist/blocks.css +99 -8
- package/dist/button.js +1 -1
- package/dist/captcha.js +1 -1
- package/dist/chat.js +1 -1
- package/dist/chunk-5PFCELGW.js +41 -0
- package/dist/chunk-5PFCELGW.js.map +1 -0
- package/dist/chunk-5RWHDX5J.js +37 -0
- package/dist/chunk-5RWHDX5J.js.map +1 -0
- package/dist/{chunk-5LANVCK7.js → chunk-BG5APGX6.js} +2 -2
- package/dist/{chunk-WOZP3JLW.js → chunk-DJ5ZPPWL.js} +1 -1
- package/dist/chunk-DJ5ZPPWL.js.map +1 -0
- package/dist/{chunk-UV4HBVH7.js → chunk-EB45EVPJ.js} +2 -2
- package/dist/{chunk-SJS6RJIT.js.map → chunk-EB45EVPJ.js.map} +1 -1
- package/dist/chunk-EUJ7337V.js +137 -0
- package/dist/chunk-EUJ7337V.js.map +1 -0
- package/dist/{chunk-6EAHUURY.js → chunk-GHAN7OOE.js} +2 -2
- package/dist/chunk-HK525THY.js +139 -0
- package/dist/chunk-HK525THY.js.map +1 -0
- package/dist/chunk-JT7ZKZT5.js +1 -0
- package/dist/chunk-JT7ZKZT5.js.map +1 -0
- package/dist/{chunk-3DHNN5V7.js → chunk-M3GEYLMR.js} +2 -2
- package/dist/{chunk-3DHNN5V7.js.map → chunk-M3GEYLMR.js.map} +1 -1
- package/dist/{chunk-7J2L4HOD.js → chunk-MTVX4RRF.js} +2 -2
- package/dist/{chunk-7J2L4HOD.js.map → chunk-MTVX4RRF.js.map} +1 -1
- package/dist/{chunk-YKEIOYJ5.js → chunk-NPMGYLJV.js} +1 -1
- package/dist/chunk-NPMGYLJV.js.map +1 -0
- package/dist/{chunk-HEKDKM5Y.js → chunk-QVHSV6RA.js} +1 -1
- package/dist/{chunk-7JG3VR4C.js → chunk-RCKXJEDQ.js} +5 -5
- package/dist/{chunk-3D2YI63L.js → chunk-SHBYNQFS.js} +7 -2
- package/dist/{chunk-3D2YI63L.js.map → chunk-SHBYNQFS.js.map} +1 -1
- package/dist/chunk-U4XTZMB7.js +103 -0
- package/dist/chunk-U4XTZMB7.js.map +1 -0
- package/dist/{chunk-SJS6RJIT.js → chunk-V7W4RLRW.js} +2 -2
- package/dist/{chunk-UV4HBVH7.js.map → chunk-V7W4RLRW.js.map} +1 -1
- package/dist/command.js +2 -2
- package/dist/confirm-button.js +1 -1
- package/dist/continue-prompt.js +1 -1
- package/dist/continue-prompt.js.map +1 -1
- package/dist/cover-hero.js +1 -1
- package/dist/dashboard-layout.js +2 -1
- package/dist/dashboard-layout.js.map +1 -1
- package/dist/data-table.js +2 -2
- package/dist/date-picker.d.ts +15 -15
- package/dist/dialog.js +2 -2
- package/dist/docs-layout.js +1 -1
- package/dist/embed-facade.d.ts +37 -0
- package/dist/embed-facade.js +96 -0
- package/dist/embed-facade.js.map +1 -0
- package/dist/file-upload.d.ts +2 -2
- package/dist/force-update-screen.js +1 -1
- package/dist/genui.js +2 -2
- package/dist/kind-config-editor.js +1 -1
- package/dist/link-card.js +2 -2
- package/dist/maintenance-screen.js +1 -1
- package/dist/map.js +6 -0
- package/dist/map.js.map +1 -1
- package/dist/margin-layout.d.ts +71 -0
- package/dist/margin-layout.js +29 -0
- package/dist/margin-layout.js.map +1 -0
- package/dist/match-dialog.js +2 -2
- package/dist/media-grid.d.ts +8 -3
- package/dist/media-grid.js +2 -2
- package/dist/meter.js +2 -1
- package/dist/native/map.js +6 -0
- package/dist/native/map.js.map +1 -1
- package/dist/native.d.ts +96 -5
- package/dist/native.js +1718 -1529
- package/dist/native.js.map +1 -1
- package/dist/nav-bar.js +1 -1
- package/dist/page-DPHDmDAQ.d.ts +131 -0
- package/dist/page-hero.js +4 -4
- package/dist/page.d.ts +7 -125
- package/dist/page.js +13 -1
- package/dist/page.js.map +1 -1
- package/dist/quota-meter.js +2 -1
- package/dist/quota-meter.js.map +1 -1
- package/dist/retro-tv.d.ts +6 -3
- package/dist/retro-tv.js +6 -5
- package/dist/retro-tv.js.map +1 -1
- package/dist/reviews.d.ts +49 -0
- package/dist/reviews.js +66 -0
- package/dist/reviews.js.map +1 -0
- package/dist/separator.d.ts +26 -3
- package/dist/separator.js +19 -1
- package/dist/separator.js.map +1 -1
- package/dist/service-card.d.ts +56 -63
- package/dist/service-card.js +49 -10
- package/dist/service-card.js.map +1 -1
- package/dist/settings-layout.js +1 -1
- package/dist/site-cahier.js +1 -1
- package/dist/specimen-tag.d.ts +15 -3
- package/dist/specimen-tag.js +4 -27
- package/dist/specimen-tag.js.map +1 -1
- package/dist/stat.d.ts +87 -5
- package/dist/stat.js +9 -53
- package/dist/stat.js.map +1 -1
- package/dist/sticky-action.d.ts +7 -2
- package/dist/sticky-action.js +24 -3
- package/dist/sticky-action.js.map +1 -1
- package/dist/theme.js +1 -1
- package/dist/update-prompt.js +1 -1
- package/dist/usage.d.ts +229 -0
- package/dist/usage.js +189 -0
- package/dist/usage.js.map +1 -0
- package/dist/vertical-video.js +2 -2
- package/dist/wall.d.ts +24 -12
- package/dist/wall.js +106 -43
- package/dist/wall.js.map +1 -1
- package/package.json +92 -13
- package/registry/account-menu.json +1 -1
- package/registry/account-settings.json +67 -6
- 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 +445 -0
- package/registry/anatomy-plate.json +1 -1
- package/registry/app-header.json +1 -1
- package/registry/app-shell.json +1 -1
- package/registry/argument-card.json +3 -3
- package/registry/audio-player.json +1 -1
- package/registry/auth-layout.json +1 -1
- package/registry/avatar.json +6 -5
- package/registry/badge.json +1 -1
- package/registry/bird-plate.json +1 -1
- package/registry/button.json +2 -2
- 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/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/countdown.json +1 -1
- package/registry/cover-hero.json +1 -1
- package/registry/cta-panel.json +1 -1
- package/registry/dashboard-layout.json +2 -2
- 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/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 +243 -0
- package/registry/empty-state.json +1 -1
- package/registry/engine-flow.json +1 -1
- package/registry/environment-notice.json +1 -1
- package/registry/error-page.json +1 -1
- package/registry/examples/account-settings/avatar-picker-folder.d.ts +4 -0
- package/registry/examples/account-settings/avatar-picker-folder.js +27 -0
- package/registry/examples/account-settings/avatar-picker-folder.tsx +23 -0
- package/registry/examples/analysis-report/document-validation.d.ts +4 -0
- package/registry/examples/analysis-report/document-validation.js +47 -0
- package/registry/examples/analysis-report/document-validation.tsx +29 -0
- package/registry/examples/analysis-report/native/document-validation.d.ts +4 -0
- package/registry/examples/analysis-report/native/document-validation.dark.png +0 -0
- package/registry/examples/analysis-report/native/document-validation.js +48 -0
- package/registry/examples/analysis-report/native/document-validation.light.png +0 -0
- package/registry/examples/analysis-report/native/document-validation.tsx +32 -0
- package/registry/examples/analysis-report/streaming.d.ts +4 -0
- package/registry/examples/analysis-report/streaming.js +42 -0
- package/registry/examples/analysis-report/streaming.tsx +23 -0
- package/registry/examples/embed-facade/tiktok.d.ts +4 -0
- package/registry/examples/embed-facade/tiktok.js +20 -0
- package/registry/examples/embed-facade/tiktok.tsx +16 -0
- package/registry/examples/embed-facade/youtube.d.ts +4 -0
- package/registry/examples/embed-facade/youtube.js +22 -0
- package/registry/examples/embed-facade/youtube.tsx +20 -0
- package/registry/examples/margin-layout/findings.d.ts +4 -0
- package/registry/examples/margin-layout/findings.js +15 -0
- package/registry/examples/margin-layout/findings.tsx +18 -0
- package/registry/examples/margin-layout/steps.d.ts +4 -0
- package/registry/examples/margin-layout/steps.js +15 -0
- package/registry/examples/margin-layout/steps.tsx +16 -0
- package/registry/examples/page/kraft.d.ts +4 -0
- package/registry/examples/page/kraft.js +14 -0
- package/registry/examples/page/kraft.tsx +12 -0
- package/registry/examples/page/papers.d.ts +4 -0
- package/registry/examples/page/papers.js +14 -0
- package/registry/examples/page/papers.tsx +13 -0
- package/registry/examples/retro-tv/facade.d.ts +4 -0
- package/registry/examples/retro-tv/facade.js +12 -0
- package/registry/examples/retro-tv/facade.tsx +13 -0
- package/registry/examples/reviews/card.d.ts +4 -0
- package/registry/examples/reviews/card.js +23 -0
- package/registry/examples/reviews/card.tsx +19 -0
- package/registry/examples/reviews/summary.d.ts +4 -0
- package/registry/examples/reviews/summary.js +23 -0
- package/registry/examples/reviews/summary.tsx +17 -0
- package/registry/examples/separator/hand.d.ts +4 -0
- package/registry/examples/separator/hand.js +19 -0
- package/registry/examples/separator/hand.tsx +16 -0
- package/registry/examples/service-card/index-card.d.ts +4 -0
- package/registry/examples/service-card/index-card.js +15 -0
- package/registry/examples/service-card/index-card.tsx +12 -0
- package/registry/examples/service-card/index-list.d.ts +4 -0
- package/registry/examples/service-card/index-list.js +14 -0
- package/registry/examples/service-card/index-list.tsx +11 -0
- package/registry/examples/specimen-tag/facts.d.ts +4 -0
- package/registry/examples/specimen-tag/facts.js +23 -0
- package/registry/examples/specimen-tag/facts.tsx +18 -0
- package/registry/examples/stat/strip.d.ts +4 -0
- package/registry/examples/stat/strip.js +25 -0
- package/registry/examples/stat/strip.tsx +25 -0
- package/registry/examples/sticky-action/hide-while-visible.d.ts +4 -0
- package/registry/examples/sticky-action/hide-while-visible.js +16 -0
- package/registry/examples/sticky-action/hide-while-visible.tsx +17 -0
- package/registry/examples/usage/credits-page.d.ts +4 -0
- package/registry/examples/usage/credits-page.js +45 -0
- package/registry/examples/usage/credits-page.tsx +40 -0
- package/registry/examples/usage/empty.d.ts +4 -0
- package/registry/examples/usage/empty.js +15 -0
- package/registry/examples/usage/empty.tsx +12 -0
- package/registry/examples/wall/brick.js +1 -1
- package/registry/examples/wall/brick.tsx +1 -1
- package/registry/examples/wall/composition-fr.js +1 -1
- package/registry/examples/wall/composition-fr.tsx +1 -1
- package/registry/examples/wall/composition.js +1 -1
- package/registry/examples/wall/composition.tsx +1 -1
- package/registry/examples/wall/pinned-note.js +2 -2
- package/registry/examples/wall/pinned-note.tsx +3 -2
- package/registry/examples/wall/plaster.js +1 -1
- package/registry/examples/wall/plaster.tsx +1 -1
- package/registry/examples/wall/ridge.js +1 -1
- package/registry/examples/wall/ridge.tsx +1 -1
- package/registry/examples/wall/shop-sign.js +5 -4
- package/registry/examples/wall/shop-sign.tsx +7 -4
- package/registry/examples/wall/zellige.js +1 -1
- package/registry/examples/wall/zellige.tsx +1 -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 +186 -18
- 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 +200 -0
- 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/nav-bar.json +2 -2
- 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 +53 -11
- 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/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/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 +45 -29
- package/registry/reviews.json +361 -0
- package/registry/router.json +1 -1
- 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 +71 -6
- package/registry/service-card.json +55 -6
- package/registry/settings-layout.json +1 -1
- 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 +57 -5
- 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 +61 -9
- 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 +27 -4
- 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 +542 -0
- 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 +3 -3
- package/registry/virtual.json +1 -1
- package/registry/wall.json +128 -40
- package/registry/waveform.json +1 -1
- package/dist/chunk-7AZ23BUX.js +0 -88
- package/dist/chunk-7AZ23BUX.js.map +0 -1
- package/dist/chunk-PW2FVPTV.js +0 -85
- package/dist/chunk-PW2FVPTV.js.map +0 -1
- package/dist/chunk-WOZP3JLW.js.map +0 -1
- package/dist/chunk-YKEIOYJ5.js.map +0 -1
- /package/dist/{chunk-5LANVCK7.js.map → chunk-BG5APGX6.js.map} +0 -0
- /package/dist/{chunk-6EAHUURY.js.map → chunk-GHAN7OOE.js.map} +0 -0
- /package/dist/{chunk-HEKDKM5Y.js.map → chunk-QVHSV6RA.js.map} +0 -0
- /package/dist/{chunk-7JG3VR4C.js.map → chunk-RCKXJEDQ.js.map} +0 -0
package/dist/usage.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BlockLink
|
|
3
|
+
} from "./chunk-FVGFPB73.js";
|
|
4
|
+
import "./chunk-JT7ZKZT5.js";
|
|
5
|
+
import {
|
|
6
|
+
Meter
|
|
7
|
+
} from "./chunk-QVHSV6RA.js";
|
|
8
|
+
import {
|
|
9
|
+
StatGrid
|
|
10
|
+
} from "./chunk-U4XTZMB7.js";
|
|
11
|
+
|
|
12
|
+
// src/usage/model.ts
|
|
13
|
+
import { formatNumber, formatPercent } from "@krizaka/intl";
|
|
14
|
+
var USAGE_PERIODS = [7, 30, 90];
|
|
15
|
+
function parsePeriod(raw, allowed = USAGE_PERIODS, fallback = 30) {
|
|
16
|
+
const value = Number(Array.isArray(raw) ? raw[0] : raw);
|
|
17
|
+
return allowed.includes(value) ? value : fallback;
|
|
18
|
+
}
|
|
19
|
+
function periodHref(base, period, param = "period") {
|
|
20
|
+
const [path = "", query = ""] = base.split("?");
|
|
21
|
+
const params = new URLSearchParams(query);
|
|
22
|
+
params.set(param, String(period));
|
|
23
|
+
return `${path}?${params.toString()}`;
|
|
24
|
+
}
|
|
25
|
+
var WORDS = {
|
|
26
|
+
fr: { vsPrevious: "{change} vs p\xE9riode pr\xE9c\xE9dente", same: "stable", up: "en hausse", down: "en baisse" },
|
|
27
|
+
en: { vsPrevious: "{change} vs previous period", same: "steady", up: "up", down: "down" }
|
|
28
|
+
};
|
|
29
|
+
var FLAT = 5e-3;
|
|
30
|
+
var wordsOf = (locale) => locale.toLowerCase().startsWith("en") ? WORDS.en : WORDS.fr;
|
|
31
|
+
function direction(change) {
|
|
32
|
+
if (change === null) return void 0;
|
|
33
|
+
if (Math.abs(change) < FLAT) return "flat";
|
|
34
|
+
return change > 0 ? "up" : "down";
|
|
35
|
+
}
|
|
36
|
+
function changeOf(value, previous) {
|
|
37
|
+
if (previous === void 0) return null;
|
|
38
|
+
if (previous === 0) return value === 0 ? 0 : null;
|
|
39
|
+
return value / previous - 1;
|
|
40
|
+
}
|
|
41
|
+
function usageTile(input, { locale = "fr-CA", words } = {}) {
|
|
42
|
+
const w = { ...wordsOf(locale), ...words };
|
|
43
|
+
const change = changeOf(input.value, input.previous);
|
|
44
|
+
const trend = direction(change);
|
|
45
|
+
const text = change === null ? void 0 : trend === "flat" ? w.same : w.vsPrevious.replace("{change}", formatPercent(change, { locale, signDisplay: "exceptZero", maximumFractionDigits: 0 }));
|
|
46
|
+
return {
|
|
47
|
+
id: input.id,
|
|
48
|
+
label: input.label,
|
|
49
|
+
value: formatNumber(input.value, { locale, maximumFractionDigits: input.digits ?? 0 }),
|
|
50
|
+
trend,
|
|
51
|
+
trendLabel: text,
|
|
52
|
+
chart: input.chart
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function usageBars(days, outcomes) {
|
|
56
|
+
const totals = days.map((d) => outcomes.reduce((sum, o) => sum + (d.values[o.id] ?? 0), 0));
|
|
57
|
+
const max = Math.max(1, ...totals);
|
|
58
|
+
return days.map((d, i) => {
|
|
59
|
+
const total = totals[i] ?? 0;
|
|
60
|
+
return {
|
|
61
|
+
label: d.label,
|
|
62
|
+
total,
|
|
63
|
+
height: total / max,
|
|
64
|
+
segments: outcomes.map((o) => ({ id: o.id, value: d.values[o.id] ?? 0, share: total === 0 ? 0 : (d.values[o.id] ?? 0) / total }))
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// src/usage/usage.tsx
|
|
70
|
+
import { formatNumber as formatNumber2 } from "@krizaka/intl";
|
|
71
|
+
import { tv } from "tailwind-variants";
|
|
72
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
73
|
+
var usage = tv({
|
|
74
|
+
slots: {
|
|
75
|
+
credits: "flex w-full min-w-0 flex-col gap-3 rounded-xl border border-border-default bg-surface-1 p-5",
|
|
76
|
+
creditsHead: "flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1",
|
|
77
|
+
creditsTitle: "m-0 text-sm font-semibold text-fg-secondary",
|
|
78
|
+
creditsFigure: "m-0 font-display text-3xl font-bold tabular-nums text-fg",
|
|
79
|
+
creditsFoot: "m-0 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs text-fg-secondary",
|
|
80
|
+
switchList: "m-0 inline-flex list-none gap-1 rounded-lg border border-border-default bg-surface-1 p-1",
|
|
81
|
+
switchLink: "inline-flex min-h-9 min-w-11 items-center justify-center rounded-md px-3 text-sm font-semibold tabular-nums text-fg-secondary no-underline transition-colors hover:text-fg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring aria-[current=page]:bg-accent-soft aria-[current=page]:text-fg",
|
|
82
|
+
chart: "m-0 flex w-full min-w-0 flex-col gap-3 rounded-xl border border-border-default bg-surface-1 p-5",
|
|
83
|
+
chartTitle: "text-sm font-semibold text-fg",
|
|
84
|
+
plot: "flex h-40 w-full items-end gap-1",
|
|
85
|
+
column: "flex h-full min-w-0 flex-1 flex-col justify-end",
|
|
86
|
+
bar: "flex w-full flex-col-reverse overflow-hidden rounded-sm",
|
|
87
|
+
legend: "m-0 flex list-none flex-wrap gap-x-4 gap-y-1 p-0 text-xs text-fg-secondary",
|
|
88
|
+
swatch: "mr-1.5 inline-block h-2 w-2 rounded-full align-baseline",
|
|
89
|
+
state: "m-0 flex h-40 items-center justify-center rounded-lg border border-dashed border-border-default px-4 text-center text-sm text-fg-secondary",
|
|
90
|
+
skeleton: "h-40 w-full animate-pulse rounded-lg bg-surface-3 motion-reduce:animate-none"
|
|
91
|
+
},
|
|
92
|
+
variants: {
|
|
93
|
+
tone: {
|
|
94
|
+
accent: { swatch: "bg-accent" },
|
|
95
|
+
success: { swatch: "bg-success" },
|
|
96
|
+
warning: { swatch: "bg-warning" },
|
|
97
|
+
danger: { swatch: "bg-danger" },
|
|
98
|
+
muted: { swatch: "bg-border-strong" }
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
var FILL = { accent: "bg-accent", success: "bg-success", warning: "bg-warning", danger: "bg-danger", muted: "bg-border-strong" };
|
|
103
|
+
var CREDIT_WORDS = {
|
|
104
|
+
fr: { of: "sur", left: "restants" },
|
|
105
|
+
en: { of: "of", left: "left" }
|
|
106
|
+
};
|
|
107
|
+
function CreditsMeter({ label, balance, total, renewal, action, locale = "fr-CA", className, ...props }) {
|
|
108
|
+
const s = usage();
|
|
109
|
+
const w = locale.toLowerCase().startsWith("en") ? CREDIT_WORDS.en : CREDIT_WORDS.fr;
|
|
110
|
+
const write = (n) => formatNumber2(n, { locale });
|
|
111
|
+
const words = `${write(balance)} ${w.of} ${write(total)}`;
|
|
112
|
+
return /* @__PURE__ */ jsxs("section", { "aria-label": label, className: s.credits({ className }), ...props, children: [
|
|
113
|
+
/* @__PURE__ */ jsxs("div", { className: s.creditsHead(), children: [
|
|
114
|
+
/* @__PURE__ */ jsx("h3", { className: s.creditsTitle(), children: label }),
|
|
115
|
+
/* @__PURE__ */ jsxs("p", { className: s.creditsFigure(), children: [
|
|
116
|
+
write(balance),
|
|
117
|
+
" ",
|
|
118
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: w.left })
|
|
119
|
+
] })
|
|
120
|
+
] }),
|
|
121
|
+
/* @__PURE__ */ jsx(Meter, { label, value: balance, max: Math.max(1, total), valueText: words, optimum: "high", thresholds: { low: 0.2, high: 0.5 }, size: "lg" }),
|
|
122
|
+
/* @__PURE__ */ jsxs("p", { className: s.creditsFoot(), children: [
|
|
123
|
+
/* @__PURE__ */ jsx("span", { children: words }),
|
|
124
|
+
renewal ? /* @__PURE__ */ jsx("span", { children: renewal }) : null,
|
|
125
|
+
action
|
|
126
|
+
] })
|
|
127
|
+
] });
|
|
128
|
+
}
|
|
129
|
+
function PeriodSwitch({ label, value, href, periods = USAGE_PERIODS, param = "period", periodLabel, locale = "fr-CA", linkAs, className, ...props }) {
|
|
130
|
+
const s = usage();
|
|
131
|
+
const unit = locale.toLowerCase().startsWith("en") ? "d" : "j";
|
|
132
|
+
const text = periodLabel ?? ((days) => `${days} ${unit}`);
|
|
133
|
+
return /* @__PURE__ */ jsx("nav", { "aria-label": label, className, ...props, children: /* @__PURE__ */ jsx("ul", { className: s.switchList(), children: periods.map((days) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(BlockLink, { href: periodHref(href, days, param), linkAs, className: s.switchLink(), "aria-current": days === value ? "page" : void 0, children: text(days) }) }, days)) }) });
|
|
134
|
+
}
|
|
135
|
+
function UsageTiles({ tiles, period, loading, locale, words, className, ...props }) {
|
|
136
|
+
const s = usage();
|
|
137
|
+
if (loading) return /* @__PURE__ */ jsx("div", { "aria-busy": "true", className: s.skeleton({ className: ["h-20", className].filter(Boolean).join(" ") }), ...props });
|
|
138
|
+
return /* @__PURE__ */ jsx(StatGrid, { variant: "strip", items: tiles.map((t) => usageTile(t, { locale, words })), period, className, ...props });
|
|
139
|
+
}
|
|
140
|
+
function Column({ bar, outcomes }) {
|
|
141
|
+
const s = usage();
|
|
142
|
+
return /* @__PURE__ */ jsx("div", { className: s.column(), children: /* @__PURE__ */ jsx("div", { className: s.bar(), style: { height: `${bar.height * 100}%` }, children: bar.segments.map(
|
|
143
|
+
(seg, i) => seg.value > 0 ? /* @__PURE__ */ jsx("span", { className: FILL[outcomes[i]?.tone ?? "muted"], style: { height: `${seg.share * 100}%` } }, seg.id) : null
|
|
144
|
+
) }) });
|
|
145
|
+
}
|
|
146
|
+
function UsageChart({ title, days, outcomes, emptyLabel, columns, loading, locale = "fr-CA", className, ...props }) {
|
|
147
|
+
const s = usage();
|
|
148
|
+
const bars = usageBars(days, outcomes);
|
|
149
|
+
const sum = (id) => days.reduce((n, d) => n + (d.values[id] ?? 0), 0);
|
|
150
|
+
const empty = bars.every((b) => b.total === 0);
|
|
151
|
+
const write = (n) => formatNumber2(n, { locale });
|
|
152
|
+
return /* @__PURE__ */ jsxs("figure", { "aria-busy": loading || void 0, className: s.chart({ className }), ...props, children: [
|
|
153
|
+
/* @__PURE__ */ jsx("figcaption", { className: s.chartTitle(), children: title }),
|
|
154
|
+
loading ? /* @__PURE__ */ jsx("div", { className: s.skeleton() }) : empty ? /* @__PURE__ */ jsx("p", { className: s.state(), children: emptyLabel }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
155
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": true, className: s.plot(), children: bars.map((bar) => /* @__PURE__ */ jsx(Column, { bar, outcomes }, bar.label)) }),
|
|
156
|
+
/* @__PURE__ */ jsx("ul", { className: s.legend(), children: outcomes.map((o) => /* @__PURE__ */ jsxs("li", { children: [
|
|
157
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: s.swatch({ tone: o.tone }) }),
|
|
158
|
+
o.label,
|
|
159
|
+
" ",
|
|
160
|
+
/* @__PURE__ */ jsx("span", { className: "tabular-nums text-fg", children: write(sum(o.id)) })
|
|
161
|
+
] }, o.id)) }),
|
|
162
|
+
/* @__PURE__ */ jsxs("table", { className: "sr-only", children: [
|
|
163
|
+
/* @__PURE__ */ jsx("caption", { children: title }),
|
|
164
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
165
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: columns.day }),
|
|
166
|
+
outcomes.map((o) => /* @__PURE__ */ jsx("th", { scope: "col", children: o.label }, o.id)),
|
|
167
|
+
/* @__PURE__ */ jsx("th", { scope: "col", children: columns.total })
|
|
168
|
+
] }) }),
|
|
169
|
+
/* @__PURE__ */ jsx("tbody", { children: days.map((d, i) => /* @__PURE__ */ jsxs("tr", { children: [
|
|
170
|
+
/* @__PURE__ */ jsx("th", { scope: "row", children: d.label }),
|
|
171
|
+
outcomes.map((o) => /* @__PURE__ */ jsx("td", { children: write(d.values[o.id] ?? 0) }, o.id)),
|
|
172
|
+
/* @__PURE__ */ jsx("td", { children: write(bars[i]?.total ?? 0) })
|
|
173
|
+
] }, d.label)) })
|
|
174
|
+
] })
|
|
175
|
+
] })
|
|
176
|
+
] });
|
|
177
|
+
}
|
|
178
|
+
export {
|
|
179
|
+
CreditsMeter,
|
|
180
|
+
PeriodSwitch,
|
|
181
|
+
USAGE_PERIODS,
|
|
182
|
+
UsageChart,
|
|
183
|
+
UsageTiles,
|
|
184
|
+
parsePeriod,
|
|
185
|
+
periodHref,
|
|
186
|
+
usage,
|
|
187
|
+
usageTile
|
|
188
|
+
};
|
|
189
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/usage/model.ts","../src/usage/usage.tsx"],"sourcesContent":["// Headless: the arithmetic and the words of the usage blocks (period, tiles, chart rows), read by the web entry.\nimport { formatNumber, formatPercent } from \"@krizaka/intl\";\nimport type * as React from \"react\";\n\nimport type { StatStripItem, StatTrend } from \"../stat\";\n\n/** The periods a usage page offers, in days. */\nexport const USAGE_PERIODS = [7, 30, 90] as const;\nexport type UsagePeriod = (typeof USAGE_PERIODS)[number];\n\n/** Reads `?period=` back: anything but an offered period is the default, so the address can never break the page. */\nexport function parsePeriod(raw: string | string[] | null | undefined, allowed: readonly number[] = USAGE_PERIODS, fallback = 30): number {\n const value = Number(Array.isArray(raw) ? raw[0] : raw);\n return allowed.includes(value) ? value : fallback;\n}\n\n/** The address of a period: the same path with `period` set, every other parameter kept. */\nexport function periodHref(base: string, period: number, param = \"period\"): string {\n const [path = \"\", query = \"\"] = base.split(\"?\");\n const params = new URLSearchParams(query);\n params.set(param, String(period));\n return `${path}?${params.toString()}`;\n}\n\nconst WORDS = {\n fr: { vsPrevious: \"{change} vs période précédente\", same: \"stable\", up: \"en hausse\", down: \"en baisse\" },\n en: { vsPrevious: \"{change} vs previous period\", same: \"steady\", up: \"up\", down: \"down\" },\n} as const;\n\nexport type UsageWords = {\n /** The change against the previous period; `{change}` is replaced by the signed percentage. */\n vsPrevious: string;\n /** When the figure did not move. */\n same: string;\n};\n\nconst FLAT = 0.005;\n\nexport interface UsageTileInput {\n id: string;\n label: string;\n value: number;\n /** The same figure for the previous period: the trend is computed from it. */\n previous?: number;\n /** Which direction is good news (latency, failures: `down`). Default `up`. */\n good?: \"up\" | \"down\";\n /** The shape of the period, rendered by the app (a `Sparkline` of @krizaka/charts, 64 × 18). */\n chart?: React.ReactNode;\n /** Digits of the figure. Default 0. */\n digits?: number;\n}\n\nexport interface UsageTileOptions {\n /** Default `fr-CA`: French figures and words with no props. */\n /** The language of the figures and the words. Default `fr-CA`. */\n locale?: string;\n /** Your own words for the change: `{change}` is the percentage. */\n words?: Partial<UsageWords>;\n}\n\nconst wordsOf = (locale: string): (typeof WORDS)[keyof typeof WORDS] => (locale.toLowerCase().startsWith(\"en\") ? WORDS.en : WORDS.fr);\n\nfunction direction(change: number | null): StatTrend | undefined {\n if (change === null) return undefined;\n if (Math.abs(change) < FLAT) return \"flat\";\n return change > 0 ? \"up\" : \"down\";\n}\n\nfunction changeOf(value: number, previous: number | undefined): number | null {\n if (previous === undefined) return null;\n if (previous === 0) return value === 0 ? 0 : null;\n return value / previous - 1;\n}\n\n/** One strip figure: the value written for the locale, the change against the previous period said in words. */\nexport function usageTile(input: UsageTileInput, { locale = \"fr-CA\", words }: UsageTileOptions = {}): StatStripItem {\n const w = { ...wordsOf(locale), ...words };\n const change = changeOf(input.value, input.previous);\n const trend = direction(change);\n const text = change === null ? undefined : trend === \"flat\" ? w.same : w.vsPrevious.replace(\"{change}\", formatPercent(change, { locale, signDisplay: \"exceptZero\", maximumFractionDigits: 0 }));\n return {\n id: input.id,\n label: input.label,\n value: formatNumber(input.value, { locale, maximumFractionDigits: input.digits ?? 0 }),\n trend,\n trendLabel: text,\n chart: input.chart,\n };\n}\n\n/** One bar of the usage chart: a day, its counts by outcome. */\nexport interface UsageDay {\n /** The day, written by the app (`3 nov.`). */\n label: string;\n values: Readonly<Partial<Record<string, number>>>;\n}\n\nexport interface UsageOutcome {\n id: string;\n label: string;\n /** `accent`, `success`, `warning`, `danger` or `muted`: tones of the tokens, never a colour. */\n tone: \"accent\" | \"success\" | \"warning\" | \"danger\" | \"muted\";\n}\n\nexport interface UsageBar {\n label: string;\n total: number;\n /** Height of the whole bar, 0–1 of the tallest day. */\n height: number;\n segments: { id: string; value: number; share: number }[];\n}\n\n/** The bars of the chart: heights relative to the tallest day, segments as shares of their bar. */\nexport function usageBars(days: readonly UsageDay[], outcomes: readonly UsageOutcome[]): UsageBar[] {\n const totals = days.map((d) => outcomes.reduce((sum, o) => sum + (d.values[o.id] ?? 0), 0));\n const max = Math.max(1, ...totals);\n return days.map((d, i) => {\n const total = totals[i] ?? 0;\n return {\n label: d.label,\n total,\n height: total / max,\n segments: outcomes.map((o) => ({ id: o.id, value: d.values[o.id] ?? 0, share: total === 0 ? 0 : (d.values[o.id] ?? 0) / total })),\n };\n });\n}\n","// Server-safe. The blocks of a « Credits & usage » page: the balance on a Meter, the period switch (the address holds it),\n// the figures on the strip, the activity stacked by outcome. Words are props (French by default for the few built in);\n// figures are written with @krizaka/intl. Demo data only in the examples.\nimport { formatNumber } from \"@krizaka/intl\";\nimport type * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { BlockLink, type LinkComponent } from \"../block-link\";\nimport { Meter } from \"../meter\";\nimport { StatGrid } from \"../stat\";\nimport { periodHref, USAGE_PERIODS, type UsageBar, usageBars, type UsageDay, type UsageOutcome, usageTile,type UsageTileInput, type UsageTileOptions } from \"./model\";\n\nexport const usage = tv({\n slots: {\n credits: \"flex w-full min-w-0 flex-col gap-3 rounded-xl border border-border-default bg-surface-1 p-5\",\n creditsHead: \"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1\",\n creditsTitle: \"m-0 text-sm font-semibold text-fg-secondary\",\n creditsFigure: \"m-0 font-display text-3xl font-bold tabular-nums text-fg\",\n creditsFoot: \"m-0 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs text-fg-secondary\",\n switchList: \"m-0 inline-flex list-none gap-1 rounded-lg border border-border-default bg-surface-1 p-1\",\n switchLink:\n \"inline-flex min-h-9 min-w-11 items-center justify-center rounded-md px-3 text-sm font-semibold tabular-nums text-fg-secondary no-underline transition-colors \" +\n \"hover:text-fg focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring aria-[current=page]:bg-accent-soft aria-[current=page]:text-fg\",\n chart: \"m-0 flex w-full min-w-0 flex-col gap-3 rounded-xl border border-border-default bg-surface-1 p-5\",\n chartTitle: \"text-sm font-semibold text-fg\",\n plot: \"flex h-40 w-full items-end gap-1\",\n column: \"flex h-full min-w-0 flex-1 flex-col justify-end\",\n bar: \"flex w-full flex-col-reverse overflow-hidden rounded-sm\",\n legend: \"m-0 flex list-none flex-wrap gap-x-4 gap-y-1 p-0 text-xs text-fg-secondary\",\n swatch: \"mr-1.5 inline-block h-2 w-2 rounded-full align-baseline\",\n state: \"m-0 flex h-40 items-center justify-center rounded-lg border border-dashed border-border-default px-4 text-center text-sm text-fg-secondary\",\n skeleton: \"h-40 w-full animate-pulse rounded-lg bg-surface-3 motion-reduce:animate-none\",\n },\n variants: {\n tone: {\n accent: { swatch: \"bg-accent\" },\n success: { swatch: \"bg-success\" },\n warning: { swatch: \"bg-warning\" },\n danger: { swatch: \"bg-danger\" },\n muted: { swatch: \"bg-border-strong\" },\n },\n },\n});\n\nconst FILL: Record<UsageOutcome[\"tone\"], string> = { accent: \"bg-accent\", success: \"bg-success\", warning: \"bg-warning\", danger: \"bg-danger\", muted: \"bg-border-strong\" };\n\nconst CREDIT_WORDS = {\n fr: { of: \"sur\", left: \"restants\" },\n en: { of: \"of\", left: \"left\" },\n} as const;\n\nexport type CreditsMeterProps = Omit<React.ComponentProps<\"section\">, \"children\"> & {\n /** What the balance is (« Crédits »): the heading and the meter's name. */\n label: string;\n /** Credits left. */\n balance: number;\n /** The allowance of the period; the meter fills with what is left. */\n total: number;\n /** The renewal, written by the app (« Renouvelés le 1er novembre »). */\n renewal?: React.ReactNode;\n /** The way to buy more: a link or a button. */\n action?: React.ReactNode;\n /** Default `fr-CA`. */\n locale?: string;\n};\n\n/** The balance: the figure large, a meter that turns to warning then danger as it runs low, the renewal and the way to buy. */\nexport function CreditsMeter({ label, balance, total, renewal, action, locale = \"fr-CA\", className, ...props }: CreditsMeterProps) {\n const s = usage();\n const w = locale.toLowerCase().startsWith(\"en\") ? CREDIT_WORDS.en : CREDIT_WORDS.fr;\n const write = (n: number) => formatNumber(n, { locale });\n const words = `${write(balance)} ${w.of} ${write(total)}`;\n return (\n <section aria-label={label} className={s.credits({ className })} {...props}>\n <div className={s.creditsHead()}>\n <h3 className={s.creditsTitle()}>{label}</h3>\n <p className={s.creditsFigure()}>\n {write(balance)} <span className=\"sr-only\">{w.left}</span>\n </p>\n </div>\n <Meter label={label} value={balance} max={Math.max(1, total)} valueText={words} optimum=\"high\" thresholds={{ low: 0.2, high: 0.5 }} size=\"lg\" />\n <p className={s.creditsFoot()}>\n <span>{words}</span>\n {renewal ? <span>{renewal}</span> : null}\n {action}\n </p>\n </section>\n );\n}\n\nexport type PeriodSwitchProps = Omit<React.ComponentProps<\"nav\">, \"children\"> & {\n /** The accessible name (« Période »). */\n label: string;\n /** The period shown, from `parsePeriod(searchParams.period)`. */\n value: number;\n /** The page's path (and any other parameters); each period is a link to it with `?period=`. */\n href: string;\n /** The periods offered, in days. Default 7 · 30 · 90. */\n periods?: readonly number[];\n /** The query parameter. Default `period`. */\n param?: string;\n /** The text of a period. Default `7 j` (`7 d` for an English locale). */\n periodLabel?: (days: number) => string;\n /** Default `fr-CA`. */\n locale?: string;\n /** The app's router link (Next's `Link`); default a plain `<a>`. */\n linkAs?: LinkComponent;\n};\n\n/** 7 · 30 · 90 d: links, so the address holds the period (`?period=30`) and the server renders it. */\nexport function PeriodSwitch({ label, value, href, periods = USAGE_PERIODS, param = \"period\", periodLabel, locale = \"fr-CA\", linkAs, className, ...props }: PeriodSwitchProps) {\n const s = usage();\n const unit = locale.toLowerCase().startsWith(\"en\") ? \"d\" : \"j\";\n const text = periodLabel ?? ((days: number) => `${days} ${unit}`);\n return (\n <nav aria-label={label} className={className} {...props}>\n <ul className={s.switchList()}>\n {periods.map((days) => (\n <li key={days}>\n <BlockLink href={periodHref(href, days, param)} linkAs={linkAs} className={s.switchLink()} aria-current={days === value ? \"page\" : undefined}>\n {text(days)}\n </BlockLink>\n </li>\n ))}\n </ul>\n </nav>\n );\n}\n\nexport type UsageTilesProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** 2 to 4 figures. */\n tiles: readonly UsageTileInput[];\n /** The period switch, above the row. */\n period?: React.ReactNode;\n /** The data is on its way: the row keeps its height. */\n loading?: boolean;\n} & UsageTileOptions;\n\n/** The figures of the period on the strip, each compared with the previous period in words. */\nexport function UsageTiles({ tiles, period, loading, locale, words, className, ...props }: UsageTilesProps) {\n const s = usage();\n if (loading) return <div aria-busy=\"true\" className={s.skeleton({ className: [\"h-20\", className].filter(Boolean).join(\" \") })} {...props} />;\n return <StatGrid variant=\"strip\" items={tiles.map((t) => usageTile(t, { locale, words }))} period={period} className={className} {...props} />;\n}\n\nexport type UsageChartProps = Omit<React.ComponentProps<\"figure\">, \"children\"> & {\n /** What it draws (« Activité par résultat »). */\n title: string;\n /** The days, oldest first. */\n days: readonly UsageDay[];\n /** The outcomes stacked in each bar, bottom first. */\n outcomes: readonly UsageOutcome[];\n /** Said when there is nothing in the period. */\n emptyLabel: string;\n /** The text version's column headings: the day, the total. */\n columns: { day: string; total: string };\n /** The data is on its way: a skeleton keeps the height. */\n loading?: boolean;\n /** Default `fr-CA`. */\n locale?: string;\n};\n\nfunction Column({ bar, outcomes }: { bar: UsageBar; outcomes: readonly UsageOutcome[] }) {\n const s = usage();\n return (\n <div className={s.column()}>\n <div className={s.bar()} style={{ height: `${bar.height * 100}%` }}>\n {bar.segments.map((seg, i) =>\n seg.value > 0 ? <span key={seg.id} className={FILL[outcomes[i]?.tone ?? \"muted\"]} style={{ height: `${seg.share * 100}%` }} /> : null,\n )}\n </div>\n </div>\n );\n}\n\n/** The activity of the period, one bar per day stacked by outcome — with its legend and its text version (a table). */\nexport function UsageChart({ title, days, outcomes, emptyLabel, columns, loading, locale = \"fr-CA\", className, ...props }: UsageChartProps) {\n const s = usage();\n const bars = usageBars(days, outcomes);\n const sum = (id: string) => days.reduce((n, d) => n + (d.values[id] ?? 0), 0);\n const empty = bars.every((b) => b.total === 0);\n const write = (n: number) => formatNumber(n, { locale });\n return (\n <figure aria-busy={loading || undefined} className={s.chart({ className })} {...props}>\n <figcaption className={s.chartTitle()}>{title}</figcaption>\n {loading ? (\n <div className={s.skeleton()} />\n ) : empty ? (\n <p className={s.state()}>{emptyLabel}</p>\n ) : (\n <>\n <div aria-hidden className={s.plot()}>\n {bars.map((bar) => (\n <Column key={bar.label} bar={bar} outcomes={outcomes} />\n ))}\n </div>\n <ul className={s.legend()}>\n {outcomes.map((o) => (\n <li key={o.id}>\n <span aria-hidden className={s.swatch({ tone: o.tone })} />\n {o.label} <span className=\"tabular-nums text-fg\">{write(sum(o.id))}</span>\n </li>\n ))}\n </ul>\n <table className=\"sr-only\">\n <caption>{title}</caption>\n <thead>\n <tr>\n <th scope=\"col\">{columns.day}</th>\n {outcomes.map((o) => (\n <th key={o.id} scope=\"col\">\n {o.label}\n </th>\n ))}\n <th scope=\"col\">{columns.total}</th>\n </tr>\n </thead>\n <tbody>\n {days.map((d, i) => (\n <tr key={d.label}>\n <th scope=\"row\">{d.label}</th>\n {outcomes.map((o) => (\n <td key={o.id}>{write(d.values[o.id] ?? 0)}</td>\n ))}\n <td>{write(bars[i]?.total ?? 0)}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </>\n )}\n </figure>\n );\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAS,cAAc,qBAAqB;AAMrC,IAAM,gBAAgB,CAAC,GAAG,IAAI,EAAE;AAIhC,SAAS,YAAY,KAA2C,UAA6B,eAAe,WAAW,IAAY;AACxI,QAAM,QAAQ,OAAO,MAAM,QAAQ,GAAG,IAAI,IAAI,CAAC,IAAI,GAAG;AACtD,SAAO,QAAQ,SAAS,KAAK,IAAI,QAAQ;AAC3C;AAGO,SAAS,WAAW,MAAc,QAAgB,QAAQ,UAAkB;AACjF,QAAM,CAAC,OAAO,IAAI,QAAQ,EAAE,IAAI,KAAK,MAAM,GAAG;AAC9C,QAAM,SAAS,IAAI,gBAAgB,KAAK;AACxC,SAAO,IAAI,OAAO,OAAO,MAAM,CAAC;AAChC,SAAO,GAAG,IAAI,IAAI,OAAO,SAAS,CAAC;AACrC;AAEA,IAAM,QAAQ;AAAA,EACZ,IAAI,EAAE,YAAY,2CAAkC,MAAM,UAAU,IAAI,aAAa,MAAM,YAAY;A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OAAM,OAAO,kBAAQ,KAAI;AAAA,UAC5B,SAAS,IAAI,CAAC,MACb,oBAAC,QAAc,OAAM,OAClB,YAAE,SADI,EAAE,EAEX,CACD;AAAA,UACD,oBAAC,QAAG,OAAM,OAAO,kBAAQ,OAAM;AAAA,WACjC,GACF;AAAA,QACA,oBAAC,WACE,eAAK,IAAI,CAAC,GAAG,MACZ,qBAAC,QACC;AAAA,8BAAC,QAAG,OAAM,OAAO,YAAE,OAAM;AAAA,UACxB,SAAS,IAAI,CAAC,MACb,oBAAC,QAAe,gBAAM,EAAE,OAAO,EAAE,EAAE,KAAK,CAAC,KAAhC,EAAE,EAAgC,CAC5C;AAAA,UACD,oBAAC,QAAI,gBAAM,KAAK,CAAC,GAAG,SAAS,CAAC,GAAE;AAAA,aALzB,EAAE,KAMX,CACD,GACH;AAAA,SACF;AAAA,OACF;AAAA,KAEJ;AAEJ;","names":["formatNumber","formatNumber"]}
|
package/dist/vertical-video.js
CHANGED
package/dist/wall.d.ts
CHANGED
|
@@ -14,9 +14,15 @@ interface PinnedNoteProps extends Omit<React.ComponentProps<"article">, "childre
|
|
|
14
14
|
text: string;
|
|
15
15
|
/** The optional author's signature, written in the handwriting role. */
|
|
16
16
|
signature?: string;
|
|
17
|
+
/** The ink of the pen: blue ink, the margin's red, or the page's hue. @default "blue" */
|
|
18
|
+
ink?: "blue" | "margin" | "hue";
|
|
19
|
+
/** How the note is held, through `Stuck`: a strip of tape or a pin. Takes over `attachment`. @default "tape" */
|
|
20
|
+
hold?: "tape" | "pin";
|
|
21
|
+
/** The lines of the text box, fixed so a late font never shifts the page (the text is read in full by assistive technology). @default 4 */
|
|
22
|
+
lines?: number;
|
|
17
23
|
}
|
|
18
|
-
/** A short word on a cut-corner card. */
|
|
19
|
-
declare function PinnedNote({ text, signature, rotation, attachment, attachmentRotation, className, ...props }: PinnedNoteProps): React.JSX.Element;
|
|
24
|
+
/** A short word on a cut-corner card, stuck into the notebook. */
|
|
25
|
+
declare function PinnedNote({ text, signature, rotation, attachment, attachmentRotation: _attachmentRotation, ink, hold, lines, className, ...props }: PinnedNoteProps): React.JSX.Element;
|
|
20
26
|
|
|
21
27
|
interface PolaroidProps extends Omit<React.ComponentProps<"figure">, "children" | "style">, WallObjectProps {
|
|
22
28
|
/** The photo slot: an img or next/image, including fill inside this positioned frame. Supply its alt text. */
|
|
@@ -29,18 +35,22 @@ interface PolaroidProps extends Omit<React.ComponentProps<"figure">, "children"
|
|
|
29
35
|
/** A photo held to the wall by tape or a pin, with a handwritten caption. */
|
|
30
36
|
declare function Polaroid({ img, caption, rotation, attachment, attachmentRotation, develop, className, ...props }: PolaroidProps): React.JSX.Element;
|
|
31
37
|
|
|
32
|
-
interface ShopSignProps extends Omit<React.ComponentProps<"div">, "
|
|
33
|
-
/** The
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
|
|
38
|
+
interface ShopSignProps extends Omit<React.ComponentProps<"div">, "style"> {
|
|
39
|
+
/** The shop's name as live text, in the sign's lettering: the page's heading (`as`). Prefer it to an image of the name. */
|
|
40
|
+
children?: React.ReactNode;
|
|
41
|
+
/** The element of the name: the page's `h1` by default, `h2`/`h3` for a second sign, `p` for none. A sign on a `Wall` is a `p` unless told otherwise. */
|
|
42
|
+
as?: "h1" | "h2" | "h3" | "p";
|
|
43
|
+
/** The owner's logo or wordmark, optional beside the name. Name an SVG/image accessibly, or use readable text. */
|
|
44
|
+
logo?: React.ReactNode;
|
|
45
|
+
/** Enamel plate and screws, softly glowing neon, a time-worn painted sign, or `none` (the name alone on paper). */
|
|
46
|
+
variant?: "enamel" | "neon" | "painted" | "none";
|
|
37
47
|
/** Deterministic tilt in degrees; defaults to zero. */
|
|
38
48
|
rotation?: number;
|
|
39
|
-
/** Allow
|
|
49
|
+
/** Allow one soft neon flicker the first time the sign is seen; defaults to true, never loops, respects reduced motion. */
|
|
40
50
|
animated?: boolean;
|
|
41
51
|
}
|
|
42
|
-
/** A shop's own mark, as a plate, a neon,
|
|
43
|
-
declare function ShopSign({ logo, variant, rotation, animated, className, ...props }: ShopSignProps): React.JSX.Element;
|
|
52
|
+
/** A shop's own mark, as a plate, a neon, a painted sign, or the name alone. */
|
|
53
|
+
declare function ShopSign({ children, as: Name, logo, variant, rotation, animated, className, ...props }: ShopSignProps): React.JSX.Element;
|
|
44
54
|
|
|
45
55
|
interface WallPosition {
|
|
46
56
|
/** Stable identity for this object. */
|
|
@@ -67,13 +77,15 @@ interface WallProps extends Omit<React.ComponentProps<"ul">, "children" | "style
|
|
|
67
77
|
items: readonly WallItem[];
|
|
68
78
|
/** CSS/SVG texture; no image download. Defaults to plaster. */
|
|
69
79
|
texture?: "brick" | "zellige" | "ridge" | "plaster";
|
|
70
|
-
/**
|
|
80
|
+
/** Draws at most this many items (the first in z order); defaults to 12. The rest belongs to the host's « see the whole wall ». */
|
|
81
|
+
max?: number;
|
|
82
|
+
/** A fixed desktop surface height in pixels (minimum 320). Absent, the surface is a fixed 16:9 box. Phones grow with content. */
|
|
71
83
|
height?: number;
|
|
72
84
|
/** Desktop object width in pixels (minimum 120); defaults to 240 and never exceeds the surface. */
|
|
73
85
|
itemWidth?: number;
|
|
74
86
|
}
|
|
75
87
|
/** A decorative textured surface over a real keyboard-reachable list; never an editor. */
|
|
76
|
-
declare function Wall({ items, texture, height, itemWidth, className, ...props }: WallProps): React.JSX.Element;
|
|
88
|
+
declare function Wall({ items, texture, max, height, itemWidth, className, ...props }: WallProps): React.JSX.Element;
|
|
77
89
|
|
|
78
90
|
export { PinnedNote, Polaroid, ShopSign, Wall };
|
|
79
91
|
export type { PinnedNoteProps, PolaroidProps, ShopSignProps, WallItem, WallPosition, WallProps };
|
package/dist/wall.js
CHANGED
|
@@ -7,29 +7,51 @@ import {
|
|
|
7
7
|
cn
|
|
8
8
|
} from "./chunk-WU4VLSEA.js";
|
|
9
9
|
|
|
10
|
-
// src/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("kz-wall-attachment", attachment === "pin" ? "kz-wall-pin" : "kz-wall-tape"), style: { transform: `rotate(${finite(attachmentRotation)}deg)` } });
|
|
10
|
+
// src/cahier-seed.ts
|
|
11
|
+
function seedUnit(seed) {
|
|
12
|
+
let h = 2166136261;
|
|
13
|
+
for (let i = 0; i < seed.length; i++) h = Math.imul(h ^ seed.charCodeAt(i), 16777619);
|
|
14
|
+
return (h >>> 0) % 2001 / 1e3 - 1;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
|
-
// src/
|
|
19
|
-
import { jsx
|
|
20
|
-
function
|
|
21
|
-
return
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
// src/stuck/stuck.tsx
|
|
18
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
function stuckTilt(seed, tilt) {
|
|
20
|
+
return tilt ?? Math.round(seedUnit(seed) * 20) / 10;
|
|
21
|
+
}
|
|
22
|
+
function Stuck({ children, hold = "tape", tilt, seed = "", doodle, as: Tag = "div", className, style, ...props }) {
|
|
23
|
+
return /* @__PURE__ */ jsxs(Tag, { className: cn("kz-stuck", className), style, ...props, children: [
|
|
24
|
+
/* @__PURE__ */ jsxs("div", { className: "kz-stuck-body", "data-hold": hold, style: { ["--kz-stuck-tilt"]: `${stuckTilt(seed, tilt)}deg` }, children: [
|
|
25
|
+
hold === "pin" ? /* @__PURE__ */ jsx("span", { className: "kz-stuck-pin", "aria-hidden": true }) : null,
|
|
26
|
+
children
|
|
27
|
+
] }),
|
|
28
|
+
doodle
|
|
27
29
|
] });
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
// src/wall/pinned-note.tsx
|
|
33
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
34
|
+
function PinnedNote({ text, signature, rotation = 0, attachment, attachmentRotation: _attachmentRotation, ink = "blue", hold, lines = 4, className, ...props }) {
|
|
35
|
+
const rows = Math.max(1, Math.round(Number.isFinite(lines) ? lines : 4));
|
|
36
|
+
return /* @__PURE__ */ jsx2(Stuck, { hold: hold ?? attachment ?? "tape", tilt: Number.isFinite(rotation) ? rotation : 0, className: "kz-wall-object kz-pinned-stuck", children: /* @__PURE__ */ jsx2("article", { ...props, className: cn("kz-pinned-note", className), "data-shape": "cut", "data-ink": ink, style: { "--kz-note-lines": rows }, children: /* @__PURE__ */ jsxs2("div", { className: "kz-pinned-note-paper", children: [
|
|
37
|
+
/* @__PURE__ */ jsx2("p", { className: "kz-pinned-note-text", children: Array.from(text).slice(0, 140).join("") }),
|
|
38
|
+
signature && /* @__PURE__ */ jsx2("p", { className: "kz-pinned-note-signature", children: signature })
|
|
39
|
+
] }) }) });
|
|
40
|
+
}
|
|
41
|
+
|
|
30
42
|
// src/wall/polaroid.tsx
|
|
31
43
|
import * as React from "react";
|
|
32
|
-
|
|
44
|
+
|
|
45
|
+
// src/wall/attachment.tsx
|
|
46
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
47
|
+
var finite = (value) => Number.isFinite(value) ? value : 0;
|
|
48
|
+
var rotationStyle = (rotation) => ({ "--kz-wall-rotation": `${finite(rotation)}deg` });
|
|
49
|
+
function Attachment({ attachment = "tape", attachmentRotation = 0 }) {
|
|
50
|
+
return /* @__PURE__ */ jsx3("span", { "aria-hidden": "true", className: cn("kz-wall-attachment", attachment === "pin" ? "kz-wall-pin" : "kz-wall-tape"), style: { transform: `rotate(${finite(attachmentRotation)}deg)` } });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/wall/polaroid.tsx
|
|
54
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
33
55
|
function Polaroid({ img, caption, rotation = 0, attachment = "tape", attachmentRotation = 0, develop = true, className, ...props }) {
|
|
34
56
|
const ref = React.useRef(null);
|
|
35
57
|
const [state, setState] = React.useState();
|
|
@@ -61,7 +83,7 @@ function Polaroid({ img, caption, rotation = 0, attachment = "tape", attachmentR
|
|
|
61
83
|
preference.removeEventListener("change", sync);
|
|
62
84
|
};
|
|
63
85
|
}, [develop]);
|
|
64
|
-
return /* @__PURE__ */
|
|
86
|
+
return /* @__PURE__ */ jsxs3(
|
|
65
87
|
TapedPhoto,
|
|
66
88
|
{
|
|
67
89
|
...props,
|
|
@@ -72,49 +94,90 @@ function Polaroid({ img, caption, rotation = 0, attachment = "tape", attachmentR
|
|
|
72
94
|
style: { "--kz-wall-attachment-rotation": `${finite(attachmentRotation)}deg` },
|
|
73
95
|
"data-develop": develop ? state : void 0,
|
|
74
96
|
children: [
|
|
75
|
-
attachment === "pin" && /* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
97
|
+
attachment === "pin" && /* @__PURE__ */ jsx4(Attachment, { attachment: "pin", attachmentRotation }),
|
|
98
|
+
/* @__PURE__ */ jsx4("div", { ref, className: "kz-polaroid-photo", children: img })
|
|
77
99
|
]
|
|
78
100
|
}
|
|
79
101
|
);
|
|
80
102
|
}
|
|
81
103
|
|
|
82
104
|
// src/wall/shop-sign.tsx
|
|
83
|
-
import
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
105
|
+
import * as React2 from "react";
|
|
106
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
107
|
+
function useFirstView(enabled) {
|
|
108
|
+
const ref = React2.useRef(null);
|
|
109
|
+
const [state, setState] = React2.useState();
|
|
110
|
+
React2.useEffect(() => {
|
|
111
|
+
if (!enabled || !ref.current || typeof IntersectionObserver === "undefined" || typeof matchMedia === "undefined") return;
|
|
112
|
+
const preference = matchMedia("(prefers-reduced-motion: reduce)");
|
|
113
|
+
let seen = false;
|
|
114
|
+
let observer;
|
|
115
|
+
const sync = () => {
|
|
116
|
+
observer?.disconnect();
|
|
117
|
+
if (preference.matches) {
|
|
118
|
+
setState(void 0);
|
|
119
|
+
} else if (!seen) {
|
|
120
|
+
setState("waiting");
|
|
121
|
+
observer = new IntersectionObserver((entries) => {
|
|
122
|
+
if (seen || !entries.some((entry) => entry.isIntersecting)) return;
|
|
123
|
+
seen = true;
|
|
124
|
+
setState("ready");
|
|
125
|
+
observer?.disconnect();
|
|
126
|
+
}, { threshold: 0.3 });
|
|
127
|
+
observer.observe(ref.current);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
sync();
|
|
131
|
+
preference.addEventListener("change", sync);
|
|
132
|
+
return () => {
|
|
133
|
+
observer?.disconnect();
|
|
134
|
+
preference.removeEventListener("change", sync);
|
|
135
|
+
};
|
|
136
|
+
}, [enabled]);
|
|
137
|
+
return [ref, state];
|
|
138
|
+
}
|
|
139
|
+
function ShopSign({ children, as: Name = "h1", logo, variant = "enamel", rotation = 0, animated = true, className, ...props }) {
|
|
140
|
+
const [ref, lit] = useFirstView(variant === "neon" && animated);
|
|
141
|
+
return /* @__PURE__ */ jsxs4("div", { ...props, ref, className: cn("kz-shop-sign kz-wall-object", className), style: rotationStyle(rotation), "data-variant": variant, "data-animated": animated ? "" : void 0, "data-lit": lit, children: [
|
|
142
|
+
variant === "enamel" && [0, 1, 2, 3].map((corner) => /* @__PURE__ */ jsx5("span", { "aria-hidden": "true", className: "kz-shop-sign-screw", "data-corner": corner }, corner)),
|
|
143
|
+
logo && /* @__PURE__ */ jsx5("div", { className: "kz-shop-sign-logo", children: logo }),
|
|
144
|
+
children && /* @__PURE__ */ jsx5(Name, { className: "kz-shop-sign-name", children })
|
|
88
145
|
] });
|
|
89
146
|
}
|
|
90
147
|
|
|
91
148
|
// src/wall/wall.tsx
|
|
92
|
-
import * as
|
|
93
|
-
import { jsx as
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
return /* @__PURE__ */
|
|
97
|
-
|
|
149
|
+
import * as React3 from "react";
|
|
150
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
151
|
+
function WallObject({ item }) {
|
|
152
|
+
if (item.kind === "polaroid") return /* @__PURE__ */ jsx6(Polaroid, { ...item, rotation: 0 });
|
|
153
|
+
if (item.kind === "note") return /* @__PURE__ */ jsx6(PinnedNote, { ...item, rotation: 0 });
|
|
154
|
+
return /* @__PURE__ */ jsx6(ShopSign, { ...item, as: item.as ?? "p", rotation: 0 });
|
|
155
|
+
}
|
|
156
|
+
function Wall({ items, texture = "plaster", max = 12, height, itemWidth = 240, className, ...props }) {
|
|
157
|
+
const patternId = React3.useId().replace(/:/g, "");
|
|
158
|
+
const drawn = Math.max(0, Math.floor(finite(max)));
|
|
159
|
+
return /* @__PURE__ */ jsxs5("ul", { ...props, role: "list", className: cn("kz-wall", className), "data-texture": texture, "data-count": Math.min(items.length, drawn), "data-fixed-height": height === void 0 ? void 0 : "", style: { ...height === void 0 ? null : { "--kz-wall-height": `${Math.max(320, finite(height))}px` }, "--kz-wall-item-width": `${Math.max(120, finite(itemWidth))}px` }, children: [
|
|
160
|
+
[...items].sort((a, b) => finite(a.z) - finite(b.z)).slice(0, drawn).map(({ id, x, y, rotation = 0, z: _z, ...item }, rank) => /* @__PURE__ */ jsx6("li", { className: "kz-wall-item", tabIndex: 0, style: {
|
|
98
161
|
"--kz-wall-x": `${Math.min(100, Math.max(0, finite(x)))}%`,
|
|
99
162
|
"--kz-wall-y": `${Math.min(100, Math.max(0, finite(y)))}%`,
|
|
100
163
|
"--kz-wall-rotation": `${finite(rotation)}deg`,
|
|
101
164
|
zIndex: rank
|
|
102
|
-
}, children:
|
|
103
|
-
texture === "brick" && /* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
/* @__PURE__ */
|
|
165
|
+
}, children: /* @__PURE__ */ jsx6(WallObject, { item }) }, id)),
|
|
166
|
+
texture === "brick" && /* @__PURE__ */ jsx6("li", { className: "kz-wall-decoration", "aria-hidden": "true", role: "presentation", children: /* @__PURE__ */ jsxs5("svg", { width: "100%", height: "100%", "aria-hidden": "true", children: [
|
|
167
|
+
/* @__PURE__ */ jsx6("defs", { children: /* @__PURE__ */ jsx6("pattern", { id: patternId, width: "96", height: "48", patternUnits: "userSpaceOnUse", children: /* @__PURE__ */ jsx6("path", { d: "M0 0H96M0 24H96M0 48H96M48 0V24M0 24V48M96 24V48", fill: "none", stroke: "var(--kz-border-default)", strokeWidth: "2" }) }) }),
|
|
168
|
+
/* @__PURE__ */ jsx6("rect", { width: "100%", height: "100%", fill: `url(#${patternId})` })
|
|
106
169
|
] }) }),
|
|
107
|
-
texture === "zellige" && /* @__PURE__ */
|
|
108
|
-
/* @__PURE__ */
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
170
|
+
texture === "zellige" && /* @__PURE__ */ jsx6("li", { className: "kz-wall-decoration", "aria-hidden": "true", role: "presentation", children: /* @__PURE__ */ jsxs5("svg", { width: "100%", height: "100%", "aria-hidden": "true", children: [
|
|
171
|
+
/* @__PURE__ */ jsx6("defs", { children: /* @__PURE__ */ jsxs5("pattern", { id: patternId, width: "64", height: "64", patternUnits: "userSpaceOnUse", children: [
|
|
172
|
+
/* @__PURE__ */ jsx6("path", { d: "M32 3 39 15 52 12 49 25 61 32 49 39 52 52 39 49 32 61 25 49 12 52 15 39 3 32 15 25 12 12 25 15Z", fill: "var(--kz-accent-soft)", stroke: "var(--kz-border-default)" }),
|
|
173
|
+
/* @__PURE__ */ jsx6("path", { d: "m32 18 14 14-14 14-14-14Z", fill: "var(--kz-surface-2)", stroke: "var(--kz-accent-2)" })
|
|
111
174
|
] }) }),
|
|
112
|
-
/* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ jsx6("rect", { width: "100%", height: "100%", fill: `url(#${patternId})` })
|
|
113
176
|
] }) }),
|
|
114
|
-
texture === "ridge" && /* @__PURE__ */
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
177
|
+
texture === "ridge" && /* @__PURE__ */ jsx6("li", { className: "kz-wall-decoration", "aria-hidden": "true", role: "presentation", children: /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 1000 600", preserveAspectRatio: "none", width: "100%", height: "100%", "aria-hidden": "true", children: [
|
|
178
|
+
/* @__PURE__ */ jsx6("path", { d: "M0 380 170 100 290 300 450 70 620 330 790 120 1000 350V600H0Z", fill: "var(--kz-accent-soft)" }),
|
|
179
|
+
/* @__PURE__ */ jsx6("path", { d: "M0 470 200 280 370 440 600 190 760 400 920 260 1000 390V600H0Z", fill: "var(--kz-surface-2)" }),
|
|
180
|
+
/* @__PURE__ */ jsx6("path", { d: "M0 540 180 430 360 520 540 390 760 520 900 410 1000 480V600H0Z", fill: "var(--kz-surface-3)" })
|
|
118
181
|
] }) })
|
|
119
182
|
] });
|
|
120
183
|
}
|