@saitec/ui 0.1.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.
Potentially problematic release.
This version of @saitec/ui might be problematic. Click here for more details.
- package/README.md +64 -0
- package/fesm2022/saitec-ui-autocomplete.mjs +214 -0
- package/fesm2022/saitec-ui-autocomplete.mjs.map +1 -0
- package/fesm2022/saitec-ui-badge.mjs +26 -0
- package/fesm2022/saitec-ui-badge.mjs.map +1 -0
- package/fesm2022/saitec-ui-button.mjs +35 -0
- package/fesm2022/saitec-ui-button.mjs.map +1 -0
- package/fesm2022/saitec-ui-card.mjs +28 -0
- package/fesm2022/saitec-ui-card.mjs.map +1 -0
- package/fesm2022/saitec-ui-checkbox.mjs +87 -0
- package/fesm2022/saitec-ui-checkbox.mjs.map +1 -0
- package/fesm2022/saitec-ui-chip.mjs +32 -0
- package/fesm2022/saitec-ui-chip.mjs.map +1 -0
- package/fesm2022/saitec-ui-confirm.mjs +93 -0
- package/fesm2022/saitec-ui-confirm.mjs.map +1 -0
- package/fesm2022/saitec-ui-core.mjs +4 -0
- package/fesm2022/saitec-ui-core.mjs.map +1 -0
- package/fesm2022/saitec-ui-date-picker.mjs +92 -0
- package/fesm2022/saitec-ui-date-picker.mjs.map +1 -0
- package/fesm2022/saitec-ui-dialog.mjs +95 -0
- package/fesm2022/saitec-ui-dialog.mjs.map +1 -0
- package/fesm2022/saitec-ui-divider.mjs +22 -0
- package/fesm2022/saitec-ui-divider.mjs.map +1 -0
- package/fesm2022/saitec-ui-drawer.mjs +96 -0
- package/fesm2022/saitec-ui-drawer.mjs.map +1 -0
- package/fesm2022/saitec-ui-fieldset.mjs +32 -0
- package/fesm2022/saitec-ui-fieldset.mjs.map +1 -0
- package/fesm2022/saitec-ui-file-upload.mjs +206 -0
- package/fesm2022/saitec-ui-file-upload.mjs.map +1 -0
- package/fesm2022/saitec-ui-form-field.mjs +30 -0
- package/fesm2022/saitec-ui-form-field.mjs.map +1 -0
- package/fesm2022/saitec-ui-input-number.mjs +250 -0
- package/fesm2022/saitec-ui-input-number.mjs.map +1 -0
- package/fesm2022/saitec-ui-input.mjs +95 -0
- package/fesm2022/saitec-ui-input.mjs.map +1 -0
- package/fesm2022/saitec-ui-menu.mjs +46 -0
- package/fesm2022/saitec-ui-menu.mjs.map +1 -0
- package/fesm2022/saitec-ui-menubar.mjs +72 -0
- package/fesm2022/saitec-ui-menubar.mjs.map +1 -0
- package/fesm2022/saitec-ui-message.mjs +28 -0
- package/fesm2022/saitec-ui-message.mjs.map +1 -0
- package/fesm2022/saitec-ui-multiselect.mjs +209 -0
- package/fesm2022/saitec-ui-multiselect.mjs.map +1 -0
- package/fesm2022/saitec-ui-panel.mjs +32 -0
- package/fesm2022/saitec-ui-panel.mjs.map +1 -0
- package/fesm2022/saitec-ui-progress-spinner.mjs +24 -0
- package/fesm2022/saitec-ui-progress-spinner.mjs.map +1 -0
- package/fesm2022/saitec-ui-select.mjs +105 -0
- package/fesm2022/saitec-ui-select.mjs.map +1 -0
- package/fesm2022/saitec-ui-table.mjs +172 -0
- package/fesm2022/saitec-ui-table.mjs.map +1 -0
- package/fesm2022/saitec-ui-tabs.mjs +170 -0
- package/fesm2022/saitec-ui-tabs.mjs.map +1 -0
- package/fesm2022/saitec-ui-tag.mjs +26 -0
- package/fesm2022/saitec-ui-tag.mjs.map +1 -0
- package/fesm2022/saitec-ui-textarea.mjs +95 -0
- package/fesm2022/saitec-ui-textarea.mjs.map +1 -0
- package/fesm2022/saitec-ui-toast.mjs +109 -0
- package/fesm2022/saitec-ui-toast.mjs.map +1 -0
- package/fesm2022/saitec-ui-toggle-switch.mjs +85 -0
- package/fesm2022/saitec-ui-toggle-switch.mjs.map +1 -0
- package/fesm2022/saitec-ui-toolbar.mjs +20 -0
- package/fesm2022/saitec-ui-toolbar.mjs.map +1 -0
- package/fesm2022/saitec-ui-tooltip.mjs +219 -0
- package/fesm2022/saitec-ui-tooltip.mjs.map +1 -0
- package/fesm2022/saitec-ui.mjs +22 -0
- package/fesm2022/saitec-ui.mjs.map +1 -0
- package/lib/core/themes/dark.css +233 -0
- package/lib/core/themes/light.css +210 -0
- package/lib/core/tokens/components/autocomplete.css +26 -0
- package/lib/core/tokens/components/badge.css +26 -0
- package/lib/core/tokens/components/button.css +90 -0
- package/lib/core/tokens/components/card.css +15 -0
- package/lib/core/tokens/components/checkbox.css +17 -0
- package/lib/core/tokens/components/chip.css +16 -0
- package/lib/core/tokens/components/confirm.css +8 -0
- package/lib/core/tokens/components/date-picker.css +18 -0
- package/lib/core/tokens/components/dialog.css +18 -0
- package/lib/core/tokens/components/divider.css +9 -0
- package/lib/core/tokens/components/drawer.css +16 -0
- package/lib/core/tokens/components/fieldset.css +15 -0
- package/lib/core/tokens/components/file-upload.css +31 -0
- package/lib/core/tokens/components/form-field.css +14 -0
- package/lib/core/tokens/components/input-number.css +20 -0
- package/lib/core/tokens/components/input.css +31 -0
- package/lib/core/tokens/components/menu.css +19 -0
- package/lib/core/tokens/components/menubar.css +18 -0
- package/lib/core/tokens/components/message.css +29 -0
- package/lib/core/tokens/components/multiselect.css +25 -0
- package/lib/core/tokens/components/panel.css +18 -0
- package/lib/core/tokens/components/progress-spinner.css +10 -0
- package/lib/core/tokens/components/select.css +18 -0
- package/lib/core/tokens/components/table.css +32 -0
- package/lib/core/tokens/components/tabs.css +18 -0
- package/lib/core/tokens/components/tag.css +29 -0
- package/lib/core/tokens/components/textarea.css +19 -0
- package/lib/core/tokens/components/toast.css +22 -0
- package/lib/core/tokens/components/toggle-switch.css +17 -0
- package/lib/core/tokens/components/toolbar.css +11 -0
- package/lib/core/tokens/components/tooltip.css +12 -0
- package/lib/core/tokens/components.css +50 -0
- package/lib/core/tokens/foundations.css +132 -0
- package/lib/core/tokens/primitives.css +159 -0
- package/package.json +162 -0
- package/styles.css +7 -0
- package/types/saitec-ui-autocomplete.d.ts +50 -0
- package/types/saitec-ui-badge.d.ts +15 -0
- package/types/saitec-ui-button.d.ts +22 -0
- package/types/saitec-ui-card.d.ts +13 -0
- package/types/saitec-ui-checkbox.d.ts +33 -0
- package/types/saitec-ui-chip.d.ts +13 -0
- package/types/saitec-ui-confirm.d.ts +38 -0
- package/types/saitec-ui-core.d.ts +7 -0
- package/types/saitec-ui-date-picker.d.ts +35 -0
- package/types/saitec-ui-dialog.d.ts +29 -0
- package/types/saitec-ui-divider.d.ts +13 -0
- package/types/saitec-ui-drawer.d.ts +31 -0
- package/types/saitec-ui-fieldset.d.ts +13 -0
- package/types/saitec-ui-file-upload.d.ts +43 -0
- package/types/saitec-ui-form-field.d.ts +14 -0
- package/types/saitec-ui-input-number.d.ts +60 -0
- package/types/saitec-ui-input.d.ts +39 -0
- package/types/saitec-ui-menu.d.ts +17 -0
- package/types/saitec-ui-menubar.d.ts +21 -0
- package/types/saitec-ui-message.d.ts +15 -0
- package/types/saitec-ui-multiselect.d.ts +54 -0
- package/types/saitec-ui-panel.d.ts +13 -0
- package/types/saitec-ui-progress-spinner.d.ts +13 -0
- package/types/saitec-ui-select.d.ts +36 -0
- package/types/saitec-ui-table.d.ts +57 -0
- package/types/saitec-ui-tabs.d.ts +57 -0
- package/types/saitec-ui-tag.d.ts +15 -0
- package/types/saitec-ui-textarea.d.ts +37 -0
- package/types/saitec-ui-toast.d.ts +43 -0
- package/types/saitec-ui-toggle-switch.d.ts +32 -0
- package/types/saitec-ui-toolbar.d.ts +9 -0
- package/types/saitec-ui-tooltip.d.ts +38 -0
- package/types/saitec-ui.d.ts +8 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, model, input, output, effect, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { DOCUMENT } from '@angular/common';
|
|
4
|
+
|
|
5
|
+
class SuiDrawer {
|
|
6
|
+
document = inject(DOCUMENT);
|
|
7
|
+
visible = model(false, /* @ts-ignore */
|
|
8
|
+
...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
9
|
+
position = input('right', /* @ts-ignore */
|
|
10
|
+
...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
|
|
11
|
+
header = input(/* @ts-ignore */
|
|
12
|
+
...(ngDevMode ? [undefined, { debugName: "header" }] : /* istanbul ignore next */ []));
|
|
13
|
+
modal = input(true, /* @ts-ignore */
|
|
14
|
+
...(ngDevMode ? [{ debugName: "modal" }] : /* istanbul ignore next */ []));
|
|
15
|
+
dismissible = input(true, /* @ts-ignore */
|
|
16
|
+
...(ngDevMode ? [{ debugName: "dismissible" }] : /* istanbul ignore next */ []));
|
|
17
|
+
closeOnEscape = input(true, /* @ts-ignore */
|
|
18
|
+
...(ngDevMode ? [{ debugName: "closeOnEscape" }] : /* istanbul ignore next */ []));
|
|
19
|
+
showCloseButton = input(true, /* @ts-ignore */
|
|
20
|
+
...(ngDevMode ? [{ debugName: "showCloseButton" }] : /* istanbul ignore next */ []));
|
|
21
|
+
blockScroll = input(true, /* @ts-ignore */
|
|
22
|
+
...(ngDevMode ? [{ debugName: "blockScroll" }] : /* istanbul ignore next */ []));
|
|
23
|
+
size = input(/* @ts-ignore */
|
|
24
|
+
...(ngDevMode ? [undefined, { debugName: "size" }] : /* istanbul ignore next */ []));
|
|
25
|
+
opened = output();
|
|
26
|
+
closed = output();
|
|
27
|
+
previousBodyOverflow;
|
|
28
|
+
constructor() {
|
|
29
|
+
effect(() => {
|
|
30
|
+
const visible = this.visible();
|
|
31
|
+
this.updateBodyScroll(visible);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
handleEscape() {
|
|
35
|
+
if (this.visible() &&
|
|
36
|
+
this.closeOnEscape()) {
|
|
37
|
+
this.close();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
handleBackdrop() {
|
|
41
|
+
if (this.modal() &&
|
|
42
|
+
this.dismissible()) {
|
|
43
|
+
this.close();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
close() {
|
|
47
|
+
if (!this.visible()) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
this.visible.set(false);
|
|
51
|
+
this.closed.emit();
|
|
52
|
+
}
|
|
53
|
+
open() {
|
|
54
|
+
if (this.visible()) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this.visible.set(true);
|
|
58
|
+
this.opened.emit();
|
|
59
|
+
}
|
|
60
|
+
updateBodyScroll(visible) {
|
|
61
|
+
if (!this.blockScroll()) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const body = this.document.body;
|
|
65
|
+
if (visible) {
|
|
66
|
+
this.previousBodyOverflow = body.style.overflow;
|
|
67
|
+
body.style.overflow = 'hidden';
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
body.style.overflow =
|
|
71
|
+
this.previousBodyOverflow ?? '';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
ngOnDestroy() {
|
|
75
|
+
if (this.blockScroll()) {
|
|
76
|
+
this.document.body.style.overflow =
|
|
77
|
+
this.previousBodyOverflow ?? '';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: SuiDrawer, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
81
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: SuiDrawer, isStandalone: true, selector: "sui-drawer", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, header: { classPropertyName: "header", publicName: "header", isSignal: true, isRequired: false, transformFunction: null }, modal: { classPropertyName: "modal", publicName: "modal", isSignal: true, isRequired: false, transformFunction: null }, dismissible: { classPropertyName: "dismissible", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "closeOnEscape", isSignal: true, isRequired: false, transformFunction: null }, showCloseButton: { classPropertyName: "showCloseButton", publicName: "showCloseButton", isSignal: true, isRequired: false, transformFunction: null }, blockScroll: { classPropertyName: "blockScroll", publicName: "blockScroll", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visible: "visibleChange", opened: "opened", closed: "closed" }, host: { listeners: { "document:keydown.escape": "handleEscape()" } }, ngImport: i0, template: "<div\n class=\"sui-drawer-overlay\"\n [class.sui-drawer-overlay-visible]=\"visible()\"\n [class.sui-drawer-overlay-modal]=\"modal()\"\n [attr.aria-hidden]=\"!visible()\"\n (click)=\"handleBackdrop()\">\n\n <aside\n class=\"sui-drawer\"\n [class.sui-drawer-visible]=\"visible()\"\n [class.sui-drawer-left]=\"position() === 'left'\"\n [class.sui-drawer-right]=\"position() === 'right'\"\n [class.sui-drawer-top]=\"position() === 'top'\"\n [class.sui-drawer-bottom]=\"position() === 'bottom'\"\n [style.--sui-drawer-size]=\"size() ?? null\"\n role=\"dialog\"\n [attr.aria-modal]=\"modal()\"\n (click)=\"$event.stopPropagation()\">\n\n <header class=\"sui-drawer-header\">\n\n <div class=\"sui-drawer-header-content\">\n\n <ng-content select=\"[suiDrawerHeader]\" />\n\n @if (header()) {\n <span class=\"sui-drawer-title\">\n {{ header() }}\n </span>\n }\n\n </div>\n\n @if (showCloseButton()) {\n <button\n type=\"button\"\n class=\"sui-drawer-close\"\n aria-label=\"Close\"\n (click)=\"close()\">\n \u00D7\n </button>\n }\n\n </header>\n\n <div class=\"sui-drawer-content\">\n <ng-content />\n </div>\n\n <footer class=\"sui-drawer-footer\">\n <ng-content select=\"[suiDrawerFooter]\" />\n </footer>\n\n </aside>\n\n</div>", styles: [":host{display:contents}.sui-drawer-overlay{position:fixed;inset:0;z-index:var(--sui-drawer-z-index);visibility:hidden;pointer-events:none;background:transparent;transition:background-color var(--sui-duration-slow) var(--sui-easing-standard),visibility var(--sui-duration-slow) var(--sui-easing-standard)}.sui-drawer-overlay-visible{visibility:visible;pointer-events:auto}.sui-drawer-overlay-visible.sui-drawer-overlay-modal{background:var(--sui-drawer-overlay-background)}.sui-drawer{position:absolute;display:flex;flex-direction:column;box-sizing:border-box;color:var(--sui-drawer-text);background:var(--sui-drawer-background);box-shadow:var(--sui-drawer-shadow);transition:transform var(--sui-duration-slow) var(--sui-easing-standard)}.sui-drawer-right{top:0;right:0;width:var(--sui-drawer-size, 25rem);height:100%;transform:translate(100%)}.sui-drawer-right.sui-drawer-visible{transform:translate(0)}.sui-drawer-left{top:0;left:0;width:var(--sui-drawer-size, 25rem);height:100%;transform:translate(-100%)}.sui-drawer-left.sui-drawer-visible{transform:translate(0)}.sui-drawer-top{top:0;left:0;width:100%;height:var(--sui-drawer-size, 20rem);transform:translateY(-100%)}.sui-drawer-top.sui-drawer-visible{transform:translateY(0)}.sui-drawer-bottom{bottom:0;left:0;width:100%;height:var(--sui-drawer-size, 20rem);transform:translateY(100%)}.sui-drawer-bottom.sui-drawer-visible{transform:translateY(0)}.sui-drawer-header{display:flex;align-items:center;justify-content:space-between;flex-shrink:0;min-height:3.5rem;padding:var(--sui-drawer-footer-padding);border-bottom:var(--sui-border-width) solid var(--sui-drawer-border)}.sui-drawer-header-content{display:flex;align-items:center;gap:var(--sui-space-2);min-width:0}.sui-drawer-title{font-family:inherit;font-size:var(--sui-control-font-size-lg);font-weight:var(--sui-font-weight-semibold);color:var(--sui-drawer-text)}.sui-drawer-close{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0;color:var(--sui-drawer-close-text);background:transparent;border:0;border-radius:.375rem;cursor:pointer;font-family:inherit;font-size:1.5rem;line-height:1}.sui-drawer-close:hover{color:var(--sui-color-content);background:var(--sui-drawer-close-background-hover)}.sui-drawer-close:focus-visible{outline:var(--sui-focus-ring-width) solid var(--sui-color-focus);outline-offset:var(--sui-focus-ring-offset)}.sui-drawer-content{flex:1;min-height:0;padding:var(--sui-drawer-content-padding);overflow:auto}.sui-drawer-footer{flex-shrink:0;padding:.75rem 1rem;border-top:var(--sui-border-width) solid var(--sui-drawer-border)}.sui-drawer-footer:empty{display:none}@media(prefers-reduced-motion:reduce){.sui-drawer,.sui-drawer-overlay{transition:none}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
82
|
+
}
|
|
83
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: SuiDrawer, decorators: [{
|
|
84
|
+
type: Component,
|
|
85
|
+
args: [{ selector: 'sui-drawer', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"sui-drawer-overlay\"\n [class.sui-drawer-overlay-visible]=\"visible()\"\n [class.sui-drawer-overlay-modal]=\"modal()\"\n [attr.aria-hidden]=\"!visible()\"\n (click)=\"handleBackdrop()\">\n\n <aside\n class=\"sui-drawer\"\n [class.sui-drawer-visible]=\"visible()\"\n [class.sui-drawer-left]=\"position() === 'left'\"\n [class.sui-drawer-right]=\"position() === 'right'\"\n [class.sui-drawer-top]=\"position() === 'top'\"\n [class.sui-drawer-bottom]=\"position() === 'bottom'\"\n [style.--sui-drawer-size]=\"size() ?? null\"\n role=\"dialog\"\n [attr.aria-modal]=\"modal()\"\n (click)=\"$event.stopPropagation()\">\n\n <header class=\"sui-drawer-header\">\n\n <div class=\"sui-drawer-header-content\">\n\n <ng-content select=\"[suiDrawerHeader]\" />\n\n @if (header()) {\n <span class=\"sui-drawer-title\">\n {{ header() }}\n </span>\n }\n\n </div>\n\n @if (showCloseButton()) {\n <button\n type=\"button\"\n class=\"sui-drawer-close\"\n aria-label=\"Close\"\n (click)=\"close()\">\n \u00D7\n </button>\n }\n\n </header>\n\n <div class=\"sui-drawer-content\">\n <ng-content />\n </div>\n\n <footer class=\"sui-drawer-footer\">\n <ng-content select=\"[suiDrawerFooter]\" />\n </footer>\n\n </aside>\n\n</div>", styles: [":host{display:contents}.sui-drawer-overlay{position:fixed;inset:0;z-index:var(--sui-drawer-z-index);visibility:hidden;pointer-events:none;background:transparent;transition:background-color var(--sui-duration-slow) var(--sui-easing-standard),visibility var(--sui-duration-slow) var(--sui-easing-standard)}.sui-drawer-overlay-visible{visibility:visible;pointer-events:auto}.sui-drawer-overlay-visible.sui-drawer-overlay-modal{background:var(--sui-drawer-overlay-background)}.sui-drawer{position:absolute;display:flex;flex-direction:column;box-sizing:border-box;color:var(--sui-drawer-text);background:var(--sui-drawer-background);box-shadow:var(--sui-drawer-shadow);transition:transform var(--sui-duration-slow) var(--sui-easing-standard)}.sui-drawer-right{top:0;right:0;width:var(--sui-drawer-size, 25rem);height:100%;transform:translate(100%)}.sui-drawer-right.sui-drawer-visible{transform:translate(0)}.sui-drawer-left{top:0;left:0;width:var(--sui-drawer-size, 25rem);height:100%;transform:translate(-100%)}.sui-drawer-left.sui-drawer-visible{transform:translate(0)}.sui-drawer-top{top:0;left:0;width:100%;height:var(--sui-drawer-size, 20rem);transform:translateY(-100%)}.sui-drawer-top.sui-drawer-visible{transform:translateY(0)}.sui-drawer-bottom{bottom:0;left:0;width:100%;height:var(--sui-drawer-size, 20rem);transform:translateY(100%)}.sui-drawer-bottom.sui-drawer-visible{transform:translateY(0)}.sui-drawer-header{display:flex;align-items:center;justify-content:space-between;flex-shrink:0;min-height:3.5rem;padding:var(--sui-drawer-footer-padding);border-bottom:var(--sui-border-width) solid var(--sui-drawer-border)}.sui-drawer-header-content{display:flex;align-items:center;gap:var(--sui-space-2);min-width:0}.sui-drawer-title{font-family:inherit;font-size:var(--sui-control-font-size-lg);font-weight:var(--sui-font-weight-semibold);color:var(--sui-drawer-text)}.sui-drawer-close{display:inline-flex;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0;color:var(--sui-drawer-close-text);background:transparent;border:0;border-radius:.375rem;cursor:pointer;font-family:inherit;font-size:1.5rem;line-height:1}.sui-drawer-close:hover{color:var(--sui-color-content);background:var(--sui-drawer-close-background-hover)}.sui-drawer-close:focus-visible{outline:var(--sui-focus-ring-width) solid var(--sui-color-focus);outline-offset:var(--sui-focus-ring-offset)}.sui-drawer-content{flex:1;min-height:0;padding:var(--sui-drawer-content-padding);overflow:auto}.sui-drawer-footer{flex-shrink:0;padding:.75rem 1rem;border-top:var(--sui-border-width) solid var(--sui-drawer-border)}.sui-drawer-footer:empty{display:none}@media(prefers-reduced-motion:reduce){.sui-drawer,.sui-drawer-overlay{transition:none}}\n"] }]
|
|
86
|
+
}], ctorParameters: () => [], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], header: [{ type: i0.Input, args: [{ isSignal: true, alias: "header", required: false }] }], modal: [{ type: i0.Input, args: [{ isSignal: true, alias: "modal", required: false }] }], dismissible: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissible", required: false }] }], closeOnEscape: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnEscape", required: false }] }], showCloseButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "showCloseButton", required: false }] }], blockScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "blockScroll", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], opened: [{ type: i0.Output, args: ["opened"] }], closed: [{ type: i0.Output, args: ["closed"] }], handleEscape: [{
|
|
87
|
+
type: HostListener,
|
|
88
|
+
args: ['document:keydown.escape']
|
|
89
|
+
}] } });
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Generated bundle index. Do not edit.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
export { SuiDrawer };
|
|
96
|
+
//# sourceMappingURL=saitec-ui-drawer.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saitec-ui-drawer.mjs","sources":["../../../projects/ui/drawer/src/drawer.component.ts","../../../projects/ui/drawer/src/drawer.component.html","../../../projects/ui/drawer/src/saitec-ui-drawer.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n HostListener,\n effect,\n inject,\n input,\n model,\n OnDestroy,\n output\n} from '@angular/core';\nimport { DOCUMENT } from '@angular/common';\n\nexport type SuiDrawerPosition =\n | 'left'\n | 'right'\n | 'top'\n | 'bottom';\n\n@Component({\n selector: 'sui-drawer',\n standalone: true,\n templateUrl: './drawer.component.html',\n styleUrl: './drawer.component.css',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SuiDrawer implements OnDestroy {\n\n private readonly document = inject(DOCUMENT);\n\n visible = model(false);\n\n position = input<SuiDrawerPosition>('right');\n\n header = input<string>();\n\n modal = input(true);\n\n dismissible = input(true);\n\n closeOnEscape = input(true);\n\n showCloseButton = input(true);\n\n blockScroll = input(true);\n\n size = input<string>();\n\n opened = output<void>();\n\n closed = output<void>();\n\n private previousBodyOverflow?: string;\n\n constructor() {\n effect(() => {\n const visible = this.visible();\n\n this.updateBodyScroll(visible);\n });\n }\n\n @HostListener('document:keydown.escape')\n protected handleEscape(): void {\n if (\n this.visible() &&\n this.closeOnEscape()\n ) {\n this.close();\n }\n }\n\n protected handleBackdrop(): void {\n if (\n this.modal() &&\n this.dismissible()\n ) {\n this.close();\n }\n }\n\n protected close(): void {\n if (!this.visible()) {\n return;\n }\n\n this.visible.set(false);\n this.closed.emit();\n }\n\n public open(): void {\n if (this.visible()) {\n return;\n }\n\n this.visible.set(true);\n this.opened.emit();\n }\n\n private updateBodyScroll(visible: boolean): void {\n if (!this.blockScroll()) {\n return;\n }\n\n const body = this.document.body;\n\n if (visible) {\n this.previousBodyOverflow = body.style.overflow;\n body.style.overflow = 'hidden';\n }\n else {\n body.style.overflow =\n this.previousBodyOverflow ?? '';\n }\n }\n\n ngOnDestroy(): void {\n if (this.blockScroll()) {\n this.document.body.style.overflow =\n this.previousBodyOverflow ?? '';\n }\n }\n}","<div\n class=\"sui-drawer-overlay\"\n [class.sui-drawer-overlay-visible]=\"visible()\"\n [class.sui-drawer-overlay-modal]=\"modal()\"\n [attr.aria-hidden]=\"!visible()\"\n (click)=\"handleBackdrop()\">\n\n <aside\n class=\"sui-drawer\"\n [class.sui-drawer-visible]=\"visible()\"\n [class.sui-drawer-left]=\"position() === 'left'\"\n [class.sui-drawer-right]=\"position() === 'right'\"\n [class.sui-drawer-top]=\"position() === 'top'\"\n [class.sui-drawer-bottom]=\"position() === 'bottom'\"\n [style.--sui-drawer-size]=\"size() ?? null\"\n role=\"dialog\"\n [attr.aria-modal]=\"modal()\"\n (click)=\"$event.stopPropagation()\">\n\n <header class=\"sui-drawer-header\">\n\n <div class=\"sui-drawer-header-content\">\n\n <ng-content select=\"[suiDrawerHeader]\" />\n\n @if (header()) {\n <span class=\"sui-drawer-title\">\n {{ header() }}\n </span>\n }\n\n </div>\n\n @if (showCloseButton()) {\n <button\n type=\"button\"\n class=\"sui-drawer-close\"\n aria-label=\"Close\"\n (click)=\"close()\">\n ×\n </button>\n }\n\n </header>\n\n <div class=\"sui-drawer-content\">\n <ng-content />\n </div>\n\n <footer class=\"sui-drawer-footer\">\n <ng-content select=\"[suiDrawerFooter]\" />\n </footer>\n\n </aside>\n\n</div>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MA0Ba,SAAS,CAAA;AAED,IAAA,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAE5C,OAAO,GAAG,KAAK,CAAC,KAAK;gFAAC;IAEtB,QAAQ,GAAG,KAAK,CAAoB,OAAO;iFAAC;AAE5C,IAAA,MAAM,GAAG,KAAK;0FAAU;IAExB,KAAK,GAAG,KAAK,CAAC,IAAI;8EAAC;IAEnB,WAAW,GAAG,KAAK,CAAC,IAAI;oFAAC;IAEzB,aAAa,GAAG,KAAK,CAAC,IAAI;sFAAC;IAE3B,eAAe,GAAG,KAAK,CAAC,IAAI;wFAAC;IAE7B,WAAW,GAAG,KAAK,CAAC,IAAI;oFAAC;AAEz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AI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ;QAClC;aACK;YACD,IAAI,CAAC,KAAK,CAAC,QAAQ;AACf,gBAAA,IAAI,CAAC,oBAAoB,IAAI,EAAE;QACvC;IACJ;IAEA,WAAW,GAAA;AACP,QAAA,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE;AACpB,YAAA,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ;AAC7B,gBAAA,IAAI,CAAC,oBAAoB,IAAI,EAAE;QACvC;IACJ;uGA/FS,SAAS,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAT,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,SAAS,o4CC1BtB,onDAuDM,EAAA,MAAA,EAAA,CAAA,6qFAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FD7BO,SAAS,EAAA,UAAA,EAAA,CAAA;kBAPrB,SAAS;AACI,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,YAAY,EAAA,UAAA,EACV,IAAI,EAAA,eAAA,EAGC,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,onDAAA,EAAA,MAAA,EAAA,CAAA,6qFAAA,CAAA,EAAA;;sBAsC9C,YAAY;uBAAC,yBAAyB;;;AE9D3C;;AAEG;;;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, model, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
class SuiFieldset {
|
|
5
|
+
legend = input(/* @ts-ignore */
|
|
6
|
+
...(ngDevMode ? [undefined, { debugName: "legend" }] : /* istanbul ignore next */ []));
|
|
7
|
+
toggleable = input(false, /* @ts-ignore */
|
|
8
|
+
...(ngDevMode ? [{ debugName: "toggleable" }] : /* istanbul ignore next */ []));
|
|
9
|
+
collapsed = model(false, /* @ts-ignore */
|
|
10
|
+
...(ngDevMode ? [{ debugName: "collapsed" }] : /* istanbul ignore next */ []));
|
|
11
|
+
disabled = input(false, /* @ts-ignore */
|
|
12
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
13
|
+
toggle() {
|
|
14
|
+
if (!this.toggleable() || this.disabled()) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
this.collapsed.update(value => !value);
|
|
18
|
+
}
|
|
19
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: SuiFieldset, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
20
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: SuiFieldset, isStandalone: true, selector: "sui-fieldset", inputs: { legend: { classPropertyName: "legend", publicName: "legend", isSignal: true, isRequired: false, transformFunction: null }, toggleable: { classPropertyName: "toggleable", publicName: "toggleable", isSignal: true, isRequired: false, transformFunction: null }, collapsed: { classPropertyName: "collapsed", publicName: "collapsed", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { collapsed: "collapsedChange" }, ngImport: i0, template: "<fieldset\n class=\"sui-fieldset\"\n [disabled]=\"disabled()\">\n\n @if (legend() || toggleable()) {\n <legend class=\"sui-fieldset-legend\">\n\n <div class=\"sui-fieldset-legend-content\">\n\n <ng-content select=\"[suiFieldsetLegend]\" />\n\n @if (legend()) {\n <span class=\"sui-fieldset-title\">\n {{ legend() }}\n </span>\n }\n\n </div>\n\n @if (toggleable()) {\n <button\n type=\"button\"\n class=\"sui-fieldset-toggle\"\n [disabled]=\"disabled()\"\n [attr.aria-expanded]=\"!collapsed()\"\n (click)=\"toggle()\">\n\n <span\n class=\"sui-fieldset-toggle-icon\"\n [class.sui-fieldset-toggle-icon-collapsed]=\"collapsed()\">\n \u25BC\n </span>\n\n </button>\n }\n\n </legend>\n }\n\n @if (!collapsed()) {\n <div class=\"sui-fieldset-content\">\n <ng-content />\n </div>\n }\n\n</fieldset>", styles: [":host{display:block}.sui-fieldset{min-width:0;margin:0;padding:0;color:var(--sui-fieldset-text);background:var(--sui-fieldset-background);border:var(--sui-fieldset-border-width) solid var(--sui-fieldset-border);border-radius:var(--sui-fieldset-radius)}.sui-fieldset-legend{display:flex;align-items:center;gap:var(--sui-fieldset-legend-gap);margin-left:.75rem;padding:0 .375rem;max-width:calc(100% - 1.5rem);color:var(--sui-fieldset-legend-text);background:var(--sui-fieldset-background)}.sui-fieldset-legend-content{display:inline-flex;align-items:center;gap:var(--sui-fieldset-legend-gap);min-width:0}.sui-fieldset-title{font-family:inherit;font-size:var(--sui-control-font-size-sm);font-weight:var(--sui-fieldset-legend-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.sui-fieldset-content{padding:var(--sui-fieldset-padding)}.sui-fieldset-toggle{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;padding:0;color:var(--sui-color-content-muted);background:transparent;border:0;border-radius:.375rem;cursor:pointer}.sui-fieldset-toggle:hover:not(:disabled){color:var(--sui-color-content);background:var(--sui-color-surface-hover)}.sui-fieldset-toggle:focus-visible{outline:var(--sui-focus-ring-width) solid var(--sui-color-focus);outline-offset:var(--sui-focus-ring-offset)}.sui-fieldset-toggle:disabled{cursor:not-allowed;opacity:.5}.sui-fieldset-toggle-icon{display:block;font-size:.75rem;transition:transform var(--sui-duration-normal) var(--sui-easing-standard)}.sui-fieldset-toggle-icon-collapsed{transform:rotate(-90deg)}.sui-fieldset:disabled{opacity:var(--sui-fieldset-disabled-opacity)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
21
|
+
}
|
|
22
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: SuiFieldset, decorators: [{
|
|
23
|
+
type: Component,
|
|
24
|
+
args: [{ selector: 'sui-fieldset', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<fieldset\n class=\"sui-fieldset\"\n [disabled]=\"disabled()\">\n\n @if (legend() || toggleable()) {\n <legend class=\"sui-fieldset-legend\">\n\n <div class=\"sui-fieldset-legend-content\">\n\n <ng-content select=\"[suiFieldsetLegend]\" />\n\n @if (legend()) {\n <span class=\"sui-fieldset-title\">\n {{ legend() }}\n </span>\n }\n\n </div>\n\n @if (toggleable()) {\n <button\n type=\"button\"\n class=\"sui-fieldset-toggle\"\n [disabled]=\"disabled()\"\n [attr.aria-expanded]=\"!collapsed()\"\n (click)=\"toggle()\">\n\n <span\n class=\"sui-fieldset-toggle-icon\"\n [class.sui-fieldset-toggle-icon-collapsed]=\"collapsed()\">\n \u25BC\n </span>\n\n </button>\n }\n\n </legend>\n }\n\n @if (!collapsed()) {\n <div class=\"sui-fieldset-content\">\n <ng-content />\n </div>\n }\n\n</fieldset>", styles: [":host{display:block}.sui-fieldset{min-width:0;margin:0;padding:0;color:var(--sui-fieldset-text);background:var(--sui-fieldset-background);border:var(--sui-fieldset-border-width) solid var(--sui-fieldset-border);border-radius:var(--sui-fieldset-radius)}.sui-fieldset-legend{display:flex;align-items:center;gap:var(--sui-fieldset-legend-gap);margin-left:.75rem;padding:0 .375rem;max-width:calc(100% - 1.5rem);color:var(--sui-fieldset-legend-text);background:var(--sui-fieldset-background)}.sui-fieldset-legend-content{display:inline-flex;align-items:center;gap:var(--sui-fieldset-legend-gap);min-width:0}.sui-fieldset-title{font-family:inherit;font-size:var(--sui-control-font-size-sm);font-weight:var(--sui-fieldset-legend-font-weight);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.sui-fieldset-content{padding:var(--sui-fieldset-padding)}.sui-fieldset-toggle{display:inline-flex;align-items:center;justify-content:center;width:1.75rem;height:1.75rem;padding:0;color:var(--sui-color-content-muted);background:transparent;border:0;border-radius:.375rem;cursor:pointer}.sui-fieldset-toggle:hover:not(:disabled){color:var(--sui-color-content);background:var(--sui-color-surface-hover)}.sui-fieldset-toggle:focus-visible{outline:var(--sui-focus-ring-width) solid var(--sui-color-focus);outline-offset:var(--sui-focus-ring-offset)}.sui-fieldset-toggle:disabled{cursor:not-allowed;opacity:.5}.sui-fieldset-toggle-icon{display:block;font-size:.75rem;transition:transform var(--sui-duration-normal) var(--sui-easing-standard)}.sui-fieldset-toggle-icon-collapsed{transform:rotate(-90deg)}.sui-fieldset:disabled{opacity:var(--sui-fieldset-disabled-opacity)}\n"] }]
|
|
25
|
+
}], propDecorators: { legend: [{ type: i0.Input, args: [{ isSignal: true, alias: "legend", required: false }] }], toggleable: [{ type: i0.Input, args: [{ isSignal: true, alias: "toggleable", required: false }] }], collapsed: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsed", required: false }] }, { type: i0.Output, args: ["collapsedChange"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Generated bundle index. Do not edit.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
export { SuiFieldset };
|
|
32
|
+
//# sourceMappingURL=saitec-ui-fieldset.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saitec-ui-fieldset.mjs","sources":["../../../projects/ui/fieldset/src/fieldset.component.ts","../../../projects/ui/fieldset/src/fieldset.component.html","../../../projects/ui/fieldset/src/saitec-ui-fieldset.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n input,\n model\n} from '@angular/core';\n\n@Component({\n selector: 'sui-fieldset',\n standalone: true,\n templateUrl: './fieldset.component.html',\n styleUrl: './fieldset.component.css',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SuiFieldset {\n\n legend = input<string>();\n\n toggleable = input(false);\n\n collapsed = model(false);\n\n disabled = input(false);\n\n protected toggle(): void {\n if (!this.toggleable() || this.disabled()) {\n return;\n }\n\n this.collapsed.update(value => !value);\n }\n}","<fieldset\n class=\"sui-fieldset\"\n [disabled]=\"disabled()\">\n\n @if (legend() || toggleable()) {\n <legend class=\"sui-fieldset-legend\">\n\n <div class=\"sui-fieldset-legend-content\">\n\n <ng-content select=\"[suiFieldsetLegend]\" />\n\n @if (legend()) {\n <span class=\"sui-fieldset-title\">\n {{ legend() }}\n </span>\n }\n\n </div>\n\n @if (toggleable()) {\n <button\n type=\"button\"\n class=\"sui-fieldset-toggle\"\n [disabled]=\"disabled()\"\n [attr.aria-expanded]=\"!collapsed()\"\n (click)=\"toggle()\">\n\n <span\n class=\"sui-fieldset-toggle-icon\"\n [class.sui-fieldset-toggle-icon-collapsed]=\"collapsed()\">\n ▼\n </span>\n\n </button>\n }\n\n </legend>\n }\n\n @if (!collapsed()) {\n <div class=\"sui-fieldset-content\">\n <ng-content />\n </div>\n }\n\n</fieldset>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;MAca,WAAW,CAAA;AAEpB,IAAA,MAAM,GAAG,KAAK;0FAAU;IAExB,UAAU,GAAG,KAAK,CAAC,KAAK;mFAAC;IAEzB,SAAS,GAAG,KAAK,CAAC,KAAK;kFAAC;IAExB,QAAQ,GAAG,KAAK,CAAC,KAAK;iFAAC;IAEb,MAAM,GAAA;QACZ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE;YACvC;QACJ;AAEA,QAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC;IAC1C;uGAhBS,WAAW,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAX,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,WAAW,soBCdxB,+sCA6CW,EAAA,MAAA,EAAA,CAAA,+nDAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FD/BE,WAAW,EAAA,UAAA,EAAA,CAAA;kBAPvB,SAAS;AACI,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,cAAc,EAAA,UAAA,EACZ,IAAI,EAAA,eAAA,EAGC,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,+sCAAA,EAAA,MAAA,EAAA,CAAA,+nDAAA,CAAA,EAAA;;;AEZnD;;AAEG;;;;"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, output, signal, viewChild, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
let nextFileUploadId = 0;
|
|
5
|
+
class SuiFileUpload {
|
|
6
|
+
id = input(`sui-file-upload-${++nextFileUploadId}`, /* @ts-ignore */
|
|
7
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
8
|
+
name = input('files', /* @ts-ignore */
|
|
9
|
+
...(ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []));
|
|
10
|
+
multiple = input(false, /* @ts-ignore */
|
|
11
|
+
...(ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []));
|
|
12
|
+
accept = input(/* @ts-ignore */
|
|
13
|
+
...(ngDevMode ? [undefined, { debugName: "accept" }] : /* istanbul ignore next */ []));
|
|
14
|
+
disabled = input(false, /* @ts-ignore */
|
|
15
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
16
|
+
maxFileSize = input(/* @ts-ignore */
|
|
17
|
+
...(ngDevMode ? [undefined, { debugName: "maxFileSize" }] : /* istanbul ignore next */ []));
|
|
18
|
+
maxFiles = input(/* @ts-ignore */
|
|
19
|
+
...(ngDevMode ? [undefined, { debugName: "maxFiles" }] : /* istanbul ignore next */ []));
|
|
20
|
+
chooseLabel = input('Choose files', /* @ts-ignore */
|
|
21
|
+
...(ngDevMode ? [{ debugName: "chooseLabel" }] : /* istanbul ignore next */ []));
|
|
22
|
+
dropLabel = input('Drop files here', /* @ts-ignore */
|
|
23
|
+
...(ngDevMode ? [{ debugName: "dropLabel" }] : /* istanbul ignore next */ []));
|
|
24
|
+
showFileList = input(true, /* @ts-ignore */
|
|
25
|
+
...(ngDevMode ? [{ debugName: "showFileList" }] : /* istanbul ignore next */ []));
|
|
26
|
+
filesChange = output();
|
|
27
|
+
fileAdded = output();
|
|
28
|
+
fileRemoved = output();
|
|
29
|
+
cleared = output();
|
|
30
|
+
error = output();
|
|
31
|
+
files = signal([], /* @ts-ignore */
|
|
32
|
+
...(ngDevMode ? [{ debugName: "files" }] : /* istanbul ignore next */ []));
|
|
33
|
+
dragging = signal(false, /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "dragging" }] : /* istanbul ignore next */ []));
|
|
35
|
+
inputElement = viewChild.required('fileInput', /* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [{ debugName: "inputElement" }] : /* istanbul ignore next */ []));
|
|
37
|
+
choose() {
|
|
38
|
+
if (this.disabled()) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
this.inputElement().nativeElement.click();
|
|
42
|
+
}
|
|
43
|
+
handleFileInput(event) {
|
|
44
|
+
const input = event.target;
|
|
45
|
+
if (!input.files) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.addFiles(Array.from(input.files));
|
|
49
|
+
/*
|
|
50
|
+
* Allows selecting the same file again.
|
|
51
|
+
*/
|
|
52
|
+
input.value = '';
|
|
53
|
+
}
|
|
54
|
+
handleDragOver(event) {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
if (this.disabled()) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.dragging.set(true);
|
|
60
|
+
}
|
|
61
|
+
handleDragLeave(event) {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
this.dragging.set(false);
|
|
64
|
+
}
|
|
65
|
+
handleDrop(event) {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
this.dragging.set(false);
|
|
68
|
+
if (this.disabled() ||
|
|
69
|
+
!event.dataTransfer?.files) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
this.addFiles(Array.from(event.dataTransfer.files));
|
|
73
|
+
}
|
|
74
|
+
removeFile(file) {
|
|
75
|
+
if (this.disabled()) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const updated = this.files().filter(current => !this.sameFile(current, file));
|
|
79
|
+
this.files.set(updated);
|
|
80
|
+
this.fileRemoved.emit(file);
|
|
81
|
+
this.filesChange.emit(updated);
|
|
82
|
+
}
|
|
83
|
+
clear() {
|
|
84
|
+
if (this.disabled()) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.files.set([]);
|
|
88
|
+
this.cleared.emit();
|
|
89
|
+
this.filesChange.emit([]);
|
|
90
|
+
}
|
|
91
|
+
formatSize(bytes) {
|
|
92
|
+
if (bytes < 1024) {
|
|
93
|
+
return `${bytes} B`;
|
|
94
|
+
}
|
|
95
|
+
if (bytes < 1024 * 1024) {
|
|
96
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
97
|
+
}
|
|
98
|
+
return `${(bytes /
|
|
99
|
+
(1024 * 1024)).toFixed(1)} MB`;
|
|
100
|
+
}
|
|
101
|
+
addFiles(incoming) {
|
|
102
|
+
const accepted = [];
|
|
103
|
+
for (const file of incoming) {
|
|
104
|
+
if (!this.validateFile(file)) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
accepted.push(file);
|
|
108
|
+
}
|
|
109
|
+
if (accepted.length === 0) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
let updated;
|
|
113
|
+
if (this.multiple()) {
|
|
114
|
+
updated = [
|
|
115
|
+
...this.files()
|
|
116
|
+
];
|
|
117
|
+
for (const file of accepted) {
|
|
118
|
+
if (updated.some(current => this.sameFile(current, file))) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
updated.push(file);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
updated = [
|
|
126
|
+
accepted[0]
|
|
127
|
+
];
|
|
128
|
+
}
|
|
129
|
+
const maxFiles = this.maxFiles();
|
|
130
|
+
if (maxFiles !== undefined &&
|
|
131
|
+
updated.length > maxFiles) {
|
|
132
|
+
this.error.emit({
|
|
133
|
+
message: `Maximum number of files is ${maxFiles}.`
|
|
134
|
+
});
|
|
135
|
+
updated =
|
|
136
|
+
updated.slice(0, maxFiles);
|
|
137
|
+
}
|
|
138
|
+
this.files.set(updated);
|
|
139
|
+
for (const file of accepted) {
|
|
140
|
+
this.fileAdded.emit(file);
|
|
141
|
+
}
|
|
142
|
+
this.filesChange.emit(updated);
|
|
143
|
+
}
|
|
144
|
+
validateFile(file) {
|
|
145
|
+
const maxFileSize = this.maxFileSize();
|
|
146
|
+
if (maxFileSize !== undefined &&
|
|
147
|
+
file.size > maxFileSize) {
|
|
148
|
+
this.error.emit({
|
|
149
|
+
file,
|
|
150
|
+
message: `${file.name} exceeds the maximum allowed size.`
|
|
151
|
+
});
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (!this.matchesAccept(file)) {
|
|
155
|
+
this.error.emit({
|
|
156
|
+
file,
|
|
157
|
+
message: `${file.name} is not an accepted file type.`
|
|
158
|
+
});
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
matchesAccept(file) {
|
|
164
|
+
const accept = this.accept();
|
|
165
|
+
if (!accept) {
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
const rules = accept
|
|
169
|
+
.split(',')
|
|
170
|
+
.map(rule => rule
|
|
171
|
+
.trim()
|
|
172
|
+
.toLowerCase())
|
|
173
|
+
.filter(Boolean);
|
|
174
|
+
const fileName = file.name.toLowerCase();
|
|
175
|
+
const fileType = file.type.toLowerCase();
|
|
176
|
+
return rules.some(rule => {
|
|
177
|
+
if (rule.startsWith('.')) {
|
|
178
|
+
return fileName.endsWith(rule);
|
|
179
|
+
}
|
|
180
|
+
if (rule.endsWith('/*')) {
|
|
181
|
+
const prefix = rule.slice(0, rule.length - 1);
|
|
182
|
+
return fileType.startsWith(prefix);
|
|
183
|
+
}
|
|
184
|
+
return fileType === rule;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
sameFile(a, b) {
|
|
188
|
+
return (a.name === b.name &&
|
|
189
|
+
a.size === b.size &&
|
|
190
|
+
a.lastModified ===
|
|
191
|
+
b.lastModified);
|
|
192
|
+
}
|
|
193
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: SuiFileUpload, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
194
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: SuiFileUpload, isStandalone: true, selector: "sui-file-upload", inputs: { id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, name: { classPropertyName: "name", publicName: "name", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, maxFileSize: { classPropertyName: "maxFileSize", publicName: "maxFileSize", isSignal: true, isRequired: false, transformFunction: null }, maxFiles: { classPropertyName: "maxFiles", publicName: "maxFiles", isSignal: true, isRequired: false, transformFunction: null }, chooseLabel: { classPropertyName: "chooseLabel", publicName: "chooseLabel", isSignal: true, isRequired: false, transformFunction: null }, dropLabel: { classPropertyName: "dropLabel", publicName: "dropLabel", isSignal: true, isRequired: false, transformFunction: null }, showFileList: { classPropertyName: "showFileList", publicName: "showFileList", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { filesChange: "filesChange", fileAdded: "fileAdded", fileRemoved: "fileRemoved", cleared: "cleared", error: "error" }, viewQueries: [{ propertyName: "inputElement", first: true, predicate: ["fileInput"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n class=\"sui-file-upload\"\n [class.sui-file-upload-disabled]=\"disabled()\">\n\n <input\n #fileInput\n class=\"sui-file-upload-input\"\n type=\"file\"\n\n [id]=\"id()\"\n [name]=\"name()\"\n\n [multiple]=\"multiple()\"\n [disabled]=\"disabled()\"\n\n [attr.accept]=\"accept() ?? null\"\n\n (change)=\"handleFileInput($event)\"\n />\n\n <div\n class=\"sui-file-upload-drop-zone\"\n\n [class.sui-file-upload-drop-zone-active]=\"dragging()\"\n\n role=\"button\"\n\n [attr.tabindex]=\"\n disabled()\n ? -1\n : 0\n \"\n\n (click)=\"choose()\"\n\n (keydown.enter)=\"choose()\"\n (keydown.space)=\"choose(); $event.preventDefault()\"\n\n (dragover)=\"handleDragOver($event)\"\n (dragleave)=\"handleDragLeave($event)\"\n (drop)=\"handleDrop($event)\">\n\n <div class=\"sui-file-upload-drop-label\">\n {{ dropLabel() }}\n </div>\n\n <div class=\"sui-file-upload-separator\">\n or\n </div>\n\n <button\n type=\"button\"\n class=\"sui-file-upload-choose\"\n [disabled]=\"disabled()\"\n (click)=\"\n $event.stopPropagation();\n choose()\n \">\n {{ chooseLabel() }}\n </button>\n\n </div>\n\n @if (\n showFileList() &&\n files().length > 0\n ) {\n\n <div class=\"sui-file-upload-list\">\n\n @for (\n file of files();\n track file.name +\n file.size +\n file.lastModified\n ) {\n\n <div class=\"sui-file-upload-file\">\n\n <div class=\"sui-file-upload-file-info\">\n\n <div class=\"sui-file-upload-file-name\">\n {{ file.name }}\n </div>\n\n <div class=\"sui-file-upload-file-size\">\n {{ formatSize(file.size) }}\n </div>\n\n </div>\n\n <button\n type=\"button\"\n class=\"sui-file-upload-remove\"\n [disabled]=\"disabled()\"\n aria-label=\"Remove file\"\n (click)=\"removeFile(file)\">\n \u00D7\n </button>\n\n </div>\n\n }\n\n @if (files().length > 1) {\n\n <div class=\"sui-file-upload-actions\">\n\n <button\n type=\"button\"\n class=\"sui-file-upload-clear\"\n [disabled]=\"disabled()\"\n (click)=\"clear()\">\n Clear\n </button>\n\n </div>\n\n }\n\n </div>\n\n }\n\n</div>", styles: [":host{display:block;width:100%}.sui-file-upload{display:block;width:100%}.sui-file-upload-input{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;opacity:0}.sui-file-upload-drop-zone{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.5rem;min-height:8rem;box-sizing:border-box;padding:1.5rem;color:var(--sui-file-upload-color);background:var(--sui-file-upload-background);border:var(--sui-file-upload-border-width) dashed var(--sui-file-upload-border-color);border-radius:var(--sui-file-upload-border-radius);cursor:pointer;transition:border-color var(--sui-duration-normal) var(--sui-easing-standard),background-color var(--sui-duration-normal) var(--sui-easing-standard)}.sui-file-upload-drop-zone:hover{border-color:var(--sui-file-upload-hover-border-color);background:var(--sui-file-upload-hover-background)}.sui-file-upload-drop-zone-active{border-color:var(--sui-file-upload-active-border-color);background:var(--sui-file-upload-active-background)}.sui-file-upload-drop-zone:focus-visible{outline:2px solid var(--sui-file-upload-focus-color);outline-offset:var(--sui-focus-ring-offset)}.sui-file-upload-drop-label{font-family:inherit;font-size:.875rem;font-weight:500}.sui-file-upload-separator{color:var(--sui-file-upload-muted-color);font-family:inherit;font-size:.75rem}.sui-file-upload-choose,.sui-file-upload-clear{padding:.5rem .75rem;font-family:inherit;font-size:.875rem;color:var(--sui-file-upload-button-color);background:var(--sui-file-upload-button-background);border:0;border-radius:.375rem;cursor:pointer}.sui-file-upload-choose:hover:not(:disabled),.sui-file-upload-clear:hover:not(:disabled){background:var(--sui-file-upload-button-hover-background)}.sui-file-upload-list{display:flex;flex-direction:column;gap:.5rem;margin-top:.75rem}.sui-file-upload-file{display:flex;align-items:center;gap:.75rem;padding:.625rem .75rem;background:var(--sui-file-upload-file-background);border:1px solid var(--sui-file-upload-file-border-color);border-radius:.375rem}.sui-file-upload-file-info{flex:1;min-width:0}.sui-file-upload-file-name{overflow:hidden;color:var(--sui-file-upload-file-color);font-family:inherit;font-size:.875rem;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.sui-file-upload-file-size{margin-top:.125rem;color:var(--sui-file-upload-muted-color);font-family:inherit;font-size:.75rem}.sui-file-upload-remove{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:1.75rem;height:1.75rem;padding:0;color:var(--sui-file-upload-remove-color);background:transparent;border:0;border-radius:.375rem;cursor:pointer;font-size:1.125rem}.sui-file-upload-remove:hover:not(:disabled){color:var(--sui-file-upload-remove-hover-color);background:var(--sui-file-upload-remove-hover-background)}.sui-file-upload-actions{display:flex;justify-content:flex-end}.sui-file-upload-clear{color:var(--sui-file-upload-clear-color);background:var(--sui-file-upload-clear-background)}.sui-file-upload-clear:hover:not(:disabled){background:var(--sui-file-upload-clear-hover-background)}.sui-file-upload-disabled{opacity:var(--sui-file-upload-disabled-opacity)}.sui-file-upload-disabled .sui-file-upload-drop-zone{cursor:not-allowed}button:disabled{cursor:not-allowed}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
195
|
+
}
|
|
196
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: SuiFileUpload, decorators: [{
|
|
197
|
+
type: Component,
|
|
198
|
+
args: [{ selector: 'sui-file-upload', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"sui-file-upload\"\n [class.sui-file-upload-disabled]=\"disabled()\">\n\n <input\n #fileInput\n class=\"sui-file-upload-input\"\n type=\"file\"\n\n [id]=\"id()\"\n [name]=\"name()\"\n\n [multiple]=\"multiple()\"\n [disabled]=\"disabled()\"\n\n [attr.accept]=\"accept() ?? null\"\n\n (change)=\"handleFileInput($event)\"\n />\n\n <div\n class=\"sui-file-upload-drop-zone\"\n\n [class.sui-file-upload-drop-zone-active]=\"dragging()\"\n\n role=\"button\"\n\n [attr.tabindex]=\"\n disabled()\n ? -1\n : 0\n \"\n\n (click)=\"choose()\"\n\n (keydown.enter)=\"choose()\"\n (keydown.space)=\"choose(); $event.preventDefault()\"\n\n (dragover)=\"handleDragOver($event)\"\n (dragleave)=\"handleDragLeave($event)\"\n (drop)=\"handleDrop($event)\">\n\n <div class=\"sui-file-upload-drop-label\">\n {{ dropLabel() }}\n </div>\n\n <div class=\"sui-file-upload-separator\">\n or\n </div>\n\n <button\n type=\"button\"\n class=\"sui-file-upload-choose\"\n [disabled]=\"disabled()\"\n (click)=\"\n $event.stopPropagation();\n choose()\n \">\n {{ chooseLabel() }}\n </button>\n\n </div>\n\n @if (\n showFileList() &&\n files().length > 0\n ) {\n\n <div class=\"sui-file-upload-list\">\n\n @for (\n file of files();\n track file.name +\n file.size +\n file.lastModified\n ) {\n\n <div class=\"sui-file-upload-file\">\n\n <div class=\"sui-file-upload-file-info\">\n\n <div class=\"sui-file-upload-file-name\">\n {{ file.name }}\n </div>\n\n <div class=\"sui-file-upload-file-size\">\n {{ formatSize(file.size) }}\n </div>\n\n </div>\n\n <button\n type=\"button\"\n class=\"sui-file-upload-remove\"\n [disabled]=\"disabled()\"\n aria-label=\"Remove file\"\n (click)=\"removeFile(file)\">\n \u00D7\n </button>\n\n </div>\n\n }\n\n @if (files().length > 1) {\n\n <div class=\"sui-file-upload-actions\">\n\n <button\n type=\"button\"\n class=\"sui-file-upload-clear\"\n [disabled]=\"disabled()\"\n (click)=\"clear()\">\n Clear\n </button>\n\n </div>\n\n }\n\n </div>\n\n }\n\n</div>", styles: [":host{display:block;width:100%}.sui-file-upload{display:block;width:100%}.sui-file-upload-input{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;opacity:0}.sui-file-upload-drop-zone{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:.5rem;min-height:8rem;box-sizing:border-box;padding:1.5rem;color:var(--sui-file-upload-color);background:var(--sui-file-upload-background);border:var(--sui-file-upload-border-width) dashed var(--sui-file-upload-border-color);border-radius:var(--sui-file-upload-border-radius);cursor:pointer;transition:border-color var(--sui-duration-normal) var(--sui-easing-standard),background-color var(--sui-duration-normal) var(--sui-easing-standard)}.sui-file-upload-drop-zone:hover{border-color:var(--sui-file-upload-hover-border-color);background:var(--sui-file-upload-hover-background)}.sui-file-upload-drop-zone-active{border-color:var(--sui-file-upload-active-border-color);background:var(--sui-file-upload-active-background)}.sui-file-upload-drop-zone:focus-visible{outline:2px solid var(--sui-file-upload-focus-color);outline-offset:var(--sui-focus-ring-offset)}.sui-file-upload-drop-label{font-family:inherit;font-size:.875rem;font-weight:500}.sui-file-upload-separator{color:var(--sui-file-upload-muted-color);font-family:inherit;font-size:.75rem}.sui-file-upload-choose,.sui-file-upload-clear{padding:.5rem .75rem;font-family:inherit;font-size:.875rem;color:var(--sui-file-upload-button-color);background:var(--sui-file-upload-button-background);border:0;border-radius:.375rem;cursor:pointer}.sui-file-upload-choose:hover:not(:disabled),.sui-file-upload-clear:hover:not(:disabled){background:var(--sui-file-upload-button-hover-background)}.sui-file-upload-list{display:flex;flex-direction:column;gap:.5rem;margin-top:.75rem}.sui-file-upload-file{display:flex;align-items:center;gap:.75rem;padding:.625rem .75rem;background:var(--sui-file-upload-file-background);border:1px solid var(--sui-file-upload-file-border-color);border-radius:.375rem}.sui-file-upload-file-info{flex:1;min-width:0}.sui-file-upload-file-name{overflow:hidden;color:var(--sui-file-upload-file-color);font-family:inherit;font-size:.875rem;font-weight:500;text-overflow:ellipsis;white-space:nowrap}.sui-file-upload-file-size{margin-top:.125rem;color:var(--sui-file-upload-muted-color);font-family:inherit;font-size:.75rem}.sui-file-upload-remove{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;width:1.75rem;height:1.75rem;padding:0;color:var(--sui-file-upload-remove-color);background:transparent;border:0;border-radius:.375rem;cursor:pointer;font-size:1.125rem}.sui-file-upload-remove:hover:not(:disabled){color:var(--sui-file-upload-remove-hover-color);background:var(--sui-file-upload-remove-hover-background)}.sui-file-upload-actions{display:flex;justify-content:flex-end}.sui-file-upload-clear{color:var(--sui-file-upload-clear-color);background:var(--sui-file-upload-clear-background)}.sui-file-upload-clear:hover:not(:disabled){background:var(--sui-file-upload-clear-hover-background)}.sui-file-upload-disabled{opacity:var(--sui-file-upload-disabled-opacity)}.sui-file-upload-disabled .sui-file-upload-drop-zone{cursor:not-allowed}button:disabled{cursor:not-allowed}\n"] }]
|
|
199
|
+
}], propDecorators: { id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], name: [{ type: i0.Input, args: [{ isSignal: true, alias: "name", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], accept: [{ type: i0.Input, args: [{ isSignal: true, alias: "accept", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], maxFileSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFileSize", required: false }] }], maxFiles: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFiles", required: false }] }], chooseLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "chooseLabel", required: false }] }], dropLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropLabel", required: false }] }], showFileList: [{ type: i0.Input, args: [{ isSignal: true, alias: "showFileList", required: false }] }], filesChange: [{ type: i0.Output, args: ["filesChange"] }], fileAdded: [{ type: i0.Output, args: ["fileAdded"] }], fileRemoved: [{ type: i0.Output, args: ["fileRemoved"] }], cleared: [{ type: i0.Output, args: ["cleared"] }], error: [{ type: i0.Output, args: ["error"] }], inputElement: [{ type: i0.ViewChild, args: ['fileInput', { isSignal: true }] }] } });
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Generated bundle index. Do not edit.
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
export { SuiFileUpload };
|
|
206
|
+
//# sourceMappingURL=saitec-ui-file-upload.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saitec-ui-file-upload.mjs","sources":["../../../projects/ui/file-upload/src/file-upload.component.ts","../../../projects/ui/file-upload/src/file-upload.component.html","../../../projects/ui/file-upload/src/saitec-ui-file-upload.ts"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n input,\n output,\n signal,\n viewChild\n} from '@angular/core';\n\nexport interface SuiFileUploadError {\n file?: File;\n message: string;\n}\n\nlet nextFileUploadId = 0;\n\n@Component({\n selector: 'sui-file-upload',\n standalone: true,\n templateUrl: './file-upload.component.html',\n styleUrl: './file-upload.component.css',\n changeDetection: ChangeDetectionStrategy.OnPush\n})\nexport class SuiFileUpload {\n\n id = input(`sui-file-upload-${++nextFileUploadId}`);\n\n name = input('files');\n\n multiple = input(false);\n\n accept = input<string>();\n\n disabled = input(false);\n\n maxFileSize = input<number>();\n\n maxFiles = input<number>();\n\n chooseLabel = input('Choose files');\n\n dropLabel = input('Drop files here');\n\n showFileList = input(true);\n\n filesChange = output<File[]>();\n\n fileAdded = output<File>();\n\n fileRemoved = output<File>();\n\n cleared = output<void>();\n\n error = output<SuiFileUploadError>();\n\n protected readonly files = signal<File[]>([]);\n\n protected readonly dragging = signal(false);\n\n private readonly inputElement =\n viewChild.required<ElementRef<HTMLInputElement>>(\n 'fileInput'\n );\n\n protected choose(): void {\n if (this.disabled()) {\n return;\n }\n\n this.inputElement().nativeElement.click();\n }\n\n protected handleFileInput(\n event: Event\n ): void {\n\n const input =\n event.target as HTMLInputElement;\n\n if (!input.files) {\n return;\n }\n\n this.addFiles(\n Array.from(input.files)\n );\n\n /*\n * Allows selecting the same file again.\n */\n input.value = '';\n }\n\n protected handleDragOver(\n event: DragEvent\n ): void {\n\n event.preventDefault();\n\n if (this.disabled()) {\n return;\n }\n\n this.dragging.set(true);\n }\n\n protected handleDragLeave(\n event: DragEvent\n ): void {\n\n event.preventDefault();\n\n this.dragging.set(false);\n }\n\n protected handleDrop(\n event: DragEvent\n ): void {\n\n event.preventDefault();\n\n this.dragging.set(false);\n\n if (\n this.disabled() ||\n !event.dataTransfer?.files\n ) {\n return;\n }\n\n this.addFiles(\n Array.from(\n event.dataTransfer.files\n )\n );\n }\n\n protected removeFile(\n file: File\n ): void {\n\n if (this.disabled()) {\n return;\n }\n\n const updated =\n this.files().filter(\n current =>\n !this.sameFile(\n current,\n file\n )\n );\n\n this.files.set(updated);\n\n this.fileRemoved.emit(file);\n this.filesChange.emit(updated);\n }\n\n protected clear(): void {\n if (this.disabled()) {\n return;\n }\n\n this.files.set([]);\n\n this.cleared.emit();\n this.filesChange.emit([]);\n }\n\n protected formatSize(\n bytes: number\n ): string {\n\n if (bytes < 1024) {\n return `${bytes} B`;\n }\n\n if (bytes < 1024 * 1024) {\n return `${(\n bytes / 1024\n ).toFixed(1)} KB`;\n }\n\n return `${(\n bytes /\n (1024 * 1024)\n ).toFixed(1)} MB`;\n }\n\n private addFiles(\n incoming: File[]\n ): void {\n\n const accepted: File[] = [];\n\n for (const file of incoming) {\n\n if (!this.validateFile(file)) {\n continue;\n }\n\n accepted.push(file);\n }\n\n if (accepted.length === 0) {\n return;\n }\n\n let updated: File[];\n\n if (this.multiple()) {\n\n updated = [\n ...this.files()\n ];\n\n for (const file of accepted) {\n\n if (\n updated.some(\n current =>\n this.sameFile(\n current,\n file\n )\n )\n ) {\n continue;\n }\n\n updated.push(file);\n }\n }\n else {\n updated = [\n accepted[0]\n ];\n }\n\n const maxFiles =\n this.maxFiles();\n\n if (\n maxFiles !== undefined &&\n updated.length > maxFiles\n ) {\n\n this.error.emit({\n message:\n `Maximum number of files is ${maxFiles}.`\n });\n\n updated =\n updated.slice(\n 0,\n maxFiles\n );\n }\n\n this.files.set(updated);\n\n for (const file of accepted) {\n this.fileAdded.emit(file);\n }\n\n this.filesChange.emit(updated);\n }\n\n private validateFile(\n file: File\n ): boolean {\n\n const maxFileSize =\n this.maxFileSize();\n\n if (\n maxFileSize !== undefined &&\n file.size > maxFileSize\n ) {\n\n this.error.emit({\n file,\n message:\n `${file.name} exceeds the maximum allowed size.`\n });\n\n return false;\n }\n\n if (\n !this.matchesAccept(file)\n ) {\n\n this.error.emit({\n file,\n message:\n `${file.name} is not an accepted file type.`\n });\n\n return false;\n }\n\n return true;\n }\n\n private matchesAccept(\n file: File\n ): boolean {\n\n const accept =\n this.accept();\n\n if (!accept) {\n return true;\n }\n\n const rules =\n accept\n .split(',')\n .map(\n rule =>\n rule\n .trim()\n .toLowerCase()\n )\n .filter(Boolean);\n\n const fileName =\n file.name.toLowerCase();\n\n const fileType =\n file.type.toLowerCase();\n\n return rules.some(rule => {\n\n if (\n rule.startsWith('.')\n ) {\n return fileName.endsWith(rule);\n }\n\n if (\n rule.endsWith('/*')\n ) {\n\n const prefix =\n rule.slice(\n 0,\n rule.length - 1\n );\n\n return fileType.startsWith(\n prefix\n );\n }\n\n return fileType === rule;\n });\n }\n\n private sameFile(\n a: File,\n b: File\n ): boolean {\n\n return (\n a.name === b.name &&\n a.size === b.size &&\n a.lastModified ===\n b.lastModified\n );\n }\n}","<div\n class=\"sui-file-upload\"\n [class.sui-file-upload-disabled]=\"disabled()\">\n\n <input\n #fileInput\n class=\"sui-file-upload-input\"\n type=\"file\"\n\n [id]=\"id()\"\n [name]=\"name()\"\n\n [multiple]=\"multiple()\"\n [disabled]=\"disabled()\"\n\n [attr.accept]=\"accept() ?? null\"\n\n (change)=\"handleFileInput($event)\"\n />\n\n <div\n class=\"sui-file-upload-drop-zone\"\n\n [class.sui-file-upload-drop-zone-active]=\"dragging()\"\n\n role=\"button\"\n\n [attr.tabindex]=\"\n disabled()\n ? -1\n : 0\n \"\n\n (click)=\"choose()\"\n\n (keydown.enter)=\"choose()\"\n (keydown.space)=\"choose(); $event.preventDefault()\"\n\n (dragover)=\"handleDragOver($event)\"\n (dragleave)=\"handleDragLeave($event)\"\n (drop)=\"handleDrop($event)\">\n\n <div class=\"sui-file-upload-drop-label\">\n {{ dropLabel() }}\n </div>\n\n <div class=\"sui-file-upload-separator\">\n or\n </div>\n\n <button\n type=\"button\"\n class=\"sui-file-upload-choose\"\n [disabled]=\"disabled()\"\n (click)=\"\n $event.stopPropagation();\n choose()\n \">\n {{ chooseLabel() }}\n </button>\n\n </div>\n\n @if (\n showFileList() &&\n files().length > 0\n ) {\n\n <div class=\"sui-file-upload-list\">\n\n @for (\n file of files();\n track file.name +\n file.size +\n file.lastModified\n ) {\n\n <div class=\"sui-file-upload-file\">\n\n <div class=\"sui-file-upload-file-info\">\n\n <div class=\"sui-file-upload-file-name\">\n {{ file.name }}\n </div>\n\n <div class=\"sui-file-upload-file-size\">\n {{ formatSize(file.size) }}\n </div>\n\n </div>\n\n <button\n type=\"button\"\n class=\"sui-file-upload-remove\"\n [disabled]=\"disabled()\"\n aria-label=\"Remove file\"\n (click)=\"removeFile(file)\">\n ×\n </button>\n\n </div>\n\n }\n\n @if (files().length > 1) {\n\n <div class=\"sui-file-upload-actions\">\n\n <button\n type=\"button\"\n class=\"sui-file-upload-clear\"\n [disabled]=\"disabled()\"\n (click)=\"clear()\">\n Clear\n </button>\n\n </div>\n\n }\n\n </div>\n\n }\n\n</div>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;AAeA,IAAI,gBAAgB,GAAG,CAAC;MASX,aAAa,CAAA;AAEtB,IAAA,EAAE,GAAG,KAAK,CAAC,CAAA,gBAAA,EAAmB,EAAE,gBAAgB,CAAA,CAAE;2EAAC;IAEnD,IAAI,GAAG,KAAK,CAAC,OAAO;6EAAC;IAErB,QAAQ,GAAG,KAAK,CAAC,KAAK;iFAAC;AAEvB,IAAA,MAAM,GAAG,KAAK;0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AA;;2FDpGO,aAAa,EAAA,UAAA,EAAA,CAAA;kBAPzB,SAAS;AACI,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,iBAAiB,EAAA,UAAA,EACf,IAAI,EAAA,eAAA,EAGC,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,8/FAAA,EAAA,MAAA,EAAA,CAAA,ktGAAA,CAAA,EAAA;uxCAwCvC,WAAW,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AE9DvB;;AAEG;;;;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
class SuiFormField {
|
|
5
|
+
label = input(/* @ts-ignore */
|
|
6
|
+
...(ngDevMode ? [undefined, { debugName: "label" }] : /* istanbul ignore next */ []));
|
|
7
|
+
hint = input(/* @ts-ignore */
|
|
8
|
+
...(ngDevMode ? [undefined, { debugName: "hint" }] : /* istanbul ignore next */ []));
|
|
9
|
+
error = input(/* @ts-ignore */
|
|
10
|
+
...(ngDevMode ? [undefined, { debugName: "error" }] : /* istanbul ignore next */ []));
|
|
11
|
+
required = input(false, /* @ts-ignore */
|
|
12
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
13
|
+
invalid = input(false, /* @ts-ignore */
|
|
14
|
+
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
15
|
+
disabled = input(false, /* @ts-ignore */
|
|
16
|
+
...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
|
|
17
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: SuiFormField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
18
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.1", type: SuiFormField, isStandalone: true, selector: "sui-form-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "<div\r\n class=\"sui-form-field\"\r\n [class.sui-form-field-invalid]=\"invalid()\"\r\n [class.sui-form-field-disabled]=\"disabled()\">\r\n\r\n @if (label()) {\r\n <label class=\"sui-form-field-label\">\r\n {{ label() }}\r\n\r\n @if (required()) {\r\n <span\r\n class=\"sui-form-field-required\"\r\n aria-hidden=\"true\">\r\n *\r\n </span>\r\n }\r\n </label>\r\n }\r\n\r\n <div class=\"sui-form-field-control\">\r\n <ng-content />\r\n </div>\r\n\r\n @if (invalid() && error()) {\r\n <div\r\n class=\"sui-form-field-error\"\r\n role=\"alert\">\r\n {{ error() }}\r\n </div>\r\n }\r\n @else if (hint()) {\r\n <div class=\"sui-form-field-hint\">\r\n {{ hint() }}\r\n </div>\r\n }\r\n\r\n</div>", styles: [":host{display:block;width:100%}.sui-form-field{display:flex;flex-direction:column;width:100%;gap:var(--sui-form-field-gap)}.sui-form-field-label{display:inline-flex;align-items:center;gap:var(--sui-form-field-label-gap);font-size:var(--sui-form-field-label-font-size);font-weight:var(--sui-form-field-label-font-weight);color:var(--sui-form-field-label-text)}.sui-form-field-required{color:var(--sui-form-field-required-text)}.sui-form-field-control{display:block;width:100%}.sui-form-field-hint,.sui-form-field-error{min-height:1rem;font-size:var(--sui-form-field-help-font-size);line-height:1rem}.sui-form-field-hint{color:var(--sui-form-field-hint-text)}.sui-form-field-error{color:var(--sui-form-field-error-text)}.sui-form-field-disabled{opacity:var(--sui-form-field-disabled-opacity)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
19
|
+
}
|
|
20
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.1", ngImport: i0, type: SuiFormField, decorators: [{
|
|
21
|
+
type: Component,
|
|
22
|
+
args: [{ selector: 'sui-form-field', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\r\n class=\"sui-form-field\"\r\n [class.sui-form-field-invalid]=\"invalid()\"\r\n [class.sui-form-field-disabled]=\"disabled()\">\r\n\r\n @if (label()) {\r\n <label class=\"sui-form-field-label\">\r\n {{ label() }}\r\n\r\n @if (required()) {\r\n <span\r\n class=\"sui-form-field-required\"\r\n aria-hidden=\"true\">\r\n *\r\n </span>\r\n }\r\n </label>\r\n }\r\n\r\n <div class=\"sui-form-field-control\">\r\n <ng-content />\r\n </div>\r\n\r\n @if (invalid() && error()) {\r\n <div\r\n class=\"sui-form-field-error\"\r\n role=\"alert\">\r\n {{ error() }}\r\n </div>\r\n }\r\n @else if (hint()) {\r\n <div class=\"sui-form-field-hint\">\r\n {{ hint() }}\r\n </div>\r\n }\r\n\r\n</div>", styles: [":host{display:block;width:100%}.sui-form-field{display:flex;flex-direction:column;width:100%;gap:var(--sui-form-field-gap)}.sui-form-field-label{display:inline-flex;align-items:center;gap:var(--sui-form-field-label-gap);font-size:var(--sui-form-field-label-font-size);font-weight:var(--sui-form-field-label-font-weight);color:var(--sui-form-field-label-text)}.sui-form-field-required{color:var(--sui-form-field-required-text)}.sui-form-field-control{display:block;width:100%}.sui-form-field-hint,.sui-form-field-error{min-height:1rem;font-size:var(--sui-form-field-help-font-size);line-height:1rem}.sui-form-field-hint{color:var(--sui-form-field-hint-text)}.sui-form-field-error{color:var(--sui-form-field-error-text)}.sui-form-field-disabled{opacity:var(--sui-form-field-disabled-opacity)}\n"] }]
|
|
23
|
+
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Generated bundle index. Do not edit.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
export { SuiFormField };
|
|
30
|
+
//# sourceMappingURL=saitec-ui-form-field.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"saitec-ui-form-field.mjs","sources":["../../../projects/ui/form-field/src/form-field.component.ts","../../../projects/ui/form-field/src/form-field.component.html","../../../projects/ui/form-field/src/saitec-ui-form-field.ts"],"sourcesContent":["import {\r\n ChangeDetectionStrategy,\r\n Component,\r\n input\r\n} from '@angular/core';\r\n\r\n@Component({\r\n selector: 'sui-form-field',\r\n standalone: true,\r\n templateUrl: './form-field.component.html',\r\n styleUrl: './form-field.component.css',\r\n changeDetection: ChangeDetectionStrategy.OnPush\r\n})\r\nexport class SuiFormField {\r\n label = input<string>();\r\n\r\n hint = input<string>();\r\n\r\n error = input<string>();\r\n\r\n required = input(false);\r\n\r\n invalid = input(false);\r\n\r\n disabled = input(false);\r\n}","<div\r\n class=\"sui-form-field\"\r\n [class.sui-form-field-invalid]=\"invalid()\"\r\n [class.sui-form-field-disabled]=\"disabled()\">\r\n\r\n @if (label()) {\r\n <label class=\"sui-form-field-label\">\r\n {{ label() }}\r\n\r\n @if (required()) {\r\n <span\r\n class=\"sui-form-field-required\"\r\n aria-hidden=\"true\">\r\n *\r\n </span>\r\n }\r\n </label>\r\n }\r\n\r\n <div class=\"sui-form-field-control\">\r\n <ng-content />\r\n </div>\r\n\r\n @if (invalid() && error()) {\r\n <div\r\n class=\"sui-form-field-error\"\r\n role=\"alert\">\r\n {{ error() }}\r\n </div>\r\n }\r\n @else if (hint()) {\r\n <div class=\"sui-form-field-hint\">\r\n {{ hint() }}\r\n </div>\r\n }\r\n\r\n</div>","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;MAaa,YAAY,CAAA;AACrB,IAAA,KAAK,GAAG,KAAK;yFAAU;AAEvB,IAAA,IAAI,GAAG,KAAK;wFAAU;AAEtB,IAAA,KAAK,GAAG,KAAK;yFAAU;IAEvB,QAAQ,GAAG,KAAK,CAAC,KAAK;iFAAC;IAEvB,OAAO,GAAG,KAAK,CAAC,KAAK;gFAAC;IAEtB,QAAQ,GAAG,KAAK,CAAC,KAAK;iFAAC;uGAXd,YAAY,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAZ,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,YAAY,2zBCbzB,w6BAoCM,EAAA,MAAA,EAAA,CAAA,0xBAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FDvBO,YAAY,EAAA,UAAA,EAAA,CAAA;kBAPxB,SAAS;AACI,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,gBAAgB,EAAA,UAAA,EACd,IAAI,EAAA,eAAA,EAGC,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,w6BAAA,EAAA,MAAA,EAAA,CAAA,0xBAAA,CAAA,EAAA;;;AEXnD;;AAEG;;;;"}
|