@consent.software/catalog 1.6.0 → 2.0.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.
Files changed (30) hide show
  1. package/dist_bundle/bundle.js +632 -401
  2. package/dist_bundle/bundle.js.map +4 -4
  3. package/dist_ts_web/00_commitinfo_data.js +1 -1
  4. package/dist_ts_web/elements/consentsoftware-cookieconsent.d.ts +4 -20
  5. package/dist_ts_web/elements/consentsoftware-cookieconsent.js +267 -303
  6. package/dist_ts_web/elements/consentsoftware-header.d.ts +3 -4
  7. package/dist_ts_web/elements/consentsoftware-header.js +89 -38
  8. package/dist_ts_web/elements/consentsoftware-mainselection.d.ts +6 -7
  9. package/dist_ts_web/elements/consentsoftware-mainselection.js +126 -54
  10. package/dist_ts_web/elements/consentsoftware-tabs.d.ts +4 -5
  11. package/dist_ts_web/elements/consentsoftware-tabs.js +109 -62
  12. package/dist_ts_web/elements/consentsoftware-toggle.d.ts +11 -9
  13. package/dist_ts_web/elements/consentsoftware-toggle.js +262 -214
  14. package/dist_ts_web/elements/shared.d.ts +35 -1
  15. package/dist_ts_web/elements/shared.js +36 -2
  16. package/dist_ts_web/pages/page1.d.ts +1 -1
  17. package/dist_ts_web/pages/page1.js +2 -2
  18. package/dist_watch/bundle.js +10228 -4196
  19. package/dist_watch/bundle.js.map +4 -4
  20. package/package.json +9 -9
  21. package/readme.md +149 -80
  22. package/ts_web/00_commitinfo_data.ts +1 -1
  23. package/ts_web/elements/consentsoftware-cookieconsent.ts +150 -218
  24. package/ts_web/elements/consentsoftware-header.ts +40 -23
  25. package/ts_web/elements/consentsoftware-mainselection.ts +63 -33
  26. package/ts_web/elements/consentsoftware-tabs.ts +51 -37
  27. package/ts_web/elements/consentsoftware-toggle.ts +123 -107
  28. package/ts_web/elements/shared.ts +38 -2
  29. package/ts_web/pages/page1.ts +1 -1
  30. package/ts_web/tsconfig.json +4 -4
@@ -1,50 +1,64 @@
1
- import { LitElement, html, css, type TemplateResult } from 'lit';
2
- import { customElement } from 'lit/decorators.js';
3
- import { property } from 'lit/decorators/property.js';
1
+ import { cssManager, colors } from './shared.js';
2
+
3
+ import {
4
+ DeesElement,
5
+ customElement,
6
+ html,
7
+ css,
8
+ type TemplateResult,
9
+ } from '@design.estate/dees-element';
4
10
 
5
11
  @customElement('consentsoftware-tabs')
