@hn250424/aero 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.
@@ -0,0 +1,47 @@
1
+ import { AeroShadowElement } from '../core/AeroShadowElement';
2
+ /**
3
+ * @module base
4
+ */
5
+ /**
6
+ * A base class for container-like elements, providing common functionality
7
+ * such as handling a background attribute.
8
+ *
9
+ * @extends AeroShadowElement
10
+ * @abstract
11
+ */
12
+ export declare class BaseAeroContainer extends AeroShadowElement {
13
+ /**
14
+ * @param {string} htmlTemplate - The HTML string to be used as the template for the shadow DOM.
15
+ * @protected
16
+ */
17
+ protected constructor(htmlTemplate: string);
18
+ /**
19
+ * Specifies the observed attributes for the custom element.
20
+ * @returns {string[]} An array of attribute names to observe.
21
+ */
22
+ static get observedAttributes(): string[];
23
+ /**
24
+ * Called when an observed attribute has been added, removed, or changed.
25
+ * @param {string} name - The name of the attribute that changed.
26
+ * @param {string | null} _oldValue - The old value of the attribute.
27
+ * @param {string | null} newValue - The new value of the attribute.
28
+ */
29
+ attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
30
+ /**
31
+ * A map of attribute names to their respective handler functions.
32
+ * @private
33
+ */
34
+ private baseAeroContainerAttributeHandlers;
35
+ /**
36
+ * Updates the background style of the container.
37
+ * @param {string | null} val - The new background value.
38
+ * @private
39
+ */
40
+ private updateBackground;
41
+ /**
42
+ * Sets the background of the container.
43
+ * @param {string} val - The new background value.
44
+ * @attr
45
+ */
46
+ set containerBackground(val: string);
47
+ }
@@ -0,0 +1,164 @@
1
+ import { AeroShadowElement } from '../core/AeroShadowElement';
2
+ /**
3
+ * @module base
4
+ */
5
+ /**
6
+ * An abstract base class for numeric input elements. It provides core functionalities
7
+ * for handling numeric values, including min, max, and step attributes.
8
+ *
9
+ * @extends AeroShadowElement
10
+ * @abstract
11
+ *
12
+ * @fires input - Fired when the value of the element has changed.
13
+ * @fires change - Fired when the value of the element has been committed by the user.
14
+ * @fires focusin - Fired when the element receives focus.
15
+ * @fires focusout - Fired when the element loses focus.
16
+ */
17
+ export declare abstract class BaseAeroNumericInput extends AeroShadowElement {
18
+ /**
19
+ * The underlying HTML input element.
20
+ * @private
21
+ */
22
+ private _input;
23
+ /**
24
+ * The HTML input element's value.
25
+ * @private
26
+ */
27
+ private _value;
28
+ /**
29
+ * The minimum allowed value.
30
+ * @private
31
+ */
32
+ private _min;
33
+ /**
34
+ * The maximum allowed value.
35
+ * @private
36
+ */
37
+ private _max;
38
+ /**
39
+ * The stepping interval.
40
+ * @private
41
+ */
42
+ private _step;
43
+ /**
44
+ * The number of decimal places to round to, inferred from the `step` value.
45
+ * @private
46
+ */
47
+ private _decimalPlaces;
48
+ /**
49
+ * @param {string} htmlTemplate - The HTML string to be used as the template for the shadow DOM.
50
+ * @protected
51
+ */
52
+ protected constructor(htmlTemplate: string);
53
+ /**
54
+ * An abstract method that must be implemented by subclasses to provide the CSS selector
55
+ * for the underlying input element.
56
+ * @returns {string} The CSS selector for the input element.
57
+ * @protected
58
+ * @abstract
59
+ */
60
+ protected abstract getInputSelector(): string;
61
+ /**
62
+ * Initializes the `_input` property by querying the shadow DOM.
63
+ * @private
64
+ */
65
+ private initializeInput;
66
+ /**
67
+ * Validates and sanitizes a given value according to the `min`, `max`, and `step` properties.
68
+ * @param {string} value - The value to validate.
69
+ * @returns {string} The validated and sanitized value.
70
+ * @protected
71
+ */
72
+ protected getValidateValue(value: string): string;
73
+ /**
74
+ * Sets up event listeners on the input element to forward native events.
75
+ * @private
76
+ */
77
+ private dispatchInputEvents;
78
+ /**
79
+ * Specifies the observed attributes for the custom element.
80
+ * @returns {string[]} An array of attribute names to observe.
81
+ */
82
+ static get observedAttributes(): string[];
83
+ /**
84
+ * Called when an observed attribute has been added, removed, or changed.
85
+ * @param {string} name - The name of the attribute that changed.
86
+ * @param {string | null} _oldValue - The old value of the attribute.
87
+ * @param {string | null} newValue - The new value of the attribute.
88
+ */
89
+ attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
90
+ /**
91
+ * A map of attribute names to their respective handler functions.
92
+ * @private
93
+ */
94
+ private baseAeroNumericInputAttributeHandlers;
95
+ /**
96
+ * Updates the internal `_value` value.
97
+ * @param {string | null} val - The new input value.
98
+ * @private
99
+ */
100
+ private updateInputValue;
101
+ /**
102
+ * Updates the internal `_min` value.
103
+ * @param {string | null} val - The new minimum value.
104
+ * @private
105
+ */
106
+ private updateMinValue;
107
+ /**
108
+ * Updates the internal `_max` value.
109
+ * @param {string | null} val - The new maximum value.
110
+ * @private
111
+ */
112
+ private updateMaxValue;
113
+ /**
114
+ * Updates the internal `_step` value and calculates the number of decimal places.
115
+ * @param {string | null} val - The new step value.
116
+ * @private
117
+ */
118
+ private updateStepValue;
119
+ /**
120
+ * The underlying HTML input element.
121
+ * @type {HTMLInputElement}
122
+ * @readonly
123
+ */
124
+ get input(): HTMLInputElement;
125
+ /**
126
+ * The current value of the numeric input.
127
+ * @type {string}
128
+ * @attr
129
+ * @default "0"
130
+ */
131
+ get value(): string;
132
+ set value(val: string);
133
+ /**
134
+ * The minimum allowed value.
135
+ * @type {string}
136
+ * @attr
137
+ * @default "0"
138
+ */
139
+ get min(): string;
140
+ set min(val: string);
141
+ /**
142
+ * The maximum allowed value.
143
+ * @type {string}
144
+ * @attr
145
+ * @default "100"
146
+ */
147
+ get max(): string;
148
+ set max(val: string);
149
+ /**
150
+ * The stepping interval for the numeric input.
151
+ * @type {string}
152
+ * @attr
153
+ * @default "1"
154
+ */
155
+ get step(): string;
156
+ set step(val: string);
157
+ /**
158
+ * The number of decimal places, derived from the `step` attribute.
159
+ * @type {string}
160
+ * @readonly
161
+ * @protected
162
+ */
163
+ protected get decimalPlaces(): string;
164
+ }
@@ -0,0 +1,18 @@
1
+ import { BaseAeroNumericInput } from '../../base/BaseAeroNumericInput';
2
+ /**
3
+ * @module components
4
+ */
5
+ /**
6
+ * A numeric input web component.
7
+ *
8
+ * @extends BaseAeroNumericInput
9
+ */
10
+ export declare class AeroNumericInput extends BaseAeroNumericInput {
11
+ constructor();
12
+ /**
13
+ * Returns the CSS selector for the internal input element.
14
+ * @returns {string} The CSS selector.
15
+ * @protected
16
+ */
17
+ protected getInputSelector(): string;
18
+ }
@@ -0,0 +1,69 @@
1
+ import { AeroShadowElement } from '../../core/AeroShadowElement';
2
+ /**
3
+ * @module components
4
+ */
5
+ /**
6
+ * A circular progress spinner component.
7
+ *
8
+ * @extends AeroShadowElement
9
+ *
10
+ * @property {string} width - The width of the spinner in pixels.
11
+ * @property {string} height - The height of the spinner in pixels.
12
+ * @property {string} background - The color of the spinner's track.
13
+ * @property {string} color - The color of the spinner's moving part.
14
+ * @property {string} cycle - The duration of one spin cycle in seconds.
15
+ */
16
+ export declare class AeroProgressSpinner extends AeroShadowElement {
17
+ constructor();
18
+ /**
19
+ * Specifies the observed attributes for the custom element.
20
+ * @returns {string[]} An array of attribute names to observe.
21
+ */
22
+ static get observedAttributes(): string[];
23
+ /**
24
+ * Called when an observed attribute has been added, removed, or changed.
25
+ */
26
+ attributeChangedCallback(_name: string, _oldValue: string | null, _newValue: string | null): void;
27
+ /**
28
+ * Updates the spinner's styles based on its current attributes.
29
+ * Using :host instead of an inner element means styles are applied to the custom element itself.
30
+ * Re-appending styles multiple times can cause conflicts or unexpected behavior.
31
+ * @private
32
+ */
33
+ private updateSpinnerStyles;
34
+ /**
35
+ * The width of the spinner in pixels.
36
+ * @param {string} val - The width value.
37
+ * @attr
38
+ * @default "50"
39
+ */
40
+ set width(val: string);
41
+ /**
42
+ * The height of the spinner in pixels.
43
+ * @param {string} val - The height value.
44
+ * @attr
45
+ * @default "50"
46
+ */
47
+ set height(val: string);
48
+ /**
49
+ * The color of the spinner's track.
50
+ * @param {string} val - The background color value.
51
+ * @attr
52
+ * @default "white"
53
+ */
54
+ set background(val: string);
55
+ /**
56
+ * The color of the spinner's moving part.
57
+ * @param {string} val - The color value.
58
+ * @attr
59
+ * @default "black"
60
+ */
61
+ set color(val: string);
62
+ /**
63
+ * The duration of one spin cycle in seconds.
64
+ * @param {string} val - The cycle duration.
65
+ * @attr
66
+ * @default "1"
67
+ */
68
+ set cycle(val: string);
69
+ }
@@ -0,0 +1,196 @@
1
+ import { AeroShadowElement } from '../../core/AeroShadowElement';
2
+ /**
3
+ * @module components
4
+ */
5
+ /**
6
+ * A container element that can be resized by dragging its edges.
7
+ *
8
+ * @extends AeroShadowElement
9
+ *
10
+ * @fires aero-resize-start - Fired when a resize operation begins. The detail object contains `width`, `height`, and `edge`.
11
+ * @fires aero-resize - Fired continuously during a resize operation. The detail object contains `width` and `height`.
12
+ * @fires aero-resize-end - Fired when a resize operation ends. The detail object contains the final `width` and `height`.
13
+ *
14
+ * @slot - The default slot for content to be placed inside the resizable box.
15
+ */
16
+ export declare class AeroResizeBox extends AeroShadowElement {
17
+ private _topResizer;
18
+ private _bottomResizer;
19
+ private _leftResizer;
20
+ private _rightResizer;
21
+ private _hasTopResizer;
22
+ private _hasBottomResizer;
23
+ private _hasLeftResizer;
24
+ private _hasRightResizer;
25
+ private _nMinWidth;
26
+ private _nMaxWidth;
27
+ private _nMinHeight;
28
+ private _nMaxHeight;
29
+ private isTopDragging;
30
+ private isBottomDragging;
31
+ private isLeftDragging;
32
+ private isRightDragging;
33
+ private isDragging;
34
+ private animationFrameId;
35
+ private resizerHandlers;
36
+ constructor();
37
+ /**
38
+ * Handles the mousedown event on a resizer element.
39
+ * @param {MouseEvent} e - The mouse event.
40
+ * @param {"top" | "bottom" | "left" | "right"} resizer - The resizer that was clicked.
41
+ * @private
42
+ */
43
+ private processMousedownEvent;
44
+ /**
45
+ * Emits the 'aero-resize' custom event.
46
+ * @param {number | null} width - The new width, or null if not changed.
47
+ * @param {number | null} height - The new height, or null if not changed.
48
+ * @private
49
+ */
50
+ private emitResize;
51
+ /**
52
+ * Specifies the observed attributes for the custom element.
53
+ * @returns {string[]} An array of attribute names to observe.
54
+ */
55
+ static get observedAttributes(): string[];
56
+ /**
57
+ * Called when an observed attribute has been added, removed, or changed.
58
+ * @param {string} name - The name of the attribute that changed.
59
+ * @param {string | null} _oldValue - The old value of the attribute.
60
+ * @param {string | null} newValue - The new value of the attribute.
61
+ */
62
+ attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
63
+ /**
64
+ * A map of attribute names to their respective handler functions.
65
+ * @private
66
+ */
67
+ private baseAeroResizeBoxAttributeHandlers;
68
+ /**
69
+ * Enables or disables the top resizer.
70
+ * @param {boolean} enabled - Whether the resizer should be enabled.
71
+ * @private
72
+ */
73
+ private updateTopResizerState;
74
+ /**
75
+ * Enables or disables the bottom resizer.
76
+ * @param {boolean} enabled - Whether the resizer should be enabled.
77
+ * @private
78
+ */
79
+ private updateBottomResizerState;
80
+ /**
81
+ * Enables or disables the left resizer.
82
+ * @param {boolean} enabled - Whether the resizer should be enabled.
83
+ * @private
84
+ */
85
+ private updateLeftResizerState;
86
+ /**
87
+ * Enables or disables the right resizer.
88
+ * @param {boolean} enabled - Whether the resizer should be enabled.
89
+ * @private
90
+ */
91
+ private updateRightResizerState;
92
+ /**
93
+ * A helper function to add or remove the mousedown event listener for a resizer.
94
+ * @param {HTMLElement} resizer - The resizer element.
95
+ * @param {boolean} enabled - Whether the resizer is enabled.
96
+ * @param {(e: MouseEvent) => void} handler - The event handler.
97
+ * @private
98
+ */
99
+ private updateResizeState;
100
+ /**
101
+ * Updates the internal minimum width value.
102
+ * @param {string | null} val - The new value.
103
+ * @private
104
+ */
105
+ private updateMinWidthValue;
106
+ /**
107
+ * Updates the internal maximum width value.
108
+ * @param {string | null} val - The new value.
109
+ * @private
110
+ */
111
+ private updateMaxWidthValue;
112
+ /**
113
+ * Updates the internal minimum height value.
114
+ * @param {string | null} val - The new value.
115
+ * @private
116
+ */
117
+ private updateMinHeightValue;
118
+ /**
119
+ * Updates the internal maximum height value.
120
+ * @param {string | null} val - The new value.
121
+ * @private
122
+ */
123
+ private updateMaxHeightValue;
124
+ /**
125
+ * The color of the resizer handles on hover.
126
+ * @param {string} color - The color value.
127
+ * @type {string}
128
+ * @attr
129
+ * @default "#ccc"
130
+ */
131
+ set resizerColor(color: string);
132
+ /**
133
+ * The minimum width of the box.
134
+ * @type {string}
135
+ * @attr min-width
136
+ * @default "0"
137
+ */
138
+ get minWidth(): string;
139
+ set minWidth(val: string);
140
+ /**
141
+ * The maximum width of the box.
142
+ * @type {string}
143
+ * @attr max-width
144
+ * @default "2000"
145
+ */
146
+ get maxWidth(): string;
147
+ set maxWidth(val: string);
148
+ /**
149
+ * The minimum height of the box.
150
+ * @type {string}
151
+ * @attr min-height
152
+ * @default "0"
153
+ */
154
+ get minHeight(): string;
155
+ set minHeight(val: string);
156
+ /**
157
+ * The maximum height of the box.
158
+ * @type {string}
159
+ * @attr max-height
160
+ * @default "2000"
161
+ */
162
+ get maxHeight(): string;
163
+ set maxHeight(val: string);
164
+ /**
165
+ * Enables the top resizer.
166
+ */
167
+ addTopResizer(): void;
168
+ /**
169
+ * Disables the top resizer.
170
+ */
171
+ removeTopResizer(): void;
172
+ /**
173
+ * Enables the bottom resizer.
174
+ */
175
+ addBottomResizer(): void;
176
+ /**
177
+ * Disables the bottom resizer.
178
+ */
179
+ removeBottomResizer(): void;
180
+ /**
181
+ * Enables the left resizer.
182
+ */
183
+ addLeftResizer(): void;
184
+ /**
185
+ * Disables the left resizer.
186
+ */
187
+ removeLeftResizer(): void;
188
+ /**
189
+ * Enables the right resizer.
190
+ */
191
+ addRightResizer(): void;
192
+ /**
193
+ * Disables the right resizer.
194
+ */
195
+ removeRightResizer(): void;
196
+ }
@@ -0,0 +1,102 @@
1
+ import { BaseAeroNumericInput } from '../../base/BaseAeroNumericInput';
2
+ /**
3
+ * @module components
4
+ */
5
+ /**
6
+ * A numeric input component with increment and decrement buttons.
7
+ *
8
+ * @extends BaseAeroNumericInput
9
+ *
10
+ */
11
+ export declare class AeroSpinbox extends BaseAeroNumericInput {
12
+ /**
13
+ * The decrement button element.
14
+ * @private
15
+ */
16
+ private minus;
17
+ /**
18
+ * The increment button element.
19
+ * @private
20
+ */
21
+ private plus;
22
+ constructor();
23
+ /**
24
+ * Returns the CSS selector for the internal input element.
25
+ * @returns {string} The CSS selector.
26
+ * @protected
27
+ */
28
+ protected getInputSelector(): string;
29
+ /**
30
+ * Specifies the observed attributes for the custom element.
31
+ * @returns {string[]} An array of attribute names to observe.
32
+ */
33
+ static get observedAttributes(): string[];
34
+ /**
35
+ * Called when an observed attribute has been added, removed, or changed.
36
+ * @param {string} name - The name of the attribute that changed.
37
+ * @param {string | null} _oldValue - The old value of the attribute.
38
+ * @param {string | null} newValue - The new value of the attribute.
39
+ */
40
+ attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null): void;
41
+ /**
42
+ * A map of attribute names to their respective handler functions for this component.
43
+ * @private
44
+ */
45
+ private aeroSpinboxAttributeHandlers;
46
+ /**
47
+ * Updates the text content of the decrement button.
48
+ * @param {string | null} val - The new text.
49
+ * @private
50
+ */
51
+ private updateMinuxText;
52
+ /**
53
+ * Updates the text content of the increment button.
54
+ * @param {string | null} val - The new text.
55
+ * @private
56
+ */
57
+ private updatePlusText;
58
+ /**
59
+ * Updates the background color of the buttons.
60
+ * @param {string | null} val - The new color.
61
+ * @private
62
+ */
63
+ private updateButtonBackgrondColor;
64
+ /**
65
+ * Adjusts the grid layout based on the component's height.
66
+ * @param {number | null} val - The new height.
67
+ * @private
68
+ */
69
+ private updateHeight;
70
+ /**
71
+ * The background color of the increment and decrement buttons.
72
+ * @param {string} color - The color value.
73
+ * @type {string}
74
+ * @attr button-backgroundcolor
75
+ * @default "#ccc"
76
+ */
77
+ set buttonBackgroundColor(color: string);
78
+ /**
79
+ * The text content for the decrement button.
80
+ * @param {string} text - The text to display.
81
+ * @type {string}
82
+ * @attr minus-text
83
+ * @default "-"
84
+ */
85
+ set minusText(text: string);
86
+ /**
87
+ * The text content for the increment button.
88
+ * @param {string} text - The text to display.
89
+ * @type {string}
90
+ * @attr plus-text
91
+ * @default "+"
92
+ */
93
+ set plusText(text: string);
94
+ /**
95
+ * Decrements the input value by the step amount.
96
+ */
97
+ decrement(): void;
98
+ /**
99
+ * Increments the input value by the step amount.
100
+ */
101
+ increment(): void;
102
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @module core
3
+ */
4
+ /**
5
+ * `AeroShadowElement` is an abstract base class that simplifies the creation of custom elements
6
+ * with a shadow DOM. It handles the boilerplate of creating a shadow root and cloning a template.
7
+ *
8
+ * @abstract
9
+ */
10
+ export declare class AeroShadowElement extends HTMLElement {
11
+ /**
12
+ * The shadow root for this element.
13
+ * @protected
14
+ */
15
+ protected shadow: ShadowRoot;
16
+ /**
17
+ * @param {string} htmlTemplate - The HTML string to be used as the template for the shadow DOM.
18
+ * @protected
19
+ */
20
+ protected constructor(htmlTemplate: string);
21
+ /**
22
+ * Queries the shadow DOM for an element matching the given selector.
23
+ * @param {string} selector - The CSS selector to match.
24
+ * @returns {T} The first element matching the selector.
25
+ * @protected
26
+ */
27
+ protected query<T extends HTMLElement>(selector: string): T;
28
+ /**
29
+ * Applies a string of CSS to the shadow DOM by creating and appending a `<style>` tag.
30
+ * @param {string} style - The CSS string to apply.
31
+ * @protected
32
+ */
33
+ protected applyStyles(style: string): void;
34
+ /**
35
+ * Dispatches a standard DOM event from this custom element.
36
+ * @param {string} type - The type of the event to dispatch (e.g., 'click', 'input').
37
+ * @protected
38
+ */
39
+ protected forwardNativeEvent(type: string): void;
40
+ /**
41
+ * Dispatches a custom event with an optional detail payload.
42
+ * @param {string} type - The name of the custom event.
43
+ * @param {object} [options] - Options for the custom event.
44
+ * @param {*} [options.detail] - The data payload to send with the event.
45
+ * @param {Event} [options.originalEvent] - The original event that triggered this custom event.
46
+ * @protected
47
+ */
48
+ protected forwardCustomEvent(type: string, options?: {
49
+ detail?: unknown;
50
+ originalEvent?: Event;
51
+ }): void;
52
+ }
@@ -0,0 +1,4 @@
1
+ declare module "*.css" {
2
+ const content: { [className: string] };
3
+ export default content;
4
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export { AeroNumericInput } from './components/numeric_input/AeroNumericInput';
2
+ export { AeroSpinbox } from './components/spinbox/AeroSpinbox';
3
+ export { AeroProgressSpinner } from './components/progress_spinner/AeroProgressSpinner';
4
+ export { AeroResizeBox } from './components/resize_box/AeroResizeBox';
@@ -0,0 +1,2 @@
1
+ /// <reference types="vite/client" />
2
+