@lavalogic/scoria 0.27.1 → 0.28.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.
@@ -59,7 +59,9 @@
59
59
  }}
60
60
  onclick={(e) => {
61
61
  if (e.target === dialog) {
62
- alertContext.onNo();
62
+ if (!alertContext.mandatory) {
63
+ dialog.close();
64
+ }
63
65
  }
64
66
  }}
65
67
  >
@@ -76,18 +78,28 @@
76
78
 
77
79
  <div class="modal-footer actions">
78
80
  <div class="button-barcode-set">
79
- <DataMatrixIcon title="Yes" icon={yesIcon} />
80
- <button type="submit" onkeydown={passthrough} onclick={alertContext.onYes}
81
- >{alertContext.yesLabel}</button
81
+ <DataMatrixIcon
82
+ title="Yes"
83
+ icon={yesIcon}
84
+ />
85
+ <button
86
+ type="submit"
87
+ onkeydown={passthrough}
88
+ onclick={alertContext.onYes}>{alertContext.yesLabel}</button
82
89
  >
83
90
  </div>
84
91
 
85
92
  {#if alertContext.otherLabel}
86
93
  {@const otherIcon = DATAMatrix('[OTHER]')}
87
94
  <div class="button-barcode-set">
88
- <DataMatrixIcon title="Other" icon={otherIcon} />
89
- <button type="button" onkeydown={passthrough} onclick={alertContext.onOther}
90
- >{alertContext.otherLabel}</button
95
+ <DataMatrixIcon
96
+ title="Other"
97
+ icon={otherIcon}
98
+ />
99
+ <button
100
+ type="button"
101
+ onkeydown={passthrough}
102
+ onclick={alertContext.onOther}>{alertContext.otherLabel}</button
91
103
  >
92
104
  </div>
93
105
  {/if}
@@ -95,9 +107,14 @@
95
107
  {#if alertContext.noLabel}
96
108
  {@const noIcon = DATAMatrix('[NO]')}
97
109
  <div class="button-barcode-set">
98
- <DataMatrixIcon title="No" icon={noIcon} />
99
- <button type="button" onkeydown={passthrough} onclick={alertContext.onNo}
100
- >{alertContext.noLabel}</button
110
+ <DataMatrixIcon
111
+ title="No"
112
+ icon={noIcon}
113
+ />
114
+ <button
115
+ type="button"
116
+ onkeydown={passthrough}
117
+ onclick={alertContext.onNo}>{alertContext.noLabel}</button
101
118
  >
102
119
  </div>
103
120
  {/if}
@@ -2,25 +2,28 @@ export declare class AlertContext {
2
2
  static readonly identifier: unique symbol;
3
3
  private _header;
4
4
  get header(): string;
5
- set header(v: string);
5
+ private set header(value);
6
6
  private _body;
7
7
  get body(): string;
8
- set body(v: string);
8
+ private set body(value);
9
9
  private _footer;
10
10
  get footer(): string | null;
11
- set footer(v: string | null);
11
+ private set footer(value);
12
12
  private _yesLabel;
13
13
  get yesLabel(): string;
14
- set yesLabel(v: string);
14
+ private set yesLabel(value);
15
15
  private _noLabel;
16
16
  get noLabel(): string | null;
17
- set noLabel(v: string | null);
17
+ private set noLabel(value);
18
18
  private _otherLabel;
19
19
  get otherLabel(): string | null;
20
- set otherLabel(v: string | null);
20
+ private set otherLabel(value);
21
21
  private _showModal;
22
22
  get showModal(): boolean;
23
- set showModal(v: boolean);
23
+ private set showModal(value);
24
+ private _mandatory;
25
+ get mandatory(): boolean;
26
+ private set mandatory(value);
24
27
  private _onYes;
25
28
  onYes: () => void;
26
29
  private _onNo;
@@ -36,6 +39,7 @@ export interface IAlertProps {
36
39
  footer?: string;
37
40
  onYes?: () => void;
38
41
  yesLabel?: string;
42
+ mandatory?: boolean;
39
43
  }
40
44
  export interface IPromptProps extends IAlertProps {
41
45
  onYes: () => void;
@@ -43,4 +47,5 @@ export interface IPromptProps extends IAlertProps {
43
47
  onOther?: () => void;
44
48
  noLabel?: string;
45
49
  otherLabel?: string;
50
+ mandatory?: boolean;
46
51
  }
@@ -49,6 +49,13 @@ export class AlertContext {
49
49
  set showModal(v) {
50
50
  this._showModal = v;
51
51
  }
52
+ _mandatory = $state(false);
53
+ get mandatory() {
54
+ return this._mandatory;
55
+ }
56
+ set mandatory(v) {
57
+ this._mandatory = v;
58
+ }
52
59
  _onYes = undefined;
53
60
  onYes = () => {
54
61
  this.showModal = false;
@@ -92,6 +99,7 @@ export class AlertContext {
92
99
  else {
93
100
  this._yesLabel = 'Okay';
94
101
  }
102
+ this.mandatory = props?.mandatory ?? false;
95
103
  this.showModal = true;
96
104
  };
97
105
  prompt = (body, props) => {
@@ -113,6 +121,7 @@ export class AlertContext {
113
121
  this._onYes = props.onYes;
114
122
  this._onNo = props.onNo;
115
123
  this._onOther = props.onOther;
124
+ this.mandatory = props.mandatory ?? false;
116
125
  this.showModal = true;
117
126
  };
118
127
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lavalogic/scoria",
3
3
  "description": "Svelte components used for the FloWMS Web Frontend",
4
- "version": "0.27.1",
4
+ "version": "0.28.0",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },