@brightspot/ui 1.1.0 → 1.2.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 (108) hide show
  1. package/README.md +3 -90
  2. package/dist/LucideDynamicLoader.d.ts +1 -0
  3. package/dist/LucideDynamicLoader.d.ts.map +1 -1
  4. package/dist/LucideDynamicLoader.js +2 -0
  5. package/dist/LucideDynamicLoader.js.map +1 -1
  6. package/dist/LucideDynamicLoader.ts +3 -0
  7. package/dist/components/avatar/Avatar.d.ts +1 -1
  8. package/dist/components/avatar/Avatar.js +2 -2
  9. package/dist/components/avatar/Avatar.js.map +1 -1
  10. package/dist/components/avatar/AvatarGroup.d.ts +1 -1
  11. package/dist/components/avatar/AvatarGroup.js +2 -2
  12. package/dist/components/avatar/AvatarGroup.js.map +1 -1
  13. package/dist/components/badge/Badge.d.ts +1 -1
  14. package/dist/components/badge/Badge.js +2 -2
  15. package/dist/components/badge/Badge.js.map +1 -1
  16. package/dist/components/circular-progress/CircularProgress.d.ts +57 -0
  17. package/dist/components/circular-progress/CircularProgress.d.ts.map +1 -0
  18. package/dist/components/circular-progress/CircularProgress.js +173 -0
  19. package/dist/components/circular-progress/CircularProgress.js.map +1 -0
  20. package/dist/components/icon/Icon.d.ts +90 -0
  21. package/dist/components/icon/Icon.d.ts.map +1 -0
  22. package/dist/components/icon/Icon.js +172 -0
  23. package/dist/components/icon/Icon.js.map +1 -0
  24. package/dist/components/linear-progress/LinearProgress.d.ts +40 -0
  25. package/dist/components/linear-progress/LinearProgress.d.ts.map +1 -0
  26. package/dist/components/linear-progress/LinearProgress.js +95 -0
  27. package/dist/components/linear-progress/LinearProgress.js.map +1 -0
  28. package/dist/custom-elements.json +341 -6
  29. package/dist/global.d.ts +4 -0
  30. package/dist/storybook/assets/{Avatar.stories-BONZm4v8.js → Avatar.stories-BlxrclP0.js} +1 -1
  31. package/dist/storybook/assets/{AvatarGroup.stories-DDKujPh2.js → AvatarGroup.stories-E3VUvBae.js} +1 -1
  32. package/dist/storybook/assets/{Badge.stories-C8Ahfpp6.js → Badge.stories-f4YvPz0W.js} +5 -18
  33. package/dist/storybook/assets/Button.stories-N66xrq4q.js +63 -0
  34. package/dist/storybook/assets/CircularProgress.stories-zWyELtfc.js +451 -0
  35. package/dist/storybook/assets/{Color-64QXVMR3-CqLd5_0n.js → Color-64QXVMR3-B3Y5c9dl.js} +1 -1
  36. package/dist/storybook/assets/{Colors.stories-BajWDIwn.js → Colors.stories-nEoNeHhf.js} +1 -1
  37. package/dist/storybook/assets/{Events.stories-B32yjxgf.js → Events.stories-BP3ensxX.js} +1 -1
  38. package/dist/storybook/assets/Heading.stories-DGqWaBpi.js +3 -0
  39. package/dist/storybook/assets/Icon.stories-BWWjh4NZ.js +245 -0
  40. package/dist/storybook/assets/LinearProgress.stories-DMVolkoE.js +397 -0
  41. package/dist/storybook/assets/ScrollShadow.stories-BmwSRNje.js +17 -0
  42. package/dist/storybook/assets/Throttle.stories-DBj-9rhV.js +303 -0
  43. package/dist/storybook/assets/{WithTooltip-SK46ZJ2J-BO-IGPcG.js → WithTooltip-SK46ZJ2J-DW4NXFWt.js} +5 -5
  44. package/dist/storybook/assets/formatter-OMEEQ6HG-BBn014aZ.js +1 -0
  45. package/dist/storybook/assets/iframe-CxsKJSj-.css +1 -0
  46. package/dist/storybook/assets/{iframe-BIFmrRK7.js → iframe-Z4F0Cgki.js} +95 -135
  47. package/dist/storybook/assets/{index-B4dkQq9N.js → index-BUj5S-B7.js} +1 -1
  48. package/dist/storybook/assets/{syntaxhighlighter-CAVLW7PM-kyZrfiLk.js → syntaxhighlighter-CAVLW7PM-CsQveU1N.js} +1 -1
  49. package/dist/storybook/iframe.html +2 -2
  50. package/dist/storybook/index.json +1 -1
  51. package/dist/storybook/project.json +1 -1
  52. package/dist/tailwind-plugin-button.js +11 -9
  53. package/dist/tailwind-plugin-button.js.map +1 -1
  54. package/dist/tailwind-plugin-button.ts +11 -10
  55. package/dist/tailwind-plugin-contrast.d.ts +2 -0
  56. package/dist/tailwind-plugin-contrast.d.ts.map +1 -0
  57. package/dist/tailwind-plugin-contrast.js +17 -0
  58. package/dist/tailwind-plugin-contrast.js.map +1 -0
  59. package/dist/tailwind-plugin-contrast.ts +18 -0
  60. package/dist/tailwind-plugin-icon.js +17 -10
  61. package/dist/tailwind-plugin-icon.js.map +1 -1
  62. package/dist/tailwind-plugin-icon.ts +17 -10
  63. package/dist/tailwind-plugin-ring-contrast.d.ts +2 -0
  64. package/dist/tailwind-plugin-ring-contrast.d.ts.map +1 -0
  65. package/dist/tailwind-plugin-ring-contrast.js +76 -0
  66. package/dist/tailwind-plugin-ring-contrast.js.map +1 -0
  67. package/dist/tailwind-plugin-ring-contrast.ts +90 -0
  68. package/dist/tailwind.config.d.ts +21 -0
  69. package/dist/tailwind.config.d.ts.map +1 -1
  70. package/dist/tailwind.config.js +25 -0
  71. package/dist/tailwind.config.js.map +1 -1
  72. package/dist/tailwind.config.ts +25 -0
  73. package/dist/{utils → util}/EventEmitterMixin.d.ts +4 -1
  74. package/dist/util/EventEmitterMixin.d.ts.map +1 -0
  75. package/dist/util/EventEmitterMixin.js.map +1 -0
  76. package/dist/util/ProgressMixin.d.ts +52 -0
  77. package/dist/util/ProgressMixin.d.ts.map +1 -0
  78. package/dist/util/ProgressMixin.js +190 -0
  79. package/dist/util/ProgressMixin.js.map +1 -0
  80. package/dist/util/ReadyMixin.d.ts.map +1 -0
  81. package/dist/util/ReadyMixin.js.map +1 -0
  82. package/dist/util/aria.d.ts +3 -0
  83. package/dist/util/aria.d.ts.map +1 -0
  84. package/dist/util/aria.js +44 -0
  85. package/dist/util/aria.js.map +1 -0
  86. package/dist/util/svg.d.ts +9 -0
  87. package/dist/util/svg.d.ts.map +1 -1
  88. package/dist/util/svg.js +22 -0
  89. package/dist/util/svg.js.map +1 -1
  90. package/dist/util/throttle.d.ts +4 -0
  91. package/dist/util/throttle.d.ts.map +1 -0
  92. package/dist/util/throttle.js +30 -0
  93. package/dist/util/throttle.js.map +1 -0
  94. package/package.json +2 -2
  95. package/dist/storybook/assets/Button.stories-Cwdvbnu1.js +0 -63
  96. package/dist/storybook/assets/Heading.stories-C0ji1wRG.js +0 -3
  97. package/dist/storybook/assets/Icon.stories-DeEHMd7f.js +0 -28543
  98. package/dist/storybook/assets/Loader.stories-NxZ0SGA0.js +0 -3
  99. package/dist/storybook/assets/ScrollShadow.stories-1W8nsrPe.js +0 -17
  100. package/dist/storybook/assets/formatter-OMEEQ6HG-wqmAyL2n.js +0 -1
  101. package/dist/storybook/assets/iframe-BEH5EoNR.css +0 -1
  102. package/dist/utils/EventEmitterMixin.d.ts.map +0 -1
  103. package/dist/utils/EventEmitterMixin.js.map +0 -1
  104. package/dist/utils/ReadyMixin.d.ts.map +0 -1
  105. package/dist/utils/ReadyMixin.js.map +0 -1
  106. /package/dist/{utils → util}/EventEmitterMixin.js +0 -0
  107. /package/dist/{utils → util}/ReadyMixin.d.ts +0 -0
  108. /package/dist/{utils → util}/ReadyMixin.js +0 -0