6
- export class ConsentsoftwareTabs extends LitElement {
12
+ export class ConsentsoftwareTabs extends DeesElement {
7
13
  public static demo = () => html`<consentsoftware-tabs></consentsoftware-tabs>`;
8
14
 
9
- public static styles = css`
10
- :host {
11
- display: block;
12
- position: relative;
13
- border-bottom: 1px solid rgba(255, 255, 255, 0.1);
14
- }
15
-
16
- .tabs {
17
- display: grid;
18
- grid-template-columns: repeat(3, 1fr);
19
- }
15
+ public static styles = [
16
+ cssManager.defaultStyles,
17
+ css`
18
+ :host {
19
+ display: block;
20
+ position: relative;
21
+ background: ${cssManager.bdTheme(colors.light.muted, colors.dark.muted)};
22
+ }
20
23
 
21
- .tabs .tab {
22
- text-align: center;
23
- line-height: 3em;
24
- cursor: pointer;
25
- }
24
+ .tabs {
25
+ display: grid;
26
+ grid-template-columns: repeat(3, 1fr);
27
+ }
26
28
 
27
- /* Media query for mobile devices: stack buttons vertically */
28
- @media (max-width: 600px) {
29
29
  .tabs .tab {
30
+ text-align: center;
31
+ padding: 8px 0;
30
32
  font-size: 0.8em;
33
+ font-weight: 500;
34
+ color: ${cssManager.bdTheme(colors.light.mutedForeground, colors.dark.mutedForeground)};
35
+ cursor: pointer;
36
+ transition: color 0.15s ease;
31
37
  }
32
- }
33
38
 
34
- .selector {
35
- position: absolute;
36
- width: calc(100% / 3);
37
- height: 1px;
38
- left: 0;
39
- bottom: 0px;
40
- background: orange;
41
- transition: all 0.2s;
42
- }
43
- `;
39
+ .tabs .tab:hover {
40
+ color: ${cssManager.bdTheme(colors.light.foreground, colors.dark.foreground)};
41
+ }
44
42
 
45
- constructor() {
46
- super();
47
- }
43
+ @media (max-width: 560px) {
44
+ .tabs .tab {
45
+ font-size: 0.75em;
46
+ padding: 6px 0;
47
+ }
48
+ }
49
+
50
+ .selector {
51
+ position: absolute;
52
+ width: calc(100% / 3);
53
+ height: 2px;
54
+ left: 0;
55
+ bottom: 0;
56
+ background: ${cssManager.bdTheme(colors.light.foreground, colors.dark.foreground)};
57
+ transition: all 0.2s ease-out;
58
+ border-radius: 1px;
59
+ }
60
+ `,
61
+ ];
48
62
 
49
63
  public render(): TemplateResult {
50
64
  return html`
@@ -57,7 +71,7 @@ export class ConsentsoftwareTabs extends LitElement {
57
71
  `;
58
72
  }
59
73
 
60
- public async handleClick(mouseEvent) {
74
+ public async handleClick(mouseEvent: MouseEvent) {
61
75
  const target = mouseEvent.target as HTMLElement;
62
76
  const tab: HTMLDivElement = target.closest('.tab');
63
77
  if (tab) {
@@ -1,10 +1,18 @@
1
- import { LitElement, html, css, type TemplateResult } from 'lit';
2
- import { customElement } from 'lit/decorators.js';
3
- import { property } from 'lit/decorators/property.js';
1
+ import { cssManager, colors } from './shared.js';
2
+
3
+ import {
4
+ DeesElement,
5
+ customElement,
6
+ html,
7
+ css,
8
+ type TemplateResult,
9
+ property,
10
+ } from '@design.estate/dees-element';
11
+
4
12
  import { delayFor } from '@push.rocks/smartdelay';
5
13
 
6
14
  @customElement('consentsoftware-toggle')
7
- export class ConsentsoftwareToggle extends LitElement {
15
+ export class ConsentsoftwareToggle extends DeesElement {
8
16
  @property({ type: Boolean })
9
17
  public accessor required = false;
10
18
 
@@ -12,9 +20,9 @@ export class ConsentsoftwareToggle extends LitElement {
12
20
  public accessor selected = false;
13
21
 
14
22
  /**
15
- * We always track the knob’s left offset in `currentX`.
16
- * - 0 => fully left
17
- * - 30 => fully right
23
+ * Knob position tracking (0 = off, maxTravel = on)
24
+ * This is the travel distance, not absolute left position.
25
+ * Actual left = padding + currentX
18
26
  */
19
27
  private currentX = 0;
20
28
 
@@ -23,82 +31,95 @@ export class ConsentsoftwareToggle extends LitElement {
23
31
  */
24
32
  private isDragging = false;
25
33
  private hasDragged = false;
26
- private startX = 0; // pointerdown offset
27
- private readonly knobWidth = 30;
28
- private readonly trackWidth = 60;
29
-
30
- public static styles = css`
31
- :host {
32
- display: block;
33
- position: relative;
34
- }
35
-
36
- .label {
37
- margin-bottom: 16px;
38
- }
39
-
40
- .toggle {
41
- user-select: none; /* helps avoid text selection on drag */
42
- }
43
-
44
- .toggleKnobArea {
45
- position: relative;
46
- margin: auto;
47
- height: 30px;
48
- width: 60px;
49
- border-radius: 20px;
50
- background: rgba(255, 255, 255, 0.1);
51
- border: 1px solid rgba(255, 255, 255, 0);
52
- overflow: hidden;
53
- transition: background 0.2s ease;
54
- cursor: pointer;
55
- }
56
-
57
- :host([selected]) .toggleKnobArea {
58
- background: green;
59
- }
60
-
61
- .toggleKnobMover {
62
- position: relative;
63
- height: 100%;
64
- width: 100%;
65
- }
66
-
67
- .toggleKnobInner {
68
- position: absolute;
69
- top: 0;
70
- left: 0;
71
- width: 30px;
72
- height: 30px;
73
- border-radius: 15px;
74
- background: rgba(255, 255, 255, 0.5);
75
- transition: left 0.2s ease, background 0.2s ease;
76
- transform: scale(0.7);
77
- /* Prevent scroll gestures on mobile */
78
- touch-action: none;
79
- }
80
-
81
- .toggleKnobInner.dragging {
82
- transition: background 0.2s ease;
83
- }
84
-
85
- :host([selected]) .toggleKnobInner {
86
- background: white;
87
- }
88
-
89
- :host([required]) .toggleKnobArea {
90
- background: none;
91
- border: 1px solid rgba(255, 255, 255, 0.1);
92
- }
93
-
94
- :host([required]) .toggleKnobInner {
95
- background: rgba(255, 255, 255, 0.1);
96
- }
97
- `;
98
-
99
- constructor() {
100
- super();
101
- }
34
+ private startX = 0;
35
+
36
+ // Toggle dimensions (with border-box, 1px border reduces inner by 2px)
37
+ private readonly trackWidth = 36; // outer width
38
+ private readonly trackHeight = 20; // outer height
39
+ private readonly knobSize = 14;
40
+ private readonly padding = 2; // padding from inner edge to knob
41
+ private readonly maxTravel = 16; // (36 - 2) - 14 - (2 * 2) = 34 - 14 - 4 = 16
42
+
43
+ public static styles = [
44
+ cssManager.defaultStyles,
45
+ css`
46
+ :host {
47
+ display: block;
48
+ position: relative;
49
+ }
50
+
51
+ .label {
52
+ margin-bottom: 8px;
53
+ font-size: 0.8em;
54
+ font-weight: 500;
55
+ color: ${cssManager.bdTheme(colors.light.mutedForeground, colors.dark.mutedForeground)};
56
+ }
57
+
58
+ .toggle {
59
+ user-select: none;
60
+ }
61
+
62
+ .toggleKnobArea {
63
+ position: relative;
64
+ margin: auto;
65
+ height: 20px;
66
+ width: 36px;
67
+ border-radius: 10px;
68
+ background: ${cssManager.bdTheme(colors.light.input, colors.dark.input)};
69
+ border: 1px solid ${cssManager.bdTheme(colors.light.border, colors.dark.border)};
70
+ overflow: hidden;
71
+ transition: all 0.15s ease;
72
+ cursor: pointer;
73
+ }
74
+
75
+ .toggleKnobArea:hover {
76
+ border-color: ${cssManager.bdTheme(colors.light.ring, colors.dark.ring)};
77
+ }
78
+
79
+ :host([selected]) .toggleKnobArea {
80
+ background: ${cssManager.bdTheme(colors.light.primary, colors.dark.primary)};
81
+ border-color: ${cssManager.bdTheme(colors.light.primary, colors.dark.primary)};
82
+ }
83
+
84
+ .toggleKnobMover {
85
+ position: relative;
86
+ height: 100%;
87
+ width: 100%;
88
+ }
89
+
90
+ .toggleKnobInner {
91
+ position: absolute;
92
+ top: 2px;
93
+ width: 14px;
94
+ height: 14px;
95
+ border-radius: 7px;
96
+ background: ${cssManager.bdTheme(colors.light.mutedForeground, colors.dark.mutedForeground)};
97
+ transition: left 0.15s ease, background 0.15s ease;
98
+ touch-action: none;
99
+ }
100
+
101
+ .toggleKnobInner.dragging {
102
+ transition: background 0.15s ease;
103
+ }
104
+
105
+ :host([selected]) .toggleKnobInner {
106
+ background: ${cssManager.bdTheme(colors.light.primaryForeground, colors.dark.primaryForeground)};
107
+ }
108
+
109
+ :host([required]) .toggleKnobArea {
110
+ cursor: not-allowed;
111
+ }
112
+
113
+ :host([required][selected]) .toggleKnobArea {
114
+ background: ${cssManager.bdTheme(colors.light.ring, colors.dark.ring)};
115
+ border-color: ${cssManager.bdTheme(colors.light.ring, colors.dark.ring)};
116
+ }
117
+
118
+ :host([required][selected]) .toggleKnobInner {
119
+ background: ${cssManager.bdTheme(colors.light.muted, colors.dark.muted)};
120
+ }
121
+ `,
122
+ ];
102
123
 
103
124
  public render(): TemplateResult {
104
125
  return html`
@@ -110,7 +131,7 @@ export class ConsentsoftwareToggle extends LitElement {
110
131
  <!-- The knob itself, with pointer events for dragging. -->
111
132
  <div
112
133
  class="toggleKnobInner"
113
- style="left: ${this.currentX}px;"
134
+ style="left: ${this.padding + this.currentX}px;"
114
135
  @pointerdown=${this.onPointerDown}
115
136
  @pointermove=${this.onPointerMove}
116
137
  @pointerup=${this.onPointerUp}
@@ -125,15 +146,14 @@ export class ConsentsoftwareToggle extends LitElement {
125
146
  /**
126
147
  * If required = true on first render, auto-select and set the knob to the right.
127
148
  */
128
- public async firstUpdated() {
149
+ public async firstUpdated(_changedProperties: Map<PropertyKey, unknown>) {
150
+ await super.firstUpdated(_changedProperties);
129
151
  if (this.required) {
130
- // If "required" => always selected
131
152
  this.selected = true;
132
- this.currentX = this.knobWidth; // 30
153
+ this.currentX = this.maxTravel;
133
154
  this.requestUpdate();
134
155
  } else {
135
- // If not required, set knob to 0 or 30 depending on `selected`
136
- this.currentX = this.selected ? this.knobWidth : 0;
156
+ this.currentX = this.selected ? this.maxTravel : 0;
137
157
  this.requestUpdate();
138
158
  }
139
159
  }
@@ -142,7 +162,6 @@ export class ConsentsoftwareToggle extends LitElement {
142
162
  * CLICK HANDLER
143
163
  */
144
164
  public async handleClick(event: MouseEvent) {
145
- // If the user truly dragged the knob, skip the normal click toggle.
146
165
  if (this.isDragging || this.hasDragged) {
147
166
  event.stopPropagation();
148
167
  event.preventDefault();
@@ -150,26 +169,23 @@ export class ConsentsoftwareToggle extends LitElement {
150
169
  }
151
170
 
152
171
  if (this.required) {
153
- // small bounce from 30 -> 20 -> 30
154
- this.currentX = this.knobWidth; // ensure at 30
172
+ // Small bounce animation for required toggles
173
+ this.currentX = this.maxTravel;
155
174
  this.requestUpdate();
156
175
  await new Promise((r) => setTimeout(r, 10));
157
-
158
- this.currentX = 20; // small bounce left
176
+ this.currentX = this.maxTravel - 3;
159
177
  this.requestUpdate();
160
- await delayFor(200);
161
-
162
- this.currentX = this.knobWidth; // back to 30
178
+ await delayFor(150);
179
+ this.currentX = this.maxTravel;
163
180
  this.requestUpdate();
164
181
  return;
165
182
  }
166
183
 
167
- // Normal toggle if no drag & not required
168
184
  event.stopPropagation();
169
185
  event.preventDefault();
170
186
 
171
187
  this.selected = !this.selected;
172
- this.currentX = this.selected ? this.knobWidth : 0; // snap knob left(0) or right(30)
188
+ this.currentX = this.selected ? this.maxTravel : 0;
173
189
  this.requestUpdate();
174
190
 
175
191
  this.dispatchEvent(new CustomEvent('toggle', { detail: { selected: this.selected } }));
@@ -189,7 +205,7 @@ export class ConsentsoftwareToggle extends LitElement {
189
205
 
190
206
  // Start dragging
191
207
  this.isDragging = true;
192
- // The difference between the pointers X and the knobs current position
208
+ // The difference between the pointer's X and the knob's current position
193
209
  this.startX = event.clientX - this.currentX;
194
210
 
195
211
  // capture pointer so we keep receiving pointermove/pointerup
@@ -203,8 +219,8 @@ export class ConsentsoftwareToggle extends LitElement {
203
219
  const toggleKnobInner: HTMLDivElement = this.shadowRoot.querySelector('.toggleKnobInner');
204
220
  toggleKnobInner.classList.add('dragging');
205
221
 
206
- // Clamp
207
- this.currentX = Math.max(0, Math.min(newX, this.trackWidth - this.knobWidth));
222
+ // Clamp to valid travel range (0 to maxTravel)
223
+ this.currentX = Math.max(0, Math.min(newX, this.maxTravel));
208
224
  this.requestUpdate();
209
225
  }
210
226
 
@@ -213,17 +229,17 @@ export class ConsentsoftwareToggle extends LitElement {
213
229
  (event.target as HTMLElement).releasePointerCapture(event.pointerId);
214
230
  this.isDragging = false;
215
231
 
216
- // If we didnt truly drag, pointerup does nothing; click handler handles toggling.
232
+ // If we didn't truly drag, pointerup does nothing; click handler handles toggling.
217
233
  if (!this.hasDragged) {
218
234
  return;
219
235
  }
220
236
  const toggleKnobInner: HTMLDivElement = this.shadowRoot.querySelector('.toggleKnobInner');
221
237
  toggleKnobInner.classList.remove('dragging');
222
238
 
223
- // Real drag => decide final side
224
- const midpoint = (this.trackWidth - this.knobWidth) / 2; // 15
239
+ // Real drag => decide final side based on midpoint
240
+ const midpoint = this.maxTravel / 2;
225
241
  this.selected = this.currentX > midpoint;
226
- this.currentX = this.selected ? this.knobWidth : 0; // snap to edge
242
+ this.currentX = this.selected ? this.maxTravel : 0; // snap to edge
227
243
  this.requestUpdate();
228
244
 
229
245
  // Dispatch toggle event
@@ -243,7 +259,7 @@ export class ConsentsoftwareToggle extends LitElement {
243
259
  !this.hasDragged &&
244
260
  !this.required
245
261
  ) {
246
- this.currentX = this.selected ? this.knobWidth : 0;
262
+ this.currentX = this.selected ? this.maxTravel : 0;
247
263
  this.requestUpdate();
248
264
  }
249
265
  super.updated(changedProperties);
@@ -1,3 +1,39 @@
1
- import { unsafeCSS } from 'lit'
1
+ import { unsafeCSS, cssManager } from '@design.estate/dees-element';
2
2
 
3
- export const fontStack = unsafeCSS('system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif');
3
+ export { cssManager };
4
+
5
+ export const fontStack = unsafeCSS('system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif');
6
+
7
+ // Shadcn-inspired color palette
8
+ export const colors = {
9
+ light: {
10
+ background: '#ffffff',
11
+ foreground: '#09090b',
12
+ muted: '#f4f4f5',
13
+ mutedForeground: '#71717a',
14
+ border: '#e4e4e7',
15
+ input: '#e4e4e7',
16
+ primary: '#18181b',
17
+ primaryForeground: '#fafafa',
18
+ secondary: '#f4f4f5',
19
+ secondaryForeground: '#18181b',
20
+ accent: '#f4f4f5',
21
+ accentForeground: '#18181b',
22
+ ring: '#a1a1aa',
23
+ },
24
+ dark: {
25
+ background: '#09090b',
26
+ foreground: '#fafafa',
27
+ muted: '#27272a',
28
+ mutedForeground: '#a1a1aa',
29
+ border: '#27272a',
30
+ input: '#27272a',
31
+ primary: '#fafafa',
32
+ primaryForeground: '#18181b',
33
+ secondary: '#27272a',
34
+ secondaryForeground: '#fafafa',
35
+ accent: '#27272a',
36
+ accentForeground: '#fafafa',
37
+ ring: '#52525b',
38
+ },
39
+ };
@@ -1,3 +1,3 @@
1
- import { html } from 'lit';
1
+ import { html } from '@design.estate/dees-element';
2
2
 
3
3
  export const page1 = () => html``;
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "target": "es2017",
4
- "module": "es2015",
5
- "moduleResolution": "node",
6
- "lib": ["es2017", "dom"],
3
+ "target": "ES2022",
4
+ "module": "ES2022",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
7
  "declaration": true,
8
8
  "inlineSources": true,
9
9
  "inlineSourceMap": true,