@basis-ng/primitives 0.0.1-alpha.18 → 0.0.1-alpha.19

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.
@@ -5,22 +5,6 @@ export declare class Input implements AfterViewInit {
5
5
  * The type of the input.
6
6
  */
7
7
  readonly type: import("@angular/core").InputSignal<"number" | "text" | "password" | "email">;
8
- /**
9
- * The placeholder text for the input.
10
- */
11
- readonly placeholder: import("@angular/core").InputSignal<string>;
12
- /**
13
- * The value of the input.
14
- */
15
- readonly value: import("@angular/core").WritableSignal<string | number | null>;
16
- /**
17
- * Whether the input is invalid.
18
- */
19
- readonly invalid: import("@angular/core").ModelSignal<boolean>;
20
- /**
21
- * Whether the input is disabled.
22
- */
23
- readonly disabled: import("@angular/core").ModelSignal<boolean>;
24
8
  /**
25
9
  * The maximum width of the input.
26
10
  */
@@ -37,14 +21,6 @@ export declare class Input implements AfterViewInit {
37
21
  * Whether the input type is number.
38
22
  */
39
23
  readonly isNumberType: import("@angular/core").Signal<boolean>;
40
- /**
41
- * Whether the input is focused.
42
- */
43
- readonly focused: import("@angular/core").WritableSignal<boolean>;
44
- /**
45
- * Event emitted when the value changes.
46
- */
47
- valueChange: import("@angular/core").OutputEmitterRef<string | number | null>;
48
24
  /**
49
25
  * Reference to the input element.
50
26
  */
@@ -53,10 +29,19 @@ export declare class Input implements AfterViewInit {
53
29
  * Reference to the ngModel directive.
54
30
  */
55
31
  private ngModel;
32
+ /**
33
+ * The size of the input.
34
+ */
35
+ readonly size: import("@angular/core").InputSignal<"1" | "2" | "3">;
56
36
  /**
57
37
  * After the view has been initialized, set the value of the select.
58
38
  */
59
39
  ngAfterViewInit(): void;
40
+ /**
41
+ * Sets the value of the input element.
42
+ * @param value The value to set.
43
+ */
44
+ setValue(value: string): void;
60
45
  /**
61
46
  * Handles the input event.
62
47
  * @param event The input event.
@@ -74,5 +59,5 @@ export declare class Input implements AfterViewInit {
74
59
  */
75
60
  formatNumber(value: string | null): string | null;
76
61
  static ɵfac: i0.ɵɵFactoryDeclaration<Input, never>;
77
- static ɵcmp: i0.ɵɵComponentDeclaration<Input, "input[b-input]", never, { "type": { "alias": "type"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "invalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "maxWidth": { "alias": "maxWidth"; "required": false; "isSignal": true; }; "decimals": { "alias": "decimals"; "required": false; "isSignal": true; }; "numberType": { "alias": "numberType"; "required": false; "isSignal": true; }; }, { "invalid": "invalidChange"; "disabled": "disabledChange"; "valueChange": "valueChange"; }, never, never, true, never>;
62
+ static ɵcmp: i0.ɵɵComponentDeclaration<Input, "input[b-input]", never, { "type": { "alias": "type"; "required": false; "isSignal": true; }; "maxWidth": { "alias": "maxWidth"; "required": false; "isSignal": true; }; "decimals": { "alias": "decimals"; "required": false; "isSignal": true; }; "numberType": { "alias": "numberType"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
78
63
  }
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { signal, inject, RendererFactory2, Injectable, input, Component, ElementRef, TemplateRef, Directive, model, computed, output, contentChildren, viewChild, contentChild, linkedSignal, forwardRef, HostListener, effect, afterNextRender, afterRenderEffect } from '@angular/core';
2
+ import { signal, inject, RendererFactory2, Injectable, input, Component, ElementRef, TemplateRef, Directive, computed, output, contentChildren, viewChild, contentChild, linkedSignal, model, forwardRef, HostListener, effect, afterNextRender, afterRenderEffect } from '@angular/core';
3
3
  import { NgStyle, NgClass, CommonModule } from '@angular/common';
4
4
  import { NgModel, NG_VALUE_ACCESSOR, ControlContainer } from '@angular/forms';
5
5
  import { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
@@ -159,22 +159,6 @@ class Input {
159
159
  * The type of the input.
160
160
  */
161
161
  type = input('text');
162
- /**
163
- * The placeholder text for the input.
164
- */
165
- placeholder = input('');
166
- /**
167
- * The value of the input.
168
- */
169
- value = signal(null);
170
- /**
171
- * Whether the input is invalid.
172
- */
173
- invalid = model(false);
174
- /**
175
- * Whether the input is disabled.
176
- */
177
- disabled = model(false);
178
162
  /**
179
163
  * The maximum width of the input.
180
164
  */
@@ -191,14 +175,6 @@ class Input {
191
175
  * Whether the input type is number.
192
176
  */
193
177
  isNumberType = computed(() => this.type() === 'number');
194
- /**
195
- * Whether the input is focused.
196
- */
197
- focused = signal(false);
198
- /**
199
- * Event emitted when the value changes.
200
- */
201
- valueChange = output();
202
178
  /**
203
179
  * Reference to the input element.
204
180
  */
@@ -207,12 +183,26 @@ class Input {
207
183
  * Reference to the ngModel directive.
208
184
  */
209
185
  ngModel = inject(NgModel, { optional: true });
186
+ /**
187
+ * The size of the input.
188
+ */
189
+ size = input('2');
210
190
  /**
211
191
  * After the view has been initialized, set the value of the select.
212
192
  */
213
193
  ngAfterViewInit() {
214
194
  const value = this.el.nativeElement.value || this.ngModel?.model;
215
- this.value.set(this.isNumberType() ? this.formatNumber(value) : value);
195
+ if (this.isNumberType()) {
196
+ const formattedValue = this.formatNumber(value) || '';
197
+ this.setValue(formattedValue);
198
+ }
199
+ }
200
+ /**
201
+ * Sets the value of the input element.
202
+ * @param value The value to set.
203
+ */
204
+ setValue(value) {
205
+ this.el.nativeElement.value = value;
216
206
  }
217
207
  /**
218
208
  * Handles the input event.
@@ -222,8 +212,7 @@ class Input {
222
212
  const target = event.target;
223
213
  // If the input is not of number type, update the value and emit the value change event.
224
214
  if (!this.isNumberType()) {
225
- this.value.set(target.value);
226
- this.valueChange.emit(target.value);
215
+ this.setValue(target.value);
227
216
  }
228
217
  }
229
218
  /**
@@ -231,13 +220,10 @@ class Input {
231
220
  * @param event - The blur event.
232
221
  */
233
222
  onBlur(event) {
234
- this.focused.set(false);
235
223
  // If the input is of number type, format the value and emit the value change event.
236
224
  if (this.isNumberType()) {
237
225
  const formattedValue = this.formatNumber(event.target.value);
238
- this.el.nativeElement.value = formattedValue || '';
239
- this.value.set(formattedValue);
240
- this.valueChange.emit(formattedValue);
226
+ this.setValue(formattedValue || '');
241
227
  }
242
228
  }
243
229
  /**
@@ -257,7 +243,7 @@ class Input {
257
243
  }
258
244
  }
259
245
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: Input, deps: [], target: i0.ɵɵFactoryTarget.Component });
260
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.7", type: Input, isStandalone: true, selector: "input[b-input]", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", 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 }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, decimals: { classPropertyName: "decimals", publicName: "decimals", isSignal: true, isRequired: false, transformFunction: null }, numberType: { classPropertyName: "numberType", publicName: "numberType", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { invalid: "invalidChange", disabled: "disabledChange", valueChange: "valueChange" }, host: { listeners: { "input": "onInput($event)", "focus": "focused.set(true)", "blur": "onBlur($event)" }, properties: { "type": "type()", "placeholder": "placeholder() || \"\"", "class.ng-invalid": "invalid()", "class.disabled": "disabled()", "style.max-width": "maxWidth()" } }, ngImport: i0, template: ``, isInline: true });
246
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "19.2.7", type: Input, isStandalone: true, selector: "input[b-input]", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, decimals: { classPropertyName: "decimals", publicName: "decimals", isSignal: true, isRequired: false, transformFunction: null }, numberType: { classPropertyName: "numberType", publicName: "numberType", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "input": "onInput($event)", "blur": "onBlur($event)" }, properties: { "type": "type()", "style.max-width": "maxWidth()", "class": " \"size-\" + size() " } }, ngImport: i0, template: ``, isInline: true });
261
247
  }
262
248
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: Input, decorators: [{
263
249
  type: Component,
@@ -266,13 +252,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
266
252
  template: ``,
267
253
  host: {
268
254
  '[type]': 'type()',
269
- '[placeholder]': 'placeholder() || ""',
270
- '[class.ng-invalid]': 'invalid()',
271
- '[class.disabled]': 'disabled()',
272
255
  '[style.max-width]': 'maxWidth()',
273
256
  '(input)': 'onInput($event)',
274
- '(focus)': 'focused.set(true)',
275
257
  '(blur)': 'onBlur($event)',
258
+ '[class]': ' "size-" + size() ',
276
259
  },
277
260
  }]
278
261
  }] });
@@ -1641,63 +1624,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
1641
1624
  args: ['document:click', ['$event']]
1642
1625
  }] } });
1643
1626
 
1644
- class Label {
1645
- /**
1646
- * The input element.
1647
- */
1648
- input = contentChild(Input);
1649
- /**
1650
- * The switch element.
1651
- */
1652
- switch = contentChild(Switch);
1653
- /**
1654
- * The checkbox element.
1655
- */
1656
- checkbox = contentChild(Checkbox);
1657
- /**
1658
- * The textarea element.
1659
- */
1660
- textarea = contentChild(Textarea);
1661
- /**
1662
- * Whether the label should be up.
1663
- */
1664
- labelUp = computed(() => {
1665
- const input = this.input();
1666
- const textarea = this.textarea();
1667
- return (input?.focused() ||
1668
- input?.value() ||
1669
- input?.placeholder() ||
1670
- textarea?.focused() ||
1671
- textarea?.value() ||
1672
- textarea?.placeholder());
1673
- });
1674
- /**
1675
- * The label width.
1676
- */
1677
- maxWidth = computed(() => {
1678
- const input = this.input();
1679
- const textarea = this.textarea();
1680
- return input?.maxWidth() || textarea?.cols();
1681
- });
1682
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: Label, deps: [], target: i0.ɵɵFactoryTarget.Component });
1683
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "19.2.7", type: Label, isStandalone: true, selector: "b-label", host: { properties: { "class.up": "labelUp()", "style.max-width": "maxWidth()", "class.is-switch": "switch()", "class.is-checkbox": "checkbox()", "class.is-textarea": "textarea()" } }, queries: [{ propertyName: "input", first: true, predicate: Input, descendants: true, isSignal: true }, { propertyName: "switch", first: true, predicate: Switch, descendants: true, isSignal: true }, { propertyName: "checkbox", first: true, predicate: Checkbox, descendants: true, isSignal: true }, { propertyName: "textarea", first: true, predicate: Textarea, descendants: true, isSignal: true }], ngImport: i0, template: `<ng-content />`, isInline: true });
1684
- }
1685
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: Label, decorators: [{
1686
- type: Component,
1687
- args: [{
1688
- selector: 'b-label',
1689
- imports: [],
1690
- template: `<ng-content />`,
1691
- host: {
1692
- '[class.up]': 'labelUp()',
1693
- '[style.max-width]': 'maxWidth()',
1694
- '[class.is-switch]': 'switch()',
1695
- '[class.is-checkbox]': 'checkbox()',
1696
- '[class.is-textarea]': 'textarea()',
1697
- },
1698
- }]
1699
- }] });
1700
-
1701
1627
  class Badge {
1702
1628
  /** The variant of the badge. */
1703
1629
  variant = input('primary');
@@ -2651,7 +2577,7 @@ class CommandComponent {
2651
2577
  (keydown.arrowUp)="commandOptions()?.previousOption()"
2652
2578
  (keydown.enter)="commandOptions()?.selectOption()"
2653
2579
  (blur)="isDesktop() && trappedInput.el.nativeElement.focus()" />
2654
- <ng-content />`, isInline: true, dependencies: [{ kind: "component", type: Input, selector: "input[b-input]", inputs: ["type", "placeholder", "invalid", "disabled", "maxWidth", "decimals", "numberType"], outputs: ["invalidChange", "disabledChange", "valueChange"] }, { kind: "directive", type: CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }] });
2580
+ <ng-content />`, isInline: true, dependencies: [{ kind: "component", type: Input, selector: "input[b-input]", inputs: ["type", "maxWidth", "decimals", "numberType", "size"] }, { kind: "directive", type: CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }] });
2655
2581
  }
2656
2582
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImport: i0, type: CommandComponent, decorators: [{
2657
2583
  type: Component,
@@ -2972,5 +2898,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.7", ngImpor
2972
2898
  * Generated bundle index. Do not edit.
2973
2899
  */
2974
2900
 
2975
- export { Alert, AttachedBox, Badge, BottomSheet, Button, ButtonGroup, Checkbox, ColorPicker, ComboboxComponent, CommandComponent, CommandOptionsComponent, Icon, InViewportDirective, InViewportService, Input, InputGroup, Label, LazyContentDirective, Menu, MenuItemCheckboxComponent, MenuItemComponent, MenuItemRadioComponent, MenuLabel, MenuTrigger, OptionComponent, Range, ResponsiveService, Row, RowItem, SelectComponent, SelectOptionsComponent, SideSheet, Spinner, Switch, Tab, Table, Tabs, Textarea, ThemeService, TooltipComponent, Tree, TreeNode };
2901
+ export { Alert, AttachedBox, Badge, BottomSheet, Button, ButtonGroup, Checkbox, ColorPicker, ComboboxComponent, CommandComponent, CommandOptionsComponent, Icon, InViewportDirective, InViewportService, Input, InputGroup, LazyContentDirective, Menu, MenuItemCheckboxComponent, MenuItemComponent, MenuItemRadioComponent, MenuLabel, MenuTrigger, OptionComponent, Range, ResponsiveService, Row, RowItem, SelectComponent, SelectOptionsComponent, SideSheet, Spinner, Switch, Tab, Table, Tabs, Textarea, ThemeService, TooltipComponent, Tree, TreeNode };
2976
2902
  //# sourceMappingURL=basis-ng-primitives.mjs.map