@besaitech/ng-design-system 0.0.55 → 0.0.56

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.
@@ -6734,6 +6734,10 @@ function sdsFileMatchesAccept(file, accept) {
6734
6734
  * affordance); clicking anywhere on the zone opens the picker too. All text is set through inputs with
6735
6735
  * English defaults.
6736
6736
  *
6737
+ * `appearance="button"` drops the zone and renders only the Browse button (files can still be dropped
6738
+ * on it) — for a "Replace photo" / "Upload logo" / "Add document" action next to a preview, with the
6739
+ * same accept/size/count checks and error messages. `browse()` opens the picker from your own control.
6740
+ *
6737
6741
  * @example
6738
6742
  * <sds-file-drop accept="image/jpeg,image/png,image/webp" multiple [maxSize]="10_000_000"
6739
6743
  * label="Drop photos here" browseLabel="Choose photos"
@@ -6752,6 +6756,10 @@ class SdsFileDrop {
6752
6756
  disabled = input(false, ...(ngDevMode ? [{ debugName: "disabled", transform: booleanAttribute }] : [{ transform: booleanAttribute }]));
6753
6757
  /** Icon in the zone at rest. */
6754
6758
  icon = input('upload', ...(ngDevMode ? [{ debugName: "icon" }] : []));
6759
+ /** `zone` (default): the dashed drop zone with a Browse button. `button`: the Browse button alone. */
6760
+ appearance = input('zone', ...(ngDevMode ? [{ debugName: "appearance" }] : []));
6761
+ /** `button` appearance: size of the button. */
6762
+ size = input('md', ...(ngDevMode ? [{ debugName: "size" }] : []));
6755
6763
  label = input('Drag and drop files here', ...(ngDevMode ? [{ debugName: "label" }] : []));
6756
6764
  /** Shown while files are dragged over the zone. */
6757
6765
  dropLabel = input('Drop to add', ...(ngDevMode ? [{ debugName: "dropLabel" }] : []));
@@ -6788,6 +6796,14 @@ class SdsFileDrop {
6788
6796
  ? `${base} cursor-copy border-brand-500 bg-brand-50 dark:bg-muted`
6789
6797
  : `${base} cursor-pointer border-border bg-muted/50 hover:border-ink-faint`;
6790
6798
  }, ...(ngDevMode ? [{ debugName: "zoneClass" }] : []));
6799
+ buttonClass = computed(() => {
6800
+ const size = this.size() === 'sm' ? 'h-8 px-3' : 'h-9 px-3.5';
6801
+ const drag = this.dragging() ? ' border-brand-500 bg-brand-50 dark:bg-muted' : ' border-border bg-surface hover:bg-muted';
6802
+ return (`inline-flex ${size} items-center gap-1.5 rounded-control border text-sm font-semibold text-ink shadow-sm ` +
6803
+ 'transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500 ' +
6804
+ 'disabled:cursor-not-allowed disabled:opacity-60' +
6805
+ drag);
6806
+ }, ...(ngDevMode ? [{ debugName: "buttonClass" }] : []));
6791
6807
  /** Open the native file picker. */
6792
6808
  browse(event) {
6793
6809
  event?.stopPropagation();
@@ -6881,7 +6897,35 @@ class SdsFileDrop {
6881
6897
  this.errors.set([]);
6882
6898
  }
6883
6899
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.25", ngImport: i0, type: SdsFileDrop, deps: [], target: i0.ɵɵFactoryTarget.Component });
6884
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: SdsFileDrop, isStandalone: true, selector: "sds-file-drop", inputs: { accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, maxSize: { classPropertyName: "maxSize", publicName: "maxSize", isSignal: true, isRequired: false, transformFunction: null }, maxFiles: { classPropertyName: "maxFiles", publicName: "maxFiles", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, dropLabel: { classPropertyName: "dropLabel", publicName: "dropLabel", isSignal: true, isRequired: false, transformFunction: null }, browseLabel: { classPropertyName: "browseLabel", publicName: "browseLabel", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, wrongTypeMessage: { classPropertyName: "wrongTypeMessage", publicName: "wrongTypeMessage", isSignal: true, isRequired: false, transformFunction: null }, tooLargeMessage: { classPropertyName: "tooLargeMessage", publicName: "tooLargeMessage", isSignal: true, isRequired: false, transformFunction: null }, tooManyMessage: { classPropertyName: "tooManyMessage", publicName: "tooManyMessage", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { files: "files", rejected: "rejected" }, host: { classAttribute: "block" }, viewQueries: [{ propertyName: "fileInput", first: true, predicate: ["fileInput"], descendants: true, isSignal: true }], ngImport: i0, template: `
6900
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.25", type: SdsFileDrop, isStandalone: true, selector: "sds-file-drop", inputs: { accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, maxSize: { classPropertyName: "maxSize", publicName: "maxSize", isSignal: true, isRequired: false, transformFunction: null }, maxFiles: { classPropertyName: "maxFiles", publicName: "maxFiles", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, dropLabel: { classPropertyName: "dropLabel", publicName: "dropLabel", isSignal: true, isRequired: false, transformFunction: null }, browseLabel: { classPropertyName: "browseLabel", publicName: "browseLabel", isSignal: true, isRequired: false, transformFunction: null }, hint: { classPropertyName: "hint", publicName: "hint", isSignal: true, isRequired: false, transformFunction: null }, wrongTypeMessage: { classPropertyName: "wrongTypeMessage", publicName: "wrongTypeMessage", isSignal: true, isRequired: false, transformFunction: null }, tooLargeMessage: { classPropertyName: "tooLargeMessage", publicName: "tooLargeMessage", isSignal: true, isRequired: false, transformFunction: null }, tooManyMessage: { classPropertyName: "tooManyMessage", publicName: "tooManyMessage", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { files: "files", rejected: "rejected" }, host: { classAttribute: "block" }, viewQueries: [{ propertyName: "fileInput", first: true, predicate: ["fileInput"], descendants: true, isSignal: true }], ngImport: i0, template: `
6901
+ @if (appearance() === 'button') {
6902
+ <button
6903
+ type="button"
6904
+ [class]="buttonClass()"
6905
+ [disabled]="disabled()"
6906
+ [attr.aria-describedby]="errors().length ? zoneId + '-errors' : null"
6907
+ [attr.data-dragging]="dragging() ? 'true' : null"
6908
+ (click)="browse($event)"
6909
+ (dragenter)="onDragEnter($event)"
6910
+ (dragover)="onDragOver($event)"
6911
+ (dragleave)="onDragLeave($event)"
6912
+ (drop)="onDrop($event)"
6913
+ >
6914
+ <sds-icon [name]="dragging() ? 'upload' : icon()" [size]="16" />
6915
+ {{ dragging() ? dropLabel() : browseLabel() }}
6916
+ </button>
6917
+ <input
6918
+ #fileInput
6919
+ type="file"
6920
+ class="sr-only"
6921
+ tabindex="-1"
6922
+ aria-hidden="true"
6923
+ [accept]="accept()"
6924
+ [multiple]="multiple()"
6925
+ [disabled]="disabled()"
6926
+ (change)="onInputChange($event)"
6927
+ />
6928
+ } @else {
6885
6929
  <div
6886
6930
  [class]="zoneClass()"
6887
6931
  [attr.aria-disabled]="disabled() ? 'true' : null"
@@ -6926,6 +6970,7 @@ class SdsFileDrop {
6926
6970
  (change)="onInputChange($event)"
6927
6971
  />
6928
6972
  </div>
6973
+ }
6929
6974
 
6930
6975
  <div aria-live="polite" aria-atomic="true">
6931
6976
  @if (errors().length) {
@@ -6949,6 +6994,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
6949
6994
  imports: [SdsIcon],
6950
6995
  host: { class: 'block' },
6951
6996
  template: `
6997
+ @if (appearance() === 'button') {
6998
+ <button
6999
+ type="button"
7000
+ [class]="buttonClass()"
7001
+ [disabled]="disabled()"
7002
+ [attr.aria-describedby]="errors().length ? zoneId + '-errors' : null"
7003
+ [attr.data-dragging]="dragging() ? 'true' : null"
7004
+ (click)="browse($event)"
7005
+ (dragenter)="onDragEnter($event)"
7006
+ (dragover)="onDragOver($event)"
7007
+ (dragleave)="onDragLeave($event)"
7008
+ (drop)="onDrop($event)"
7009
+ >
7010
+ <sds-icon [name]="dragging() ? 'upload' : icon()" [size]="16" />
7011
+ {{ dragging() ? dropLabel() : browseLabel() }}
7012
+ </button>
7013
+ <input
7014
+ #fileInput
7015
+ type="file"
7016
+ class="sr-only"
7017
+ tabindex="-1"
7018
+ aria-hidden="true"
7019
+ [accept]="accept()"
7020
+ [multiple]="multiple()"
7021
+ [disabled]="disabled()"
7022
+ (change)="onInputChange($event)"
7023
+ />
7024
+ } @else {
6952
7025
  <div
6953
7026
  [class]="zoneClass()"
6954
7027
  [attr.aria-disabled]="disabled() ? 'true' : null"
@@ -6993,6 +7066,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
6993
7066
  (change)="onInputChange($event)"
6994
7067
  />
6995
7068
  </div>
7069
+ }
6996
7070
 
6997
7071
  <div aria-live="polite" aria-atomic="true">
6998
7072
  @if (errors().length) {
@@ -7008,7 +7082,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
7008
7082
  </div>
7009
7083
  `,
7010
7084
  }]
7011
- }], propDecorators: { fileInput: [{ type: i0.ViewChild, args: ['fileInput', { isSignal: true }] }], accept: [{ type: i0.Input, args: [{ isSignal: true, alias: "accept", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], maxSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSize", required: false }] }], maxFiles: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFiles", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], dropLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropLabel", required: false }] }], browseLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "browseLabel", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], wrongTypeMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "wrongTypeMessage", required: false }] }], tooLargeMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooLargeMessage", required: false }] }], tooManyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooManyMessage", required: false }] }], files: [{ type: i0.Output, args: ["files"] }], rejected: [{ type: i0.Output, args: ["rejected"] }] } });
7085
+ }], propDecorators: { fileInput: [{ type: i0.ViewChild, args: ['fileInput', { isSignal: true }] }], accept: [{ type: i0.Input, args: [{ isSignal: true, alias: "accept", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], maxSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSize", required: false }] }], maxFiles: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxFiles", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], dropLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "dropLabel", required: false }] }], browseLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "browseLabel", required: false }] }], hint: [{ type: i0.Input, args: [{ isSignal: true, alias: "hint", required: false }] }], wrongTypeMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "wrongTypeMessage", required: false }] }], tooLargeMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooLargeMessage", required: false }] }], tooManyMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooManyMessage", required: false }] }], files: [{ type: i0.Output, args: ["files"] }], rejected: [{ type: i0.Output, args: ["rejected"] }] } });
7012
7086
 
7013
7087
  let nextId$8 = 0;
7014
7088
  /**