@sondor-technology/sondor-components 1.0.2 → 1.0.4

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.
Files changed (40) hide show
  1. package/dist/components/checkbox/checkbox.d.ts +3 -0
  2. package/dist/components/checkbox/checkbox.d.ts.map +1 -1
  3. package/dist/components/checkbox/checkbox.js +38 -20
  4. package/dist/components/form/form-step.d.ts +1 -0
  5. package/dist/components/form/form-step.d.ts.map +1 -1
  6. package/dist/components/form/form-step.js +3 -0
  7. package/dist/components/form/form.d.ts +7 -2
  8. package/dist/components/form/form.d.ts.map +1 -1
  9. package/dist/components/form/form.js +157 -59
  10. package/dist/components/icon/icon-paths.d.ts +16 -0
  11. package/dist/components/icon/icon-paths.d.ts.map +1 -1
  12. package/dist/components/icon/icon-paths.js +16 -0
  13. package/dist/components/icon/icon.d.ts +2 -1
  14. package/dist/components/icon/icon.d.ts.map +1 -1
  15. package/dist/components/modal/modal.d.ts +11 -0
  16. package/dist/components/modal/modal.d.ts.map +1 -1
  17. package/dist/components/modal/modal.js +103 -15
  18. package/dist/components/router/router.d.ts +27 -3
  19. package/dist/components/router/router.d.ts.map +1 -1
  20. package/dist/components/router/router.js +72 -12
  21. package/dist/components/skeleton/skeleton.d.ts +2 -3
  22. package/dist/components/skeleton/skeleton.d.ts.map +1 -1
  23. package/dist/components/skeleton/skeleton.js +89 -18
  24. package/dist/components/vertical-nav/vertical-nav-group.d.ts +6 -0
  25. package/dist/components/vertical-nav/vertical-nav-group.d.ts.map +1 -1
  26. package/dist/components/vertical-nav/vertical-nav-group.js +37 -21
  27. package/dist/components/vertical-nav/vertical-nav-item.d.ts +6 -0
  28. package/dist/components/vertical-nav/vertical-nav-item.d.ts.map +1 -1
  29. package/dist/components/vertical-nav/vertical-nav-item.js +27 -7
  30. package/package.json +5 -1
  31. package/src/components/checkbox/checkbox.ts +54 -26
  32. package/src/components/form/form-step.ts +5 -1
  33. package/src/components/form/form.ts +182 -66
  34. package/src/components/icon/icon-paths.ts +16 -0
  35. package/src/components/icon/icon.ts +3 -1
  36. package/src/components/modal/modal.ts +103 -15
  37. package/src/components/router/router.ts +99 -12
  38. package/src/components/skeleton/skeleton.ts +87 -20
  39. package/src/components/vertical-nav/vertical-nav-group.ts +40 -21
  40. package/src/components/vertical-nav/vertical-nav-item.ts +30 -7
@@ -12,25 +12,22 @@ let StNavGroup = class StNavGroup extends LitElement {
12
12
  super(...arguments);
13
13
  this.label = '';
14
14
  this.open = false;
15
+ this.depth = 0;
15
16
  }
16
17
  _toggle() {
17
18
  this.open = !this.open;
18
19
  }
