@auriel/peppertino 0.5.0 → 0.6.1

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 (134) hide show
  1. package/CHANGELOG.txt +249 -224
  2. package/LICENSE +21 -21
  3. package/MIGRATION.md +52 -52
  4. package/README.md +811 -764
  5. package/agents/peppertino/SKILL.md +84 -0
  6. package/agents/peppertino/accordion.md +134 -0
  7. package/agents/peppertino/alert.md +116 -0
  8. package/agents/peppertino/badge.md +74 -0
  9. package/agents/peppertino/base.md +252 -0
  10. package/agents/peppertino/button.md +65 -0
  11. package/agents/peppertino/card.md +82 -0
  12. package/agents/peppertino/carousel.md +147 -0
  13. package/agents/peppertino/catalog.md +83 -0
  14. package/agents/peppertino/components-ai-search.md +10 -0
  15. package/agents/peppertino/components-display.md +19 -0
  16. package/agents/peppertino/components-inputs.md +15 -0
  17. package/agents/peppertino/components-navigation.md +12 -0
  18. package/agents/peppertino/dark-mode.md +152 -0
  19. package/agents/peppertino/footer.md +109 -0
  20. package/agents/peppertino/forms-fieldset.md +85 -0
  21. package/agents/peppertino/forms-form-instructions.md +94 -0
  22. package/agents/peppertino/forms-label.md +110 -0
  23. package/agents/peppertino/forms-text-field.md +134 -0
  24. package/agents/peppertino/forms-validation.md +153 -0
  25. package/agents/peppertino/gradient.md +41 -0
  26. package/agents/peppertino/header.md +105 -0
  27. package/agents/peppertino/modal.md +123 -0
  28. package/agents/peppertino/section.md +56 -0
  29. package/agents/peppertino/select.md +110 -0
  30. package/agents/peppertino/switch.md +72 -0
  31. package/agents/peppertino/table.md +69 -0
  32. package/agents/peppertino/tabs.md +115 -0
  33. package/agents/peppertino/toast.md +96 -0
  34. package/agents/peppertino/tooltip.md +111 -0
  35. package/agents/peppertino/typography.md +118 -0
  36. package/agents/peppertino/utilities.md +194 -0
  37. package/agents/skill.md +65 -0
  38. package/build.js +53 -53
  39. package/dist/accordion.js +1 -1
  40. package/dist/accordion.js.map +2 -2
  41. package/dist/alert.js.map +1 -1
  42. package/dist/carousel.js.map +1 -1
  43. package/dist/header.js.map +1 -1
  44. package/dist/main.css +2566 -1008
  45. package/dist/main.css.map +1 -1
  46. package/dist/main.min.css +1 -0
  47. package/dist/modal.js.map +1 -1
  48. package/dist/peppertino.js +1 -1
  49. package/dist/peppertino.js.map +2 -2
  50. package/dist/select.js.map +1 -1
  51. package/dist/switch.js.map +1 -1
  52. package/dist/tabs.js.map +1 -1
  53. package/dist/theme.js.map +1 -1
  54. package/dist/toast.js.map +1 -1
  55. package/dist/validation.js.map +1 -1
  56. package/icon.svg +4 -0
  57. package/index.html +2177 -2098
  58. package/package.json +28 -28
  59. package/scripts/hex-to-hsl.mjs +75 -75
  60. package/scripts/lint-bem.mjs +53 -53
  61. package/scripts/lint-colors.mjs +87 -87
  62. package/site.webmanifest +18 -0
  63. package/src/js/accordion.js +105 -103
  64. package/src/js/alert.js +28 -28
  65. package/src/js/carousel.js +153 -153
  66. package/src/js/header.js +85 -85
  67. package/src/js/modal.js +138 -138
  68. package/src/js/peppertino.js +15 -15
  69. package/src/js/select.js +101 -101
  70. package/src/js/switch.js +28 -28
  71. package/src/js/tabs.js +104 -104
  72. package/src/js/theme.js +47 -47
  73. package/src/js/toast.js +79 -79
  74. package/src/js/validation.js +132 -132
  75. package/src/scss/accordion.scss +190 -156
  76. package/src/scss/activity.scss +17 -0
  77. package/src/scss/alert.scss +203 -203
  78. package/src/scss/badge.scss +90 -90
  79. package/src/scss/base.scss +511 -506
  80. package/src/scss/button.scss +119 -119
  81. package/src/scss/card.scss +121 -121
  82. package/src/scss/carousel.scss +303 -303
  83. package/src/scss/code-block.scss +22 -0
  84. package/src/scss/counter.scss +5 -0
  85. package/src/scss/dark-mode.scss +514 -514
  86. package/src/scss/duration.scss +26 -0
  87. package/src/scss/folder.scss +27 -0
  88. package/src/scss/footer.scss +224 -224
  89. package/src/scss/forms/fieldset.scss +127 -127
  90. package/src/scss/forms/form-instructions.scss +133 -133
  91. package/src/scss/forms/label.scss +115 -115
  92. package/src/scss/forms/text-field.scss +240 -240
  93. package/src/scss/forms/validation.scss +215 -215
  94. package/src/scss/forms.scss +8 -8
  95. package/src/scss/gradient.scss +11 -11
  96. package/src/scss/gravity-letters.scss +7 -0
  97. package/src/scss/header.scss +257 -238
  98. package/src/scss/helpers/color.scss +9 -0
  99. package/src/scss/helpers/flex.scss +14 -0
  100. package/src/scss/helpers/index.scss +6 -0
  101. package/src/scss/helpers/layout.scss +14 -0
  102. package/src/scss/helpers/spacing.scss +14 -0
  103. package/src/scss/helpers/typography.scss +11 -0
  104. package/src/scss/helpers/visibility.scss +9 -0
  105. package/src/scss/main.scss +49 -24
  106. package/src/scss/modal.scss +188 -188
  107. package/src/scss/model-picker.scss +5 -0
  108. package/src/scss/notification.scss +5 -0
  109. package/src/scss/orb.scss +7 -0
  110. package/src/scss/otp.scss +5 -0
  111. package/src/scss/pill-nav.scss +10 -0
  112. package/src/scss/prompt.scss +28 -0
  113. package/src/scss/rail.scss +7 -0
  114. package/src/scss/reactions.scss +5 -0
  115. package/src/scss/reset.scss +84 -84
  116. package/src/scss/response.scss +11 -0
  117. package/src/scss/reveal.scss +5 -0
  118. package/src/scss/scroll-progress.scss +4 -0
  119. package/src/scss/search-results.scss +13 -0
  120. package/src/scss/section.scss +87 -79
  121. package/src/scss/select.scss +210 -210
  122. package/src/scss/sidebar.scss +8 -0
  123. package/src/scss/status.scss +5 -0
  124. package/src/scss/step-list.scss +13 -0
  125. package/src/scss/switch.scss +121 -121
  126. package/src/scss/table.scss +89 -89
  127. package/src/scss/tabs.scss +156 -156
  128. package/src/scss/task-list.scss +18 -0
  129. package/src/scss/theme-picker.scss +5 -0
  130. package/src/scss/toast.scss +170 -170
  131. package/src/scss/tooltip.scss +126 -126
  132. package/src/scss/typography.scss +58 -58
  133. package/src/scss/utilities.scss +243 -243
  134. package/src/scss/voice-note.scss +5 -0
