@brightspot/ui 1.11.0 → 3.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.
- package/dist/components/action-bar/ActionBar.d.ts +1 -1
- package/dist/components/action-bar/ActionBar.js +7 -7
- package/dist/components/action-bar/ActionBar.js.map +1 -1
- package/dist/components/action-bar/ActionItem.d.ts +5 -5
- package/dist/components/action-bar/ActionItem.d.ts.map +1 -1
- package/dist/components/action-bar/ActionItem.js +13 -13
- package/dist/components/action-bar/ActionItem.js.map +1 -1
- package/dist/components/avatar/AvatarGroup.d.ts +3 -0
- package/dist/components/avatar/AvatarGroup.d.ts.map +1 -1
- package/dist/components/avatar/AvatarGroup.js +3 -0
- package/dist/components/avatar/AvatarGroup.js.map +1 -1
- package/dist/components/badge/Badge.d.ts +3 -1
- package/dist/components/badge/Badge.d.ts.map +1 -1
- package/dist/components/badge/Badge.js +2 -0
- package/dist/components/badge/Badge.js.map +1 -1
- package/dist/components/button-group/ButtonGroup.d.ts +138 -0
- package/dist/components/button-group/ButtonGroup.d.ts.map +1 -0
- package/dist/components/button-group/ButtonGroup.js +436 -0
- package/dist/components/button-group/ButtonGroup.js.map +1 -0
- package/dist/components/checkbox/Checkbox.d.ts +107 -0
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/Checkbox.js +224 -0
- package/dist/components/checkbox/Checkbox.js.map +1 -0
- package/dist/components/circular-progress/CircularProgress.d.ts +2 -2
- package/dist/components/circular-progress/CircularProgress.js +2 -2
- package/dist/components/copy-to-clipboard/CopyToClipboard.d.ts +7 -2
- package/dist/components/copy-to-clipboard/CopyToClipboard.d.ts.map +1 -1
- package/dist/components/copy-to-clipboard/CopyToClipboard.js +10 -5
- package/dist/components/copy-to-clipboard/CopyToClipboard.js.map +1 -1
- package/dist/components/dropdown/Dropdown.d.ts +5 -5
- package/dist/components/dropdown/Dropdown.d.ts.map +1 -1
- package/dist/components/dropdown/Dropdown.js +11 -16
- package/dist/components/dropdown/Dropdown.js.map +1 -1
- package/dist/components/dropdown/DropdownItem.d.ts +14 -6
- package/dist/components/dropdown/DropdownItem.d.ts.map +1 -1
- package/dist/components/dropdown/DropdownItem.js +21 -15
- package/dist/components/dropdown/DropdownItem.js.map +1 -1
- package/dist/components/dropdown/DropdownMenu.d.ts +4 -4
- package/dist/components/dropdown/DropdownMenu.d.ts.map +1 -1
- package/dist/components/dropdown/DropdownMenu.js +6 -6
- package/dist/components/dropdown/DropdownMenu.js.map +1 -1
- package/dist/components/empty-state/EmptyState.css +4 -0
- package/dist/components/empty-state/EmptyState.d.ts +103 -0
- package/dist/components/empty-state/EmptyState.d.ts.map +1 -0
- package/dist/components/empty-state/EmptyState.js +209 -0
- package/dist/components/empty-state/EmptyState.js.map +1 -0
- package/dist/components/icon/Icon.d.ts +23 -10
- package/dist/components/icon/Icon.d.ts.map +1 -1
- package/dist/components/icon/Icon.js +40 -9
- package/dist/components/icon/Icon.js.map +1 -1
- package/dist/components/icon-button/IconButton.d.ts +7 -21
- package/dist/components/icon-button/IconButton.d.ts.map +1 -1
- package/dist/components/icon-button/IconButton.js +12 -18
- package/dist/components/icon-button/IconButton.js.map +1 -1
- package/dist/components/linear-progress/LinearProgress.d.ts +2 -2
- package/dist/components/linear-progress/LinearProgress.js +2 -2
- package/dist/components/pagination/Pagination.js +10 -10
- package/dist/components/popover/Popover.d.ts +6 -0
- package/dist/components/popover/Popover.d.ts.map +1 -1
- package/dist/components/popover/Popover.js +6 -0
- package/dist/components/popover/Popover.js.map +1 -1
- package/dist/components/switch/Switch.d.ts +5 -1
- package/dist/components/switch/Switch.d.ts.map +1 -1
- package/dist/components/switch/Switch.js +10 -6
- package/dist/components/switch/Switch.js.map +1 -1
- package/dist/components/tabs/Tab.d.ts +4 -4
- package/dist/components/tabs/Tab.d.ts.map +1 -1
- package/dist/components/tabs/Tab.js +5 -5
- package/dist/components/tabs/Tab.js.map +1 -1
- package/dist/components/tabs/Tabs.d.ts +3 -3
- package/dist/components/tabs/Tabs.d.ts.map +1 -1
- package/dist/components/tabs/Tabs.js +20 -20
- package/dist/components/tabs/Tabs.js.map +1 -1
- package/dist/components/upload/Upload.d.ts +157 -0
- package/dist/components/upload/Upload.d.ts.map +1 -0
- package/dist/components/upload/Upload.js +538 -0
- package/dist/components/upload/Upload.js.map +1 -0
- package/dist/components/upload/UploadItem.d.ts +73 -0
- package/dist/components/upload/UploadItem.d.ts.map +1 -0
- package/dist/components/upload/UploadItem.js +180 -0
- package/dist/components/upload/UploadItem.js.map +1 -0
- package/dist/components/widget/Widget.d.ts +1 -6
- package/dist/components/widget/Widget.d.ts.map +1 -1
- package/dist/components/widget/Widget.js +1 -6
- package/dist/components/widget/Widget.js.map +1 -1
- package/dist/custom-elements.json +7499 -2087
- package/dist/storybook/assets/{ActionBar.stories--nAeDC-G.js → ActionBar.stories-DRIVI-W2.js} +65 -65
- package/dist/storybook/assets/{ActionItem.stories-BHrGjk-P.js → ActionItem.stories-5qlgxYNB.js} +41 -41
- package/dist/storybook/assets/{Avatar.stories-Da-mRj6_.js → Avatar.stories-B3VkhRhP.js} +2 -2
- package/dist/storybook/assets/{AvatarGroup.stories-BQlaC_yl.js → AvatarGroup.stories-DOfim2NY.js} +5 -5
- package/dist/storybook/assets/{Badge.stories-DnVnOrnF.js → Badge.stories-B04VNAcc.js} +2 -2
- package/dist/storybook/assets/{Button-CFLAI1H9.js → Button-CILTcGRT.js} +1 -1
- package/dist/storybook/assets/{Button.stories-DxaBOjwv.js → Button.stories-CzWAltrX.js} +1 -1
- package/dist/storybook/assets/ButtonGroup.stories-1uAJf79o.js +588 -0
- package/dist/storybook/assets/{Celebrate.stories-CuMm15Nr.js → Celebrate.stories-BEqj0VnW.js} +7 -7
- package/dist/storybook/assets/Checkbox.stories-DXAGFS0M.js +141 -0
- package/dist/storybook/assets/{CircularProgress.stories-DRN8Mtvj.js → CircularProgress.stories-D4rftw22.js} +7 -7
- package/dist/storybook/assets/{ClipboardMixin.stories-DR7Ou2Av.js → ClipboardMixin.stories-z2n2HWt1.js} +31 -28
- package/dist/storybook/assets/{Color-6BZIO3FS-Die62Y0Z.js → Color-6BZIO3FS-C6KyMgZz.js} +1 -1
- package/dist/storybook/assets/{Colors.stories-bIq_ssbI.js → Colors.stories-CX-Ny3B_.js} +1 -1
- package/dist/storybook/assets/{CombinedEffects.stories-CtKzOUZn.js → CombinedEffects.stories-BkqtiVHp.js} +33 -33
- package/dist/storybook/assets/{ComponentStatesMixin-DMLCk9fE.js → ComponentStatesMixin-DLd0feFg.js} +1 -1
- package/dist/storybook/assets/{ComponentStatesMixin.stories-D8UI9o-d.js → ComponentStatesMixin.stories-D6Yc5Jgl.js} +3 -3
- package/dist/storybook/assets/{CopyToClipboard.stories-ti6CpJNp.js → CopyToClipboard.stories-B-omwDDJ.js} +16 -16
- package/dist/storybook/assets/{Debounce.stories-DzZUSvbk.js → Debounce.stories-B2vE5QIx.js} +9 -9
- package/dist/storybook/assets/{DocsRenderer-LL677BLK-CIRGv5IX.js → DocsRenderer-LL677BLK-DNUlRvMg.js} +3 -3
- package/dist/storybook/assets/{Dropdown.stories-Lt4cY0Re.js → Dropdown.stories-_bx4WDLr.js} +60 -60
- package/dist/storybook/assets/EmptyState.stories-CGMbmo77.js +318 -0
- package/dist/storybook/assets/{Events.stories-B1ddcgpT.js → Events.stories-CkQYKcoZ.js} +1 -1
- package/dist/storybook/assets/{Heading.stories-DI4w61cf.js → Heading.stories-BU5Do_od.js} +1 -1
- package/dist/storybook/assets/{HueRipple.stories-DjhoxxEw.js → HueRipple.stories-Di2zmxo3.js} +11 -11
- package/dist/storybook/assets/Icon.stories-Dk4ZXhhJ.js +441 -0
- package/dist/storybook/assets/{IconButton.stories-KjN28hfc.js → IconButton.stories-BSCiXPXa.js} +126 -146
- package/dist/storybook/assets/{LinearProgress.stories-DcIpdz6R.js → LinearProgress.stories-BGxPZuni.js} +7 -7
- package/dist/storybook/assets/{Pagination.stories-BBkLEwoP.js → Pagination.stories-z3Zq8b4f.js} +6 -6
- package/dist/storybook/assets/{Popover.stories-DLv48c2h.js → Popover.stories-C9GxWcax.js} +33 -62
- package/dist/storybook/assets/ReadyMixin-CQw8N6P9.js +1 -0
- package/dist/storybook/assets/{RovingTabindexMixin.stories-BWaFx9mu.js → RovingTabindexMixin.stories-ByxLBi6m.js} +6 -6
- package/dist/storybook/assets/{Rtc.stories-Ve7Bwo_l.js → Rtc.stories-DQJlCXWR.js} +3 -3
- package/dist/storybook/assets/{ScrollShadow.stories-C6XmrRLm.js → ScrollShadow.stories-gjTIAbUA.js} +2 -2
- package/dist/storybook/assets/{Switch.stories-Cf8WM1LG.js → Switch.stories-BEeqPZiP.js} +21 -21
- package/dist/storybook/assets/{Tab.stories-CEtdEtOx.js → Tab.stories-DpB3I-WZ.js} +33 -33
- package/dist/storybook/assets/{Tabs.stories-CIAO1bPO.js → Tabs.stories-C6mG6Xi7.js} +2 -2
- package/dist/storybook/assets/{Throttle.stories-BqxVIb-r.js → Throttle.stories-x9tpGeQh.js} +10 -10
- package/dist/storybook/assets/{Tooltip.stories-B6fw6875.js → Tooltip.stories-CqcLqdmc.js} +2 -2
- package/dist/storybook/assets/Upload.stories-CMaAbCSH.js +447 -0
- package/dist/storybook/assets/UploadItem.stories-GB98L3JQ.js +167 -0
- package/dist/storybook/assets/{Welcome.stories-CfJtSM19.js → Welcome.stories-6h9cUZ7v.js} +1 -1
- package/dist/storybook/assets/{Widget.stories-CiOho7lO.js → Widget.stories-DiA1PR6Y.js} +13 -13
- package/dist/storybook/assets/{WithTooltip-65CFNBJE-PGcopp73.js → WithTooltip-65CFNBJE-DTsHhBb_.js} +1 -1
- package/dist/storybook/assets/{blocks-dP2DwISI.js → blocks-IXdn9TGW.js} +5 -5
- package/dist/storybook/assets/{formatter-EIJCOSYU-CZSAC3tg.js → formatter-EIJCOSYU-Cum4J6N4.js} +1 -1
- package/dist/storybook/assets/if-defined-CgfCxQoV.js +1 -0
- package/dist/storybook/assets/iframe-BgFj0b5u.css +1 -0
- package/dist/storybook/assets/{iframe-DloIUNZz.js → iframe-Sf9RHZFu.js} +191 -191
- package/dist/storybook/assets/{index-DKF0ypu5.js → index-D605PvQH.js} +1 -1
- package/dist/storybook/assets/{onFind-C0l4Gew0.js → onFind-C41m8c_a.js} +1 -1
- package/dist/storybook/assets/{onFind.stories-DOTt9puO.js → onFind.stories-MOTfGlJd.js} +53 -77
- package/dist/storybook/assets/{onRemove.stories-CQ9ZC5dm.js → onRemove.stories-DX58Bf6f.js} +6 -10
- package/dist/storybook/assets/{onVisible.stories-Cbj5_Vz0.js → onVisible.stories-NNFeFeD8.js} +3 -3
- package/dist/storybook/assets/{style-map-DLXysq3r.js → style-map-B99QiqCo.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-ED5Y7EFY-Bjjbl9ca.js → syntaxhighlighter-ED5Y7EFY-BqQ-o9mS.js} +1 -1
- package/dist/storybook/box-illustration.svg +51 -0
- package/dist/storybook/cloud-illustration.svg +49 -0
- package/dist/storybook/docs-illustration.svg +92 -0
- package/dist/storybook/iframe.html +2 -2
- package/dist/storybook/index.json +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/tailwind-plugin-badge.js +1 -1
- package/dist/tailwind-plugin-badge.ts +1 -1
- package/dist/tailwind-plugin-button-group.d.ts +2 -0
- package/dist/tailwind-plugin-button-group.d.ts.map +1 -0
- package/dist/tailwind-plugin-button-group.js +215 -0
- package/dist/tailwind-plugin-button-group.js.map +1 -0
- package/dist/tailwind-plugin-button-group.ts +238 -0
- package/dist/tailwind-plugin-button.js +1 -1
- package/dist/tailwind-plugin-button.ts +1 -1
- package/dist/tailwind-plugin-checkbox.d.ts +2 -0
- package/dist/tailwind-plugin-checkbox.d.ts.map +1 -0
- package/dist/tailwind-plugin-checkbox.js +246 -0
- package/dist/tailwind-plugin-checkbox.js.map +1 -0
- package/dist/tailwind-plugin-checkbox.ts +281 -0
- package/dist/tailwind-plugin-empty-state.d.ts +2 -0
- package/dist/tailwind-plugin-empty-state.d.ts.map +1 -0
- package/dist/tailwind-plugin-empty-state.js +113 -0
- package/dist/tailwind-plugin-empty-state.js.map +1 -0
- package/dist/tailwind-plugin-empty-state.ts +124 -0
- package/dist/tailwind-plugin-icon.js +122 -18
- package/dist/tailwind-plugin-icon.js.map +1 -1
- package/dist/tailwind-plugin-icon.ts +131 -18
- package/dist/tailwind-plugin-loader.js +3 -3
- package/dist/tailwind-plugin-loader.ts +3 -3
- package/dist/tailwind-plugin-tabs.js +7 -0
- package/dist/tailwind-plugin-tabs.js.map +1 -1
- package/dist/tailwind-plugin-tabs.ts +7 -0
- package/dist/tailwind-plugin-upload.d.ts +2 -0
- package/dist/tailwind-plugin-upload.d.ts.map +1 -0
- package/dist/tailwind-plugin-upload.js +322 -0
- package/dist/tailwind-plugin-upload.js.map +1 -0
- package/dist/tailwind-plugin-upload.ts +362 -0
- package/dist/tailwind.config.d.ts.map +1 -1
- package/dist/tailwind.config.js +1 -0
- package/dist/tailwind.config.js.map +1 -1
- package/dist/tailwind.config.ts +1 -0
- package/dist/util/ClipboardMixin.d.ts +7 -2
- package/dist/util/ClipboardMixin.d.ts.map +1 -1
- package/dist/util/ClipboardMixin.js +15 -13
- package/dist/util/ClipboardMixin.js.map +1 -1
- package/dist/util/ComponentStatesMixin.d.ts +2 -1
- package/dist/util/ComponentStatesMixin.d.ts.map +1 -1
- package/dist/util/ComponentStatesMixin.js +4 -0
- package/dist/util/ComponentStatesMixin.js.map +1 -1
- package/dist/util/EventEmitterMixin.d.ts +42 -4
- package/dist/util/EventEmitterMixin.d.ts.map +1 -1
- package/dist/util/EventEmitterMixin.js +5 -2
- package/dist/util/EventEmitterMixin.js.map +1 -1
- package/dist/util/ProgressMixin.d.ts +9 -2
- package/dist/util/ProgressMixin.d.ts.map +1 -1
- package/dist/util/ProgressMixin.js +22 -18
- package/dist/util/ProgressMixin.js.map +1 -1
- package/dist/util/RovingTabindexMixin.d.ts +8 -0
- package/dist/util/RovingTabindexMixin.d.ts.map +1 -1
- package/dist/util/RovingTabindexMixin.js +8 -8
- package/dist/util/RovingTabindexMixin.js.map +1 -1
- package/dist/util/TetherLayout.d.ts.map +1 -1
- package/dist/util/TetherLayout.js +3 -0
- package/dist/util/TetherLayout.js.map +1 -1
- package/dist/util/TooltipMixin.d.ts.map +1 -1
- package/dist/util/TooltipMixin.js +5 -4
- package/dist/util/TooltipMixin.js.map +1 -1
- package/dist/util/upload.d.ts +53 -0
- package/dist/util/upload.d.ts.map +1 -0
- package/dist/util/upload.js +113 -0
- package/dist/util/upload.js.map +1 -0
- package/docs/components/ActionBar.md +6 -0
- package/docs/components/ActionItem.md +52 -27
- package/docs/components/Avatar.md +42 -12
- package/docs/components/AvatarGroup.md +4 -3
- package/docs/components/Badge.md +13 -1
- package/docs/components/ButtonGroup.md +91 -0
- package/docs/components/Checkbox.md +91 -0
- package/docs/components/CircularProgress.md +41 -12
- package/docs/components/CopyToClipboard.md +13 -11
- package/docs/components/Dropdown.md +44 -19
- package/docs/components/DropdownItem.md +39 -26
- package/docs/components/DropdownMenu.md +9 -9
- package/docs/components/EmptyState.md +75 -0
- package/docs/components/Icon.md +22 -14
- package/docs/components/IconButton.md +46 -21
- package/docs/components/LinearProgress.md +43 -4
- package/docs/components/Pagination.md +11 -10
- package/docs/components/Popover.md +16 -0
- package/docs/components/README.md +5 -0
- package/docs/components/Switch.md +21 -16
- package/docs/components/Tab.md +8 -2
- package/docs/components/Tabs.md +8 -0
- package/docs/components/Upload.md +112 -0
- package/docs/components/UploadItem.md +61 -0
- package/docs/components/Widget.md +12 -6
- package/package.json +4 -2
- package/dist/storybook/assets/Icon.stories-CpziAhae.js +0 -264
- package/dist/storybook/assets/ReadyMixin-Cw2Dfbu2.js +0 -1
- package/dist/storybook/assets/if-defined-B1RdczOE.js +0 -1
- package/dist/storybook/assets/iframe-bJgLXZKK.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e}from"./iframe-
|
|
1
|
+
import{R as e}from"./iframe-Sf9RHZFu.js";import"./preload-helper-PPVm8Dsz.js";const o={},c=e.createContext(o);function u(n){const t=e.useContext(c);return e.useMemo(function(){return typeof n=="function"?n(t):{...t,...n}},[t,n])}function r(n){let t;return n.disableParentContext?t=typeof n.components=="function"?n.components(o):n.components||o:t=u(n.components),e.createElement(c.Provider,{value:t},n.children)}export{r as MDXProvider,u as useMDXComponents};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as W}from"./iframe-
|
|
1
|
+
import{Q as W}from"./iframe-Sf9RHZFu.js";var w={exports:{}},K=w.exports,I;function V(){return I||(I=1,(function(a){(function(t,e){a.exports?a.exports=e():t.log=e()})(K,function(){var t=function(){},e="undefined",s=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],n={},c=null;function k(i,u){var r=i[u];if(typeof r.bind=="function")return r.bind(i);try{return Function.prototype.bind.call(r,i)}catch{return function(){return Function.prototype.apply.apply(r,[i,arguments])}}}function U(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function P(i){return i==="debug"&&(i="log"),typeof console===e?!1:i==="trace"&&s?U:console[i]!==void 0?k(console,i):console.log!==void 0?k(console,"log"):t}function v(){for(var i=this.getLevel(),u=0;u<o.length;u++){var r=o[u];this[r]=u<i?t:this.methodFactory(r,i,this.name)}if(this.log=this.debug,typeof console===e&&i<this.levels.SILENT)return"No console available for logging"}function q(i){return function(){typeof console!==e&&(v.call(this),this[i].apply(this,arguments))}}function z(i,u,r){return P(i)||q.apply(this,arguments)}function T(i,u){var r=this,b,E,h,g="loglevel";typeof i=="string"?g+=":"+i:typeof i=="symbol"&&(g=void 0);function D(l){var f=(o[l]||"silent").toUpperCase();if(!(typeof window===e||!g)){try{window.localStorage[g]=f;return}catch{}try{window.document.cookie=encodeURIComponent(g)+"="+f+";"}catch{}}}function x(){var l;if(!(typeof window===e||!g)){try{l=window.localStorage[g]}catch{}if(typeof l===e)try{var f=window.document.cookie,m=encodeURIComponent(g),C=f.indexOf(m+"=");C!==-1&&(l=/^([^;]+)/.exec(f.slice(C+m.length+1))[1])}catch{}return r.levels[l]===void 0&&(l=void 0),l}}function $(){if(!(typeof window===e||!g)){try{window.localStorage.removeItem(g)}catch{}try{window.document.cookie=encodeURIComponent(g)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function y(l){var f=l;if(typeof f=="string"&&r.levels[f.toUpperCase()]!==void 0&&(f=r.levels[f.toUpperCase()]),typeof f=="number"&&f>=0&&f<=r.levels.SILENT)return f;throw new TypeError("log.setLevel() called with invalid level: "+l)}r.name=i,r.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},r.methodFactory=u||z,r.getLevel=function(){return h??E??b},r.setLevel=function(l,f){return h=y(l),f!==!1&&D(h),v.call(r)},r.setDefaultLevel=function(l){E=y(l),x()||r.setLevel(l,!1)},r.resetLevel=function(){h=null,$(),v.call(r)},r.enableAll=function(l){r.setLevel(r.levels.TRACE,l)},r.disableAll=function(l){r.setLevel(r.levels.SILENT,l)},r.rebuild=function(){if(c!==r&&(b=y(c.getLevel())),v.call(r),c===r)for(var l in n)n[l].rebuild()},b=y(c?c.getLevel():"WARN");var F=x();F!=null&&(h=y(F)),v.call(r)}c=new T,c.getLogger=function(u){if(typeof u!="symbol"&&typeof u!="string"||u==="")throw new TypeError("You must supply a name when creating a logger.");var r=n[u];return r||(r=n[u]=new T(u,c.methodFactory)),r};var _=typeof window!==e?window.log:void 0;return c.noConflict=function(){return typeof window!==e&&window.log===c&&(window.log=_),c},c.getLoggers=function(){return n},c.default=c,c})})(w)),w.exports}var Y=V();const G=W(Y),R=Symbol.for("brightspot.onFind");let p;function d(){return p||(p=globalThis[R],p||(p={calledIndex:0,callbacks:[],blacklist:[],triggerPaused:!1,triggerOnResume:!1,triggerAll:!1,triggerElements:[],triggerFrame:0,initialized:!1},globalThis[R]=p),p)}class J{#r;#e;#t;#i;#n;constructor(t,e,s){this.#r=t,this.#e=`data-ofc${d().calledIndex++}`,Array.isArray(e)||(e=[e]),this.#t=e.map(e.some(n=>n.indexOf(",")>-1)?n=>n:n=>`${n}:not([${this.#e}])`).join(","),this.#i=s;const o=e.map(n=>n.trim()).filter(n=>n.indexOf(" ")<0&&n.indexOf(",")<0);o.length===e.length&&(this.#n=o)}addTriggerElements(t,e){if(this.#r.contains(e)){e.matches(this.#t)&&t.push(e);for(const s of e.querySelectorAll(this.#t))t.push(s)}}trigger(t){if(document.readyState!=="loading")if(this.#n&&Array.isArray(t))for(const e of t)this.#n.some(s=>e.matches(s))&&this.#o(e);else for(const e of this.#r.querySelectorAll(this.#t))this.#o(e)}#o(t){if(!N(t)&&!t.hasAttribute(this.#e)){t.setAttribute(this.#e,"");try{this.#i(t)}catch(e){G.error("Failed callback!",t,e)}}}}function N(a){if(!(a instanceof Element))return!1;const{blacklist:t}=d();return t.length>0&&t.some(e=>a.closest(e)!==null)}const S=Array.prototype.every,O=a=>a.nodeType===Node.TEXT_NODE;function L(a){const t=d();if(t.triggerPaused){t.triggerOnResume=!0;return}const e=Array.isArray(a),s=[];if(e){for(const o of a){const n=o.target;if(!N(n))switch(o.type){case"attributes":o.oldValue!==n.getAttribute(o.attributeName)&&s.push(o);break;case"childList":(!S.call(o.addedNodes,O)||!S.call(o.removedNodes,O))&&s.push(o);break}}if(s.length===0)return}if(s.length>500&&(t.triggerAll=!0),!t.triggerAll)if(e)for(const o of s){const n=o.target;switch(o.type){case"attributes":t.triggerElements.push(n);break;case"childList":for(const c of t.callbacks)c.addTriggerElements(t.triggerElements,n);break}}else t.triggerAll=!0;(t.triggerAll||t.triggerElements.length>0)&&!t.triggerFrame&&(t.triggerFrame=window.requestAnimationFrame(()=>{const o=t.triggerAll?void 0:t.triggerElements;t.triggerAll=!1,t.triggerElements=[],t.triggerFrame=0,t.callbacks.forEach(n=>n.trigger(o))}))}function M(){L(),new MutationObserver(L).observe(document,{attributes:!0,attributeFilter:["class","data-bsp-autosubmit","data-chart-type","data-code-type","data-internal-name","data-tab","name","rel","target"],attributeOldValue:!0,childList:!0,subtree:!0})}function Q(){const a=d();a.initialized||(a.initialized=!0,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",M):M())}function A(a,t,e){Q();let s,o;typeof e<"u"?(s=a,o=t):(s=document,o=a,e=t);const n=new J(s,o,e);n.trigger(),d().callbacks.push(n)}A.triggerCallbacks=L;A.pause=()=>{d().triggerPaused=!0};A.resume=()=>{const a=d();a.triggerPaused=!1,a.triggerOnResume&&(a.triggerOnResume=!1,setTimeout(L,100))};A.ignore=(...a)=>{const{blacklist:t}=d();for(const e of a){try{document.querySelector(e)}catch{continue}t.includes(e)||t.push(e)}};export{G as l,A as o};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as
|
|
1
|
+
import{x as f}from"./iframe-Sf9RHZFu.js";import{l as P,o as b}from"./onFind-C41m8c_a.js";import"./preload-helper-PPVm8Dsz.js";const F=Symbol.for("brightspot.onFind");let y;function v(){return y||(y=globalThis[F],y||(y={calledIndex:0,callbacks:[],blacklist:[],triggerPaused:!1,triggerOnResume:!1,triggerAll:!1,triggerElements:[],triggerFrame:0,initialized:!1},globalThis[F]=y),y)}class O{#n;#e;#t;#a;#s;constructor(t,e,n){this.#n=t,this.#e=`data-ofc${v().calledIndex++}`,Array.isArray(e)||(e=[e]),this.#t=e.map(e.some(o=>o.indexOf(",")>-1)?o=>o:o=>`${o}:not([${this.#e}])`).join(","),this.#a=n;const a=e.map(o=>o.trim()).filter(o=>o.indexOf(" ")<0&&o.indexOf(",")<0);a.length===e.length&&(this.#s=a)}addTriggerElements(t,e){if(this.#n.contains(e)){e.matches(this.#t)&&t.push(e);for(const n of e.querySelectorAll(this.#t))t.push(n)}}trigger(t){if(document.readyState!=="loading")if(this.#s&&Array.isArray(t))for(const e of t)this.#s.some(n=>e.matches(n))&&this.#o(e);else for(const e of this.#n.querySelectorAll(this.#t))this.#o(e)}#o(t){if(!H(t)&&!t.hasAttribute(this.#e)){t.setAttribute(this.#e,"");try{this.#a(t)}catch(e){P.error("Failed callback!",t,e)}}}}function H(s){if(!(s instanceof Element))return!1;const{blacklist:t}=v();return t.length>0&&t.some(e=>s.closest(e)!==null)}const $=Array.prototype.every,S=s=>s.nodeType===Node.TEXT_NODE;function C(s){const t=v();if(t.triggerPaused){t.triggerOnResume=!0;return}const e=Array.isArray(s),n=[];if(e){for(const a of s){const o=a.target;if(!H(o))switch(a.type){case"attributes":a.oldValue!==o.getAttribute(a.attributeName)&&n.push(a);break;case"childList":(!$.call(a.addedNodes,S)||!$.call(a.removedNodes,S))&&n.push(a);break}}if(n.length===0)return}if(n.length>500&&(t.triggerAll=!0),!t.triggerAll)if(e)for(const a of n){const o=a.target;switch(a.type){case"attributes":t.triggerElements.push(o);break;case"childList":for(const r of t.callbacks)r.addTriggerElements(t.triggerElements,o);break}}else t.triggerAll=!0;(t.triggerAll||t.triggerElements.length>0)&&!t.triggerFrame&&(t.triggerFrame=window.requestAnimationFrame(()=>{const a=t.triggerAll?void 0:t.triggerElements;t.triggerAll=!1,t.triggerElements=[],t.triggerFrame=0,t.callbacks.forEach(o=>o.trigger(a))}))}function z(){C(),new MutationObserver(C).observe(document,{attributes:!0,attributeFilter:["class","data-bsp-autosubmit","data-chart-type","data-code-type","data-internal-name","data-tab","name","rel","target"],attributeOldValue:!0,childList:!0,subtree:!0})}function D(){const s=v();s.initialized||(s.initialized=!0,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",z):z())}function m(s,t,e){D();let n,a;typeof e<"u"?(n=s,a=t):(n=document,a=s,e=t);const o=new O(n,a,e);o.trigger(),v().callbacks.push(o)}m.triggerCallbacks=C;m.pause=()=>{v().triggerPaused=!0};m.resume=()=>{const s=v();s.triggerPaused=!1,s.triggerOnResume&&(s.triggerOnResume=!1,setTimeout(C,100))};m.ignore=(...s)=>{const{blacklist:t}=v();for(const e of s){try{document.querySelector(e)}catch{continue}t.includes(e)||t.push(e)}};const{expect:d,userEvent:c,waitFor:u,within:k}=__STORYBOOK_MODULE_TEST__,R={title:"Utilities/onFind",tags:["autodocs"],parameters:{docs:{subtitle:"The `onFind` utility observes DOM mutations and executes callbacks when elements matching specified selectors appear. Uses MutationObserver internally to efficiently track element additions and attribute changes."},controls:{expanded:!0}},argTypes:{selector:{control:{type:"text"},description:"CSS selector to watch for"}},args:{selector:".dynamic-item"}},x={render:s=>{const t=`onfind-${Math.random().toString(36).substring(2,9)}`,e=`.dynamic-item-${t}`;let n=0,a=0;const o=()=>{const i=document.getElementById(`${t}-items-count`),l=document.getElementById(`${t}-found-count`);i&&(i.textContent=String(n)),l&&(l.textContent=String(a))};return b(e,i=>{a++,o(),i.classList.add("ring-2","ring-success-500")}),f`
|
|
2
2
|
<div class="space-y-4">
|
|
3
3
|
<div class="text-base">
|
|
4
4
|
<p class="mb-2">
|
|
@@ -8,18 +8,10 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
10
|
<div class="flex gap-2">
|
|
11
|
-
<button
|
|
12
|
-
data-testid="add-item"
|
|
13
|
-
@click=${()=>{n++;const i=document.getElementById(`${t}-container`);if(i){const l=document.createElement("div");l.className=`dynamic-item-${t} rounded border bg-white p-4`,l.textContent=`Item ${n}`,i.appendChild(l)}o()}}
|
|
14
|
-
class="bg-primary-500 hover:bg-primary-600 rounded px-4 py-2 text-white"
|
|
15
|
-
>
|
|
11
|
+
<button data-testid="add-item" @click=${()=>{n++;const i=document.getElementById(`${t}-container`);if(i){const l=document.createElement("div");l.className=`dynamic-item-${t} rounded border bg-white p-4`,l.textContent=`Item ${n}`,i.appendChild(l)}o()}} class="btu-button-primary btu-button-sm btu-button">
|
|
16
12
|
Add Item
|
|
17
13
|
</button>
|
|
18
|
-
<button
|
|
19
|
-
data-testid="clear-items"
|
|
20
|
-
@click=${()=>{n=0,a=0;const i=document.getElementById(`${t}-container`);i&&(i.innerHTML=""),o()}}
|
|
21
|
-
class="rounded bg-gray-200 px-4 py-2 hover:bg-gray-300"
|
|
22
|
-
>
|
|
14
|
+
<button data-testid="clear-items" @click=${()=>{n=0,a=0;const i=document.getElementById(`${t}-container`);i&&(i.innerHTML=""),o()}} class="btu-button-gray btu-button-sm btu-button">
|
|
23
15
|
Clear All
|
|
24
16
|
</button>
|
|
25
17
|
</div>
|
|
@@ -37,13 +29,13 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
37
29
|
</div>
|
|
38
30
|
<div>
|
|
39
31
|
<div class="text-xs text-gray-500">Items detected by onFind</div>
|
|
40
|
-
<div data-testid="found-count" id="${t}-found-count" class="text-
|
|
32
|
+
<div data-testid="found-count" id="${t}-found-count" class="text-2xl font-bold text-primary-600">
|
|
41
33
|
0
|
|
42
34
|
</div>
|
|
43
35
|
</div>
|
|
44
36
|
</div>
|
|
45
37
|
</div>
|
|
46
|
-
`},parameters:{docs:{description:{story:"Interactive example showing onFind detecting dynamically added elements. Elements are automatically highlighted when detected."}}},play:async({canvasElement:s,step:t})=>{const e=k(s);await t("Detects dynamically added element",async()=>{await c.click(e.getByTestId("add-item")),await u(()=>d(e.getByTestId("found-count")).toHaveTextContent("1"))}),await t("Detects multiple elements",async()=>{await c.click(e.getByTestId("add-item")),await c.click(e.getByTestId("add-item")),await u(()=>d(e.getByTestId("found-count")).toHaveTextContent("3"))}),await t("Clear resets counts",async()=>{await c.click(e.getByTestId("clear-items")),d(e.getByTestId("items-count")).toHaveTextContent("0"),d(e.getByTestId("found-count")).toHaveTextContent("0")}),await t("Detection resumes after clear",async()=>{await c.click(e.getByTestId("add-item")),await u(()=>d(e.getByTestId("found-count")).toHaveTextContent("1"))})}},B={render:()=>{const s="onfind-ignore-demo",t=".ignore-demo-item",e="ignore-demo-zone";let n=0,a=0;const o=()=>{const i=document.getElementById(`${s}-found-count`);i&&(i.textContent=String(n))};return b.ignore(`.${e}`),b(t,i=>{n++,o(),i.classList.add("ring-2","ring-success-500")}),
|
|
38
|
+
`},parameters:{docs:{description:{story:"Interactive example showing onFind detecting dynamically added elements. Elements are automatically highlighted when detected."}}},play:async({canvasElement:s,step:t})=>{const e=k(s);await t("Detects dynamically added element",async()=>{await c.click(e.getByTestId("add-item")),await u(()=>d(e.getByTestId("found-count")).toHaveTextContent("1"))}),await t("Detects multiple elements",async()=>{await c.click(e.getByTestId("add-item")),await c.click(e.getByTestId("add-item")),await u(()=>d(e.getByTestId("found-count")).toHaveTextContent("3"))}),await t("Clear resets counts",async()=>{await c.click(e.getByTestId("clear-items")),d(e.getByTestId("items-count")).toHaveTextContent("0"),d(e.getByTestId("found-count")).toHaveTextContent("0")}),await t("Detection resumes after clear",async()=>{await c.click(e.getByTestId("add-item")),await u(()=>d(e.getByTestId("found-count")).toHaveTextContent("1"))})}},B={render:()=>{const s="onfind-ignore-demo",t=".ignore-demo-item",e="ignore-demo-zone";let n=0,a=0;const o=()=>{const i=document.getElementById(`${s}-found-count`);i&&(i.textContent=String(n))};return b.ignore(`.${e}`),b(t,i=>{n++,o(),i.classList.add("ring-2","ring-success-500")}),f`
|
|
47
39
|
<div class="space-y-4">
|
|
48
40
|
<p class="text-base">
|
|
49
41
|
Elements added inside the <strong>ignored zone</strong> are skipped by onFind callbacks. Elements added
|
|
@@ -51,14 +43,10 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
51
43
|
</p>
|
|
52
44
|
|
|
53
45
|
<div class="flex gap-2">
|
|
54
|
-
<button
|
|
55
|
-
data-testid="add-outside"
|
|
56
|
-
@click=${()=>{a++;const i=document.getElementById(`${s}-outside`);if(i){const l=document.createElement("div");l.className=`${t.slice(1)} rounded border bg-white p-4`,l.textContent=`Outside ${a}`,i.appendChild(l)}}}
|
|
57
|
-
class="bg-primary-500 hover:bg-primary-600 rounded px-4 py-2 text-white"
|
|
58
|
-
>
|
|
46
|
+
<button data-testid="add-outside" @click=${()=>{a++;const i=document.getElementById(`${s}-outside`);if(i){const l=document.createElement("div");l.className=`${t.slice(1)} rounded border bg-white p-4`,l.textContent=`Outside ${a}`,i.appendChild(l)}}} class="btu-button-primary btu-button-sm btu-button">
|
|
59
47
|
Add Outside
|
|
60
48
|
</button>
|
|
61
|
-
<button data-testid="add-inside" @click=${()=>{a++;const i=document.getElementById(`${s}-inside`);if(i){const l=document.createElement("div");l.className=`${t.slice(1)} rounded border bg-white p-4`,l.textContent=`Inside ${a}`,i.appendChild(l)}}} class="
|
|
49
|
+
<button data-testid="add-inside" @click=${()=>{a++;const i=document.getElementById(`${s}-inside`);if(i){const l=document.createElement("div");l.className=`${t.slice(1)} rounded border bg-white p-4`,l.textContent=`Inside ${a}`,i.appendChild(l)}}} class="btu-button-gray btu-button-sm btu-button">
|
|
62
50
|
Add Inside Ignored
|
|
63
51
|
</button>
|
|
64
52
|
</div>
|
|
@@ -74,7 +62,7 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
74
62
|
<div class="mb-1 text-xs font-semibold text-gray-500">Ignored zone</div>
|
|
75
63
|
<div
|
|
76
64
|
id="${s}-inside"
|
|
77
|
-
class="${e} min-h-32 space-y-2 rounded border-2
|
|
65
|
+
class="${e} border-red-300 bg-red-50 min-h-32 space-y-2 rounded border-2 p-4"
|
|
78
66
|
>
|
|
79
67
|
<div class="text-sm text-gray-400">Items ignored here</div>
|
|
80
68
|
</div>
|
|
@@ -86,13 +74,13 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
86
74
|
<div
|
|
87
75
|
data-testid="ignore-found-count"
|
|
88
76
|
id="${s}-found-count"
|
|
89
|
-
class="text-
|
|
77
|
+
class="text-2xl font-bold text-primary-600"
|
|
90
78
|
>
|
|
91
79
|
0
|
|
92
80
|
</div>
|
|
93
81
|
</div>
|
|
94
82
|
</div>
|
|
95
|
-
`},parameters:{docs:{description:{story:"Demonstrates `onFind.ignore()` — elements inside ignored containers are excluded from callback processing. Useful for skipping rich-text editors or other zones where DOM mutations should not trigger component initialization."}}},play:async({canvasElement:s,step:t})=>{const e=k(s);await t("Detects outside ignored zone",async()=>{await c.click(e.getByTestId("add-outside")),await u(()=>d(e.getByTestId("ignore-found-count")).toHaveTextContent("1"))}),await t("Skips inside ignored zone",async()=>{await c.click(e.getByTestId("add-inside")),await new Promise(n=>requestAnimationFrame(()=>requestAnimationFrame(n))),d(e.getByTestId("ignore-found-count")).toHaveTextContent("1")}),await t("Continues detecting outside",async()=>{await c.click(e.getByTestId("add-outside")),await u(()=>d(e.getByTestId("ignore-found-count")).toHaveTextContent("2"))})}},
|
|
83
|
+
`},parameters:{docs:{description:{story:"Demonstrates `onFind.ignore()` — elements inside ignored containers are excluded from callback processing. Useful for skipping rich-text editors or other zones where DOM mutations should not trigger component initialization."}}},play:async({canvasElement:s,step:t})=>{const e=k(s);await t("Detects outside ignored zone",async()=>{await c.click(e.getByTestId("add-outside")),await u(()=>d(e.getByTestId("ignore-found-count")).toHaveTextContent("1"))}),await t("Skips inside ignored zone",async()=>{await c.click(e.getByTestId("add-inside")),await new Promise(n=>requestAnimationFrame(()=>requestAnimationFrame(n))),d(e.getByTestId("ignore-found-count")).toHaveTextContent("1")}),await t("Continues detecting outside",async()=>{await c.click(e.getByTestId("add-outside")),await u(()=>d(e.getByTestId("ignore-found-count")).toHaveTextContent("2"))})}},I={render:()=>{const s="onfind-pause-demo",t=".pause-demo-item";let e=0,n=0;const a=()=>{const i=document.getElementById(`${s}-found-count`);i&&(i.textContent=String(e))};b(t,i=>{e++,a(),i.classList.add("ring-2","ring-success-500")});const o=()=>{n++;const i=document.getElementById(`${s}-container`);if(i){const l=document.createElement("div");l.className=`${t.slice(1)} rounded border bg-white p-4`,l.textContent=`Item ${n}`,i.appendChild(l)}};let r=!1;return f`
|
|
96
84
|
<div class="space-y-4">
|
|
97
85
|
<p class="text-base">
|
|
98
86
|
Use <code>onFind.pause()</code> to temporarily stop detection and <code>onFind.resume()</code> to restart it.
|
|
@@ -100,10 +88,10 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
100
88
|
</p>
|
|
101
89
|
|
|
102
90
|
<div class="flex gap-2">
|
|
103
|
-
<button data-testid="pause-add" @click=${o} class="btu-button btu-button-
|
|
91
|
+
<button data-testid="pause-add" @click=${o} class="btu-button-primary btu-button-sm btu-button">
|
|
104
92
|
Add Item
|
|
105
93
|
</button>
|
|
106
|
-
<button data-testid="toggle-pause" @click=${()=>{r=!r,r?b.pause():b.resume();const i=document.querySelector('[data-testid="toggle-pause"]');i&&(i.textContent=r?"Resume":"Pause",i.className=r?"btu-button btu-button-success btu-button-sm":"btu-button btu-button-warning btu-button-sm")}} class="btu-button btu-button-
|
|
94
|
+
<button data-testid="toggle-pause" @click=${()=>{r=!r,r?b.pause():b.resume();const i=document.querySelector('[data-testid="toggle-pause"]');i&&(i.textContent=r?"Resume":"Pause",i.className=r?"btu-button btu-button-success btu-button-sm":"btu-button btu-button-warning btu-button-sm")}} class="btu-button-warning btu-button-sm btu-button">
|
|
107
95
|
Pause
|
|
108
96
|
</button>
|
|
109
97
|
</div>
|
|
@@ -117,13 +105,13 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
117
105
|
<div
|
|
118
106
|
data-testid="pause-found-count"
|
|
119
107
|
id="${s}-found-count"
|
|
120
|
-
class="text-
|
|
108
|
+
class="text-2xl font-bold text-primary-600"
|
|
121
109
|
>
|
|
122
110
|
0
|
|
123
111
|
</div>
|
|
124
112
|
</div>
|
|
125
113
|
</div>
|
|
126
|
-
`},parameters:{docs:{description:{story:"Demonstrates `onFind.pause()` and `onFind.resume()`. While paused, DOM mutations are queued and processed when resumed."}}},play:async({canvasElement:s,step:t})=>{const e=k(s);await t("Normal detection before pause",async()=>{await c.click(e.getByTestId("pause-add")),await u(()=>d(e.getByTestId("pause-found-count")).toHaveTextContent("1"))}),await t("Pause stops detection",async()=>{await c.click(e.getByTestId("toggle-pause")),await c.click(e.getByTestId("pause-add")),await new Promise(n=>setTimeout(n,200)),d(e.getByTestId("pause-found-count")).toHaveTextContent("1")}),await t("Resume triggers pending detection",async()=>{await c.click(e.getByTestId("toggle-pause")),await u(()=>d(e.getByTestId("pause-found-count")).toHaveTextContent("2"),{timeout:2e3})})}},
|
|
114
|
+
`},parameters:{docs:{description:{story:"Demonstrates `onFind.pause()` and `onFind.resume()`. While paused, DOM mutations are queued and processed when resumed."}}},play:async({canvasElement:s,step:t})=>{const e=k(s);await t("Normal detection before pause",async()=>{await c.click(e.getByTestId("pause-add")),await u(()=>d(e.getByTestId("pause-found-count")).toHaveTextContent("1"))}),await t("Pause stops detection",async()=>{await c.click(e.getByTestId("toggle-pause")),await c.click(e.getByTestId("pause-add")),await new Promise(n=>setTimeout(n,200)),d(e.getByTestId("pause-found-count")).toHaveTextContent("1")}),await t("Resume triggers pending detection",async()=>{await c.click(e.getByTestId("toggle-pause")),await u(()=>d(e.getByTestId("pause-found-count")).toHaveTextContent("2"),{timeout:2e3})})}},w={render:()=>{const s=b,t=".singleton-item-a",e=".singleton-item-b";let n=0,a=0;const o=()=>{const g=document.getElementById("singleton-count-a"),h=document.getElementById("singleton-count-b");g&&(g.textContent=String(n)),h&&(h.textContent=String(a))};s.ignore(".singleton-ignored-zone"),s(t,g=>{n++,o(),g.classList.add("ring-2","ring-blue-500")}),m(e,g=>{a++,o(),g.classList.add("ring-2","ring-purple-500")});const r=(g,h,M)=>{const A=document.getElementById(M);if(A){const E=document.createElement("div");E.className=`${g.slice(1)} rounded border bg-white p-4`,E.textContent=h,A.appendChild(E)}};let p=!1;return f`
|
|
127
115
|
<div class="space-y-4">
|
|
128
116
|
<p class="text-base">
|
|
129
117
|
Two separate ES module instances of <code>onFind</code> (each with its own <code>_state</code> cache) share
|
|
@@ -134,11 +122,11 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
134
122
|
<button
|
|
135
123
|
data-testid="singleton-toggle-pause"
|
|
136
124
|
@click=${()=>{p=!p,p?s.pause():s.resume();const g=document.querySelector('[data-testid="singleton-toggle-pause"]');g&&(g.textContent=p?"Resume":"Pause",g.className=p?"btu-button btu-button-success btu-button-sm":"btu-button btu-button-warning btu-button-sm")}}
|
|
137
|
-
class="btu-button btu-button-
|
|
125
|
+
class="btu-button-warning btu-button-sm btu-button"
|
|
138
126
|
>
|
|
139
127
|
Pause
|
|
140
128
|
</button>
|
|
141
|
-
<div class="flex items-center gap-1 text-sm
|
|
129
|
+
<div class="text-blue-600 flex items-center gap-1 text-sm">
|
|
142
130
|
Bundle A:
|
|
143
131
|
<span data-testid="singleton-count-a" id="singleton-count-a" class="font-bold">0</span>
|
|
144
132
|
items found
|
|
@@ -152,24 +140,24 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
152
140
|
|
|
153
141
|
<div class="grid grid-cols-3 gap-4">
|
|
154
142
|
<div>
|
|
155
|
-
<div class="mb-2 text-xs font-semibold
|
|
143
|
+
<div class="text-blue-600 mb-2 text-xs font-semibold">Bundle A zone</div>
|
|
156
144
|
<div class="mb-2 flex gap-1">
|
|
157
145
|
<button
|
|
158
146
|
data-testid="singleton-add-a"
|
|
159
147
|
@click=${()=>r(t,"Bundle A item","singleton-zone-a")}
|
|
160
|
-
class="btu-button btu-button-
|
|
148
|
+
class="btu-button-primary btu-button-sm btu-button"
|
|
161
149
|
>
|
|
162
150
|
Add A
|
|
163
151
|
</button>
|
|
164
152
|
<button
|
|
165
153
|
data-testid="singleton-zone-a-add-b"
|
|
166
154
|
@click=${()=>r(e,"Bundle B item","singleton-zone-a")}
|
|
167
|
-
class="btu-button btu-button-
|
|
155
|
+
class="btu-button-purple btu-button-sm btu-button"
|
|
168
156
|
>
|
|
169
157
|
Add B
|
|
170
158
|
</button>
|
|
171
159
|
</div>
|
|
172
|
-
<div id="singleton-zone-a" class="min-h-24 space-y-2 rounded border-2
|
|
160
|
+
<div id="singleton-zone-a" class="border-blue-300 bg-blue-50 min-h-24 space-y-2 rounded border-2 p-4">
|
|
173
161
|
<div class="text-sm text-gray-400">A items here</div>
|
|
174
162
|
</div>
|
|
175
163
|
</div>
|
|
@@ -179,14 +167,14 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
179
167
|
<button
|
|
180
168
|
data-testid="singleton-zone-b-add-a"
|
|
181
169
|
@click=${()=>r(t,"Bundle A item","singleton-zone-b")}
|
|
182
|
-
class="btu-button btu-button-
|
|
170
|
+
class="btu-button-primary btu-button-sm btu-button"
|
|
183
171
|
>
|
|
184
172
|
Add A
|
|
185
173
|
</button>
|
|
186
174
|
<button
|
|
187
175
|
data-testid="singleton-add-b"
|
|
188
176
|
@click=${()=>r(e,"Bundle B item","singleton-zone-b")}
|
|
189
|
-
class="btu-button btu-button-
|
|
177
|
+
class="btu-button-purple btu-button-sm btu-button"
|
|
190
178
|
>
|
|
191
179
|
Add B
|
|
192
180
|
</button>
|
|
@@ -196,26 +184,26 @@ import{x as h}from"./iframe-DloIUNZz.js";import{l as P,o as b}from"./onFind-C0l4
|
|
|
196
184
|
</div>
|
|
197
185
|
</div>
|
|
198
186
|
<div>
|
|
199
|
-
<div class="mb-2 text-xs font-semibold
|
|
187
|
+
<div class="text-red-600 mb-2 text-xs font-semibold">Ignored zone</div>
|
|
200
188
|
<div class="mb-2 flex gap-1">
|
|
201
189
|
<button
|
|
202
190
|
data-testid="singleton-add-ignored"
|
|
203
191
|
@click=${()=>{r(t,"Ignored A","singleton-ignored"),r(e,"Ignored B","singleton-ignored")}}
|
|
204
|
-
class="btu-button btu-button-
|
|
192
|
+
class="btu-button-gray btu-button-sm btu-button"
|
|
205
193
|
>
|
|
206
194
|
Add A & B
|
|
207
195
|
</button>
|
|
208
196
|
</div>
|
|
209
197
|
<div
|
|
210
198
|
id="singleton-ignored"
|
|
211
|
-
class="singleton-ignored-zone min-h-24 space-y-2 rounded border-2
|
|
199
|
+
class="singleton-ignored-zone border-red-300 bg-red-50 min-h-24 space-y-2 rounded border-2 p-4"
|
|
212
200
|
>
|
|
213
201
|
<div class="text-sm text-gray-400">Items ignored here</div>
|
|
214
202
|
</div>
|
|
215
203
|
</div>
|
|
216
204
|
</div>
|
|
217
205
|
</div>
|
|
218
|
-
`},parameters:{docs:{description:{story:"Two independent module instances of `onFind` (simulating separate bundles) share a single MutationObserver, ignore list, and pause/resume state through the `globalThis[Symbol.for()]` singleton pattern."}}},play:async({canvasElement:s,step:t})=>{const e=k(s);await t("Shared observer: Bundle A detects A items, Bundle B detects B items",async()=>{await c.click(e.getByTestId("singleton-add-a")),await u(()=>d(e.getByTestId("singleton-count-a")).toHaveTextContent("1")),await c.click(e.getByTestId("singleton-add-b")),await u(()=>d(e.getByTestId("singleton-count-b")).toHaveTextContent("1"))}),await t("Cross-zone detection fires correct callback",async()=>{await c.click(e.getByTestId("singleton-zone-a-add-b")),await u(()=>d(e.getByTestId("singleton-count-b")).toHaveTextContent("2")),d(e.getByTestId("singleton-count-a")).toHaveTextContent("1"),await c.click(e.getByTestId("singleton-zone-b-add-a")),await u(()=>d(e.getByTestId("singleton-count-a")).toHaveTextContent("2")),d(e.getByTestId("singleton-count-b")).toHaveTextContent("2")}),await t("Shared ignore list: Bundle A ignore() blocks Bundle B callbacks",async()=>{const n=e.getByTestId("singleton-count-a").textContent,a=e.getByTestId("singleton-count-b").textContent;await c.click(e.getByTestId("singleton-add-ignored")),await new Promise(o=>requestAnimationFrame(()=>requestAnimationFrame(o))),d(e.getByTestId("singleton-count-a")).toHaveTextContent(n),d(e.getByTestId("singleton-count-b")).toHaveTextContent(a)}),await t("Ignore lists are merged and deduped across bundles",async()=>{const n=globalThis[Symbol.for("brightspot.onFind")],a=n.blacklist.length;m.ignore(".singleton-ignored-zone"),d(n.blacklist.length).toBe(a),m.ignore(".bundle-b-ignored"),d(n.blacklist).toContain(".singleton-ignored-zone"),d(n.blacklist).toContain(".bundle-b-ignored"),d(n.blacklist.length).toBe(a+1)}),await t("Shared pause/resume: Bundle A pause() stops Bundle B detection",async()=>{await c.click(e.getByTestId("singleton-toggle-pause")),await c.click(e.getByTestId("singleton-add-a")),await c.click(e.getByTestId("singleton-add-b")),await new Promise(n=>setTimeout(n,200)),d(e.getByTestId("singleton-count-a")).toHaveTextContent("2"),d(e.getByTestId("singleton-count-b")).toHaveTextContent("2"),await c.click(e.getByTestId("singleton-toggle-pause")),await u(()=>d(e.getByTestId("singleton-count-a")).toHaveTextContent("3"),{timeout:2e3}),await u(()=>d(e.getByTestId("singleton-count-b")).toHaveTextContent("3"),{timeout:2e3})}),await t("No index collision on data-ofc attributes",async()=>{const n=s.querySelectorAll(".singleton-item-a, .singleton-item-b"),a=new Set;n.forEach(o=>{o.getAttributeNames().filter(r=>r.startsWith("data-ofc")).forEach(r=>a.add(r))}),d(a.size).toBeGreaterThanOrEqual(2)}),await t("Singleton state: both bundles share the same globalThis object",async()=>{const n=globalThis[Symbol.for("brightspot.onFind")];d(n).toBeDefined(),d(n.callbacks).toBeDefined(),d(Array.isArray(n.callbacks)).toBe(!0),d(n.initialized).toBe(!0),d(b.pause).not.toBe(m.pause),d(b.resume).not.toBe(m.resume)})}},T={render:()=>
|
|
206
|
+
`},parameters:{docs:{description:{story:"Two independent module instances of `onFind` (simulating separate bundles) share a single MutationObserver, ignore list, and pause/resume state through the `globalThis[Symbol.for()]` singleton pattern."}}},play:async({canvasElement:s,step:t})=>{const e=k(s);await t("Shared observer: Bundle A detects A items, Bundle B detects B items",async()=>{await c.click(e.getByTestId("singleton-add-a")),await u(()=>d(e.getByTestId("singleton-count-a")).toHaveTextContent("1")),await c.click(e.getByTestId("singleton-add-b")),await u(()=>d(e.getByTestId("singleton-count-b")).toHaveTextContent("1"))}),await t("Cross-zone detection fires correct callback",async()=>{await c.click(e.getByTestId("singleton-zone-a-add-b")),await u(()=>d(e.getByTestId("singleton-count-b")).toHaveTextContent("2")),d(e.getByTestId("singleton-count-a")).toHaveTextContent("1"),await c.click(e.getByTestId("singleton-zone-b-add-a")),await u(()=>d(e.getByTestId("singleton-count-a")).toHaveTextContent("2")),d(e.getByTestId("singleton-count-b")).toHaveTextContent("2")}),await t("Shared ignore list: Bundle A ignore() blocks Bundle B callbacks",async()=>{const n=e.getByTestId("singleton-count-a").textContent,a=e.getByTestId("singleton-count-b").textContent;await c.click(e.getByTestId("singleton-add-ignored")),await new Promise(o=>requestAnimationFrame(()=>requestAnimationFrame(o))),d(e.getByTestId("singleton-count-a")).toHaveTextContent(n),d(e.getByTestId("singleton-count-b")).toHaveTextContent(a)}),await t("Ignore lists are merged and deduped across bundles",async()=>{const n=globalThis[Symbol.for("brightspot.onFind")],a=n.blacklist.length;m.ignore(".singleton-ignored-zone"),d(n.blacklist.length).toBe(a),m.ignore(".bundle-b-ignored"),d(n.blacklist).toContain(".singleton-ignored-zone"),d(n.blacklist).toContain(".bundle-b-ignored"),d(n.blacklist.length).toBe(a+1)}),await t("Shared pause/resume: Bundle A pause() stops Bundle B detection",async()=>{await c.click(e.getByTestId("singleton-toggle-pause")),await c.click(e.getByTestId("singleton-add-a")),await c.click(e.getByTestId("singleton-add-b")),await new Promise(n=>setTimeout(n,200)),d(e.getByTestId("singleton-count-a")).toHaveTextContent("2"),d(e.getByTestId("singleton-count-b")).toHaveTextContent("2"),await c.click(e.getByTestId("singleton-toggle-pause")),await u(()=>d(e.getByTestId("singleton-count-a")).toHaveTextContent("3"),{timeout:2e3}),await u(()=>d(e.getByTestId("singleton-count-b")).toHaveTextContent("3"),{timeout:2e3})}),await t("No index collision on data-ofc attributes",async()=>{const n=s.querySelectorAll(".singleton-item-a, .singleton-item-b"),a=new Set;n.forEach(o=>{o.getAttributeNames().filter(r=>r.startsWith("data-ofc")).forEach(r=>a.add(r))}),d(a.size).toBeGreaterThanOrEqual(2)}),await t("Singleton state: both bundles share the same globalThis object",async()=>{const n=globalThis[Symbol.for("brightspot.onFind")];d(n).toBeDefined(),d(n.callbacks).toBeDefined(),d(Array.isArray(n.callbacks)).toBe(!0),d(n.initialized).toBe(!0),d(b.pause).not.toBe(m.pause),d(b.resume).not.toBe(m.resume)})}},T={render:()=>f`
|
|
219
207
|
<div class="space-y-4 text-sm">
|
|
220
208
|
<div>
|
|
221
209
|
<h3 class="mb-2 font-bold">Basic Usage</h3>
|
|
@@ -348,7 +336,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
348
336
|
</p>
|
|
349
337
|
</div>
|
|
350
338
|
</div>
|
|
351
|
-
`,parameters:{docs:{description:{story:"Code examples and documentation for using the onFind utility."}}}};
|
|
339
|
+
`,parameters:{docs:{description:{story:"Code examples and documentation for using the onFind utility."}}}};x.parameters={...x.parameters,docs:{...x.parameters?.docs,source:{originalSource:`{
|
|
352
340
|
render: args => {
|
|
353
341
|
const instanceId = \`onfind-\${Math.random().toString(36).substring(2, 9)}\`;
|
|
354
342
|
const uniqueSelector = \`.dynamic-item-\${instanceId}\`;
|
|
@@ -397,18 +385,10 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
397
385
|
</div>
|
|
398
386
|
|
|
399
387
|
<div class="flex gap-2">
|
|
400
|
-
<button
|
|
401
|
-
data-testid="add-item"
|
|
402
|
-
@click=\${addItem}
|
|
403
|
-
class="bg-primary-500 hover:bg-primary-600 rounded px-4 py-2 text-white"
|
|
404
|
-
>
|
|
388
|
+
<button data-testid="add-item" @click=\${addItem} class="btu-button-primary btu-button-sm btu-button">
|
|
405
389
|
Add Item
|
|
406
390
|
</button>
|
|
407
|
-
<button
|
|
408
|
-
data-testid="clear-items"
|
|
409
|
-
@click=\${clearItems}
|
|
410
|
-
class="rounded bg-gray-200 px-4 py-2 hover:bg-gray-300"
|
|
411
|
-
>
|
|
391
|
+
<button data-testid="clear-items" @click=\${clearItems} class="btu-button-gray btu-button-sm btu-button">
|
|
412
392
|
Clear All
|
|
413
393
|
</button>
|
|
414
394
|
</div>
|
|
@@ -426,7 +406,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
426
406
|
</div>
|
|
427
407
|
<div>
|
|
428
408
|
<div class="text-xs text-gray-500">Items detected by onFind</div>
|
|
429
|
-
<div data-testid="found-count" id="\${instanceId}-found-count" class="text-
|
|
409
|
+
<div data-testid="found-count" id="\${instanceId}-found-count" class="text-2xl font-bold text-primary-600">
|
|
430
410
|
0
|
|
431
411
|
</div>
|
|
432
412
|
</div>
|
|
@@ -465,7 +445,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
465
445
|
await waitFor(() => expect(canvas.getByTestId('found-count')).toHaveTextContent('1'));
|
|
466
446
|
});
|
|
467
447
|
}
|
|
468
|
-
}`,...
|
|
448
|
+
}`,...x.parameters?.docs?.source}}};B.parameters={...B.parameters,docs:{...B.parameters?.docs,source:{originalSource:`{
|
|
469
449
|
render: () => {
|
|
470
450
|
const instanceId = 'onfind-ignore-demo';
|
|
471
451
|
const itemSelector = '.ignore-demo-item';
|
|
@@ -510,14 +490,10 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
510
490
|
</p>
|
|
511
491
|
|
|
512
492
|
<div class="flex gap-2">
|
|
513
|
-
<button
|
|
514
|
-
data-testid="add-outside"
|
|
515
|
-
@click=\${addOutside}
|
|
516
|
-
class="bg-primary-500 hover:bg-primary-600 rounded px-4 py-2 text-white"
|
|
517
|
-
>
|
|
493
|
+
<button data-testid="add-outside" @click=\${addOutside} class="btu-button-primary btu-button-sm btu-button">
|
|
518
494
|
Add Outside
|
|
519
495
|
</button>
|
|
520
|
-
<button data-testid="add-inside" @click=\${addInside} class="
|
|
496
|
+
<button data-testid="add-inside" @click=\${addInside} class="btu-button-gray btu-button-sm btu-button">
|
|
521
497
|
Add Inside Ignored
|
|
522
498
|
</button>
|
|
523
499
|
</div>
|
|
@@ -533,7 +509,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
533
509
|
<div class="mb-1 text-xs font-semibold text-gray-500">Ignored zone</div>
|
|
534
510
|
<div
|
|
535
511
|
id="\${instanceId}-inside"
|
|
536
|
-
class="\${ignoredClass} min-h-32 space-y-2 rounded border-2
|
|
512
|
+
class="\${ignoredClass} border-red-300 bg-red-50 min-h-32 space-y-2 rounded border-2 p-4"
|
|
537
513
|
>
|
|
538
514
|
<div class="text-sm text-gray-400">Items ignored here</div>
|
|
539
515
|
</div>
|
|
@@ -545,7 +521,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
545
521
|
<div
|
|
546
522
|
data-testid="ignore-found-count"
|
|
547
523
|
id="\${instanceId}-found-count"
|
|
548
|
-
class="text-
|
|
524
|
+
class="text-2xl font-bold text-primary-600"
|
|
549
525
|
>
|
|
550
526
|
0
|
|
551
527
|
</div>
|
|
@@ -580,7 +556,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
580
556
|
await waitFor(() => expect(canvas.getByTestId('ignore-found-count')).toHaveTextContent('2'));
|
|
581
557
|
});
|
|
582
558
|
}
|
|
583
|
-
}`,...B.parameters?.docs?.source}}};
|
|
559
|
+
}`,...B.parameters?.docs?.source}}};I.parameters={...I.parameters,docs:{...I.parameters?.docs,source:{originalSource:`{
|
|
584
560
|
render: () => {
|
|
585
561
|
const instanceId = 'onfind-pause-demo';
|
|
586
562
|
const itemSelector = '.pause-demo-item';
|
|
@@ -627,10 +603,10 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
627
603
|
</p>
|
|
628
604
|
|
|
629
605
|
<div class="flex gap-2">
|
|
630
|
-
<button data-testid="pause-add" @click=\${addItem} class="btu-button btu-button-
|
|
606
|
+
<button data-testid="pause-add" @click=\${addItem} class="btu-button-primary btu-button-sm btu-button">
|
|
631
607
|
Add Item
|
|
632
608
|
</button>
|
|
633
|
-
<button data-testid="toggle-pause" @click=\${togglePause} class="btu-button btu-button-
|
|
609
|
+
<button data-testid="toggle-pause" @click=\${togglePause} class="btu-button-warning btu-button-sm btu-button">
|
|
634
610
|
Pause
|
|
635
611
|
</button>
|
|
636
612
|
</div>
|
|
@@ -644,7 +620,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
644
620
|
<div
|
|
645
621
|
data-testid="pause-found-count"
|
|
646
622
|
id="\${instanceId}-found-count"
|
|
647
|
-
class="text-
|
|
623
|
+
class="text-2xl font-bold text-primary-600"
|
|
648
624
|
>
|
|
649
625
|
0
|
|
650
626
|
</div>
|
|
@@ -683,7 +659,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
683
659
|
});
|
|
684
660
|
});
|
|
685
661
|
}
|
|
686
|
-
}`,...
|
|
662
|
+
}`,...I.parameters?.docs?.source}}};w.parameters={...w.parameters,docs:{...w.parameters?.docs,source:{originalSource:`{
|
|
687
663
|
render: () => {
|
|
688
664
|
const onFindA = onFind;
|
|
689
665
|
const selectorA = '.singleton-item-a';
|
|
@@ -753,11 +729,11 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
753
729
|
<button
|
|
754
730
|
data-testid="singleton-toggle-pause"
|
|
755
731
|
@click=\${togglePause}
|
|
756
|
-
class="btu-button btu-button-
|
|
732
|
+
class="btu-button-warning btu-button-sm btu-button"
|
|
757
733
|
>
|
|
758
734
|
Pause
|
|
759
735
|
</button>
|
|
760
|
-
<div class="flex items-center gap-1 text-sm
|
|
736
|
+
<div class="text-blue-600 flex items-center gap-1 text-sm">
|
|
761
737
|
Bundle A:
|
|
762
738
|
<span data-testid="singleton-count-a" id="singleton-count-a" class="font-bold">0</span>
|
|
763
739
|
items found
|
|
@@ -771,24 +747,24 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
771
747
|
|
|
772
748
|
<div class="grid grid-cols-3 gap-4">
|
|
773
749
|
<div>
|
|
774
|
-
<div class="mb-2 text-xs font-semibold
|
|
750
|
+
<div class="text-blue-600 mb-2 text-xs font-semibold">Bundle A zone</div>
|
|
775
751
|
<div class="mb-2 flex gap-1">
|
|
776
752
|
<button
|
|
777
753
|
data-testid="singleton-add-a"
|
|
778
754
|
@click=\${() => addItem(selectorA, 'Bundle A item', 'singleton-zone-a')}
|
|
779
|
-
class="btu-button btu-button-
|
|
755
|
+
class="btu-button-primary btu-button-sm btu-button"
|
|
780
756
|
>
|
|
781
757
|
Add A
|
|
782
758
|
</button>
|
|
783
759
|
<button
|
|
784
760
|
data-testid="singleton-zone-a-add-b"
|
|
785
761
|
@click=\${() => addItem(selectorB, 'Bundle B item', 'singleton-zone-a')}
|
|
786
|
-
class="btu-button btu-button-
|
|
762
|
+
class="btu-button-purple btu-button-sm btu-button"
|
|
787
763
|
>
|
|
788
764
|
Add B
|
|
789
765
|
</button>
|
|
790
766
|
</div>
|
|
791
|
-
<div id="singleton-zone-a" class="min-h-24 space-y-2 rounded border-2
|
|
767
|
+
<div id="singleton-zone-a" class="border-blue-300 bg-blue-50 min-h-24 space-y-2 rounded border-2 p-4">
|
|
792
768
|
<div class="text-sm text-gray-400">A items here</div>
|
|
793
769
|
</div>
|
|
794
770
|
</div>
|
|
@@ -798,14 +774,14 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
798
774
|
<button
|
|
799
775
|
data-testid="singleton-zone-b-add-a"
|
|
800
776
|
@click=\${() => addItem(selectorA, 'Bundle A item', 'singleton-zone-b')}
|
|
801
|
-
class="btu-button btu-button-
|
|
777
|
+
class="btu-button-primary btu-button-sm btu-button"
|
|
802
778
|
>
|
|
803
779
|
Add A
|
|
804
780
|
</button>
|
|
805
781
|
<button
|
|
806
782
|
data-testid="singleton-add-b"
|
|
807
783
|
@click=\${() => addItem(selectorB, 'Bundle B item', 'singleton-zone-b')}
|
|
808
|
-
class="btu-button btu-button-
|
|
784
|
+
class="btu-button-purple btu-button-sm btu-button"
|
|
809
785
|
>
|
|
810
786
|
Add B
|
|
811
787
|
</button>
|
|
@@ -815,19 +791,19 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
815
791
|
</div>
|
|
816
792
|
</div>
|
|
817
793
|
<div>
|
|
818
|
-
<div class="mb-2 text-xs font-semibold
|
|
794
|
+
<div class="text-red-600 mb-2 text-xs font-semibold">Ignored zone</div>
|
|
819
795
|
<div class="mb-2 flex gap-1">
|
|
820
796
|
<button
|
|
821
797
|
data-testid="singleton-add-ignored"
|
|
822
798
|
@click=\${addIgnored}
|
|
823
|
-
class="btu-button btu-button-
|
|
799
|
+
class="btu-button-gray btu-button-sm btu-button"
|
|
824
800
|
>
|
|
825
801
|
Add A & B
|
|
826
802
|
</button>
|
|
827
803
|
</div>
|
|
828
804
|
<div
|
|
829
805
|
id="singleton-ignored"
|
|
830
|
-
class="singleton-ignored-zone min-h-24 space-y-2 rounded border-2
|
|
806
|
+
class="singleton-ignored-zone border-red-300 bg-red-50 min-h-24 space-y-2 rounded border-2 p-4"
|
|
831
807
|
>
|
|
832
808
|
<div class="text-sm text-gray-400">Items ignored here</div>
|
|
833
809
|
</div>
|
|
@@ -924,7 +900,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
924
900
|
expect(onFind.resume).not.toBe(onFindB.resume);
|
|
925
901
|
});
|
|
926
902
|
}
|
|
927
|
-
}`,...
|
|
903
|
+
}`,...w.parameters?.docs?.source}}};T.parameters={...T.parameters,docs:{...T.parameters?.docs,source:{originalSource:`{
|
|
928
904
|
render: () => html\`
|
|
929
905
|
<div class="space-y-4 text-sm">
|
|
930
906
|
<div>
|
|
@@ -1066,4 +1042,4 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
1066
1042
|
}
|
|
1067
1043
|
}
|
|
1068
1044
|
}
|
|
1069
|
-
}`,...T.parameters?.docs?.source}}};const U=["Interactive","Ignore","PauseResume","Singleton","UsageExample"];export{B as Ignore,
|
|
1045
|
+
}`,...T.parameters?.docs?.source}}};const U=["Interactive","Ignore","PauseResume","Singleton","UsageExample"];export{B as Ignore,x as Interactive,I as PauseResume,w as Singleton,T as UsageExample,U as __namedExportsOrder,R as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as p}from"./iframe-
|
|
1
|
+
import{x as p}from"./iframe-Sf9RHZFu.js";import"./preload-helper-PPVm8Dsz.js";let l=!1;function m(e,o){const s=new MutationObserver(r=>{for(const v of r)for(const n of v.removedNodes)n.contains(e)&&!l&&(s.disconnect(),o())});s.observe(document,{childList:!0,subtree:!0})}m.pause=()=>{l=!0};m.resume=()=>{l=!1};const h={title:"Utilities/onRemove",tags:["autodocs"],parameters:{docs:{subtitle:"The `onRemove` utility triggers a callback when a DOM element is removed from the document. Uses MutationObserver to watch for removals, with global pause/resume support."},controls:{expanded:!0}},argTypes:{selector:{control:{type:"text"},description:"CSS selector of element to watch"}},args:{selector:".watched-item"}},i={render:()=>{const e=`onremove-${Math.random().toString(36).substring(2,9)}`;let o=0,s=0;const r=()=>{const n=document.getElementById(`${e}-items-count`),t=document.getElementById(`${e}-removed-count`);n&&(n.textContent=String(o)),t&&(t.textContent=String(s))};return p`
|
|
2
2
|
<div class="space-y-4">
|
|
3
3
|
<div class="text-base">
|
|
4
4
|
<p class="mb-2">
|
|
@@ -8,9 +8,7 @@ import{x as p}from"./iframe-DloIUNZz.js";import"./preload-helper-PPVm8Dsz.js";le
|
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
10
|
<div class="flex gap-2">
|
|
11
|
-
<button @click=${()=>{o++;const n=document.getElementById(`${e}-container`);if(!n)return;const t=document.createElement("div"),u=o;t.className="flex items-center justify-between rounded border bg-white p-4",t.innerHTML=`<span>Item ${u}</span>`;const d=document.createElement("button");d.className="rounded bg-red-100 px-2 py-1 text-xs text-red-700 hover:bg-red-200",d.textContent="Remove",d.addEventListener("click",()=>t.remove()),t.appendChild(d),n.appendChild(t),m(t,()=>{s++,o--,r();const g=document.getElementById(`${e}-log`);if(g){const c=document.createElement("div");c.className="text-sm text-gray-600",c.textContent=`Item ${u} removed at ${new Date().toLocaleTimeString()}`,g.prepend(c)}}),r()}} class="
|
|
12
|
-
Add Item
|
|
13
|
-
</button>
|
|
11
|
+
<button @click=${()=>{o++;const n=document.getElementById(`${e}-container`);if(!n)return;const t=document.createElement("div"),u=o;t.className="flex items-center justify-between rounded border bg-white p-4",t.innerHTML=`<span>Item ${u}</span>`;const d=document.createElement("button");d.className="rounded bg-red-100 px-2 py-1 text-xs text-red-700 hover:bg-red-200",d.textContent="Remove",d.addEventListener("click",()=>t.remove()),t.appendChild(d),n.appendChild(t),m(t,()=>{s++,o--,r();const g=document.getElementById(`${e}-log`);if(g){const c=document.createElement("div");c.className="text-sm text-gray-600",c.textContent=`Item ${u} removed at ${new Date().toLocaleTimeString()}`,g.prepend(c)}}),r()}} class="btu-button-primary btu-button-sm btu-button">Add Item</button>
|
|
14
12
|
</div>
|
|
15
13
|
|
|
16
14
|
<div id="${e}-container" class="min-h-32 space-y-2 rounded border-2 border-gray-300 bg-gray-50 p-4">
|
|
@@ -24,7 +22,7 @@ import{x as p}from"./iframe-DloIUNZz.js";import"./preload-helper-PPVm8Dsz.js";le
|
|
|
24
22
|
</div>
|
|
25
23
|
<div>
|
|
26
24
|
<div class="text-xs text-gray-500">Removals detected</div>
|
|
27
|
-
<div id="${e}-removed-count" class="text-
|
|
25
|
+
<div id="${e}-removed-count" class="text-2xl font-bold text-primary-600">0</div>
|
|
28
26
|
</div>
|
|
29
27
|
</div>
|
|
30
28
|
|
|
@@ -136,9 +134,7 @@ onRemove.resume()</code></pre>
|
|
|
136
134
|
</div>
|
|
137
135
|
|
|
138
136
|
<div class="flex gap-2">
|
|
139
|
-
<button @click=\${addItem} class="
|
|
140
|
-
Add Item
|
|
141
|
-
</button>
|
|
137
|
+
<button @click=\${addItem} class="btu-button-primary btu-button-sm btu-button">Add Item</button>
|
|
142
138
|
</div>
|
|
143
139
|
|
|
144
140
|
<div id="\${instanceId}-container" class="min-h-32 space-y-2 rounded border-2 border-gray-300 bg-gray-50 p-4">
|
|
@@ -152,7 +148,7 @@ onRemove.resume()</code></pre>
|
|
|
152
148
|
</div>
|
|
153
149
|
<div>
|
|
154
150
|
<div class="text-xs text-gray-500">Removals detected</div>
|
|
155
|
-
<div id="\${instanceId}-removed-count" class="text-
|
|
151
|
+
<div id="\${instanceId}-removed-count" class="text-2xl font-bold text-primary-600">0</div>
|
|
156
152
|
</div>
|
|
157
153
|
</div>
|
|
158
154
|
|
|
@@ -231,4 +227,4 @@ onRemove.resume()</code></pre>
|
|
|
231
227
|
}
|
|
232
228
|
}
|
|
233
229
|
}
|
|
234
|
-
}`,...a.parameters?.docs?.source}}};const y=["Interactive","UsageExample"];export{i as Interactive,a as UsageExample,y as __namedExportsOrder,
|
|
230
|
+
}`,...a.parameters?.docs?.source}}};const y=["Interactive","UsageExample"];export{i as Interactive,a as UsageExample,y as __namedExportsOrder,h as default};
|
package/dist/storybook/assets/{onVisible.stories-Cbj5_Vz0.js → onVisible.stories-NNFeFeD8.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as d}from"./iframe-
|
|
1
|
+
import{x as d}from"./iframe-Sf9RHZFu.js";import{o as g}from"./onFind-C41m8c_a.js";import"./preload-helper-PPVm8Dsz.js";const b=Symbol.for("brightspot.onVisible");let t;function v(){return t||(t=globalThis[b],t||(t={calledIndex:0},globalThis[b]=t),t)}function h(i,r){const s=`_ovc${v().calledIndex++}`,n=new IntersectionObserver(e=>{for(const o of e)if(o.isIntersecting){const c=o.target,m=c.classList;m.contains(s)||(m.add(s),n.unobserve(c),r(c))}});g(i,e=>{n.observe(e)})}const f={title:"Utilities/onVisible",tags:["autodocs"],parameters:{docs:{subtitle:"The `onVisible` utility triggers a callback once when elements matching a selector become visible in the viewport. Combines `onFind` with `IntersectionObserver` for lazy initialization of dynamically added elements."},controls:{expanded:!0}},argTypes:{selector:{control:{type:"text"},description:"CSS selector to watch for visibility"}},args:{selector:".lazy-item"}},l={render:()=>{const i=`onvisible-${Math.random().toString(36).substring(2,9)}`,r=`.lazy-item-${i}`;let s=0;const n=()=>{const e=document.getElementById(`${i}-visible-count`);e&&(e.textContent=String(s))};return h(r,e=>{s++,n(),e.classList.remove("opacity-30"),e.classList.add("ring-2","ring-success-500","opacity-100"),e.textContent+=" — visible!"}),d`
|
|
2
2
|
<div class="space-y-4">
|
|
3
3
|
<div class="text-base">
|
|
4
4
|
<p class="mb-2">
|
|
@@ -10,7 +10,7 @@ import{x as d}from"./iframe-DloIUNZz.js";import{o as g}from"./onFind-C0l4Gew0.js
|
|
|
10
10
|
<div class="flex justify-around">
|
|
11
11
|
<div>
|
|
12
12
|
<div class="text-xs text-gray-500">Items detected as visible</div>
|
|
13
|
-
<div id="${i}-visible-count" class="text-
|
|
13
|
+
<div id="${i}-visible-count" class="text-2xl font-bold text-primary-600">0</div>
|
|
14
14
|
</div>
|
|
15
15
|
</div>
|
|
16
16
|
|
|
@@ -101,7 +101,7 @@ onVisible('.chart-container', (element) => {
|
|
|
101
101
|
<div class="flex justify-around">
|
|
102
102
|
<div>
|
|
103
103
|
<div class="text-xs text-gray-500">Items detected as visible</div>
|
|
104
|
-
<div id="\${instanceId}-visible-count" class="text-
|
|
104
|
+
<div id="\${instanceId}-visible-count" class="text-2xl font-bold text-primary-600">0</div>
|
|
105
105
|
</div>
|
|
106
106
|
</div>
|
|
107
107
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as l,ae as u,af as c,ag as a}from"./iframe-
|
|
1
|
+
import{e as l,ae as u,af as c,ag as a}from"./iframe-Sf9RHZFu.js";const o="important",d=" !"+o,h=l(class extends u{constructor(s){if(super(s),s.type!==c.ATTRIBUTE||s.name!=="style"||s.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(s){return Object.keys(s).reduce(((n,t)=>{const e=s[t];return e==null?n:n+`${t=t.includes("-")?t:t.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${e};`}),"")}update(s,[n]){const{style:t}=s.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(n)),this.render(n);for(const e of this.ft)n[e]==null&&(this.ft.delete(e),e.includes("-")?t.removeProperty(e):t[e]=null);for(const e in n){const r=n[e];if(r!=null){this.ft.add(e);const i=typeof r=="string"&&r.endsWith(d);e.includes("-")||i?t.setProperty(e,i?r.slice(0,-11):r,i?o:""):t[e]=r}}return a}});export{h as o};
|