19
20
  render() {
20
21
  return html `
21
- <button @click=${this._toggle} aria-expanded=${this.open}>
22
- ${this.label}
23
- <svg viewBox="0 0 24 24">
24
- <path d="M6 9l6 6 6-6"></path>
25
- </svg>
22
+ <button @click=${this._toggle} aria-expanded=${this.open} style="--nav-depth: ${this.depth}">
23
+ <slot name="icon"></slot>
24
+ <span class="label">${this.label}</span>
25
+ <svg class="chevron" viewBox="0 0 24 24"><path d="M6 9l6 6 6-6"></path></svg>
26
26
  </button>
27
27
 
28
28
  <div class="drawer">
29
29
  <div class="drawer-content">
30
- <!-- We add slight padding top/bottom so the inner links breathe -->
31
- <div style="padding: 4px 0;">
32
- <slot></slot>
33
- </div>
30
+ <slot></slot>
34
31
  </div>
35
32
  </div>
36
33
  `;
@@ -41,32 +38,51 @@ StNavGroup.styles = [
41
38
  css `
42
39
  :host {
43
40
  display: block;
44
- margin-bottom: var(--st-spacing-sm);
41
+ margin-bottom: 2px;
42
+ overflow: hidden;
45
43
  }
46
44
 
47
45
  button {
48
46
  display: flex;
49
47
  align-items: center;
50
- justify-content: space-between;
48
+ gap: var(--st-spacing-sm, 8px);
51
49
  width: 100%;
50
+ box-sizing: border-box;
52
51
  background: transparent;
53
52
  border: none;
54
- padding: var(--st-spacing-xs) var(--st-spacing-lg);
53
+ padding: var(--st-spacing-sm) var(--st-spacing-xl);
54
+ padding-left: calc(var(--st-spacing-xl, 24px) + (var(--nav-depth, 0) * 16px));
55
55
  color: var(--st-color-text);
56
56
  font-size: var(--st-font-size-sm);
57
- font-weight: var(--st-font-weight-bold);
57
+ font-weight: var(--st-font-weight-semibold);
58
58
  cursor: pointer;
59
- text-align: left;
60
- transition: color 0.2s ease;
59
+ transition: background-color 0.2s ease, color 0.2s ease;
61
60
  }
62
61
 
63
62
  button:hover {
64
- color: var(--st-color-primary);
63
+ background-color: var(--st-color-surface-hover, rgba(0,0,0,0.03));
65
64
  }
66
65
 
67
- svg {
66
+ /* Styles for slotted icons */
67
+ ::slotted([slot="icon"]) {
68
68
  width: 1rem;
69
69
  height: 1rem;
70
+ flex-shrink: 0;
71
+ color: var(--st-color-text-muted);
72
+ }
73
+
74
+ .label {
75
+ flex: 1;
76
+ white-space: nowrap;
77
+ overflow: hidden;
78
+ text-overflow: ellipsis;
79
+ text-align: left;
80
+ }
81
+
82
+ svg.chevron {
83
+ width: 1rem;
84
+ height: 1rem;
85
+ flex-shrink: 0;
70
86
  fill: none;
71
87
  stroke: currentColor;
72
88
  stroke-width: 2;
@@ -75,12 +91,10 @@ StNavGroup.styles = [
75
91
  transition: transform 0.2s ease;
76
92
  }
77
93
 
78
- /* Rotate Chevron when open */
79
- :host([open]) svg {
94
+ :host([open]) svg.chevron {
80
95
  transform: rotate(180deg);
81
96
  }
82
97
 
83
- /* Modern CSS Grid Animation trick for accordion height */
84
98
  .drawer {
85
99
  display: grid;
86
100
  grid-template-rows: 0fr;
@@ -95,7 +109,6 @@ StNavGroup.styles = [
95
109
  overflow: hidden;
96
110
  display: flex;
97
111
  flex-direction: column;
98
- gap: 2px;
99
112
  }
100
113
  `
101
114
  ];
@@ -105,6 +118,9 @@ __decorate([
105
118
  __decorate([
106
119
  property({ type: Boolean, reflect: true })
107
120
  ], StNavGroup.prototype, "open", void 0);
121
+ __decorate([
122
+ property({ type: Number })
123
+ ], StNavGroup.prototype, "depth", void 0);
108
124
  StNavGroup = __decorate([
109
125
  customElement('st-vertical-nav-group')
110
126
  ], StNavGroup);
@@ -2,7 +2,13 @@ import { LitElement } from 'lit';
2
2
  export declare class StNavItem extends LitElement {
3
3
  href: string;
4
4
  active: boolean;
5
+ depth: number;
5
6
  static styles: import("lit").CSSResult[];
6
7
  render(): import("lit-html").TemplateResult<1>;
7
8
  }
9
+ declare global {
10
+ interface HTMLElementTagNameMap {
11
+ 'st-vertical-nav-item': StNavItem;
12
+ }
13
+ }
8
14
  //# sourceMappingURL=vertical-nav-item.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vertical-nav-item.d.ts","sourceRoot":"","sources":["../../../src/components/vertical-nav/vertical-nav-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C,qBACa,SAAU,SAAQ,UAAU;IACX,IAAI,SAAO;IACK,MAAM,UAAS;IAE3D,MAAM,CAAC,MAAM,4BA+BX;IAEF,MAAM,yCAML;CACF"}
1
+ {"version":3,"file":"vertical-nav-item.d.ts","sourceRoot":"","sources":["../../../src/components/vertical-nav/vertical-nav-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAI5C,qBACa,SAAU,SAAQ,UAAU;IACX,IAAI,SAAO;IACK,MAAM,UAAS;IAC/B,KAAK,SAAK;IAEtC,MAAM,CAAC,MAAM,4BA8CX;IAEF,MAAM,yCAOL;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,sBAAsB,EAAE,SAAS,CAAC;KACnC;CACF"}
@@ -12,10 +12,12 @@ let StNavItem = class StNavItem extends LitElement {
12
12
  super(...arguments);
13
13
  this.href = '#';
14
14
  this.active = false;
15
+ this.depth = 0;
15
16
  }
16
17
  render() {
17
18
  return html `
18
- <a href=${this.href} part="link">
19
+ <a href=${this.href} part="link" style="--nav-depth: ${this.depth}">
20
+ <slot name="icon"></slot>
19
21
  <slot></slot>
20
22
  </a>
21
23
  `;
@@ -26,30 +28,45 @@ StNavItem.styles = [
26
28
  css `
27
29
  :host {
28
30
  display: block;
31
+ overflow: hidden;
29
32
  }
30
33
 
31
34
  a {
32
35
  display: flex;
33
36
  align-items: center;
34
- padding: 6px var(--st-spacing-lg);
37
+ gap: var(--st-spacing-sm, 8px);
38
+ width: 100%;
39
+ box-sizing: border-box;
40
+ padding: 8px var(--st-spacing-xl);
41
+ padding-left: calc(var(--st-spacing-xl, 24px) + (var(--nav-depth, 0) * 16px));
35
42
  color: var(--st-color-text-muted);
36
43
  font-size: var(--st-font-size-sm);
37
44
  text-decoration: none;
38
- border-left: 2px solid transparent;
45
+ border-left: 3px solid transparent;
39
46
  transition: all 0.15s ease;
47
+
48
+ white-space: nowrap;
49
+ overflow: hidden;
50
+ text-overflow: ellipsis;
40
51
  }
41
52
 
42
53
  a:hover {
43
54
  color: var(--st-color-text);
44
- background-color: var(--st-color-surface);
55
+ background-color: var(--st-color-surface-hover, rgba(0,0,0,0.03));
56
+ }
57
+
58
+ ::slotted([slot="icon"]) {
59
+ width: 1rem;
60
+ height: 1rem;
61
+ flex-shrink: 0;
62
+ color: inherit;
45
63
  }
46
64
 
47
- /* Active state: Purple text with a left border indicator */
48
65
  :host([active]) a {
49
66
  color: var(--st-color-primary);
50
67
  border-left-color: var(--st-color-primary);
51
- font-weight: var(--st-font-weight-medium);
52
- background-color: transparent;
68
+ font-weight: var(--st-font-weight-bold);
69
+ background-color: var(--st-color-primary-light, rgba(98, 0, 238, 0.05));
53
70
  }
54
71
  `
55
72
  ];
@@ -59,6 +76,9 @@ __decorate([
59
76
  __decorate([
60
77
  property({ type: Boolean, reflect: true })
61
78
  ], StNavItem.prototype, "active", void 0);
79
+ __decorate([
80
+ property({ type: Number })
81
+ ], StNavItem.prototype, "depth", void 0);
62
82
  StNavItem = __decorate([
63
83
  customElement('st-vertical-nav-item')
64
84
  ], StNavItem);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sondor-technology/sondor-components",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -101,6 +101,10 @@
101
101
  "types": "./dist/components/icon/icon.d.ts",
102
102
  "default": "./dist/components/icon/icon.js"
103
103
  },
104
+ "./icon-paths": {
105
+ "types": "./dist/components/icon/icon-paths.d.ts",
106
+ "default": "./dist/components/icon/icon-paths.js"
107
+ },
104
108
  "./footer": {
105
109
  "types": "./dist/components/footer/footer.d.ts",
106
110
  "default": "./dist/components/footer/footer.js"
@@ -11,7 +11,6 @@ export class StCheckbox extends LitElement {
11
11
 
12
12
  @property({type: String, reflect: true}) size: "sm" | "md" | "lg" = "md";
13
13
  @property({type: String, reflect: true}) name = "";
14
- // Checkboxes default to 'on' natively if no value is provided
15
14
  @property({type: String}) value = "on";
16
15
 
17
16
  @property({type: Boolean, reflect: true}) checked = false;
@@ -20,21 +19,20 @@ export class StCheckbox extends LitElement {
20
19
  @property({type: Boolean, reflect: true}) disabled = false;
21
20
  @property({type: Boolean, reflect: true}) invalid = false;
22
21
  @property({type: Boolean, reflect: true}) required = false;
22
+ @property({type: String}) errorMessage = "";
23
23
 
24
24
  @property({attribute: "aria-label"}) ariaLabel = "";
25
25
 
26
- constructor() {
26
+ constructor() {
27
27
  super();
28
28
  this._internals = this.attachInternals();
29
29
 
30
- // 1. Trigger error state if the user clicks away and the field is invalid
31
30
  this.addEventListener('focusout', () => {
32
- this.invalid = !this._inputEl.validity.valid;
31
+ this.invalid = !this.checkValidity();
33
32
  });
34
33
 
35
- // 2. Trigger error state if the st-form tries to submit and fails
36
34
  this.addEventListener('invalid', () => {
37
- this.invalid = true;
35
+ this.invalid = !this.checkValidity();
38
36
  });
39
37
  }
40
38
 
@@ -67,7 +65,6 @@ constructor() {
67
65
  font-size: var(--st-font-size-base);
68
66
  }
69
67
 
70
- /* Visually hide the native input but keep it in the DOM for focus/screen readers */
71
68
  input {
72
69
  position: absolute;
73
70
  width: var(--checkbox-size);
@@ -80,7 +77,6 @@ constructor() {
80
77
  border-width: 0;
81
78
  }
82
79
 
83
- /* Custom Checkbox Box */
84
80
  .control {
85
81
  display: flex;
86
82
  align-items: center;
@@ -92,30 +88,25 @@ constructor() {
92
88
  background-color: var(--st-color-bg);
93
89
  transition: all 0.2s ease;
94
90
  flex-shrink: 0;
95
- /* Aligns the box nicely with standard text line-height */
96
91
  margin-top: 0.125rem;
97
92
  }
98
93
 
99
- /* Hover State */
100
94
  label:hover .control {
101
95
  border-color: var(--st-color-primary-hover);
102
96
  }
103
97
 
104
- /* Focus State */
105
98
  input:focus-visible + .control {
106
99
  box-shadow:
107
100
  0 0 0 2px var(--st-color-bg),
108
101
  0 0 0 4px var(--st-color-primary);
109
102
  }
110
103
 
111
- /* Checked & Indeterminate States */
112
104
  :host([checked]) .control,
113
105
  :host([indeterminate]) .control {
114
106
  border-color: var(--st-color-primary);
115
107
  background-color: var(--st-color-primary);
116
108
  }
117
109
 
118
- /* SVG Icons */
119
110
  svg {
120
111
  width: var(--checkbox-icon-size);
121
112
  height: var(--checkbox-icon-size);
@@ -131,14 +122,12 @@ constructor() {
131
122
  opacity 0.2s ease;
132
123
  }
133
124
 
134
- /* Reveal Icons */
135
125
  :host([checked]) svg.icon-check,
136
126
  :host([indeterminate]) svg.icon-minus {
137
127
  opacity: 1;
138
128
  transform: scale(1);
139
129
  }
140
130
 
141
- /* Disabled State */
142
131
  :host([disabled]) {
143
132
  pointer-events: none;
144
133
  }
@@ -147,7 +136,6 @@ constructor() {
147
136
  cursor: not-allowed;
148
137
  }
149
138
 
150
- /* Invalid State */
151
139
  :host([invalid]) .control {
152
140
  border-color: var(--st-color-error);
153
141
  }
@@ -162,8 +150,7 @@ constructor() {
162
150
  override updated(changedProperties: PropertyValues<this>) {
163
151
  super.updated(changedProperties);
164
152
 
165
- if (changedProperties.has("checked") || changedProperties.has("value")) {
166
- // Form API: If checked, submit the value. If unchecked, submit null to remove it from FormData.
153
+ if (changedProperties.has("checked") || changedProperties.has("value") || changedProperties.has("errorMessage")) {
167
154
  this._internals.setFormValue(this.checked ? this.value : null);
168
155
  this._syncValidity();
169
156
  }
@@ -175,16 +162,54 @@ constructor() {
175
162
 
176
163
  private _syncValidity() {
177
164
  if (!this._inputEl) return;
178
- this._internals.setValidity(
179
- this._inputEl.validity,
180
- this._inputEl.validationMessage,
181
- this._inputEl,
182
- );
165
+
166
+ if (this.required && !this.checked) {
167
+ const message = this.errorMessage || this._inputEl.validationMessage || "Please check this box if you want to proceed.";
168
+ this._internals.setValidity(
169
+ {valueMissing: true},
170
+ message,
171
+ this._inputEl,
172
+ );
173
+ } else {
174
+ this._internals.setValidity(
175
+ this._inputEl.validity,
176
+ this._inputEl.validationMessage,
177
+ this._inputEl,
178
+ );
179
+ }
180
+ }
181
+
182
+ public checkValidity(): boolean {
183
+ if (!this._inputEl) return true;
184
+
185
+ if (this.required && !this.checked) {
186
+ const message = this.errorMessage || this._inputEl.validationMessage || "Please check this box if you want to proceed.";
187
+ this._internals.setValidity(
188
+ {valueMissing: true},
189
+ message,
190
+ this._inputEl,
191
+ );
192
+ this.invalid = true;
193
+ return false;
194
+ }
195
+
196
+ const isValid = this._inputEl.checkValidity();
197
+ this._syncValidity();
198
+ this.invalid = !isValid;
199
+ return isValid;
200
+ }
201
+
202
+ public reportValidity(): boolean {
203
+ this._syncValidity();
204
+ const isValid = this._internals.reportValidity();
205
+ this.invalid = !isValid;
206
+ return isValid;
183
207
  }
184
208
 
185
209
  formResetCallback() {
186
210
  this.checked = false;
187
211
  this.indeterminate = false;
212
+ this.invalid = false;
188
213
  this._internals.setFormValue(null);
189
214
  this.updateComplete.then(() => this._syncValidity());
190
215
  }
@@ -194,12 +219,16 @@ constructor() {
194
219
 
195
220
  if (this.disabled) return;
196
221
 
197
- // Standard native behavior: clicking an indeterminate checkbox unsets the indeterminate state
198
222
  if (this.indeterminate) {
199
223
  this.indeterminate = false;
200
224
  }
201
225
 
202
226
  this.checked = this._inputEl.checked;
227
+
228
+ if (this.checkValidity()) {
229
+ this.invalid = false;
230
+ }
231
+
203
232
  this.dispatchEvent(new Event("change", {bubbles: true, composed: true}));
204
233
  }
205
234
 
@@ -218,7 +247,6 @@ constructor() {
218
247
  @change=${this._handleChange}
219
248
  />
220
249
  <div class="control">
221
- <!-- Render both SVGs and use CSS to conditionally reveal them based on host attributes -->
222
250
  ${this.indeterminate
223
251
  ? html`<svg class="icon-minus" viewBox="0 0 24 24"><path d="M5 12h14"></path></svg>`
224
252
  : html`<svg class="icon-check" viewBox="0 0 24 24">
@@ -235,4 +263,4 @@ declare global {
235
263
  interface HTMLElementTagNameMap {
236
264
  "st-checkbox": StCheckbox;
237
265
  }
238
- }
266
+ }
@@ -6,6 +6,10 @@ import {resetStyles} from "../../styles/reset.js";
6
6
  export class StFormStep extends LitElement {
7
7
  @property({type: String}) title = "";
8
8
  @property({type: Boolean, reflect: true}) active = false;
9
+
10
+ // Declare the validate function property (attribute: false prevents reflection of functions to DOM attributes)
11
+ @property({attribute: false})
12
+ validate?: () => Promise<boolean> | boolean;
9
13
 
10
14
  static styles = [
11
15
  resetStyles,
@@ -29,4 +33,4 @@ declare global {
29
33
  interface HTMLElementTagNameMap {
30
34
  "st-form-step": StFormStep;
31
35
  }
32
- }
36
+ }