package/src/js/select.js CHANGED
@@ -1,101 +1,101 @@
1
- (function () {
2
- function initSelect(wrapper, idx) {
3
- const trigger = wrapper.querySelector('.pp-select__trigger');
4
- const panel = wrapper.querySelector('.pp-select__panel');
5
- const options = wrapper.querySelectorAll('.pp-select__option');
6
- const valueEl = wrapper.querySelector('.pp-select__value');
7
-
8
- if (!trigger || !panel) return;
9
-
10
- // IDs for aria-controls / aria-activedescendant
11
- const panelId = panel.id || `pp-select-panel-${idx}`;
12
- panel.id = panelId;
13
-
14
- options.forEach((opt, i) => {
15
- if (!opt.id) opt.id = `pp-select-opt-${idx}-${i}`;
16
- opt.setAttribute('role', 'option');
17
- opt.setAttribute('aria-selected', opt.classList.contains('is-selected') ? 'true' : 'false');
18
- });
19
-
20
- panel.setAttribute('role', 'listbox');
21
- trigger.setAttribute('role', 'combobox');
22
- trigger.setAttribute('aria-haspopup', 'listbox');
23
- trigger.setAttribute('aria-expanded', 'false');
24
- trigger.setAttribute('aria-controls', panelId);
25
-
26
- // Set initial aria-activedescendant to the selected option
27
- const selected = wrapper.querySelector('.pp-select__option.is-selected');
28
- if (selected) trigger.setAttribute('aria-activedescendant', selected.id);
29
-
30
- function open() {
31
- wrapper.classList.add('is-open');
32
- trigger.setAttribute('aria-expanded', 'true');
33
- panel.removeAttribute('hidden');
34
- }
35
-
36
- function close() {
37
- wrapper.classList.remove('is-open');
38
- trigger.setAttribute('aria-expanded', 'false');
39
- panel.setAttribute('hidden', '');
40
- }
41
-
42
- function toggle() {
43
- wrapper.classList.contains('is-open') ? close() : open();
44
- }
45
-
46
- // Initial state — JS takes over from :focus-within
47
- panel.setAttribute('hidden', '');
48
-
49
- trigger.addEventListener('click', (e) => {
50
- e.stopPropagation();
51
- toggle();
52
- });
53
-
54
- // Option selection
55
- options.forEach((opt) => {
56
- opt.addEventListener('click', () => {
57
- options.forEach((o) => {
58
- o.classList.remove('is-selected');
59
- o.setAttribute('aria-selected', 'false');
60
- });
61
- opt.classList.add('is-selected');
62
- opt.setAttribute('aria-selected', 'true');
63
- trigger.setAttribute('aria-activedescendant', opt.id);
64
-
65
- if (valueEl) valueEl.textContent = opt.textContent.trim();
66
-
67
- const nativeSelect = wrapper.querySelector('select[data-pp-select]');
68
- if (nativeSelect) nativeSelect.value = opt.dataset.value ?? opt.textContent.trim();
69
-
70
- const detail = { value: opt.dataset.value, label: opt.textContent.trim() };
71
- wrapper.dispatchEvent(new CustomEvent('pp:select:change', { bubbles: true, detail }));
72
-
73
- close();
74
- trigger.focus();
75
- });
76
- });
77
-
78
- // Keyboard navigation
79
- trigger.addEventListener('keydown', (e) => {
80
- if (e.key === 'ArrowDown') { e.preventDefault(); open(); options[0]?.focus(); }
81
- if (e.key === 'Escape') close();
82
- });
83
-
84
- panel.addEventListener('keydown', (e) => {
85
- const focusable = [...options];
86
- const idx = focusable.indexOf(document.activeElement);
87
-
88
- if (e.key === 'ArrowDown') { e.preventDefault(); focusable[idx + 1]?.focus(); }
89
- if (e.key === 'ArrowUp') { e.preventDefault(); idx > 0 ? focusable[idx - 1]?.focus() : trigger.focus(); }
90
- if (e.key === 'Escape') { close(); trigger.focus(); }
91
- if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); document.activeElement?.click(); }
92
- });
93
-
94
- // Close on outside click
95
- document.addEventListener('click', (e) => {
96
- if (!wrapper.contains(e.target)) close();
97
- });
98
- }
99
-
100
- document.querySelectorAll('.pp-select').forEach((el, i) => initSelect(el, i));
101
- })();
1
+ (function () {
2
+ function initSelect(wrapper, idx) {
3
+ const trigger = wrapper.querySelector('.pp-select__trigger');
4
+ const panel = wrapper.querySelector('.pp-select__panel');
5
+ const options = wrapper.querySelectorAll('.pp-select__option');
6
+ const valueEl = wrapper.querySelector('.pp-select__value');
7
+
8
+ if (!trigger || !panel) return;
9
+
10
+ // IDs for aria-controls / aria-activedescendant
11
+ const panelId = panel.id || `pp-select-panel-${idx}`;
12
+ panel.id = panelId;
13
+
14
+ options.forEach((opt, i) => {
15
+ if (!opt.id) opt.id = `pp-select-opt-${idx}-${i}`;
16
+ opt.setAttribute('role', 'option');
17
+ opt.setAttribute('aria-selected', opt.classList.contains('is-selected') ? 'true' : 'false');
18
+ });
19
+
20
+ panel.setAttribute('role', 'listbox');
21
+ trigger.setAttribute('role', 'combobox');
22
+ trigger.setAttribute('aria-haspopup', 'listbox');
23
+ trigger.setAttribute('aria-expanded', 'false');
24
+ trigger.setAttribute('aria-controls', panelId);
25
+
26
+ // Set initial aria-activedescendant to the selected option
27
+ const selected = wrapper.querySelector('.pp-select__option.is-selected');
28
+ if (selected) trigger.setAttribute('aria-activedescendant', selected.id);
29
+
30
+ function open() {
31
+ wrapper.classList.add('is-open');
32
+ trigger.setAttribute('aria-expanded', 'true');
33
+ panel.removeAttribute('hidden');
34
+ }
35
+
36
+ function close() {
37
+ wrapper.classList.remove('is-open');
38
+ trigger.setAttribute('aria-expanded', 'false');
39
+ panel.setAttribute('hidden', '');
40
+ }
41
+
42
+ function toggle() {
43
+ wrapper.classList.contains('is-open') ? close() : open();
44
+ }
45
+
46
+ // Initial state — JS takes over from :focus-within
47
+ panel.setAttribute('hidden', '');
48
+
49
+ trigger.addEventListener('click', (e) => {
50
+ e.stopPropagation();
51
+ toggle();
52
+ });
53
+
54
+ // Option selection
55
+ options.forEach((opt) => {
56
+ opt.addEventListener('click', () => {
57
+ options.forEach((o) => {
58
+ o.classList.remove('is-selected');
59
+ o.setAttribute('aria-selected', 'false');
60
+ });
61
+ opt.classList.add('is-selected');
62
+ opt.setAttribute('aria-selected', 'true');
63
+ trigger.setAttribute('aria-activedescendant', opt.id);
64
+
65
+ if (valueEl) valueEl.textContent = opt.textContent.trim();
66
+
67
+ const nativeSelect = wrapper.querySelector('select[data-pp-select]');
68
+ if (nativeSelect) nativeSelect.value = opt.dataset.value ?? opt.textContent.trim();
69
+
70
+ const detail = { value: opt.dataset.value, label: opt.textContent.trim() };
71
+ wrapper.dispatchEvent(new CustomEvent('pp:select:change', { bubbles: true, detail }));
72
+
73
+ close();
74
+ trigger.focus();
75
+ });
76
+ });
77
+
78
+ // Keyboard navigation
79
+ trigger.addEventListener('keydown', (e) => {
80
+ if (e.key === 'ArrowDown') { e.preventDefault(); open(); options[0]?.focus(); }
81
+ if (e.key === 'Escape') close();
82
+ });
83
+
84
+ panel.addEventListener('keydown', (e) => {
85
+ const focusable = [...options];
86
+ const idx = focusable.indexOf(document.activeElement);
87
+
88
+ if (e.key === 'ArrowDown') { e.preventDefault(); focusable[idx + 1]?.focus(); }
89
+ if (e.key === 'ArrowUp') { e.preventDefault(); idx > 0 ? focusable[idx - 1]?.focus() : trigger.focus(); }
90
+ if (e.key === 'Escape') { close(); trigger.focus(); }
91
+ if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); document.activeElement?.click(); }
92
+ });
93
+
94
+ // Close on outside click
95
+ document.addEventListener('click', (e) => {
96
+ if (!wrapper.contains(e.target)) close();
97
+ });
98
+ }
99
+
100
+ document.querySelectorAll('.pp-select').forEach((el, i) => initSelect(el, i));
101
+ })();
package/src/js/switch.js CHANGED
@@ -1,28 +1,28 @@
1
- (function () {
2
- function initSwitch(el) {
3
- if (el.dataset.ppSwitchInit) return;
4
- el.dataset.ppSwitchInit = '1';
5
-
6
- function toggle() {
7
- if (el.disabled || el.getAttribute('aria-disabled') === 'true') return;
8
- const checked = el.getAttribute('aria-checked') === 'true';
9
- const next = !checked;
10
- el.setAttribute('aria-checked', String(next));
11
- el.dispatchEvent(new CustomEvent('pp:switch:change', {
12
- bubbles: true,
13
- detail: { checked: next },
14
- }));
15
- }
16
-
17
- el.addEventListener('click', toggle);
18
- el.addEventListener('keydown', (e) => {
19
- if (e.key === ' ') { e.preventDefault(); toggle(); }
20
- });
21
-
22
- // Ensure role is set
23
- if (!el.getAttribute('role')) el.setAttribute('role', 'switch');
24
- if (!el.getAttribute('aria-checked')) el.setAttribute('aria-checked', 'false');
25
- }
26
-
27
- document.querySelectorAll('[role="switch"], .pp-switch').forEach(initSwitch);
28
- })();
1
+ (function () {
2
+ function initSwitch(el) {
3
+ if (el.dataset.ppSwitchInit) return;
4
+ el.dataset.ppSwitchInit = '1';
5
+
6
+ function toggle() {
7
+ if (el.disabled || el.getAttribute('aria-disabled') === 'true') return;
8
+ const checked = el.getAttribute('aria-checked') === 'true';
9
+ const next = !checked;
10
+ el.setAttribute('aria-checked', String(next));
11
+ el.dispatchEvent(new CustomEvent('pp:switch:change', {
12
+ bubbles: true,
13
+ detail: { checked: next },
14
+ }));
15
+ }
16
+
17
+ el.addEventListener('click', toggle);
18
+ el.addEventListener('keydown', (e) => {
19
+ if (e.key === ' ') { e.preventDefault(); toggle(); }
20
+ });
21
+
22
+ // Ensure role is set
23
+ if (!el.getAttribute('role')) el.setAttribute('role', 'switch');
24
+ if (!el.getAttribute('aria-checked')) el.setAttribute('aria-checked', 'false');
25
+ }
26
+
27
+ document.querySelectorAll('[role="switch"], .pp-switch').forEach(initSwitch);
28
+ })();
package/src/js/tabs.js CHANGED
@@ -1,104 +1,104 @@
1
- (function () {
2
- const registry = {};
3
-
4
- function initTabs(tabGroup, groupIdx) {
5
- const items = [...tabGroup.querySelectorAll('.pp-tabs__item')];
6
- const targetAttr = 'data-tab-target';
7
-
8
- if (!tabGroup.getAttribute('role')) tabGroup.setAttribute('role', 'tablist');
9
-
10
- items.forEach((item, i) => {
11
- item.setAttribute('role', 'tab');
12
- if (!item.id) item.id = `pp-tab-${groupIdx}-${i}`;
13
-
14
- const targetId = item.getAttribute(targetAttr);
15
- if (targetId) {
16
- item.setAttribute('aria-controls', targetId);
17
- const panel = document.querySelector(`[data-tab-panel="${targetId}"]`);
18
- if (panel) {
19
- if (!panel.id) panel.id = targetId;
20
- panel.setAttribute('role', 'tabpanel');
21
- panel.setAttribute('aria-labelledby', item.id);
22
- }
23
- }
24
- });
25
-
26
- function activate(item) {
27
- items.forEach((i) => {
28
- i.classList.remove('is-active');
29
- i.setAttribute('aria-selected', 'false');
30
- i.setAttribute('tabindex', '-1');
31
- });
32
-
33
- item.classList.add('is-active');
34
- item.setAttribute('aria-selected', 'true');
35
- item.setAttribute('tabindex', '0');
36
-
37
- const targetId = item.getAttribute(targetAttr);
38
- if (targetId) {
39
- document.querySelectorAll('[data-tab-panel]').forEach((panel) => {
40
- const isVisible = panel.getAttribute('data-tab-panel') === targetId;
41
- panel.hidden = !isVisible;
42
- panel.setAttribute('aria-hidden', String(!isVisible));
43
- });
44
- }
45
-
46
- const detail = { value: item.dataset.tabTarget, label: item.textContent.trim(), index: items.indexOf(item) };
47
- tabGroup.dispatchEvent(new CustomEvent('pp:tabs:change', { bubbles: true, detail }));
48
- }
49
-
50
- items.forEach((item) => {
51
- item.addEventListener('click', () => activate(item));
52
- });
53
-
54
- tabGroup.addEventListener('keydown', (e) => {
55
- const current = items.findIndex((i) => i === document.activeElement);
56
- if (current === -1) return;
57
-
58
- if (e.key === 'ArrowRight') {
59
- e.preventDefault();
60
- const next = items[(current + 1) % items.length];
61
- activate(next); next.focus();
62
- }
63
- if (e.key === 'ArrowLeft') {
64
- e.preventDefault();
65
- const prev = items[(current - 1 + items.length) % items.length];
66
- activate(prev); prev.focus();
67
- }
68
- if (e.key === 'Home') {
69
- e.preventDefault();
70
- activate(items[0]); items[0].focus();
71
- }
72
- if (e.key === 'End') {
73
- e.preventDefault();
74
- activate(items[items.length - 1]); items[items.length - 1].focus();
75
- }
76
- });
77
-
78
- items.forEach((item) => {
79
- item.setAttribute('tabindex', item.classList.contains('is-active') ? '0' : '-1');
80
- });
81
-
82
- return {
83
- activate(index) {
84
- const item = items[index];
85
- if (item) { activate(item); item.focus(); }
86
- },
87
- };
88
- }
89
-
90
- document.querySelectorAll('.pp-tabs').forEach((el, i) => {
91
- const id = el.id || `pp-tabs-${i}`;
92
- if (!el.id) el.id = id;
93
- const api = initTabs(el, i);
94
- if (api) registry[id] = api;
95
- });
96
-
97
- window.ppTabs = {
98
- get(ref) {
99
- if (typeof ref === 'string') return registry[ref];
100
- if (ref instanceof Element) return registry[ref.id];
101
- return null;
102
- },
103
- };
104
- })();
1
+ (function () {
2
+ const registry = {};
3
+
4
+ function initTabs(tabGroup, groupIdx) {
5
+ const items = [...tabGroup.querySelectorAll('.pp-tabs__item')];
6
+ const targetAttr = 'data-tab-target';
7
+
8
+ if (!tabGroup.getAttribute('role')) tabGroup.setAttribute('role', 'tablist');
9
+
10
+ items.forEach((item, i) => {
11
+ item.setAttribute('role', 'tab');
12
+ if (!item.id) item.id = `pp-tab-${groupIdx}-${i}`;
13
+
14
+ const targetId = item.getAttribute(targetAttr);
15
+ if (targetId) {
16
+ item.setAttribute('aria-controls', targetId);
17
+ const panel = document.querySelector(`[data-tab-panel="${targetId}"]`);
18
+ if (panel) {
19
+ if (!panel.id) panel.id = targetId;
20
+ panel.setAttribute('role', 'tabpanel');
21
+ panel.setAttribute('aria-labelledby', item.id);
22
+ }
23
+ }
24
+ });
25
+
26
+ function activate(item) {
27
+ items.forEach((i) => {
28
+ i.classList.remove('is-active');
29
+ i.setAttribute('aria-selected', 'false');
30
+ i.setAttribute('tabindex', '-1');
31
+ });
32
+
33
+ item.classList.add('is-active');
34
+ item.setAttribute('aria-selected', 'true');
35
+ item.setAttribute('tabindex', '0');
36
+
37
+ const targetId = item.getAttribute(targetAttr);
38
+ if (targetId) {
39
+ document.querySelectorAll('[data-tab-panel]').forEach((panel) => {
40
+ const isVisible = panel.getAttribute('data-tab-panel') === targetId;
41
+ panel.hidden = !isVisible;
42
+ panel.setAttribute('aria-hidden', String(!isVisible));
43
+ });
44
+ }
45
+
46
+ const detail = { value: item.dataset.tabTarget, label: item.textContent.trim(), index: items.indexOf(item) };
47
+ tabGroup.dispatchEvent(new CustomEvent('pp:tabs:change', { bubbles: true, detail }));
48
+ }
49
+
50
+ items.forEach((item) => {
51
+ item.addEventListener('click', () => activate(item));
52
+ });
53
+
54
+ tabGroup.addEventListener('keydown', (e) => {
55
+ const current = items.findIndex((i) => i === document.activeElement);
56
+ if (current === -1) return;
57
+
58
+ if (e.key === 'ArrowRight') {
59
+ e.preventDefault();
60
+ const next = items[(current + 1) % items.length];
61
+ activate(next); next.focus();
62
+ }
63
+ if (e.key === 'ArrowLeft') {
64
+ e.preventDefault();
65
+ const prev = items[(current - 1 + items.length) % items.length];
66
+ activate(prev); prev.focus();
67
+ }
68
+ if (e.key === 'Home') {
69
+ e.preventDefault();
70
+ activate(items[0]); items[0].focus();
71
+ }
72
+ if (e.key === 'End') {
73
+ e.preventDefault();
74
+ activate(items[items.length - 1]); items[items.length - 1].focus();
75
+ }
76
+ });
77
+
78
+ items.forEach((item) => {
79
+ item.setAttribute('tabindex', item.classList.contains('is-active') ? '0' : '-1');
80
+ });
81
+
82
+ return {
83
+ activate(index) {
84
+ const item = items[index];
85
+ if (item) { activate(item); item.focus(); }
86
+ },
87
+ };
88
+ }
89
+
90
+ document.querySelectorAll('.pp-tabs').forEach((el, i) => {
91
+ const id = el.id || `pp-tabs-${i}`;
92
+ if (!el.id) el.id = id;
93
+ const api = initTabs(el, i);
94
+ if (api) registry[id] = api;
95
+ });
96
+
97
+ window.ppTabs = {
98
+ get(ref) {
99
+ if (typeof ref === 'string') return registry[ref];
100
+ if (ref instanceof Element) return registry[ref.id];
101
+ return null;
102
+ },
103
+ };
104
+ })();
package/src/js/theme.js CHANGED
@@ -1,47 +1,47 @@
1
- (function () {
2
- const STORAGE_KEY = 'pp-theme';
3
- const ROOT = document.documentElement;
4
-
5
- function applyTheme(theme) {
6
- if (theme === 'dark') {
7
- ROOT.classList.add('dark');
8
- } else {
9
- ROOT.classList.remove('dark');
10
- }
11
- try { localStorage.setItem(STORAGE_KEY, theme); } catch (_) {}
12
-
13
- document.dispatchEvent(new CustomEvent('pp:theme:change', {
14
- bubbles: false,
15
- detail: { theme },
16
- }));
17
- }
18
-
19
- window.ppTheme = {
20
- set(theme) {
21
- applyTheme(theme === 'dark' ? 'dark' : 'light');
22
- },
23
-
24
- get() {
25
- return ROOT.classList.contains('dark') ? 'dark' : 'light';
26
- },
27
-
28
- toggle() {
29
- applyTheme(ROOT.classList.contains('dark') ? 'light' : 'dark');
30
- },
31
- };
32
-
33
- // Restore from localStorage on load
34
- (function init() {
35
- let saved;
36
- try { saved = localStorage.getItem(STORAGE_KEY); } catch (_) {}
37
- if (saved === 'dark' || saved === 'light') {
38
- applyTheme(saved);
39
- }
40
- })();
41
-
42
- // Auto-wire [data-theme-toggle] buttons
43
- document.addEventListener('click', (e) => {
44
- const btn = e.target.closest('[data-theme-toggle]');
45
- if (btn) ppTheme.toggle();
46
- });
47
- })();
1
+ (function () {
2
+ const STORAGE_KEY = 'pp-theme';
3
+ const ROOT = document.documentElement;
4
+
5
+ function applyTheme(theme) {
6
+ if (theme === 'dark') {
7
+ ROOT.classList.add('dark');
8
+ } else {
9
+ ROOT.classList.remove('dark');
10
+ }
11
+ try { localStorage.setItem(STORAGE_KEY, theme); } catch (_) {}
12
+
13
+ document.dispatchEvent(new CustomEvent('pp:theme:change', {
14
+ bubbles: false,
15
+ detail: { theme },
16
+ }));
17
+ }
18
+
19
+ window.ppTheme = {
20
+ set(theme) {
21
+ applyTheme(theme === 'dark' ? 'dark' : 'light');
22
+ },
23
+
24
+ get() {
25
+ return ROOT.classList.contains('dark') ? 'dark' : 'light';
26
+ },
27
+
28
+ toggle() {
29
+ applyTheme(ROOT.classList.contains('dark') ? 'light' : 'dark');
30
+ },
31
+ };
32
+
33
+ // Restore from localStorage on load
34
+ (function init() {
35
+ let saved;
36
+ try { saved = localStorage.getItem(STORAGE_KEY); } catch (_) {}
37
+ if (saved === 'dark' || saved === 'light') {
38
+ applyTheme(saved);
39
+ }
40
+ })();
41
+
42
+ // Auto-wire [data-theme-toggle] buttons
43
+ document.addEventListener('click', (e) => {
44
+ const btn = e.target.closest('[data-theme-toggle]');
45
+ if (btn) ppTheme.toggle();
46
+ });
47
+ })();