@@ -0,0 +1,303 @@
1
+ import{x as u}from"./iframe-Z4F0Cgki.js";import"./preload-helper-PPVm8Dsz.js";function v(e,t){if(e<=0)return t;let n,o=0;return function(){if(n)return;const r=Date.now(),s=e-r+o;s<=0?(o=r,t.apply(this,[...arguments])):n=setTimeout(()=>{o=r,n=void 0,t.apply(this,[...arguments])},s)}}const x={title:"Utilities/Throttle",tags:["autodocs"],parameters:{docs:{subtitle:"The `throttle` utility function limits how often a function can execute, ensuring it runs at most once per specified interval. Useful for high-frequency events like scroll, resize, or mousemove."},controls:{expanded:!0}},argTypes:{interval:{control:{type:"number",min:0,max:2e3,step:50},description:"Throttle interval in milliseconds"}},args:{interval:200}},a={render:e=>{const t=`throttle-${Math.random().toString(36).substring(2,9)}`;let n=0,o=0;const r=()=>{const h=document.getElementById(`${t}-normal-count`),m=document.getElementById(`${t}-throttled-count`);h&&(h.textContent=String(n)),m&&(m.textContent=String(o))},s=v(e.interval,()=>{o++,r()}),d=()=>{n++,r()},l=()=>{d(),s()};return u`
2
+ <div class="space-y-4">
3
+ <div class="text-base">
4
+ <p class="mb-2">
5
+ Move your mouse over the box below to trigger events. The throttled handler executes at most once per
6
+ ${e.interval}ms.
7
+ </p>
8
+ </div>
9
+
10
+ <div @mousemove=${l} class="cursor-pointer rounded border-2 border-gray-300 bg-gray-50 p-8">
11
+ <div class="space-y-2 text-center">
12
+ <div class="text-sm text-gray-600">Hover over this area</div>
13
+ <div class="mt-4 flex justify-around">
14
+ <div>
15
+ <div class="text-xs text-gray-500">Normal calls</div>
16
+ <div id="${t}-normal-count" class="text-2xl font-bold text-gray-900">0</div>
17
+ </div>
18
+ <div>
19
+ <div class="text-xs text-gray-500">Throttled calls (${e.interval}ms)</div>
20
+ <div id="${t}-throttled-count" class="text-primary-600 text-2xl font-bold">0</div>
21
+ </div>
22
+ </div>
23
+ </div>
24
+ </div>
25
+
26
+ <button
27
+ @click=${()=>{n=0,o=0,r()}}
28
+ class="rounded bg-gray-200 px-4 py-2 hover:bg-gray-300"
29
+ >
30
+ Reset Counters
31
+ </button>
32
+ </div>
33
+ `},parameters:{docs:{description:{story:"Interactive example showing throttle in action. Move your mouse over the box to see how throttling reduces function calls."}}}},i={render:()=>{const e=`scroll-${Math.random().toString(36).substring(2,9)}`;let t=0,n=0;const o=()=>{const d=document.getElementById(`${e}-normal-count`),l=document.getElementById(`${e}-throttled-count`);d&&(d.textContent=String(t)),l&&(l.textContent=String(n))},r=v(300,()=>{n++,o()});return u`
34
+ <div class="space-y-4">
35
+ <div class="text-base">
36
+ <p class="mb-2">
37
+ Scroll the content below. The throttled handler executes at most once per 300ms, reducing unnecessary calls
38
+ during continuous scrolling.
39
+ </p>
40
+ </div>
41
+
42
+ <div @scroll=${()=>{t++,o(),r()}} class="h-64 overflow-y-scroll rounded border-2 border-gray-300 bg-gray-50 p-4">
43
+ <div class="space-y-4">
44
+ ${Array.from({length:50},(d,l)=>u` <div class="rounded border bg-white p-4">Item ${l+1}</div> `)}
45
+ </div>
46
+ </div>
47
+
48
+ <div class="flex justify-around">
49
+ <div>
50
+ <div class="text-xs text-gray-500">Normal scroll events</div>
51
+ <div id="${e}-normal-count" class="text-2xl font-bold text-gray-900">0</div>
52
+ </div>
53
+ <div>
54
+ <div class="text-xs text-gray-500">Throttled calls (300ms)</div>
55
+ <div id="${e}-throttled-count" class="text-primary-600 text-2xl font-bold">0</div>
56
+ </div>
57
+ </div>
58
+
59
+ <button
60
+ @click=${()=>{t=0,n=0,o()}}
61
+ class="rounded bg-gray-200 px-4 py-2 hover:bg-gray-300"
62
+ >
63
+ Reset Counters
64
+ </button>
65
+ </div>
66
+ `},parameters:{docs:{description:{story:"Example demonstrating throttle with scroll events. The throttled handler fires much less frequently than the raw scroll event."}}}},c={render:()=>u`
67
+ <div class="space-y-4 text-sm">
68
+ <div>
69
+ <h3 class="mb-2 font-bold">Basic Usage</h3>
70
+ <pre
71
+ class="overflow-x-auto rounded bg-gray-900 p-4 text-gray-100"
72
+ ><code>import { throttle } from '@brightspot/ui/dist/util/throttle.js'
73
+
74
+ const handleScroll = throttle(200, () => {
75
+ console.log('Scroll handler - max once per 200ms')
76
+ })
77
+
78
+ window.addEventListener('scroll', handleScroll)</code></pre>
79
+ </div>
80
+
81
+ <div>
82
+ <h3 class="mb-2 font-bold">Common Use Cases</h3>
83
+ <ul class="list-inside list-disc space-y-1 text-gray-700">
84
+ <li>Scroll event handlers to update UI elements</li>
85
+ <li>Window resize handlers for responsive layouts</li>
86
+ <li>Mousemove handlers for drag operations</li>
87
+ <li>Input event handlers for search-as-you-type</li>
88
+ <li>API calls triggered by user interactions</li>
89
+ </ul>
90
+ </div>
91
+
92
+ <div>
93
+ <h3 class="mb-2 font-bold">Parameters</h3>
94
+ <ul class="space-y-2">
95
+ <li>
96
+ <code class="rounded bg-gray-200 px-1">interval</code> (number): The minimum time in milliseconds between
97
+ function executions
98
+ </li>
99
+ <li><code class="rounded bg-gray-200 px-1">fn</code> (function): The function to throttle</li>
100
+ </ul>
101
+ </div>
102
+
103
+ <div>
104
+ <h3 class="mb-2 font-bold">Returns</h3>
105
+ <p class="text-gray-700">
106
+ A throttled version of the input function that will execute at most once per interval, preserving the original
107
+ function's
108
+ <code class="rounded bg-gray-200 px-1">this</code> context and arguments.
109
+ </p>
110
+ </div>
111
+ </div>
112
+ `,parameters:{docs:{description:{story:"Code examples and documentation for using the throttle utility."}}}};a.parameters={...a.parameters,docs:{...a.parameters?.docs,source:{originalSource:`{
113
+ render: args => {
114
+ const instanceId = \`throttle-\${Math.random().toString(36).substring(2, 9)}\`;
115
+ let normalCount = 0;
116
+ let throttledCount = 0;
117
+ const updateCounts = () => {
118
+ const normalEl = document.getElementById(\`\${instanceId}-normal-count\`);
119
+ const throttledEl = document.getElementById(\`\${instanceId}-throttled-count\`);
120
+ if (normalEl) normalEl.textContent = String(normalCount);
121
+ if (throttledEl) throttledEl.textContent = String(throttledCount);
122
+ };
123
+ const handleThrottled = throttle(args.interval, () => {
124
+ throttledCount++;
125
+ updateCounts();
126
+ });
127
+ const handleNormal = () => {
128
+ normalCount++;
129
+ updateCounts();
130
+ };
131
+ const handleEvent = () => {
132
+ handleNormal();
133
+ handleThrottled();
134
+ };
135
+ return html\`
136
+ <div class="space-y-4">
137
+ <div class="text-base">
138
+ <p class="mb-2">
139
+ Move your mouse over the box below to trigger events. The throttled handler executes at most once per
140
+ \${args.interval}ms.
141
+ </p>
142
+ </div>
143
+
144
+ <div @mousemove=\${handleEvent} class="cursor-pointer rounded border-2 border-gray-300 bg-gray-50 p-8">
145
+ <div class="space-y-2 text-center">
146
+ <div class="text-sm text-gray-600">Hover over this area</div>
147
+ <div class="mt-4 flex justify-around">
148
+ <div>
149
+ <div class="text-xs text-gray-500">Normal calls</div>
150
+ <div id="\${instanceId}-normal-count" class="text-2xl font-bold text-gray-900">0</div>
151
+ </div>
152
+ <div>
153
+ <div class="text-xs text-gray-500">Throttled calls (\${args.interval}ms)</div>
154
+ <div id="\${instanceId}-throttled-count" class="text-primary-600 text-2xl font-bold">0</div>
155
+ </div>
156
+ </div>
157
+ </div>
158
+ </div>
159
+
160
+ <button
161
+ @click=\${() => {
162
+ normalCount = 0;
163
+ throttledCount = 0;
164
+ updateCounts();
165
+ }}
166
+ class="rounded bg-gray-200 px-4 py-2 hover:bg-gray-300"
167
+ >
168
+ Reset Counters
169
+ </button>
170
+ </div>
171
+ \`;
172
+ },
173
+ parameters: {
174
+ docs: {
175
+ description: {
176
+ story: \`Interactive example showing throttle in action. Move your mouse over the box to see how throttling reduces function calls.\`
177
+ }
178
+ }
179
+ }
180
+ }`,...a.parameters?.docs?.source}}};i.parameters={...i.parameters,docs:{...i.parameters?.docs,source:{originalSource:`{
181
+ render: () => {
182
+ const instanceId = \`scroll-\${Math.random().toString(36).substring(2, 9)}\`;
183
+ let scrollCount = 0;
184
+ let throttledScrollCount = 0;
185
+ const updateScrollCounts = () => {
186
+ const normalEl = document.getElementById(\`\${instanceId}-normal-count\`);
187
+ const throttledEl = document.getElementById(\`\${instanceId}-throttled-count\`);
188
+ if (normalEl) normalEl.textContent = String(scrollCount);
189
+ if (throttledEl) throttledEl.textContent = String(throttledScrollCount);
190
+ };
191
+ const handleThrottledScroll = throttle(300, () => {
192
+ throttledScrollCount++;
193
+ updateScrollCounts();
194
+ });
195
+ const handleScroll = () => {
196
+ scrollCount++;
197
+ updateScrollCounts();
198
+ handleThrottledScroll();
199
+ };
200
+ return html\`
201
+ <div class="space-y-4">
202
+ <div class="text-base">
203
+ <p class="mb-2">
204
+ Scroll the content below. The throttled handler executes at most once per 300ms, reducing unnecessary calls
205
+ during continuous scrolling.
206
+ </p>
207
+ </div>
208
+
209
+ <div @scroll=\${handleScroll} class="h-64 overflow-y-scroll rounded border-2 border-gray-300 bg-gray-50 p-4">
210
+ <div class="space-y-4">
211
+ \${Array.from({
212
+ length: 50
213
+ }, (_, i) => html\` <div class="rounded border bg-white p-4">Item \${i + 1}</div> \`)}
214
+ </div>
215
+ </div>
216
+
217
+ <div class="flex justify-around">
218
+ <div>
219
+ <div class="text-xs text-gray-500">Normal scroll events</div>
220
+ <div id="\${instanceId}-normal-count" class="text-2xl font-bold text-gray-900">0</div>
221
+ </div>
222
+ <div>
223
+ <div class="text-xs text-gray-500">Throttled calls (300ms)</div>
224
+ <div id="\${instanceId}-throttled-count" class="text-primary-600 text-2xl font-bold">0</div>
225
+ </div>
226
+ </div>
227
+
228
+ <button
229
+ @click=\${() => {
230
+ scrollCount = 0;
231
+ throttledScrollCount = 0;
232
+ updateScrollCounts();
233
+ }}
234
+ class="rounded bg-gray-200 px-4 py-2 hover:bg-gray-300"
235
+ >
236
+ Reset Counters
237
+ </button>
238
+ </div>
239
+ \`;
240
+ },
241
+ parameters: {
242
+ docs: {
243
+ description: {
244
+ story: \`Example demonstrating throttle with scroll events. The throttled handler fires much less frequently than the raw scroll event.\`
245
+ }
246
+ }
247
+ }
248
+ }`,...i.parameters?.docs?.source}}};c.parameters={...c.parameters,docs:{...c.parameters?.docs,source:{originalSource:`{
249
+ render: () => html\`
250
+ <div class="space-y-4 text-sm">
251
+ <div>
252
+ <h3 class="mb-2 font-bold">Basic Usage</h3>
253
+ <pre
254
+ class="overflow-x-auto rounded bg-gray-900 p-4 text-gray-100"
255
+ ><code>import { throttle } from '@brightspot/ui/dist/util/throttle.js'
256
+
257
+ const handleScroll = throttle(200, () => {
258
+ console.log('Scroll handler - max once per 200ms')
259
+ })
260
+
261
+ window.addEventListener('scroll', handleScroll)</code></pre>
262
+ </div>
263
+
264
+ <div>
265
+ <h3 class="mb-2 font-bold">Common Use Cases</h3>
266
+ <ul class="list-inside list-disc space-y-1 text-gray-700">
267
+ <li>Scroll event handlers to update UI elements</li>
268
+ <li>Window resize handlers for responsive layouts</li>
269
+ <li>Mousemove handlers for drag operations</li>
270
+ <li>Input event handlers for search-as-you-type</li>
271
+ <li>API calls triggered by user interactions</li>
272
+ </ul>
273
+ </div>
274
+
275
+ <div>
276
+ <h3 class="mb-2 font-bold">Parameters</h3>
277
+ <ul class="space-y-2">
278
+ <li>
279
+ <code class="rounded bg-gray-200 px-1">interval</code> (number): The minimum time in milliseconds between
280
+ function executions
281
+ </li>
282
+ <li><code class="rounded bg-gray-200 px-1">fn</code> (function): The function to throttle</li>
283
+ </ul>
284
+ </div>
285
+
286
+ <div>
287
+ <h3 class="mb-2 font-bold">Returns</h3>
288
+ <p class="text-gray-700">
289
+ A throttled version of the input function that will execute at most once per interval, preserving the original
290
+ function's
291
+ <code class="rounded bg-gray-200 px-1">this</code> context and arguments.
292
+ </p>
293
+ </div>
294
+ </div>
295
+ \`,
296
+ parameters: {
297
+ docs: {
298
+ description: {
299
+ story: \`Code examples and documentation for using the throttle utility.\`
300
+ }
301
+ }
302
+ }
303
+ }`,...c.parameters?.docs?.source}}};const y=["Interactive","ScrollExample","UsageExample"];export{a as Interactive,i as ScrollExample,c as UsageExample,y as __namedExportsOrder,x as default};