@joanroucoux/cairn-ui 0.10.0 → 0.11.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/CHANGELOG.md +37 -0
- package/README.md +2 -0
- package/fesm2022/joanroucoux-cairn-ui-action-bar.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-alert.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-amount.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-async.mjs +85 -81
- package/fesm2022/joanroucoux-cairn-ui-async.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-avatar.mjs +6 -6
- package/fesm2022/joanroucoux-cairn-ui-back-link.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-badge.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-button.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-card.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-choice-chips.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-choice-chips.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-delta.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-dialog.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-dialog.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-donut.mjs +7 -7
- package/fesm2022/joanroucoux-cairn-ui-donut.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-drawer.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-drawer.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-empty.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-empty.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-external-link.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-external-link.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-fact.mjs +6 -6
- package/fesm2022/joanroucoux-cairn-ui-fact.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-field.mjs +9 -9
- package/fesm2022/joanroucoux-cairn-ui-filter-chips.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-group-header.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-group-header.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-icon-toggle.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-input.mjs +6 -6
- package/fesm2022/joanroucoux-cairn-ui-input.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-line-chart.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-menu.mjs +17 -10
- package/fesm2022/joanroucoux-cairn-ui-menu.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-meter.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-motion.mjs +12 -12
- package/fesm2022/joanroucoux-cairn-ui-nav-item.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-result-group.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-result-group.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-row.mjs +15 -15
- package/fesm2022/joanroucoux-cairn-ui-row.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-segmented.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-select-pill.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-select.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-skeleton.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-stale-link.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-stale-link.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-stat.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-switch.mjs +3 -3
- package/fesm2022/joanroucoux-cairn-ui-tab-bar.mjs +6 -6
- package/fesm2022/joanroucoux-cairn-ui-table.mjs +27 -27
- package/fesm2022/joanroucoux-cairn-ui-table.mjs.map +1 -1
- package/fesm2022/joanroucoux-cairn-ui-toast.mjs +7 -7
- package/fesm2022/joanroucoux-cairn-ui-toast.mjs.map +1 -1
- package/mcp-manifest.json +1 -0
- package/package.json +5 -2
- package/styles/theme.css +4 -0
- package/styles/tokens.css +0 -4
- package/types/joanroucoux-cairn-ui-async.d.ts +7 -5
- package/types/joanroucoux-cairn-ui-choice-chips.d.ts +2 -2
- package/types/joanroucoux-cairn-ui-dialog.d.ts +3 -0
- package/types/joanroucoux-cairn-ui-donut.d.ts +1 -1
- package/types/joanroucoux-cairn-ui-drawer.d.ts +1 -1
- package/types/joanroucoux-cairn-ui-empty.d.ts +3 -3
- package/types/joanroucoux-cairn-ui-external-link.d.ts +1 -1
- package/types/joanroucoux-cairn-ui-fact.d.ts +1 -1
- package/types/joanroucoux-cairn-ui-group-header.d.ts +1 -1
- package/types/joanroucoux-cairn-ui-input.d.ts +4 -1
- package/types/joanroucoux-cairn-ui-menu.d.ts +3 -3
- package/types/joanroucoux-cairn-ui-result-group.d.ts +3 -3
- package/types/joanroucoux-cairn-ui-row.d.ts +1 -1
- package/types/joanroucoux-cairn-ui-stale-link.d.ts +2 -2
- package/types/joanroucoux-cairn-ui-table.d.ts +16 -6
- package/types/joanroucoux-cairn-ui-toast.d.ts +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joanroucoux-cairn-ui-choice-chips.mjs","names":[],"sources":["../../../projects/ui/choice-chips/choice-chips.ts"],"sourcesContent":["import {\n Component,\n ElementRef,\n booleanAttribute,\n computed,\n forwardRef,\n inject,\n input,\n model,\n output,\n viewChildren,\n} from '@angular/core';\n\nimport { UI_CONTROL, type UiControl, type UiControlError } from '@joanroucoux/cairn-ui/control';\nimport { CONTROL_SURFACE_CLASSES, type ControlSurface } from '@joanroucoux/cairn-ui/input';\n\nexport type ChoiceChipOption = {\n value: string;\n label: string;\n};\n\nconst CHIP_CLASSES =\n 'h-10 px-3.5 pointer-fine:h-8 pointer-fine:px-3 rounded-pill text-label font-medium cursor-pointer transition-transform duration-(--duration-press) ease-out active:scale-(--press-scale) disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)';\n\nconst SELECTED_CLASSES = 'bg-(--primary) text-(--primary-foreground)';\n\nconst UNSELECTED_CLASSES = 'text-(--foreground) shadow-[inset_0_0_0_1px_var(--border)]';\n\nconst nextId = (() => {\n let count = 0;\n\n return (): string => `ui-choice-chips-${++count}`;\n})();\n\n/**\n * Exclusive choice among a handful of named options, shown as wrapping pills. Binds to Signal Forms\n * with `[formField]`.\n *\n * @example\n * <ui-choice-chips label=\"
|
|
1
|
+
{"version":3,"file":"joanroucoux-cairn-ui-choice-chips.mjs","names":[],"sources":["../../../projects/ui/choice-chips/choice-chips.ts"],"sourcesContent":["import {\n Component,\n ElementRef,\n booleanAttribute,\n computed,\n forwardRef,\n inject,\n input,\n model,\n output,\n viewChildren,\n} from '@angular/core';\n\nimport { UI_CONTROL, type UiControl, type UiControlError } from '@joanroucoux/cairn-ui/control';\nimport { CONTROL_SURFACE_CLASSES, type ControlSurface } from '@joanroucoux/cairn-ui/input';\n\nexport type ChoiceChipOption = {\n value: string;\n label: string;\n};\n\nconst CHIP_CLASSES =\n 'h-10 px-3.5 pointer-fine:h-8 pointer-fine:px-3 rounded-pill text-label font-medium cursor-pointer transition-transform duration-(--duration-press) ease-out active:scale-(--press-scale) disabled:cursor-not-allowed disabled:opacity-50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring)';\n\nconst SELECTED_CLASSES = 'bg-(--primary) text-(--primary-foreground)';\n\nconst UNSELECTED_CLASSES = 'text-(--foreground) shadow-[inset_0_0_0_1px_var(--border)]';\n\nconst nextId = (() => {\n let count = 0;\n\n return (): string => `ui-choice-chips-${++count}`;\n})();\n\n/**\n * Exclusive choice among a handful of named options, shown as wrapping pills. Binds to Signal Forms\n * with `[formField]`.\n *\n * @example\n * <ui-choice-chips label=\"Wrapper\" [options]=\"wrappers\" [(value)]=\"wrapper\" />\n *\n * @example\n * <ui-choice-chips label=\"Wrapper\" [options]=\"wrappers\" [formField]=\"form.wrapper\" />\n */\n@Component({\n selector: 'ui-choice-chips',\n template: `\n <div\n class=\"flex flex-col gap-1.5\"\n role=\"radiogroup\"\n [attr.aria-invalid]=\"invalid() || null\"\n [attr.aria-label]=\"ariaLabel() ?? null\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [attr.aria-required]=\"required() || null\"\n (focusout)=\"onFocusOut($event)\"\n >\n @if (label()) {\n <span class=\"text-label leading-[17px] font-medium text-(--muted-foreground)\" [id]=\"labelId\">{{\n label()\n }}</span>\n }\n\n <div class=\"flex flex-wrap gap-1.5\">\n @for (option of options(); track option.value; let index = $index) {\n <button\n #radio\n role=\"radio\"\n type=\"button\"\n [attr.aria-checked]=\"option.value === value()\"\n [attr.tabindex]=\"tabIndexFor(option.value)\"\n [class]=\"chipClasses(option.value)\"\n [disabled]=\"disabled()\"\n (click)=\"select(option.value)\"\n (keydown)=\"onKeydown($event, index)\"\n >\n {{ option.label }}\n </button>\n }\n </div>\n </div>\n `,\n providers: [{ provide: UI_CONTROL, useExisting: forwardRef(() => UiChoiceChips) }],\n})\nexport class UiChoiceChips implements UiControl {\n readonly options = input.required<ChoiceChipOption[]>();\n readonly value = model.required<string>();\n readonly label = input<string>();\n readonly ariaLabel = input<string>();\n readonly ariaLabelledby = input<string>();\n readonly surface = input<ControlSurface>('background');\n readonly disabled = input(false, { transform: booleanAttribute });\n readonly errors = input<readonly UiControlError[]>([]);\n readonly invalid = input(false, { transform: booleanAttribute });\n readonly required = input(false, { transform: booleanAttribute });\n readonly touched = input(false);\n readonly touch = output<void>();\n\n protected readonly labelId = nextId();\n readonly #host = inject<ElementRef<HTMLElement>>(ElementRef);\n protected readonly radios = viewChildren<ElementRef<HTMLButtonElement>>('radio');\n\n protected readonly labelledBy = computed(() => this.ariaLabelledby() ?? (this.label() ? this.labelId : null));\n\n protected chipClasses(optionValue: string): string {\n const state =\n optionValue === this.value()\n ? SELECTED_CLASSES\n : `${CONTROL_SURFACE_CLASSES[this.surface()]} ${UNSELECTED_CLASSES}`;\n\n return `${CHIP_CLASSES} ${state}`;\n }\n\n protected tabIndexFor(optionValue: string): number {\n const opts = this.options();\n const tabStopValue = opts.some((option) => option.value === this.value()) ? this.value() : opts[0]?.value;\n\n return optionValue === tabStopValue ? 0 : -1;\n }\n\n protected select(optionValue: string): void {\n this.value.set(optionValue);\n }\n\n protected onFocusOut(event: FocusEvent): void {\n if (!this.#host.nativeElement.contains(event.relatedTarget as Node | null)) {\n this.touch.emit();\n }\n }\n\n protected onKeydown(event: KeyboardEvent, index: number): void {\n const opts = this.options();\n const target = {\n ArrowRight: index + 1,\n ArrowDown: index + 1,\n ArrowLeft: index - 1,\n ArrowUp: index - 1,\n Home: 0,\n End: opts.length - 1,\n }[event.key];\n\n if (target === undefined) {\n return;\n }\n event.preventDefault();\n\n const nextIndex = ((target % opts.length) + opts.length) % opts.length;\n\n this.value.set(opts[nextIndex]!.value);\n this.radios()[nextIndex]!.nativeElement.focus();\n }\n}\n"],"mappings":";;;;AAqBA,MAAM,eACJ;AAEF,MAAM,mBAAmB;AAEzB,MAAM,qBAAqB;AAE3B,MAAM,gBAAe;CACnB,IAAI,QAAQ;CAEZ,aAAqB,mBAAmB,EAAE;AAC5C,EAAA,CAAE;AAmDF,IAAa,gBAAb,MAAa,cAAa;CACf,UAAU,MAAM,SAA8B,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAC9C,QAAQ,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAChC,QAAQ,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACvB,YAAY,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAC3B,iBAA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A;EAAA,QAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA,SAAO,EAAA,UAAA,KAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -40,7 +40,7 @@ var UiDelta = class UiDelta {
|
|
|
40
40
|
}, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
41
41
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
42
42
|
minVersion: "12.0.0",
|
|
43
|
-
version: "22.2.
|
|
43
|
+
version: "22.2.2",
|
|
44
44
|
ngImport: i0,
|
|
45
45
|
type: UiDelta,
|
|
46
46
|
deps: [],
|
|
@@ -48,7 +48,7 @@ var UiDelta = class UiDelta {
|
|
|
48
48
|
});
|
|
49
49
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
50
50
|
minVersion: "17.0.0",
|
|
51
|
-
version: "22.2.
|
|
51
|
+
version: "22.2.2",
|
|
52
52
|
type: UiDelta,
|
|
53
53
|
isStandalone: true,
|
|
54
54
|
selector: "ui-delta",
|
|
@@ -104,7 +104,7 @@ var UiDelta = class UiDelta {
|
|
|
104
104
|
};
|
|
105
105
|
i0.ɵɵngDeclareClassMetadata({
|
|
106
106
|
minVersion: "12.0.0",
|
|
107
|
-
version: "22.2.
|
|
107
|
+
version: "22.2.2",
|
|
108
108
|
ngImport: i0,
|
|
109
109
|
type: UiDelta,
|
|
110
110
|
decorators: [{
|
|
@@ -314,7 +314,7 @@ var UiDialog = class UiDialog {
|
|
|
314
314
|
}
|
|
315
315
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
316
316
|
minVersion: "12.0.0",
|
|
317
|
-
version: "22.2.
|
|
317
|
+
version: "22.2.2",
|
|
318
318
|
ngImport: i0,
|
|
319
319
|
type: UiDialog,
|
|
320
320
|
deps: [],
|
|
@@ -322,7 +322,7 @@ var UiDialog = class UiDialog {
|
|
|
322
322
|
});
|
|
323
323
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
324
324
|
minVersion: "17.0.0",
|
|
325
|
-
version: "22.2.
|
|
325
|
+
version: "22.2.2",
|
|
326
326
|
type: UiDialog,
|
|
327
327
|
isStandalone: true,
|
|
328
328
|
selector: "ui-dialog",
|
|
@@ -483,7 +483,7 @@ var UiDialog = class UiDialog {
|
|
|
483
483
|
};
|
|
484
484
|
i0.ɵɵngDeclareClassMetadata({
|
|
485
485
|
minVersion: "12.0.0",
|
|
486
|
-
version: "22.2.
|
|
486
|
+
version: "22.2.2",
|
|
487
487
|
ngImport: i0,
|
|
488
488
|
type: UiDialog,
|
|
489
489
|
decorators: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joanroucoux-cairn-ui-dialog.mjs","names":[],"sources":["../../../projects/ui/dialog/internal/dialog-styles.ts","../../../projects/ui/dialog/internal/dialog-exit.ts","../../../projects/ui/dialog/internal/modal-close.ts","../../../projects/ui/dialog/internal/sheet-drag.ts","../../../projects/ui/dialog/dialog.ts"],"sourcesContent":["export const DIALOG_STYLES = `\ndialog {\n --dialog-ease: var(--ease-sheet);\n transition:\n transform var(--duration-base) var(--dialog-ease),\n overlay var(--duration-base) allow-discrete,\n display var(--duration-base) allow-discrete;\n transform: translateY(var(--drag-y, 0px));\n}\n\ndialog:not([open]) {\n transform: translateY(100%);\n transition-duration: var(--duration-exit);\n}\n\n@starting-style {\n dialog[open] {\n transform: translateY(100%);\n }\n}\n\ndialog[data-dragging] {\n transition: none;\n}\n\n@media (prefers-reduced-motion: reduce) {\n dialog {\n transition:\n opacity var(--duration-base) var(--dialog-ease),\n overlay var(--duration-base) allow-discrete,\n display var(--duration-base) allow-discrete;\n opacity: 1;\n }\n\n dialog:not([open]) {\n opacity: 0;\n transform: translateY(var(--drag-y, 0px));\n }\n\n @starting-style {\n dialog[open] {\n opacity: 0;\n transform: translateY(0);\n }\n }\n}\n\n@media (min-width: 64rem) {\n dialog {\n --dialog-ease: var(--ease-out);\n transition:\n opacity var(--duration-base) var(--dialog-ease),\n transform var(--duration-base) var(--dialog-ease),\n overlay var(--duration-base) allow-discrete,\n display var(--duration-base) allow-discrete;\n opacity: 1;\n transform: scale(1);\n }\n\n dialog:not([open]) {\n opacity: 0;\n transform: scale(var(--enter-scale));\n }\n\n @starting-style {\n dialog[open] {\n opacity: 0;\n transform: scale(var(--enter-scale));\n }\n }\n}\n\ndialog::backdrop {\n transition: opacity var(--duration-base) var(--ease-out);\n opacity: 1;\n}\n\ndialog:not([open])::backdrop {\n opacity: 0;\n transition-duration: var(--duration-exit);\n}\n\n@starting-style {\n dialog[open]::backdrop {\n opacity: 0;\n }\n}\n`;\n","const GRACE = 50;\n\nexport function afterExit(element: HTMLElement, done: () => void): () => void {\n const style = getComputedStyle(element);\n const wait = longest(style.transitionDuration) + longest(style.transitionDelay);\n\n if (wait === 0) {\n done();\n return () => undefined;\n }\n\n const onEnd = (event: TransitionEvent): void => {\n if (event.target === element && !event.pseudoElement) {\n cancel();\n done();\n }\n };\n const timer = setTimeout(() => {\n cancel();\n done();\n }, wait + GRACE);\n const cancel = (): void => {\n clearTimeout(timer);\n element.removeEventListener('transitionend', onEnd);\n };\n\n element.addEventListener('transitionend', onEnd);\n\n return cancel;\n}\n\nfunction longest(list: string): number {\n return Math.max(0, ...list.split(',').map(toMs));\n}\n\nfunction toMs(value: string): number {\n const amount = Number.parseFloat(value);\n\n if (Number.isNaN(amount)) {\n return 0;\n }\n\n return value.trim().endsWith('ms') ? amount : amount * 1000;\n}\n","import { DestroyRef, ElementRef, type OutputEmitterRef, type Signal, afterRenderEffect, inject } from '@angular/core';\n\nimport { afterExit } from './dialog-exit';\n\ntype SharedReason = 'escape' | 'backdrop' | 'cross' | 'programmatic';\n\nexport type ModalCloseConfig<R extends string> = {\n readonly open: Signal<boolean>;\n readonly busy: Signal<boolean>;\n readonly dismissed: OutputEmitterRef<void>;\n readonly closed: OutputEmitterRef<R | SharedReason>;\n readonly reset?: () => void;\n readonly opening?: () => void;\n};\n\n/**\n * The close protocol of a modal on the native <dialog> under the host: `open` drives `showModal()` and `close()`,\n * Escape and a press-and-release on the veil close it unless `busy`, `dismissed` reports a close the user asked for\n * and `closed` its reason once the exit transition has played. `opening` runs just before `showModal()`. Must be\n * created in an injection context.\n */\nexport class ModalClose<R extends string> {\n readonly #host = inject<ElementRef<HTMLElement>>(ElementRef);\n readonly #config: ModalCloseConfig<R>;\n\n #pressedOnBackdrop = false;\n #reason: R | SharedReason | null = null;\n #cancelExit: () => void = () => undefined;\n\n constructor(config: ModalCloseConfig<R>) {\n this.#config = config;\n inject(DestroyRef).onDestroy(() => this.#cancelExit());\n\n afterRenderEffect(() => {\n const dialog = this.#dialog;\n\n if (config.open() && !dialog.open) {\n this.#cancelExit();\n config.reset?.();\n config.opening?.();\n dialog.showModal();\n } else if (!config.open() && dialog.open) {\n this.close('programmatic');\n }\n });\n }\n\n close(reason: R | SharedReason): void {\n if (this.#dialog.open) {\n this.#reason = reason;\n this.#dialog.close();\n }\n }\n\n onCancel(event: Event): void {\n if (event.target !== event.currentTarget) {\n return;\n }\n event.preventDefault();\n if (!this.#config.busy()) {\n this.close('escape');\n }\n }\n\n onKeydown(event: KeyboardEvent): void {\n if (event.key === 'Escape' && this.#config.busy() && (event.target as Element).closest('dialog') === this.#dialog) {\n event.preventDefault();\n }\n }\n\n onPointerDown(event: MouseEvent): void {\n this.#pressedOnBackdrop = event.target === this.#dialog && this.#outside(event);\n }\n\n onClick(event: MouseEvent): void {\n if (this.#pressedOnBackdrop && !this.#config.busy() && event.target === this.#dialog && this.#outside(event)) {\n this.close('backdrop');\n }\n this.#pressedOnBackdrop = false;\n }\n\n onNativeClose(): void {\n const asked = this.#reason;\n\n this.#reason = null;\n if (this.#dialog.open) {\n return;\n }\n if (asked === null && this.#config.busy()) {\n this.#dialog.showModal();\n return;\n }\n const reason = asked ?? 'escape';\n if (reason !== 'programmatic') {\n this.#config.dismissed.emit();\n }\n this.#cancelExit();\n this.#cancelExit = afterExit(this.#dialog, () => {\n this.#cancelExit = () => undefined;\n this.#config.reset?.();\n this.#config.closed.emit(reason);\n });\n }\n\n get #dialog(): HTMLDialogElement {\n return this.#host.nativeElement.querySelector('dialog') as HTMLDialogElement;\n }\n\n #outside(event: MouseEvent): boolean {\n const rect = this.#dialog.getBoundingClientRect();\n\n return (\n event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom\n );\n }\n}\n","const DISMISS_RATIO = 0.3;\nconst DISMISS_SPEED = 0.5;\nconst SPEED_WINDOW = 100;\nconst SLOP = 6;\nconst CONTROLS = 'button, a, input, select, textarea, [role=\"button\"]';\n\ntype Sample = { y: number; at: number };\n\ntype Gesture = {\n id: number;\n startX: number;\n startY: number;\n dragging: boolean;\n height: number;\n offset: number;\n samples: Sample[];\n};\n\nexport class SheetDrag {\n readonly #panel: HTMLElement;\n readonly #grips: readonly HTMLElement[];\n readonly #dismiss: () => void;\n readonly #enabled: () => boolean;\n #gesture: Gesture | null = null;\n\n constructor(panel: HTMLElement, grips: readonly HTMLElement[], dismiss: () => void, enabled: () => boolean) {\n this.#panel = panel;\n this.#grips = grips;\n this.#dismiss = dismiss;\n this.#enabled = enabled;\n\n for (const grip of grips) {\n grip.addEventListener('pointerdown', this.#onDown);\n grip.addEventListener('pointermove', this.#onMove);\n grip.addEventListener('pointerup', this.#onUp);\n grip.addEventListener('pointercancel', this.#onCancel);\n }\n }\n\n reset(): void {\n this.#gesture = null;\n this.#panel.removeAttribute('data-dragging');\n this.#panel.style.removeProperty('--drag-y');\n }\n\n destroy(): void {\n for (const grip of this.#grips) {\n grip.removeEventListener('pointerdown', this.#onDown);\n grip.removeEventListener('pointermove', this.#onMove);\n grip.removeEventListener('pointerup', this.#onUp);\n grip.removeEventListener('pointercancel', this.#onCancel);\n }\n }\n\n readonly #onDown = (event: PointerEvent): void => {\n const grip = event.currentTarget as HTMLElement;\n\n if (event.button !== 0 || !this.#enabled() || !isSheet() || (event.target as Element).closest(CONTROLS)) {\n return;\n }\n\n grip.setPointerCapture(event.pointerId);\n this.#gesture = {\n id: event.pointerId,\n startX: event.clientX,\n startY: event.clientY,\n dragging: false,\n height: 0,\n offset: 0,\n samples: [{ y: event.clientY, at: event.timeStamp }],\n };\n };\n\n readonly #onMove = (event: PointerEvent): void => {\n const gesture = this.#current(event);\n\n if (!gesture) {\n return;\n }\n\n const dx = event.clientX - gesture.startX;\n const dy = event.clientY - gesture.startY;\n\n if (!gesture.dragging) {\n if (Math.max(Math.abs(dx), Math.abs(dy)) < SLOP) {\n return;\n }\n if (Math.abs(dx) > Math.abs(dy)) {\n this.#gesture = null;\n return;\n }\n gesture.dragging = true;\n gesture.height = this.#panel.getBoundingClientRect().height;\n this.#panel.setAttribute('data-dragging', '');\n }\n\n gesture.offset = Math.max(0, dy);\n gesture.samples.push({ y: event.clientY, at: event.timeStamp });\n this.#panel.style.setProperty('--drag-y', `${gesture.offset}px`);\n };\n\n readonly #onUp = (event: PointerEvent): void => {\n const gesture = this.#current(event);\n\n if (!gesture) {\n return;\n }\n\n this.#gesture = null;\n\n if (!gesture.dragging) {\n return;\n }\n\n this.#panel.removeAttribute('data-dragging');\n\n const release = { y: event.clientY, at: event.timeStamp };\n\n if (gesture.offset > gesture.height * DISMISS_RATIO || releaseSpeed(gesture.samples, release) > DISMISS_SPEED) {\n this.#dismiss();\n } else {\n this.reset();\n }\n };\n\n readonly #onCancel = (event: PointerEvent): void => {\n if (this.#current(event)) {\n this.#gesture = null;\n this.#panel.removeAttribute('data-dragging');\n this.reset();\n }\n };\n\n #current(event: PointerEvent): Gesture | null {\n return this.#gesture?.id === event.pointerId ? this.#gesture : null;\n }\n}\n\nfunction isSheet(): boolean {\n return typeof matchMedia === 'function' && !matchMedia('(min-width: 64rem)').matches;\n}\n\nfunction releaseSpeed(samples: readonly Sample[], last: Sample): number {\n const first = samples.find((sample) => sample.at >= last.at - SPEED_WINDOW) ?? last;\n const elapsed = last.at - first.at;\n\n return elapsed > 0 ? (last.y - first.y) / elapsed : 0;\n}\n","import {\n Component,\n DestroyRef,\n ElementRef,\n afterNextRender,\n booleanAttribute,\n computed,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\n\nimport { DIALOG_STYLES } from './internal/dialog-styles';\nimport { ModalClose } from './internal/modal-close';\nimport { SheetDrag } from './internal/sheet-drag';\n\n/** Named dialog widths; any other CSS length is accepted as is. */\nexport const DIALOG_WIDTHS = ['md', 'lg'] as const;\nexport type DialogWidth = (typeof DIALOG_WIDTHS)[number];\n\nconst WIDTH_VALUES: Record<DialogWidth, string> = {\n md: '28rem',\n lg: '560px',\n};\n\n/** `confirm` is a short alertdialog: no cross, no hairlines, one 24px padding, 440px wide unless told otherwise. */\nexport const DIALOG_VARIANTS = ['default', 'confirm'] as const;\nexport type DialogVariant = (typeof DIALOG_VARIANTS)[number];\n\n/** `full` makes the sheet under `64rem` fill the screen below the status area; `fit` sizes it to its content. */\nexport const DIALOG_SHEETS = ['fit', 'full'] as const;\nexport type DialogSheet = (typeof DIALOG_SHEETS)[number];\n\ntype VariantClasses = {\n handle: string;\n header: string;\n body: string;\n footer: string;\n};\n\nconst VARIANTS: Record<DialogVariant, VariantClasses> = {\n default: {\n handle: 'pt-[7.5px]',\n header: 'pb-3 lg:py-4 lg:pl-6',\n body: 'py-4 lg:py-5',\n footer: 'pt-3 empty:hidden lg:py-4',\n },\n confirm: {\n handle: 'pt-[11.5px]',\n header: 'pt-3 lg:pt-6 lg:pl-6',\n body: 'pt-3',\n footer: 'not-empty:pt-5 lg:pb-6 lg:not-empty:pt-6',\n },\n};\n\nconst DEFAULT_WIDTHS: Record<DialogVariant, string> = {\n default: 'lg',\n confirm: '440px',\n};\n\n/** What started a close, as `closed` reports it. */\nexport const DIALOG_CLOSE_REASONS = ['escape', 'backdrop', 'cross', 'drag', 'programmatic'] as const;\nexport type DialogCloseReason = (typeof DIALOG_CLOSE_REASONS)[number];\n\nconst nextId = (() => {\n let count = 0;\n\n return () => `ui-dialog-${++count}`;\n})();\n\n/**\n * Modal dialog on the native <dialog>: a bottom sheet under `64rem`, centered above it.\n *\n * `busy` keeps it open while its action runs: Escape, a backdrop click and a sheet drag do nothing\n * and the cross is disabled. The owner disables its own buttons and still closes it through `open`.\n *\n * @example\n * <ui-dialog heading=\"Buy\" description=\"Ferrari\" closeLabel=\"Close\" width=\"528px\" [open]=\"buying()\" (dismissed)=\"buying.set(false)\">\n * <p>Body</p>\n * <button dialogActions ui-button variant=\"outline\" class=\"max-lg:hidden\" (click)=\"buying.set(false)\">Cancel</button>\n * <button dialogActions ui-button>Buy 40 shares</button>\n * </ui-dialog>\n */\n@Component({\n selector: 'ui-dialog',\n host: {\n '(pointerdown)': 'modal.onPointerDown($event)',\n '(click)': 'modal.onClick($event)',\n '(keydown)': 'modal.onKeydown($event)',\n },\n template: `\n <dialog\n #dlg\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-labelledby]=\"headingId\"\n [attr.role]=\"variant() === 'confirm' ? 'alertdialog' : 'dialog'\"\n [class]=\"classes()\"\n [style.--dialog-width]=\"widthValue()\"\n (cancel)=\"modal.onCancel($event)\"\n (close)=\"modal.onNativeClose()\"\n >\n <div\n aria-hidden=\"true\"\n class=\"flex h-5 touch-none justify-center lg:hidden\"\n data-dialog-handle\n [class]=\"spec().handle\"\n >\n <span class=\"rounded-pill h-[5px] w-9 bg-(--border)\"></span>\n </div>\n\n <div data-dialog-header [class]=\"headerClasses()\">\n <div class=\"flex min-w-0 flex-1 flex-col\" [class.max-lg:pt-1]=\"description()\">\n <h2 class=\"text-title font-semibold\" [id]=\"headingId\">{{ heading() }}</h2>\n\n @if (description()) {\n <p\n class=\"text-label text-(--muted-foreground)\"\n [class.truncate]=\"truncateDescription()\"\n [id]=\"descriptionId\"\n >\n {{ description() }}\n </p>\n }\n </div>\n\n @if (closeLabel()) {\n <button\n type=\"button\"\n [attr.aria-label]=\"closeLabel()\"\n [class]=\"crossClasses\"\n [disabled]=\"busy()\"\n (click)=\"modal.close('cross')\"\n >\n <svg\n aria-hidden=\"true\"\n class=\"block size-[22px] fill-none stroke-current stroke-[1.75]\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n viewBox=\"0 0 24 24\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </button>\n }\n </div>\n\n <div\n class=\"min-h-0 flex-1 overflow-y-auto px-4 outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring) lg:px-6\"\n data-dialog-body\n [attr.aria-labelledby]=\"scrollable() ? headingId : null\"\n [attr.role]=\"scrollable() ? 'region' : null\"\n [attr.tabindex]=\"scrollable() ? 0 : null\"\n [id]=\"bodyId\"\n >\n <div class=\"flex flex-col gap-4 empty:hidden\" [class]=\"spec().body\">\n <ng-content />\n </div>\n </div>\n\n <div data-dialog-footer [class]=\"footerClasses()\">\n <ng-content select=\"[dialogActions]\" />\n </div>\n </dialog>\n `,\n styles: DIALOG_STYLES,\n})\nexport class UiDialog {\n readonly heading = input.required<string>();\n readonly description = input<string>();\n readonly closeLabel = input<string>();\n readonly variant = input<DialogVariant>('default');\n readonly sheet = input<DialogSheet>('fit');\n readonly truncateDescription = input(false, { transform: booleanAttribute });\n readonly width = input<DialogWidth | (string & {})>();\n readonly open = input(false, { transform: booleanAttribute });\n readonly busy = input(false, { transform: booleanAttribute });\n readonly dismissed = output<void>();\n readonly closed = output<DialogCloseReason>();\n\n protected readonly headingId = nextId();\n protected readonly descriptionId = `${this.headingId}-description`;\n protected readonly bodyId = `${this.headingId}-body`;\n protected readonly scrollable = signal(false);\n protected readonly stacked = signal(false);\n\n protected readonly describedBy = computed(() => {\n if (this.description()) {\n return this.descriptionId;\n }\n\n return this.variant() === 'confirm' ? this.bodyId : null;\n });\n\n protected readonly widthValue = computed(() => {\n const width = this.width() ?? DEFAULT_WIDTHS[this.variant()];\n\n return Object.hasOwn(WIDTH_VALUES, width) ? WIDTH_VALUES[width as DialogWidth] : width;\n });\n\n protected readonly spec = computed(() => VARIANTS[this.variant()]);\n\n protected readonly hairlines = computed(() => Boolean(this.closeLabel()) && this.variant() === 'default');\n\n protected readonly headerClasses = computed(\n () =>\n `flex ${this.description() ? 'items-start' : 'items-center'} gap-2 pl-4 max-lg:touch-none lg:gap-3 ${this.spec().header} ${this.closeLabel() ? 'pr-2 lg:pr-4' : 'pr-4 lg:pr-6'} ${this.hairlines() ? 'shadow-[inset_0_-1px_0_var(--hairline)]' : ''}`,\n );\n\n protected readonly crossClasses =\n 'rounded-pill lg:rounded-control grid size-11 flex-none cursor-pointer place-items-center text-(--muted-foreground) transition-[scale,background-color,color] [transition-duration:var(--duration-press),var(--duration-fast),var(--duration-fast)] ease-out outline-none focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-(--ring) active:scale-(--press-scale) active:bg-(--soft) disabled:pointer-events-none disabled:opacity-40 lg:size-9 lg:hover:bg-(--glow) lg:hover:text-(--foreground)';\n\n protected readonly footerClasses = computed(\n () =>\n `max-lg:[&>[ui-button]]:text-body flex justify-end gap-2 px-4 pb-[calc(8px+env(safe-area-inset-bottom))] max-lg:flex-col-reverse max-lg:[&>[ui-button]]:h-[50px] max-lg:[&>[ui-button]]:w-full lg:px-6 ${this.spec().footer} ${this.hairlines() ? 'shadow-[inset_0_1px_0_var(--hairline)]' : ''}`,\n );\n\n protected readonly classes = computed(\n () =>\n `open:flex w-full flex-col overflow-hidden m-auto mt-auto max-lg:max-h-[calc(100dvh-2rem)] lg:max-h-[calc(100dvh-96px)] max-lg:mb-0 max-lg:max-w-none max-lg:rounded-b-none lg:max-w-(--dialog-width) rounded-container bg-(--card) text-(--foreground) outline-none shadow-[0_0_0_1px_var(--border),0_24px_64px_rgb(0_0_0/0.24)] max-lg:shadow-[0_-1px_0_var(--border),0_-12px_32px_rgb(0_0_0/0.16)] ${this.stacked() ? 'backdrop:bg-black/[0.24]' : 'backdrop:bg-black/[0.36]'} ${this.sheet() === 'full' ? 'max-lg:h-[calc(100dvh-58px)]' : ''}`,\n );\n\n readonly #host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n #drag: SheetDrag | null = null;\n\n protected readonly modal: ModalClose<DialogCloseReason>;\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n\n afterNextRender(() => {\n const host = this.#host.nativeElement;\n const dialog = host.querySelector('dialog') as HTMLDialogElement;\n const grips = ['[data-dialog-handle]', '[data-dialog-header]'].map(\n (grip) => host.querySelector(grip) as HTMLElement,\n );\n\n this.#drag = new SheetDrag(\n dialog,\n grips,\n () => this.modal.close('drag'),\n () => !this.busy(),\n );\n destroyRef.onDestroy(() => this.#drag?.destroy());\n\n if (typeof ResizeObserver === 'undefined') {\n return;\n }\n\n const body = host.querySelector('[data-dialog-body]') as HTMLElement;\n const observer = new ResizeObserver(() => this.scrollable.set(body.scrollHeight > body.clientHeight));\n\n observer.observe(body);\n observer.observe(body.firstElementChild as Element);\n destroyRef.onDestroy(() => observer.disconnect());\n });\n\n this.modal = new ModalClose<DialogCloseReason>({\n open: this.open,\n busy: this.busy,\n dismissed: this.dismissed,\n closed: this.closed,\n reset: () => this.#drag?.reset(),\n opening: () => this.stacked.set(this.#overAnotherModal()),\n });\n }\n\n #overAnotherModal(): boolean {\n const open = this.#host.nativeElement.ownerDocument.querySelectorAll('dialog[open]');\n\n return Array.from(open).some((dialog) => dialog.matches(':modal'));\n }\n}\n"],"mappings":";;ACAA,MAAM,QAAQ;AAEd,SAAgB,UAAU,SAAsB,MAAgB;CAC9D,MAAM,QAAQ,iBAAiB,OAAO;CACtC,MAAM,OAAO,QAAQ,MAAM,kBAAkB,IAAI,QAAQ,MAAM,eAAe;CAE9E,IAAI,SAAS,GAAG;EACd,KAAI;EACJ,aAAa;CACf;CAEA,MAAM,SAAS,UAAgC;EAC7C,IAAI,MAAM,WAAW,WAAW,CAAC,MAAM,eAAe;GACpD,OAAM;GACN,KAAI;EACN;CACF;CACA,MAAM,QAAQ,iBAAgB;EAC5B,OAAM;EACN,KAAI;CACN,GAAG,OAAO,KAAK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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2ET,UAAA;EAAA,QAAA,CAAA,o3CAAA;CAAA,CAAA;;AAGU,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EArFpB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAW,MACf;IACJ,iBAAiB;IACjB,WAAW;IACX,aAAa;GACd;GAAA,UACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2ET,QAAA,CAAA,o3CAAA;EAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"joanroucoux-cairn-ui-dialog.mjs","names":[],"sources":["../../../projects/ui/dialog/internal/dialog-styles.ts","../../../projects/ui/dialog/internal/dialog-exit.ts","../../../projects/ui/dialog/internal/modal-close.ts","../../../projects/ui/dialog/internal/sheet-drag.ts","../../../projects/ui/dialog/dialog.ts"],"sourcesContent":["export const DIALOG_STYLES = `\ndialog {\n --dialog-ease: var(--ease-sheet);\n transition:\n transform var(--duration-base) var(--dialog-ease),\n overlay var(--duration-base) allow-discrete,\n display var(--duration-base) allow-discrete;\n transform: translateY(var(--drag-y, 0px));\n}\n\ndialog:not([open]) {\n transform: translateY(100%);\n transition-duration: var(--duration-exit);\n}\n\n@starting-style {\n dialog[open] {\n transform: translateY(100%);\n }\n}\n\ndialog[data-dragging] {\n transition: none;\n}\n\n@media (prefers-reduced-motion: reduce) {\n dialog {\n transition:\n opacity var(--duration-base) var(--dialog-ease),\n overlay var(--duration-base) allow-discrete,\n display var(--duration-base) allow-discrete;\n opacity: 1;\n }\n\n dialog:not([open]) {\n opacity: 0;\n transform: translateY(var(--drag-y, 0px));\n }\n\n @starting-style {\n dialog[open] {\n opacity: 0;\n transform: translateY(0);\n }\n }\n}\n\n@media (min-width: 64rem) {\n dialog {\n --dialog-ease: var(--ease-out);\n transition:\n opacity var(--duration-base) var(--dialog-ease),\n transform var(--duration-base) var(--dialog-ease),\n overlay var(--duration-base) allow-discrete,\n display var(--duration-base) allow-discrete;\n opacity: 1;\n transform: scale(1);\n }\n\n dialog:not([open]) {\n opacity: 0;\n transform: scale(var(--enter-scale));\n }\n\n @starting-style {\n dialog[open] {\n opacity: 0;\n transform: scale(var(--enter-scale));\n }\n }\n}\n\ndialog::backdrop {\n transition: opacity var(--duration-base) var(--ease-out);\n opacity: 1;\n}\n\ndialog:not([open])::backdrop {\n opacity: 0;\n transition-duration: var(--duration-exit);\n}\n\n@starting-style {\n dialog[open]::backdrop {\n opacity: 0;\n }\n}\n`;\n","const GRACE = 50;\n\nexport function afterExit(element: HTMLElement, done: () => void): () => void {\n const style = getComputedStyle(element);\n const wait = longest(style.transitionDuration) + longest(style.transitionDelay);\n\n if (wait === 0) {\n done();\n return () => undefined;\n }\n\n const onEnd = (event: TransitionEvent): void => {\n if (event.target === element && !event.pseudoElement) {\n cancel();\n done();\n }\n };\n const timer = setTimeout(() => {\n cancel();\n done();\n }, wait + GRACE);\n const cancel = (): void => {\n clearTimeout(timer);\n element.removeEventListener('transitionend', onEnd);\n };\n\n element.addEventListener('transitionend', onEnd);\n\n return cancel;\n}\n\nfunction longest(list: string): number {\n return Math.max(0, ...list.split(',').map(toMs));\n}\n\nfunction toMs(value: string): number {\n const amount = Number.parseFloat(value);\n\n if (Number.isNaN(amount)) {\n return 0;\n }\n\n return value.trim().endsWith('ms') ? amount : amount * 1000;\n}\n","import { DestroyRef, ElementRef, type OutputEmitterRef, type Signal, afterRenderEffect, inject } from '@angular/core';\n\nimport { afterExit } from './dialog-exit';\n\ntype SharedReason = 'escape' | 'backdrop' | 'cross' | 'programmatic';\n\n/** @internal */\nexport type ModalCloseConfig<R extends string> = {\n readonly open: Signal<boolean>;\n readonly busy: Signal<boolean>;\n readonly dismissed: OutputEmitterRef<void>;\n readonly closed: OutputEmitterRef<R | SharedReason>;\n readonly reset?: () => void;\n readonly opening?: () => void;\n};\n\n/**\n * The close protocol of a modal on the native <dialog> under the host: `open` drives `showModal()` and `close()`,\n * Escape and a press-and-release on the veil close it unless `busy`, `dismissed` reports a close the user asked for\n * and `closed` its reason once the exit transition has played. `opening` runs just before `showModal()`. Must be\n * created in an injection context.\n *\n * @internal Shared by `ui-dialog` and `ui-drawer`, not meant for applications.\n */\nexport class ModalClose<R extends string> {\n readonly #host = inject<ElementRef<HTMLElement>>(ElementRef);\n readonly #config: ModalCloseConfig<R>;\n\n #pressedOnBackdrop = false;\n #reason: R | SharedReason | null = null;\n #cancelExit: () => void = () => undefined;\n\n constructor(config: ModalCloseConfig<R>) {\n this.#config = config;\n inject(DestroyRef).onDestroy(() => this.#cancelExit());\n\n afterRenderEffect(() => {\n const dialog = this.#dialog;\n\n if (config.open() && !dialog.open) {\n this.#cancelExit();\n config.reset?.();\n config.opening?.();\n dialog.showModal();\n } else if (!config.open() && dialog.open) {\n this.close('programmatic');\n }\n });\n }\n\n close(reason: R | SharedReason): void {\n if (this.#dialog.open) {\n this.#reason = reason;\n this.#dialog.close();\n }\n }\n\n onCancel(event: Event): void {\n if (event.target !== event.currentTarget) {\n return;\n }\n event.preventDefault();\n if (!this.#config.busy()) {\n this.close('escape');\n }\n }\n\n onKeydown(event: KeyboardEvent): void {\n if (event.key === 'Escape' && this.#config.busy() && (event.target as Element).closest('dialog') === this.#dialog) {\n event.preventDefault();\n }\n }\n\n onPointerDown(event: MouseEvent): void {\n this.#pressedOnBackdrop = event.target === this.#dialog && this.#outside(event);\n }\n\n onClick(event: MouseEvent): void {\n if (this.#pressedOnBackdrop && !this.#config.busy() && event.target === this.#dialog && this.#outside(event)) {\n this.close('backdrop');\n }\n this.#pressedOnBackdrop = false;\n }\n\n onNativeClose(): void {\n const asked = this.#reason;\n\n this.#reason = null;\n if (this.#dialog.open) {\n return;\n }\n if (asked === null && this.#config.busy()) {\n this.#dialog.showModal();\n return;\n }\n const reason = asked ?? 'escape';\n if (reason !== 'programmatic') {\n this.#config.dismissed.emit();\n }\n this.#cancelExit();\n this.#cancelExit = afterExit(this.#dialog, () => {\n this.#cancelExit = () => undefined;\n this.#config.reset?.();\n this.#config.closed.emit(reason);\n });\n }\n\n get #dialog(): HTMLDialogElement {\n return this.#host.nativeElement.querySelector('dialog') as HTMLDialogElement;\n }\n\n #outside(event: MouseEvent): boolean {\n const rect = this.#dialog.getBoundingClientRect();\n\n return (\n event.clientX < rect.left || event.clientX > rect.right || event.clientY < rect.top || event.clientY > rect.bottom\n );\n }\n}\n","const DISMISS_RATIO = 0.3;\nconst DISMISS_SPEED = 0.5;\nconst SPEED_WINDOW = 100;\nconst SLOP = 6;\nconst CONTROLS = 'button, a, input, select, textarea, [role=\"button\"]';\n\ntype Sample = { y: number; at: number };\n\ntype Gesture = {\n id: number;\n startX: number;\n startY: number;\n dragging: boolean;\n height: number;\n offset: number;\n samples: Sample[];\n};\n\nexport class SheetDrag {\n readonly #panel: HTMLElement;\n readonly #grips: readonly HTMLElement[];\n readonly #dismiss: () => void;\n readonly #enabled: () => boolean;\n #gesture: Gesture | null = null;\n\n constructor(panel: HTMLElement, grips: readonly HTMLElement[], dismiss: () => void, enabled: () => boolean) {\n this.#panel = panel;\n this.#grips = grips;\n this.#dismiss = dismiss;\n this.#enabled = enabled;\n\n for (const grip of grips) {\n grip.addEventListener('pointerdown', this.#onDown);\n grip.addEventListener('pointermove', this.#onMove);\n grip.addEventListener('pointerup', this.#onUp);\n grip.addEventListener('pointercancel', this.#onCancel);\n }\n }\n\n reset(): void {\n this.#gesture = null;\n this.#panel.removeAttribute('data-dragging');\n this.#panel.style.removeProperty('--drag-y');\n }\n\n destroy(): void {\n for (const grip of this.#grips) {\n grip.removeEventListener('pointerdown', this.#onDown);\n grip.removeEventListener('pointermove', this.#onMove);\n grip.removeEventListener('pointerup', this.#onUp);\n grip.removeEventListener('pointercancel', this.#onCancel);\n }\n }\n\n readonly #onDown = (event: PointerEvent): void => {\n const grip = event.currentTarget as HTMLElement;\n\n if (event.button !== 0 || !this.#enabled() || !isSheet() || (event.target as Element).closest(CONTROLS)) {\n return;\n }\n\n grip.setPointerCapture(event.pointerId);\n this.#gesture = {\n id: event.pointerId,\n startX: event.clientX,\n startY: event.clientY,\n dragging: false,\n height: 0,\n offset: 0,\n samples: [{ y: event.clientY, at: event.timeStamp }],\n };\n };\n\n readonly #onMove = (event: PointerEvent): void => {\n const gesture = this.#current(event);\n\n if (!gesture) {\n return;\n }\n\n const dx = event.clientX - gesture.startX;\n const dy = event.clientY - gesture.startY;\n\n if (!gesture.dragging) {\n if (Math.max(Math.abs(dx), Math.abs(dy)) < SLOP) {\n return;\n }\n if (Math.abs(dx) > Math.abs(dy)) {\n this.#gesture = null;\n return;\n }\n gesture.dragging = true;\n gesture.height = this.#panel.getBoundingClientRect().height;\n this.#panel.setAttribute('data-dragging', '');\n }\n\n gesture.offset = Math.max(0, dy);\n gesture.samples.push({ y: event.clientY, at: event.timeStamp });\n this.#panel.style.setProperty('--drag-y', `${gesture.offset}px`);\n };\n\n readonly #onUp = (event: PointerEvent): void => {\n const gesture = this.#current(event);\n\n if (!gesture) {\n return;\n }\n\n this.#gesture = null;\n\n if (!gesture.dragging) {\n return;\n }\n\n this.#panel.removeAttribute('data-dragging');\n\n const release = { y: event.clientY, at: event.timeStamp };\n\n if (gesture.offset > gesture.height * DISMISS_RATIO || releaseSpeed(gesture.samples, release) > DISMISS_SPEED) {\n this.#dismiss();\n } else {\n this.reset();\n }\n };\n\n readonly #onCancel = (event: PointerEvent): void => {\n if (this.#current(event)) {\n this.#gesture = null;\n this.#panel.removeAttribute('data-dragging');\n this.reset();\n }\n };\n\n #current(event: PointerEvent): Gesture | null {\n return this.#gesture?.id === event.pointerId ? this.#gesture : null;\n }\n}\n\nfunction isSheet(): boolean {\n return typeof matchMedia === 'function' && !matchMedia('(min-width: 64rem)').matches;\n}\n\nfunction releaseSpeed(samples: readonly Sample[], last: Sample): number {\n const first = samples.find((sample) => sample.at >= last.at - SPEED_WINDOW) ?? last;\n const elapsed = last.at - first.at;\n\n return elapsed > 0 ? (last.y - first.y) / elapsed : 0;\n}\n","import {\n Component,\n DestroyRef,\n ElementRef,\n afterNextRender,\n booleanAttribute,\n computed,\n inject,\n input,\n output,\n signal,\n} from '@angular/core';\n\nimport { DIALOG_STYLES } from './internal/dialog-styles';\nimport { ModalClose } from './internal/modal-close';\nimport { SheetDrag } from './internal/sheet-drag';\n\n/** Named dialog widths; any other CSS length is accepted as is. */\nexport const DIALOG_WIDTHS = ['md', 'lg'] as const;\nexport type DialogWidth = (typeof DIALOG_WIDTHS)[number];\n\nconst WIDTH_VALUES: Record<DialogWidth, string> = {\n md: '28rem',\n lg: '560px',\n};\n\n/** `confirm` is a short alertdialog: no cross, no hairlines, one 24px padding, 440px wide unless told otherwise. */\nexport const DIALOG_VARIANTS = ['default', 'confirm'] as const;\nexport type DialogVariant = (typeof DIALOG_VARIANTS)[number];\n\n/** `full` makes the sheet under `64rem` fill the screen below the status area; `fit` sizes it to its content. */\nexport const DIALOG_SHEETS = ['fit', 'full'] as const;\nexport type DialogSheet = (typeof DIALOG_SHEETS)[number];\n\ntype VariantClasses = {\n handle: string;\n header: string;\n body: string;\n footer: string;\n};\n\nconst VARIANTS: Record<DialogVariant, VariantClasses> = {\n default: {\n handle: 'pt-[7.5px]',\n header: 'pb-3 lg:py-4 lg:pl-6',\n body: 'py-4 lg:py-5',\n footer: 'pt-3 empty:hidden lg:py-4',\n },\n confirm: {\n handle: 'pt-[11.5px]',\n header: 'pt-3 lg:pt-6 lg:pl-6',\n body: 'pt-3',\n footer: 'not-empty:pt-5 lg:pb-6 lg:not-empty:pt-6',\n },\n};\n\nconst DEFAULT_WIDTHS: Record<DialogVariant, string> = {\n default: 'lg',\n confirm: '440px',\n};\n\n/** What started a close, as `closed` reports it. */\nexport const DIALOG_CLOSE_REASONS = ['escape', 'backdrop', 'cross', 'drag', 'programmatic'] as const;\nexport type DialogCloseReason = (typeof DIALOG_CLOSE_REASONS)[number];\n\nconst nextId = (() => {\n let count = 0;\n\n return () => `ui-dialog-${++count}`;\n})();\n\n/**\n * Modal dialog on the native <dialog>: a bottom sheet under `64rem`, centered above it.\n *\n * `busy` keeps it open while its action runs: Escape, a backdrop click and a sheet drag do nothing\n * and the cross is disabled. The owner disables its own buttons and still closes it through `open`.\n *\n * @example\n * <ui-dialog heading=\"Buy\" description=\"Ferrari\" closeLabel=\"Close\" width=\"528px\" [open]=\"buying()\" (dismissed)=\"buying.set(false)\">\n * <p>Body</p>\n * <button dialogActions ui-button variant=\"outline\" class=\"max-lg:hidden\" (click)=\"buying.set(false)\">Cancel</button>\n * <button dialogActions ui-button>Buy 40 shares</button>\n * </ui-dialog>\n */\n@Component({\n selector: 'ui-dialog',\n host: {\n '(pointerdown)': 'modal.onPointerDown($event)',\n '(click)': 'modal.onClick($event)',\n '(keydown)': 'modal.onKeydown($event)',\n },\n template: `\n <dialog\n #dlg\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-labelledby]=\"headingId\"\n [attr.role]=\"variant() === 'confirm' ? 'alertdialog' : 'dialog'\"\n [class]=\"classes()\"\n [style.--dialog-width]=\"widthValue()\"\n (cancel)=\"modal.onCancel($event)\"\n (close)=\"modal.onNativeClose()\"\n >\n <div\n aria-hidden=\"true\"\n class=\"flex h-5 touch-none justify-center lg:hidden\"\n data-dialog-handle\n [class]=\"spec().handle\"\n >\n <span class=\"rounded-pill h-[5px] w-9 bg-(--border)\"></span>\n </div>\n\n <div data-dialog-header [class]=\"headerClasses()\">\n <div class=\"flex min-w-0 flex-1 flex-col\" [class.max-lg:pt-1]=\"description()\">\n <h2 class=\"text-title font-semibold\" [id]=\"headingId\">{{ heading() }}</h2>\n\n @if (description()) {\n <p\n class=\"text-label text-(--muted-foreground)\"\n [class.truncate]=\"truncateDescription()\"\n [id]=\"descriptionId\"\n >\n {{ description() }}\n </p>\n }\n </div>\n\n @if (closeLabel()) {\n <button\n type=\"button\"\n [attr.aria-label]=\"closeLabel()\"\n [class]=\"crossClasses\"\n [disabled]=\"busy()\"\n (click)=\"modal.close('cross')\"\n >\n <svg\n aria-hidden=\"true\"\n class=\"block size-[22px] fill-none stroke-current stroke-[1.75]\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n viewBox=\"0 0 24 24\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </button>\n }\n </div>\n\n <div\n class=\"min-h-0 flex-1 overflow-y-auto px-4 outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring) lg:px-6\"\n data-dialog-body\n [attr.aria-labelledby]=\"scrollable() ? headingId : null\"\n [attr.role]=\"scrollable() ? 'region' : null\"\n [attr.tabindex]=\"scrollable() ? 0 : null\"\n [id]=\"bodyId\"\n >\n <div class=\"flex flex-col gap-4 empty:hidden\" [class]=\"spec().body\">\n <ng-content />\n </div>\n </div>\n\n <div data-dialog-footer [class]=\"footerClasses()\">\n <ng-content select=\"[dialogActions]\" />\n </div>\n </dialog>\n `,\n styles: DIALOG_STYLES,\n})\nexport class UiDialog {\n readonly heading = input.required<string>();\n readonly description = input<string>();\n readonly closeLabel = input<string>();\n readonly variant = input<DialogVariant>('default');\n readonly sheet = input<DialogSheet>('fit');\n readonly truncateDescription = input(false, { transform: booleanAttribute });\n readonly width = input<DialogWidth | (string & {})>();\n readonly open = input(false, { transform: booleanAttribute });\n readonly busy = input(false, { transform: booleanAttribute });\n readonly dismissed = output<void>();\n readonly closed = output<DialogCloseReason>();\n\n protected readonly headingId = nextId();\n protected readonly descriptionId = `${this.headingId}-description`;\n protected readonly bodyId = `${this.headingId}-body`;\n protected readonly scrollable = signal(false);\n protected readonly stacked = signal(false);\n\n protected readonly describedBy = computed(() => {\n if (this.description()) {\n return this.descriptionId;\n }\n\n return this.variant() === 'confirm' ? this.bodyId : null;\n });\n\n protected readonly widthValue = computed(() => {\n const width = this.width() ?? DEFAULT_WIDTHS[this.variant()];\n\n return Object.hasOwn(WIDTH_VALUES, width) ? WIDTH_VALUES[width as DialogWidth] : width;\n });\n\n protected readonly spec = computed(() => VARIANTS[this.variant()]);\n\n protected readonly hairlines = computed(() => Boolean(this.closeLabel()) && this.variant() === 'default');\n\n protected readonly headerClasses = computed(\n () =>\n `flex ${this.description() ? 'items-start' : 'items-center'} gap-2 pl-4 max-lg:touch-none lg:gap-3 ${this.spec().header} ${this.closeLabel() ? 'pr-2 lg:pr-4' : 'pr-4 lg:pr-6'} ${this.hairlines() ? 'shadow-[inset_0_-1px_0_var(--hairline)]' : ''}`,\n );\n\n protected readonly crossClasses =\n 'rounded-pill lg:rounded-control grid size-11 flex-none cursor-pointer place-items-center text-(--muted-foreground) transition-[scale,background-color,color] [transition-duration:var(--duration-press),var(--duration-fast),var(--duration-fast)] ease-out outline-none focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-(--ring) active:scale-(--press-scale) active:bg-(--soft) disabled:pointer-events-none disabled:opacity-40 lg:size-9 lg:hover:bg-(--glow) lg:hover:text-(--foreground)';\n\n protected readonly footerClasses = computed(\n () =>\n `max-lg:[&>[ui-button]]:text-body flex justify-end gap-2 px-4 pb-[calc(8px+env(safe-area-inset-bottom))] max-lg:flex-col-reverse max-lg:[&>[ui-button]]:h-[50px] max-lg:[&>[ui-button]]:w-full lg:px-6 ${this.spec().footer} ${this.hairlines() ? 'shadow-[inset_0_1px_0_var(--hairline)]' : ''}`,\n );\n\n protected readonly classes = computed(\n () =>\n `open:flex w-full flex-col overflow-hidden m-auto mt-auto max-lg:max-h-[calc(100dvh-2rem)] lg:max-h-[calc(100dvh-96px)] max-lg:mb-0 max-lg:max-w-none max-lg:rounded-b-none lg:max-w-(--dialog-width) rounded-container bg-(--card) text-(--foreground) outline-none shadow-[0_0_0_1px_var(--border),0_24px_64px_rgb(0_0_0/0.24)] max-lg:shadow-[0_-1px_0_var(--border),0_-12px_32px_rgb(0_0_0/0.16)] ${this.stacked() ? 'backdrop:bg-black/[0.24]' : 'backdrop:bg-black/[0.36]'} ${this.sheet() === 'full' ? 'max-lg:h-[calc(100dvh-58px)]' : ''}`,\n );\n\n readonly #host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n #drag: SheetDrag | null = null;\n\n protected readonly modal: ModalClose<DialogCloseReason>;\n\n constructor() {\n const destroyRef = inject(DestroyRef);\n\n afterNextRender(() => {\n const host = this.#host.nativeElement;\n const dialog = host.querySelector('dialog') as HTMLDialogElement;\n const grips = ['[data-dialog-handle]', '[data-dialog-header]'].map(\n (grip) => host.querySelector(grip) as HTMLElement,\n );\n\n this.#drag = new SheetDrag(\n dialog,\n grips,\n () => this.modal.close('drag'),\n () => !this.busy(),\n );\n destroyRef.onDestroy(() => this.#drag?.destroy());\n\n if (typeof ResizeObserver === 'undefined') {\n return;\n }\n\n const body = host.querySelector('[data-dialog-body]') as HTMLElement;\n const observer = new ResizeObserver(() => this.scrollable.set(body.scrollHeight > body.clientHeight));\n\n observer.observe(body);\n observer.observe(body.firstElementChild as Element);\n destroyRef.onDestroy(() => observer.disconnect());\n });\n\n this.modal = new ModalClose<DialogCloseReason>({\n open: this.open,\n busy: this.busy,\n dismissed: this.dismissed,\n closed: this.closed,\n reset: () => this.#drag?.reset(),\n opening: () => this.stacked.set(this.#overAnotherModal()),\n });\n }\n\n #overAnotherModal(): boolean {\n const open = this.#host.nativeElement.ownerDocument.querySelectorAll('dialog[open]');\n\n return Array.from(open).some((dialog) => dialog.matches(':modal'));\n }\n}\n"],"mappings":";;ACAA,MAAM,QAAQ;AAEd,SAAgB,UAAU,SAAsB,MAAgB;CAC9D,MAAM,QAAQ,iBAAiB,OAAO;CACtC,MAAM,OAAO,QAAQ,MAAM,kBAAkB,IAAI,QAAQ,MAAM,eAAe;CAE9E,IAAI,SAAS,GAAG;EACd,KAAI;EACJ,aAAa;CACf;CAEA,MAAM,SAAS,UAAgC;EAC7C,IAAI,MAAM,WAAW,WAAW,CA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A;GAAA,QAAA;EAAA;EAAA,MAAA,EAAA,WAAA;GAAA,eAAA;GAAA,SAAA;GAAA,WAAA;EAAA,EAAA;EAAA,UAAA;EAAA,UA9ET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2ET,UAAA;EAAA,QAAA,CAAA,o3CAAA;CAAA,CAAA;;AAGU,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EArFpB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAW,MACf;IACJ,iBAAiB;IACjB,WAAW;IACX,aAAa;GACd;GAAA,UACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2ET,QAAA,CAAA,o3CAAA;EAAA,CAAA"}
|
|
@@ -4,16 +4,16 @@ import { Component, computed, input, output, signal } from "@angular/core";
|
|
|
4
4
|
const CIRCUMFERENCE = 2 * Math.PI * 78;
|
|
5
5
|
const GAP = 2;
|
|
6
6
|
function positionSlices(slices) {
|
|
7
|
-
let
|
|
7
|
+
let traveled = 0;
|
|
8
8
|
return slices.map((slice) => {
|
|
9
9
|
const length = slice.share * CIRCUMFERENCE;
|
|
10
10
|
const drawn = Math.max(0, length - GAP);
|
|
11
11
|
const positioned = {
|
|
12
12
|
...slice,
|
|
13
13
|
dash: `${drawn.toFixed(2)} ${(CIRCUMFERENCE - drawn).toFixed(2)}`,
|
|
14
|
-
offset: (-
|
|
14
|
+
offset: (-traveled).toFixed(2)
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
traveled += length;
|
|
17
17
|
return positioned;
|
|
18
18
|
});
|
|
19
19
|
}
|
|
@@ -76,7 +76,7 @@ var UiDonut = class UiDonut {
|
|
|
76
76
|
}, ...ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []);
|
|
77
77
|
ariaLabel = computed(() => {
|
|
78
78
|
const detail = shareSlices(this.slices()).map((slice) => `${slice.label} ${this.shareFormat()(slice.share)}`).join(", ");
|
|
79
|
-
return detail ? `${this.label()}
|
|
79
|
+
return detail ? `${this.label()}: ${detail}` : this.label();
|
|
80
80
|
}, ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
|
|
81
81
|
radius = 78;
|
|
82
82
|
ringWidth = 30;
|
|
@@ -120,7 +120,7 @@ var UiDonut = class UiDonut {
|
|
|
120
120
|
}
|
|
121
121
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
122
122
|
minVersion: "12.0.0",
|
|
123
|
-
version: "22.2.
|
|
123
|
+
version: "22.2.2",
|
|
124
124
|
ngImport: i0,
|
|
125
125
|
type: UiDonut,
|
|
126
126
|
deps: [],
|
|
@@ -128,7 +128,7 @@ var UiDonut = class UiDonut {
|
|
|
128
128
|
});
|
|
129
129
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
130
130
|
minVersion: "17.0.0",
|
|
131
|
-
version: "22.2.
|
|
131
|
+
version: "22.2.2",
|
|
132
132
|
type: UiDonut,
|
|
133
133
|
isStandalone: true,
|
|
134
134
|
selector: "ui-donut",
|
|
@@ -284,7 +284,7 @@ var UiDonut = class UiDonut {
|
|
|
284
284
|
};
|
|
285
285
|
i0.ɵɵngDeclareClassMetadata({
|
|
286
286
|
minVersion: "12.0.0",
|
|
287
|
-
version: "22.2.
|
|
287
|
+
version: "22.2.2",
|
|
288
288
|
ngImport: i0,
|
|
289
289
|
type: UiDonut,
|
|
290
290
|
decorators: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joanroucoux-cairn-ui-donut.mjs","names":[],"sources":["../../../projects/ui/donut/internal/donut-geometry.ts","../../../projects/ui/donut/internal/donut-slices.ts","../../../projects/ui/donut/donut.ts"],"sourcesContent":["import type { RankedSlice } from './donut-slices';\n\nexport type PositionedSlice = RankedSlice & { dash: string; offset: string };\n\nexport const RADIUS = 78;\nexport const RING_WIDTH = 30;\nexport const CIRCUMFERENCE = 2 * Math.PI * RADIUS;\n\nconst GAP = 2;\n\nexport function positionSlices(slices: RankedSlice[]): PositionedSlice[] {\n let travelled = 0;\n\n return slices.map((slice) => {\n const length = slice.share * CIRCUMFERENCE;\n const drawn = Math.max(0, length - GAP);\n const positioned = {\n ...slice,\n dash: `${drawn.toFixed(2)} ${(CIRCUMFERENCE - drawn).toFixed(2)}`,\n offset: (-travelled).toFixed(2),\n };\n travelled += length;\n\n return positioned;\n });\n}\n","export type DonutSlice = {\n id: string;\n label: string;\n value: number;\n sublabel?: string;\n};\n\nexport type Ramp = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type SharedSlice = DonutSlice & { share: number };\n\nexport type RankedSlice = DonutSlice & { share: number; ramp: Ramp; members: string[] };\n\nconst MAX_RAMP = 6;\nconst OTHERS_ID = 'others';\n\nexport function shareSlices(slices: DonutSlice[]): SharedSlice[] {\n const positive = slices.filter((slice) => slice.value > 0).sort((a, b) => b.value - a.value);\n const total = positive.reduce((sum, slice) => sum + slice.value, 0);\n\n return positive.map((slice) => ({ ...slice, share: slice.value / total }));\n}\n\nexport function rankSlices(slices: DonutSlice[], othersLabel: string): RankedSlice[] {\n const shared = shareSlices(slices);\n\n const toRanked = (slice: SharedSlice, ramp: Ramp, members: string[] = []): RankedSlice => ({\n ...slice,\n ramp,\n members,\n });\n\n if (shared.length <= MAX_RAMP) {\n return shared.map((slice, index) => toRanked(slice, (index + 1) as Ramp));\n }\n\n const kept = shared.slice(0, MAX_RAMP - 1);\n const rest = shared.slice(MAX_RAMP - 1);\n const othersValue = rest.reduce((sum, slice) => sum + slice.value, 0);\n const othersShare = rest.reduce((sum, slice) => sum + slice.share, 0);\n\n return [\n ...kept.map((slice, index) => toRanked(slice, (index + 1) as Ramp)),\n toRanked(\n { id: OTHERS_ID, label: othersLabel, value: othersValue, share: othersShare },\n MAX_RAMP,\n rest.map((slice) => slice.label),\n ),\n ];\n}\n","import { NgTemplateOutlet } from '@angular/common';\nimport { Component, computed, input, output, signal } from '@angular/core';\n\nimport { RADIUS, RING_WIDTH, positionSlices } from './internal/donut-geometry';\nimport { type DonutSlice, type Ramp, type RankedSlice, rankSlices, shareSlices } from './internal/donut-slices';\n\nexport type { DonutSlice };\n\nconst identityValue = (value: number): string => `${value}`;\nconst identityShare = (share: number): string => `${Math.round(share * 100)}%`;\n\nconst ROW_CLASSES =\n 'flex w-full items-center gap-3 min-h-14 px-2 py-1 [font-variant-numeric:var(--numeric)] rounded-control text-left transition-[scale,background-color] [transition-duration:var(--duration-press),var(--duration-fast)] ease-out hover:bg-(--glow) active:bg-(--soft) active:scale-(--press-scale) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring)';\n\nconst SLICE_CLASSES =\n 'cursor-pointer origin-center [transform-box:view-box] transition-[scale,opacity] duration-(--duration-fast) ease-out';\n\nconst RAMP_DOT_CLASSES: Record<Ramp, string> = {\n 1: 'bg-(--ramp-1)',\n 2: 'bg-(--ramp-2)',\n 3: 'bg-(--ramp-3)',\n 4: 'bg-(--ramp-4)',\n 5: 'bg-(--ramp-5)',\n 6: 'bg-(--ramp-6)',\n};\n\n/**\n * A ring chart with a legend: slices rank from largest to smallest, and hovering, focusing or\n * activating a legend row highlights its slice.\n *\n * @example\n * <ui-donut [slices]=\"byAssetClass()\" label=\"Par classe d'actif\" othersLabel=\"Autres\" [valueFormat]=\"formatEur\" [shareFormat]=\"formatShare\" (sliceSelect)=\"goToHoldings($event)\" />\n */\n@Component({\n selector: 'ui-donut',\n template: `\n <div class=\"relative size-[232px] flex-none sm:size-60\">\n <svg class=\"block h-full w-full -rotate-90\" role=\"img\" viewBox=\"0 0 200 200\" [attr.aria-label]=\"ariaLabel()\">\n <circle\n class=\"stroke-(--muted)\"\n cx=\"100\"\n cy=\"100\"\n fill=\"none\"\n [attr.r]=\"radius\"\n [attr.stroke-width]=\"ringWidth\"\n />\n @for (slice of positioned(); track slice.id) {\n <circle\n cx=\"100\"\n cy=\"100\"\n data-slice\n fill=\"none\"\n [attr.r]=\"radius\"\n [attr.stroke-dasharray]=\"slice.dash\"\n [attr.stroke-dashoffset]=\"slice.offset\"\n [attr.stroke-width]=\"ringWidth\"\n [class]=\"sliceClasses(slice)\"\n [style.stroke]=\"strokeColor(slice)\"\n (click)=\"select(slice)\"\n (pointerenter)=\"highlight(slice.id)\"\n (pointerleave)=\"clearHighlight(slice.id)\"\n />\n }\n </svg>\n\n @if (active(); as slice) {\n <div\n class=\"pointer-events-none absolute inset-0 flex flex-col items-center justify-center px-12 text-center\"\n data-testid=\"donut-centre\"\n >\n <span class=\"text-label max-w-full truncate font-medium whitespace-nowrap text-(--muted-foreground)\">{{\n slice.label\n }}</span>\n <span class=\"text-heading font-semibold tracking-(--tracking-display)\">{{ shareFormat()(slice.share) }}</span>\n <span class=\"text-caption tracking-normal text-(--muted-foreground) [font-variant-numeric:var(--numeric)]\">{{\n valueFormat()(slice.value)\n }}</span>\n </div>\n }\n </div>\n\n <div class=\"flex w-full min-w-0 flex-1 flex-col sm:w-auto\" data-testid=\"donut-legend\">\n @for (slice of ranked(); track slice.id) {\n @if (hrefFor(slice.id); as href) {\n <a\n [attr.href]=\"href\"\n [class]=\"rowClasses(slice)\"\n (blur)=\"clearHighlight(slice.id)\"\n (click)=\"follow($event, slice)\"\n (focus)=\"highlight(slice.id)\"\n (pointerenter)=\"highlight(slice.id)\"\n (pointerleave)=\"clearHighlight(slice.id)\"\n >\n <ng-container *ngTemplateOutlet=\"rowContent; context: { $implicit: slice }\" />\n </a>\n } @else {\n <button\n type=\"button\"\n [class]=\"rowClasses(slice)\"\n (blur)=\"clearHighlight(slice.id)\"\n (click)=\"select(slice)\"\n (focus)=\"highlight(slice.id)\"\n (pointerenter)=\"highlight(slice.id)\"\n (pointerleave)=\"clearHighlight(slice.id)\"\n >\n <ng-container *ngTemplateOutlet=\"rowContent; context: { $implicit: slice }\" />\n </button>\n }\n }\n </div>\n\n <ng-template #rowContent let-slice>\n <span [class]=\"dotClasses(slice)\"></span>\n <span class=\"flex min-w-0 flex-1 flex-col\">\n <span class=\"text-body truncate font-medium\">{{ slice.label }}</span>\n <span class=\"text-caption truncate tracking-(--tracking-caption) text-(--subtle-foreground)\">{{\n subLabel(slice)\n }}</span>\n </span>\n <span class=\"flex flex-none flex-col items-end whitespace-nowrap\">\n <span class=\"text-body font-medium\">{{ shareFormat()(slice.share) }}</span>\n <span class=\"text-caption tracking-normal text-(--muted-foreground)\">{{ valueFormat()(slice.value) }}</span>\n </span>\n </ng-template>\n `,\n imports: [NgTemplateOutlet],\n host: {\n class: 'flex flex-col items-center gap-3 sm:flex-row sm:items-center sm:gap-8',\n },\n})\nexport class UiDonut {\n readonly slices = input.required<DonutSlice[]>();\n readonly label = input.required<string>();\n readonly othersLabel = input.required<string>();\n readonly valueFormat = input<(value: number) => string>(identityValue);\n readonly shareFormat = input<(share: number) => string>(identityShare);\n\n readonly legendHref = input<((id: string) => string | null) | undefined>();\n\n readonly sliceSelect = output<DonutSlice['id']>();\n\n protected readonly activeId = signal<string | null>(null);\n\n protected readonly ranked = computed(() => rankSlices(this.slices(), this.othersLabel()));\n protected readonly positioned = computed(() => positionSlices(this.ranked()));\n\n protected readonly active = computed<RankedSlice | null>(() => {\n const ranked = this.ranked();\n const id = this.activeId();\n\n return ranked.find((slice) => slice.id === id) ?? ranked[0] ?? null;\n });\n\n protected readonly ariaLabel = computed(() => {\n const detail = shareSlices(this.slices())\n .map((slice) => `${slice.label} ${this.shareFormat()(slice.share)}`)\n .join(', ');\n\n return detail ? `${this.label()} : ${detail}` : this.label();\n });\n\n protected readonly radius = RADIUS;\n protected readonly ringWidth = RING_WIDTH;\n\n protected strokeColor(slice: RankedSlice): string {\n return `var(--ramp-${slice.ramp})`;\n }\n\n protected sliceClasses(slice: RankedSlice): string {\n const id = this.activeId();\n if (id === null) {\n return SLICE_CLASSES;\n }\n\n return `${SLICE_CLASSES} ${id === slice.id ? 'scale-104 motion-reduce:scale-100' : 'opacity-50'}`;\n }\n\n protected dotClasses(slice: RankedSlice): string {\n return `size-3 flex-none rounded-pill shadow-[inset_0_0_0_1px_var(--border)] ${RAMP_DOT_CLASSES[slice.ramp]}`;\n }\n\n protected rowClasses(slice: RankedSlice): string {\n return `${ROW_CLASSES}${this.isActive(slice) ? ' bg-(--soft)' : ''}`;\n }\n\n protected subLabel(slice: RankedSlice): string {\n return slice.members.length > 0 ? slice.members.join(', ') : (slice.sublabel ?? '');\n }\n\n protected isActive(slice: RankedSlice): boolean {\n return this.active()?.id === slice.id;\n }\n\n protected highlight(id: string): void {\n this.activeId.set(id);\n }\n\n protected clearHighlight(id: string): void {\n if (this.activeId() === id) {\n this.activeId.set(null);\n }\n }\n\n protected hrefFor(id: string): string | null {\n return this.legendHref()?.(id) ?? null;\n }\n\n protected follow(event: MouseEvent, slice: RankedSlice): void {\n if (event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {\n return;\n }\n event.preventDefault();\n this.select(slice);\n }\n\n protected select(slice: RankedSlice): void {\n this.activeId.set(slice.id);\n this.sliceSelect.emit(slice.id);\n }\n}\n"],"mappings":";;;AAMA,MAAa,gBAAgB,IAAI,KAAK,KAAA;AAEtC,MAAM,MAAM;AAEZ,SAAgB,eAAe,QAAqB;CAClD,IAAI,YAAY;CAEhB,OAAO,OAAO,KAAK,UAAS;EAC1B,MAAM,SAAS,MAAM,QAAQ;EAC7B,MAAM,QAAQ,KAAK,IAAI,GAAG,SAAS,GAAG;EACtC,MAAM,aAAa;GACjB,GAAG;GACH,MAAM,GAAG,MAAM,QAAQ,CAAC,EAAC,IAAK,gBAAgB,MAAA,CAAO,QAAQ,CAAC;GAC9D,SAAS,CAAC,UAAA,CAAW,QAAQ,CAAC;EAC/B;EACD,aAAa;EAEb,OAAO;CACT,CAAC;AACH;ACZA,MAAM,WAAW;AACjB,MAAM,YAAY;AAElB,SAAgB,YAAY,QAAoB;CAC9C,MAAM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MAAM,EACJ,OAAO,wEACR;EACF,CAAA"}
|
|
1
|
+
{"version":3,"file":"joanroucoux-cairn-ui-donut.mjs","names":[],"sources":["../../../projects/ui/donut/internal/donut-geometry.ts","../../../projects/ui/donut/internal/donut-slices.ts","../../../projects/ui/donut/donut.ts"],"sourcesContent":["import type { RankedSlice } from './donut-slices';\n\nexport type PositionedSlice = RankedSlice & { dash: string; offset: string };\n\nexport const RADIUS = 78;\nexport const RING_WIDTH = 30;\nexport const CIRCUMFERENCE = 2 * Math.PI * RADIUS;\n\nconst GAP = 2;\n\nexport function positionSlices(slices: RankedSlice[]): PositionedSlice[] {\n let traveled = 0;\n\n return slices.map((slice) => {\n const length = slice.share * CIRCUMFERENCE;\n const drawn = Math.max(0, length - GAP);\n const positioned = {\n ...slice,\n dash: `${drawn.toFixed(2)} ${(CIRCUMFERENCE - drawn).toFixed(2)}`,\n offset: (-traveled).toFixed(2),\n };\n traveled += length;\n\n return positioned;\n });\n}\n","export type DonutSlice = {\n id: string;\n label: string;\n value: number;\n sublabel?: string;\n};\n\nexport type Ramp = 1 | 2 | 3 | 4 | 5 | 6;\n\nexport type SharedSlice = DonutSlice & { share: number };\n\nexport type RankedSlice = DonutSlice & { share: number; ramp: Ramp; members: string[] };\n\nconst MAX_RAMP = 6;\nconst OTHERS_ID = 'others';\n\nexport function shareSlices(slices: DonutSlice[]): SharedSlice[] {\n const positive = slices.filter((slice) => slice.value > 0).sort((a, b) => b.value - a.value);\n const total = positive.reduce((sum, slice) => sum + slice.value, 0);\n\n return positive.map((slice) => ({ ...slice, share: slice.value / total }));\n}\n\nexport function rankSlices(slices: DonutSlice[], othersLabel: string): RankedSlice[] {\n const shared = shareSlices(slices);\n\n const toRanked = (slice: SharedSlice, ramp: Ramp, members: string[] = []): RankedSlice => ({\n ...slice,\n ramp,\n members,\n });\n\n if (shared.length <= MAX_RAMP) {\n return shared.map((slice, index) => toRanked(slice, (index + 1) as Ramp));\n }\n\n const kept = shared.slice(0, MAX_RAMP - 1);\n const rest = shared.slice(MAX_RAMP - 1);\n const othersValue = rest.reduce((sum, slice) => sum + slice.value, 0);\n const othersShare = rest.reduce((sum, slice) => sum + slice.share, 0);\n\n return [\n ...kept.map((slice, index) => toRanked(slice, (index + 1) as Ramp)),\n toRanked(\n { id: OTHERS_ID, label: othersLabel, value: othersValue, share: othersShare },\n MAX_RAMP,\n rest.map((slice) => slice.label),\n ),\n ];\n}\n","import { NgTemplateOutlet } from '@angular/common';\nimport { Component, computed, input, output, signal } from '@angular/core';\n\nimport { RADIUS, RING_WIDTH, positionSlices } from './internal/donut-geometry';\nimport { type DonutSlice, type Ramp, type RankedSlice, rankSlices, shareSlices } from './internal/donut-slices';\n\nexport type { DonutSlice };\n\nconst identityValue = (value: number): string => `${value}`;\nconst identityShare = (share: number): string => `${Math.round(share * 100)}%`;\n\nconst ROW_CLASSES =\n 'flex w-full items-center gap-3 min-h-14 px-2 py-1 [font-variant-numeric:var(--numeric)] rounded-control text-left transition-[scale,background-color] [transition-duration:var(--duration-press),var(--duration-fast)] ease-out hover:bg-(--glow) active:bg-(--soft) active:scale-(--press-scale) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring)';\n\nconst SLICE_CLASSES =\n 'cursor-pointer origin-center [transform-box:view-box] transition-[scale,opacity] duration-(--duration-fast) ease-out';\n\nconst RAMP_DOT_CLASSES: Record<Ramp, string> = {\n 1: 'bg-(--ramp-1)',\n 2: 'bg-(--ramp-2)',\n 3: 'bg-(--ramp-3)',\n 4: 'bg-(--ramp-4)',\n 5: 'bg-(--ramp-5)',\n 6: 'bg-(--ramp-6)',\n};\n\n/**\n * A ring chart with a legend: slices rank from largest to smallest, and hovering, focusing or\n * activating a legend row highlights its slice.\n *\n * @example\n * <ui-donut [slices]=\"byAssetClass()\" label=\"By asset class\" othersLabel=\"Other\" [valueFormat]=\"formatEur\" [shareFormat]=\"formatShare\" (sliceSelect)=\"goToHoldings($event)\" />\n */\n@Component({\n selector: 'ui-donut',\n template: `\n <div class=\"relative size-[232px] flex-none sm:size-60\">\n <svg class=\"block h-full w-full -rotate-90\" role=\"img\" viewBox=\"0 0 200 200\" [attr.aria-label]=\"ariaLabel()\">\n <circle\n class=\"stroke-(--muted)\"\n cx=\"100\"\n cy=\"100\"\n fill=\"none\"\n [attr.r]=\"radius\"\n [attr.stroke-width]=\"ringWidth\"\n />\n @for (slice of positioned(); track slice.id) {\n <circle\n cx=\"100\"\n cy=\"100\"\n data-slice\n fill=\"none\"\n [attr.r]=\"radius\"\n [attr.stroke-dasharray]=\"slice.dash\"\n [attr.stroke-dashoffset]=\"slice.offset\"\n [attr.stroke-width]=\"ringWidth\"\n [class]=\"sliceClasses(slice)\"\n [style.stroke]=\"strokeColor(slice)\"\n (click)=\"select(slice)\"\n (pointerenter)=\"highlight(slice.id)\"\n (pointerleave)=\"clearHighlight(slice.id)\"\n />\n }\n </svg>\n\n @if (active(); as slice) {\n <div\n class=\"pointer-events-none absolute inset-0 flex flex-col items-center justify-center px-12 text-center\"\n data-testid=\"donut-centre\"\n >\n <span class=\"text-label max-w-full truncate font-medium whitespace-nowrap text-(--muted-foreground)\">{{\n slice.label\n }}</span>\n <span class=\"text-heading font-semibold tracking-(--tracking-display)\">{{ shareFormat()(slice.share) }}</span>\n <span class=\"text-caption tracking-normal text-(--muted-foreground) [font-variant-numeric:var(--numeric)]\">{{\n valueFormat()(slice.value)\n }}</span>\n </div>\n }\n </div>\n\n <div class=\"flex w-full min-w-0 flex-1 flex-col sm:w-auto\" data-testid=\"donut-legend\">\n @for (slice of ranked(); track slice.id) {\n @if (hrefFor(slice.id); as href) {\n <a\n [attr.href]=\"href\"\n [class]=\"rowClasses(slice)\"\n (blur)=\"clearHighlight(slice.id)\"\n (click)=\"follow($event, slice)\"\n (focus)=\"highlight(slice.id)\"\n (pointerenter)=\"highlight(slice.id)\"\n (pointerleave)=\"clearHighlight(slice.id)\"\n >\n <ng-container *ngTemplateOutlet=\"rowContent; context: { $implicit: slice }\" />\n </a>\n } @else {\n <button\n type=\"button\"\n [class]=\"rowClasses(slice)\"\n (blur)=\"clearHighlight(slice.id)\"\n (click)=\"select(slice)\"\n (focus)=\"highlight(slice.id)\"\n (pointerenter)=\"highlight(slice.id)\"\n (pointerleave)=\"clearHighlight(slice.id)\"\n >\n <ng-container *ngTemplateOutlet=\"rowContent; context: { $implicit: slice }\" />\n </button>\n }\n }\n </div>\n\n <ng-template #rowContent let-slice>\n <span [class]=\"dotClasses(slice)\"></span>\n <span class=\"flex min-w-0 flex-1 flex-col\">\n <span class=\"text-body truncate font-medium\">{{ slice.label }}</span>\n <span class=\"text-caption truncate tracking-(--tracking-caption) text-(--subtle-foreground)\">{{\n subLabel(slice)\n }}</span>\n </span>\n <span class=\"flex flex-none flex-col items-end whitespace-nowrap\">\n <span class=\"text-body font-medium\">{{ shareFormat()(slice.share) }}</span>\n <span class=\"text-caption tracking-normal text-(--muted-foreground)\">{{ valueFormat()(slice.value) }}</span>\n </span>\n </ng-template>\n `,\n imports: [NgTemplateOutlet],\n host: {\n class: 'flex flex-col items-center gap-3 sm:flex-row sm:items-center sm:gap-8',\n },\n})\nexport class UiDonut {\n readonly slices = input.required<DonutSlice[]>();\n readonly label = input.required<string>();\n readonly othersLabel = input.required<string>();\n readonly valueFormat = input<(value: number) => string>(identityValue);\n readonly shareFormat = input<(share: number) => string>(identityShare);\n\n readonly legendHref = input<((id: string) => string | null) | undefined>();\n\n readonly sliceSelect = output<DonutSlice['id']>();\n\n protected readonly activeId = signal<string | null>(null);\n\n protected readonly ranked = computed(() => rankSlices(this.slices(), this.othersLabel()));\n protected readonly positioned = computed(() => positionSlices(this.ranked()));\n\n protected readonly active = computed<RankedSlice | null>(() => {\n const ranked = this.ranked();\n const id = this.activeId();\n\n return ranked.find((slice) => slice.id === id) ?? ranked[0] ?? null;\n });\n\n protected readonly ariaLabel = computed(() => {\n const detail = shareSlices(this.slices())\n .map((slice) => `${slice.label} ${this.shareFormat()(slice.share)}`)\n .join(', ');\n\n return detail ? `${this.label()}: ${detail}` : this.label();\n });\n\n protected readonly radius = RADIUS;\n protected readonly ringWidth = RING_WIDTH;\n\n protected strokeColor(slice: RankedSlice): string {\n return `var(--ramp-${slice.ramp})`;\n }\n\n protected sliceClasses(slice: RankedSlice): string {\n const id = this.activeId();\n if (id === null) {\n return SLICE_CLASSES;\n }\n\n return `${SLICE_CLASSES} ${id === slice.id ? 'scale-104 motion-reduce:scale-100' : 'opacity-50'}`;\n }\n\n protected dotClasses(slice: RankedSlice): string {\n return `size-3 flex-none rounded-pill shadow-[inset_0_0_0_1px_var(--border)] ${RAMP_DOT_CLASSES[slice.ramp]}`;\n }\n\n protected rowClasses(slice: RankedSlice): string {\n return `${ROW_CLASSES}${this.isActive(slice) ? ' bg-(--soft)' : ''}`;\n }\n\n protected subLabel(slice: RankedSlice): string {\n return slice.members.length > 0 ? slice.members.join(', ') : (slice.sublabel ?? '');\n }\n\n protected isActive(slice: RankedSlice): boolean {\n return this.active()?.id === slice.id;\n }\n\n protected highlight(id: string): void {\n this.activeId.set(id);\n }\n\n protected clearHighlight(id: string): void {\n if (this.activeId() === id) {\n this.activeId.set(null);\n }\n }\n\n protected hrefFor(id: string): string | null {\n return this.legendHref()?.(id) ?? null;\n }\n\n protected follow(event: MouseEvent, slice: RankedSlice): void {\n if (event.button !== 0 || event.ctrlKey || event.metaKey || event.shiftKey || event.altKey) {\n return;\n }\n event.preventDefault();\n this.select(slice);\n }\n\n protected select(slice: RankedSlice): void {\n this.activeId.set(slice.id);\n this.sliceSelect.emit(slice.id);\n }\n}\n"],"mappings":";;;AAMA,MAAa,gBAAgB,IAAI,KAAK,KAAA;AAEtC,MAAM,MAAM;AAEZ,SAAgB,eAAe,QAAqB;CAClD,IAAI,WAAW;CAEf,OAAO,OAAO,KAAK,UAAS;EAC1B,MAAM,SAAS,MAAM,QAAQ;EAC7B,MAAM,QAAQ,KAAK,IAAI,GAAG,SAAS,GAAG;EACtC,MAAM,aAAa;GACjB,GAAG;GACH,MAAM,G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AA,UAAA;CAAA,MAAA;CAAO,YAAA,CAAA;EAjGnB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FV,SAAS,CAAC,gBAAgB;GAC1B,MAAM,EACJ,OAAO,wEACR;EACF,CAAA"}
|
|
@@ -44,7 +44,7 @@ var UiDrawer = class UiDrawer {
|
|
|
44
44
|
});
|
|
45
45
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
46
46
|
minVersion: "12.0.0",
|
|
47
|
-
version: "22.2.
|
|
47
|
+
version: "22.2.2",
|
|
48
48
|
ngImport: i0,
|
|
49
49
|
type: UiDrawer,
|
|
50
50
|
deps: [],
|
|
@@ -52,7 +52,7 @@ var UiDrawer = class UiDrawer {
|
|
|
52
52
|
});
|
|
53
53
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
54
54
|
minVersion: "17.0.0",
|
|
55
|
-
version: "22.2.
|
|
55
|
+
version: "22.2.2",
|
|
56
56
|
type: UiDrawer,
|
|
57
57
|
isStandalone: true,
|
|
58
58
|
selector: "ui-drawer",
|
|
@@ -170,7 +170,7 @@ var UiDrawer = class UiDrawer {
|
|
|
170
170
|
};
|
|
171
171
|
i0.ɵɵngDeclareClassMetadata({
|
|
172
172
|
minVersion: "12.0.0",
|
|
173
|
-
version: "22.2.
|
|
173
|
+
version: "22.2.2",
|
|
174
174
|
ngImport: i0,
|
|
175
175
|
type: UiDrawer,
|
|
176
176
|
decorators: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joanroucoux-cairn-ui-drawer.mjs","names":[],"sources":["../../../projects/ui/drawer/internal/drawer-styles.ts","../../../projects/ui/drawer/drawer.ts"],"sourcesContent":["export const DRAWER_STYLES = `\ndialog {\n transition:\n opacity var(--duration-base) var(--ease-out),\n transform var(--duration-base) var(--ease-out),\n overlay var(--duration-base) allow-discrete,\n display var(--duration-base) allow-discrete;\n opacity: 1;\n transform: none;\n}\n\ndialog:not([open]) {\n opacity: 0;\n transform: translateX(24px);\n transition-duration: var(--duration-exit);\n}\n\n@starting-style {\n dialog[open] {\n opacity: 0;\n transform: translateX(24px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n dialog:not([open]) {\n transform: none;\n }\n\n @starting-style {\n dialog[open] {\n transform: none;\n }\n }\n}\n\ndialog::backdrop {\n transition: opacity var(--duration-base) var(--ease-out);\n opacity: 1;\n}\n\ndialog:not([open])::backdrop {\n opacity: 0;\n transition-duration: var(--duration-exit);\n}\n\n@starting-style {\n dialog[open]::backdrop {\n opacity: 0;\n }\n}\n`;\n","import { Component, booleanAttribute, computed, input, output } from '@angular/core';\n\nimport { ModalClose } from '@joanroucoux/cairn-ui/dialog';\n\nimport { DRAWER_STYLES } from './internal/drawer-styles';\n\n/** What started a close, as `closed` reports it. */\nexport const DRAWER_CLOSE_REASONS = ['escape', 'backdrop', 'cross', 'programmatic'] as const;\nexport type DrawerCloseReason = (typeof DRAWER_CLOSE_REASONS)[number];\n\nconst nextId = (() => {\n let count = 0;\n\n return () => `ui-drawer-${++count}`;\n})();\n\n/**\n * Modal side panel on the native <dialog>, against the right edge at full height, for a detail opened from a list.\n *\n * Without `heading` it draws no header: the content brings its own title and close button, and `label` names it.\n * With both, `label` names the panel and the heading stays its visible title.\n *\n * @example\n * <ui-drawer heading=\"Northwind
|
|
1
|
+
{"version":3,"file":"joanroucoux-cairn-ui-drawer.mjs","names":[],"sources":["../../../projects/ui/drawer/internal/drawer-styles.ts","../../../projects/ui/drawer/drawer.ts"],"sourcesContent":["export const DRAWER_STYLES = `\ndialog {\n transition:\n opacity var(--duration-base) var(--ease-out),\n transform var(--duration-base) var(--ease-out),\n overlay var(--duration-base) allow-discrete,\n display var(--duration-base) allow-discrete;\n opacity: 1;\n transform: none;\n}\n\ndialog:not([open]) {\n opacity: 0;\n transform: translateX(24px);\n transition-duration: var(--duration-exit);\n}\n\n@starting-style {\n dialog[open] {\n opacity: 0;\n transform: translateX(24px);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n dialog:not([open]) {\n transform: none;\n }\n\n @starting-style {\n dialog[open] {\n transform: none;\n }\n }\n}\n\ndialog::backdrop {\n transition: opacity var(--duration-base) var(--ease-out);\n opacity: 1;\n}\n\ndialog:not([open])::backdrop {\n opacity: 0;\n transition-duration: var(--duration-exit);\n}\n\n@starting-style {\n dialog[open]::backdrop {\n opacity: 0;\n }\n}\n`;\n","import { Component, booleanAttribute, computed, input, output } from '@angular/core';\n\nimport { ModalClose } from '@joanroucoux/cairn-ui/dialog';\n\nimport { DRAWER_STYLES } from './internal/drawer-styles';\n\n/** What started a close, as `closed` reports it. */\nexport const DRAWER_CLOSE_REASONS = ['escape', 'backdrop', 'cross', 'programmatic'] as const;\nexport type DrawerCloseReason = (typeof DRAWER_CLOSE_REASONS)[number];\n\nconst nextId = (() => {\n let count = 0;\n\n return () => `ui-drawer-${++count}`;\n})();\n\n/**\n * Modal side panel on the native <dialog>, against the right edge at full height, for a detail opened from a list.\n *\n * Without `heading` it draws no header: the content brings its own title and close button, and `label` names it.\n * With both, `label` names the panel and the heading stays its visible title.\n *\n * @example\n * <ui-drawer heading=\"Northwind World\" closeLabel=\"Close the detail\" [open]=\"open()\" (dismissed)=\"open.set(false)\">\n * <p>Body</p>\n * </ui-drawer>\n */\n@Component({\n selector: 'ui-drawer',\n host: {\n '(pointerdown)': 'modal.onPointerDown($event)',\n '(click)': 'modal.onClick($event)',\n '(keydown)': 'modal.onKeydown($event)',\n },\n template: `\n <dialog\n class=\"fixed inset-y-0 right-0 left-auto m-0 h-dvh max-h-none w-(--drawer-width) max-w-full [scrollbar-width:none] flex-col gap-6 overflow-y-auto overscroll-contain bg-(--card) p-6 text-(--foreground) shadow-[-1px_0_0_var(--border),-24px_0_48px_rgb(0_0_0/0.12)] outline-none backdrop:bg-black/[0.36] open:flex\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-describedby]=\"describedBy()\"\n [attr.aria-label]=\"ariaLabel()\"\n [attr.aria-labelledby]=\"labelledBy()\"\n [style.--drawer-width]=\"width()\"\n (cancel)=\"modal.onCancel($event)\"\n (close)=\"modal.onNativeClose()\"\n >\n @if (heading()) {\n <div class=\"flex items-start justify-between gap-3\">\n <div class=\"flex min-w-0 flex-col gap-0.5\">\n <h2 class=\"text-title font-semibold text-pretty\" [id]=\"headingId\">{{ heading() }}</h2>\n\n @if (description()) {\n <p class=\"text-label text-(--muted-foreground)\" [id]=\"descriptionId\">{{ description() }}</p>\n }\n </div>\n\n @if (closeLabel()) {\n <button\n class=\"rounded-control -mt-1 -mr-2 grid size-9 flex-none cursor-pointer place-items-center text-(--muted-foreground) transition-[scale] duration-(--duration-press) ease-out outline-none hover:bg-(--glow) hover:text-(--foreground) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--ring) active:scale-(--press-scale) disabled:pointer-events-none disabled:opacity-40\"\n type=\"button\"\n [attr.aria-label]=\"closeLabel()\"\n [disabled]=\"busy()\"\n (click)=\"modal.close('cross')\"\n >\n <svg\n aria-hidden=\"true\"\n class=\"block size-5 fill-none stroke-current stroke-[1.75]\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n viewBox=\"0 0 24 24\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </button>\n }\n </div>\n }\n\n <ng-content />\n </dialog>\n `,\n styles: DRAWER_STYLES,\n})\nexport class UiDrawer {\n readonly heading = input<string>();\n readonly description = input<string>();\n readonly closeLabel = input<string>();\n readonly label = input<string>();\n readonly width = input('440px');\n readonly open = input(false, { transform: booleanAttribute });\n readonly busy = input(false, { transform: booleanAttribute });\n readonly dismissed = output<void>();\n readonly closed = output<DrawerCloseReason>();\n\n protected readonly headingId = nextId();\n protected readonly descriptionId = `${this.headingId}-description`;\n\n protected readonly describedBy = computed(() => (this.heading() && this.description() ? this.descriptionId : null));\n\n protected readonly ariaLabel = computed(() => {\n if (this.label()) {\n return this.label();\n }\n if (!this.heading()) {\n throw new Error('ui-drawer needs a heading or a label: without either it has no accessible name.');\n }\n return null;\n });\n\n protected readonly labelledBy = computed(() => (this.heading() && !this.label() ? this.headingId : null));\n\n protected readonly modal = new ModalClose<DrawerCloseReason>({\n open: this.open,\n busy: this.busy,\n dismissed: this.dismissed,\n closed: this.closed,\n });\n}\n"],"mappings":";;;ACOA,MAAa,uBAAuB;CAAC;CAAU;CAAY;CAAS;AAAc;AAGlF,MAAM,gBAAe;CACnB,IAAI,QAAQ;CAEZ,aAAa,aAAa,EAAE;AAC9B,EAAA,CAAE;AAqEF,IAAa,WAAb,MAAa,SAAQ;CACV,UAAU,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CACzB,cAAc,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,cAAA,CAAA,+BAAA,CAAA,CAAA;CAC7B,aAAa,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,aAAA,CAAA,+BAAA,CAAA,CAAA;CAC5B,QAAQ,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACvB,QAAQ,MAAM,SAAQ,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACtB,OAAO,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,OAAA,+BAAA,CAAA;EAAI,WAAW;CAAgB,CAAA;CACjD,OAAO,MAAM,OAAK;EAAA,GAAA,YAAA,EAAA,WAAA,OAAA,+BAAA,CAAA;EAAI,WAAW;CAAgB,CAAA;CACjD,YAAY,OAAM;CAClB,SAAS,OAAM;CAEL,YAAY,OAAM;CAClB,gBAAgB,GAAG,KAAK,UAAS;CAEjC,cAAc,eAAgB,KAAK,QAAO,KAAM,KAAK,YAAW,I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YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,MAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,SAAA;GAAA,WAAA;GAAA,QAAA;EAAA;EAAA,MAAA,EAAA,WAAA;GAAA,eAAA;GAAA,SAAA;GAAA,WAAA;EAAA,EAAA;EAAA,UAAA;EAAA,UAjDT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8CT,UAAA;EAAA,QAAA,CAAA,gtBAAA;CAAA,CAAA;;AAGU,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA;EAxDpB,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAW,MACf;IACJ,iBAAiB;IACjB,WAAW;IACX,aAAa;GACd;GAAA,UACS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CT,QAAA,CAAA,gtBAAA;EAAA,CAAA"}
|
|
@@ -5,7 +5,7 @@ var UiEmpty = class UiEmpty {
|
|
|
5
5
|
hint = input("", ...ngDevMode ? [{ debugName: "hint" }] : /* istanbul ignore next */ []);
|
|
6
6
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
7
7
|
minVersion: "12.0.0",
|
|
8
|
-
version: "22.2.
|
|
8
|
+
version: "22.2.2",
|
|
9
9
|
ngImport: i0,
|
|
10
10
|
type: UiEmpty,
|
|
11
11
|
deps: [],
|
|
@@ -13,7 +13,7 @@ var UiEmpty = class UiEmpty {
|
|
|
13
13
|
});
|
|
14
14
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
15
15
|
minVersion: "17.0.0",
|
|
16
|
-
version: "22.2.
|
|
16
|
+
version: "22.2.2",
|
|
17
17
|
type: UiEmpty,
|
|
18
18
|
isStandalone: true,
|
|
19
19
|
selector: "ui-empty",
|
|
@@ -47,7 +47,7 @@ var UiEmpty = class UiEmpty {
|
|
|
47
47
|
};
|
|
48
48
|
i0.ɵɵngDeclareClassMetadata({
|
|
49
49
|
minVersion: "12.0.0",
|
|
50
|
-
version: "22.2.
|
|
50
|
+
version: "22.2.2",
|
|
51
51
|
ngImport: i0,
|
|
52
52
|
type: UiEmpty,
|
|
53
53
|
decorators: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joanroucoux-cairn-ui-empty.mjs","names":[],"sources":["../../../projects/ui/empty/empty.ts"],"sourcesContent":["import { Component, input } from '@angular/core';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"joanroucoux-cairn-ui-empty.mjs","names":[],"sources":["../../../projects/ui/empty/empty.ts"],"sourcesContent":["import { Component, input } from '@angular/core';\n\n/**\n * Centered empty state: a title, a hint and an action slot, such as a search that matches nothing.\n *\n * @example\n * <ui-empty heading=\"No holding matches “zzz”\" hint=\"Search covers the name and the ISIN.\">\n * <button ui-button variant=\"outline\" size=\"md\" type=\"button\">Add a holding</button>\n * </ui-empty>\n */\n@Component({\n selector: 'ui-empty',\n template: `\n <span class=\"text-body font-medium text-pretty\">{{ heading() }}</span>\n @if (hint()) {\n <span class=\"text-label text-(--muted-foreground)\">{{ hint() }}</span>\n }\n <div class=\"mt-2 empty:hidden\"><ng-content /></div>\n `,\n host: { class: 'flex flex-col items-center gap-1.5 px-2 py-6 text-center lg:py-12' },\n})\nexport class UiEmpty {\n readonly heading = input.required<string>();\n readonly hint = input('');\n}\n"],"mappings":";;AAqBA,IAAa,UAAb,MAAa,QAAO;CACT,UAAU,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CAClC,OAAO,MAAM,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,OAAA,CAAA,+BAAA,CAAA,CAAA;CAFd,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAO,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAP,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAO,cAAA;EAAA,UAAA;EAAA,QAAA;GAAA,SAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;GAAA,MAAA;IAAA,mBAAA;IAAA,YAAA;IAAA,UAAA;IAAA,YAAA;IAAA,mBAAA;GAAA;EAAA;EAAA,MAAA,EAAA,gBAAA,oEAAA;EAAA,UAAA;EAAA,UATR;;;;;;;EAMT,UAAA;CAAA,CAAA;;AAGU,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAO,YAAA,CAAA;EAXnB,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;;;;;;;GAOV,MAAM,EAAE,OAAO,oEAAmE;EACnF,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { Component } from "@angular/core";
|
|
|
3
3
|
var UiExternalLink = class UiExternalLink {
|
|
4
4
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
5
5
|
minVersion: "12.0.0",
|
|
6
|
-
version: "22.2.
|
|
6
|
+
version: "22.2.2",
|
|
7
7
|
ngImport: i0,
|
|
8
8
|
type: UiExternalLink,
|
|
9
9
|
deps: [],
|
|
@@ -11,7 +11,7 @@ var UiExternalLink = class UiExternalLink {
|
|
|
11
11
|
});
|
|
12
12
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
13
13
|
minVersion: "14.0.0",
|
|
14
|
-
version: "22.2.
|
|
14
|
+
version: "22.2.2",
|
|
15
15
|
type: UiExternalLink,
|
|
16
16
|
isStandalone: true,
|
|
17
17
|
selector: "a[ui-external-link]",
|
|
@@ -40,7 +40,7 @@ var UiExternalLink = class UiExternalLink {
|
|
|
40
40
|
};
|
|
41
41
|
i0.ɵɵngDeclareClassMetadata({
|
|
42
42
|
minVersion: "12.0.0",
|
|
43
|
-
version: "22.2.
|
|
43
|
+
version: "22.2.2",
|
|
44
44
|
ngImport: i0,
|
|
45
45
|
type: UiExternalLink,
|
|
46
46
|
decorators: [{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joanroucoux-cairn-ui-external-link.mjs","names":[],"sources":["../../../projects/ui/external-link/external-link.ts"],"sourcesContent":["import { Component } from '@angular/core';\n\n/**\n * Link to another site: the label followed by an external-link icon.\n *\n * @example\n * <a ui-external-link href=\"https://
|
|
1
|
+
{"version":3,"file":"joanroucoux-cairn-ui-external-link.mjs","names":[],"sources":["../../../projects/ui/external-link/external-link.ts"],"sourcesContent":["import { Component } from '@angular/core';\n\n/**\n * Link to another site: the label followed by an external-link icon.\n *\n * @example\n * <a ui-external-link href=\"https://www.contoso.com\" target=\"_blank\" rel=\"noopener\">Page on contoso.com</a>\n */\n@Component({\n selector: 'a[ui-external-link]',\n template: `\n <ng-content />\n <svg\n aria-hidden=\"true\"\n fill=\"none\"\n height=\"14\"\n stroke=\"currentColor\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n stroke-width=\"1.75\"\n viewBox=\"0 0 24 24\"\n width=\"14\"\n >\n <path d=\"M15 3h6v6\" />\n <path d=\"M10 14 21 3\" />\n <path d=\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\" />\n </svg>\n `,\n host: {\n class:\n 'inline-flex min-h-11 items-center gap-1.5 rounded-[4px] text-label leading-[17px] font-medium lg:min-h-0 hover:underline underline-offset-3 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--ring) [&>svg]:flex-none',\n },\n})\nexport class UiExternalLink {}\n"],"mappings":";;AAiCA,IAAa,iBAAb,MAAa,eAAc;CAAd,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAc,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAd,OAAA,OAAA,GAAA,qBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,MAAA;EAAc,cAAA;EAAA,UAAA;EAAA,MAAA,EAAA,gBAAA,sPAAA;EAAA,UAAA;EAAA,UAvBf;;;;;;;;;;;;;;;;;;EAiBT,UAAA;CAAA,CAAA;;AAMU,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAc,YAAA,CAAA;EAzB1B,MAAA;EAAU,MAAA,CAAA;GACT,UAAU;GACV,UAAU;;;;;;;;;;;;;;;;;;GAkBV,MAAM,EACJ,OACE,sPACH;EACF,CAAA"}
|
|
@@ -37,7 +37,7 @@ var UiFacts = class UiFacts {
|
|
|
37
37
|
classes = computed(() => this.ruled() ? "m-0 flex flex-col shadow-[inset_0_1px_0_var(--hairline)]" : "m-0 flex flex-col", ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
|
|
38
38
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
39
39
|
minVersion: "12.0.0",
|
|
40
|
-
version: "22.2.
|
|
40
|
+
version: "22.2.2",
|
|
41
41
|
ngImport: i0,
|
|
42
42
|
type: UiFacts,
|
|
43
43
|
deps: [],
|
|
@@ -45,7 +45,7 @@ var UiFacts = class UiFacts {
|
|
|
45
45
|
});
|
|
46
46
|
static ɵdir = i0.ɵɵngDeclareDirective({
|
|
47
47
|
minVersion: "17.1.0",
|
|
48
|
-
version: "22.2.
|
|
48
|
+
version: "22.2.2",
|
|
49
49
|
type: UiFacts,
|
|
50
50
|
isStandalone: true,
|
|
51
51
|
selector: "dl[uiFacts]",
|
|
@@ -62,7 +62,7 @@ var UiFacts = class UiFacts {
|
|
|
62
62
|
};
|
|
63
63
|
i0.ɵɵngDeclareClassMetadata({
|
|
64
64
|
minVersion: "12.0.0",
|
|
65
|
-
version: "22.2.
|
|
65
|
+
version: "22.2.2",
|
|
66
66
|
ngImport: i0,
|
|
67
67
|
type: UiFacts,
|
|
68
68
|
decorators: [{
|
|
@@ -91,7 +91,7 @@ var UiFact = class UiFact {
|
|
|
91
91
|
subClasses = computed(() => `text-caption ${SUB_TONE_CLASSES[this.subTone()]}`, ...ngDevMode ? [{ debugName: "subClasses" }] : /* istanbul ignore next */ []);
|
|
92
92
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
93
93
|
minVersion: "12.0.0",
|
|
94
|
-
version: "22.2.
|
|
94
|
+
version: "22.2.2",
|
|
95
95
|
ngImport: i0,
|
|
96
96
|
type: UiFact,
|
|
97
97
|
deps: [],
|
|
@@ -99,7 +99,7 @@ var UiFact = class UiFact {
|
|
|
99
99
|
});
|
|
100
100
|
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
101
101
|
minVersion: "17.0.0",
|
|
102
|
-
version: "22.2.
|
|
102
|
+
version: "22.2.2",
|
|
103
103
|
type: UiFact,
|
|
104
104
|
isStandalone: true,
|
|
105
105
|
selector: "div[ui-fact]",
|
|
@@ -149,7 +149,7 @@ var UiFact = class UiFact {
|
|
|
149
149
|
};
|
|
150
150
|
i0.ɵɵngDeclareClassMetadata({
|
|
151
151
|
minVersion: "12.0.0",
|
|
152
|
-
version: "22.2.
|
|
152
|
+
version: "22.2.2",
|
|
153
153
|
ngImport: i0,
|
|
154
154
|
type: UiFact,
|
|
155
155
|
decorators: [{
|