@brightspot/ui 6.0.5 → 6.0.6
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/storybook/assets/{ActionBar.stories-BSwwf2PX.js → ActionBar.stories-BI_iTJEQ.js} +1 -1
- package/dist/storybook/assets/{ActionItem.stories-SCIA5Rt0.js → ActionItem.stories-BJWzexGS.js} +1 -1
- package/dist/storybook/assets/{AiSparkle.stories-ByeiNU3G.js → AiSparkle.stories-DaA5HO3d.js} +1 -1
- package/dist/storybook/assets/{Avatar.stories-1EUJytBr.js → Avatar.stories-Dw8QVNJ-.js} +1 -1
- package/dist/storybook/assets/{AvatarGroup.stories-Bstlt4go.js → AvatarGroup.stories-BsNMLTiE.js} +1 -1
- package/dist/storybook/assets/{Badge.stories-X7m0Vl2G.js → Badge.stories-GY-ektak.js} +1 -1
- package/dist/storybook/assets/{Banner.stories-ljxjOtEc.js → Banner.stories-Bg9VB-Fy.js} +1 -1
- package/dist/storybook/assets/{Button-Dbpmp5Ih.js → Button-BOLW3-O-.js} +1 -1
- package/dist/storybook/assets/{Button.stories-C5qS3rIw.js → Button.stories-DMRHEd8n.js} +1 -1
- package/dist/storybook/assets/{ButtonGroup.stories-Bl1Ko9jX.js → ButtonGroup.stories-B2gFm6tD.js} +1 -1
- package/dist/storybook/assets/{Card.stories-CfFIzXg5.js → Card.stories-CLdjETEv.js} +1 -1
- package/dist/storybook/assets/{Celebrate.stories-TSJrIQR8.js → Celebrate.stories-navEPsY4.js} +1 -1
- package/dist/storybook/assets/{Checkbox.stories-DUpT9Iwh.js → Checkbox.stories-5VfpC9R_.js} +1 -1
- package/dist/storybook/assets/{CircularProgress.stories-usNosiIU.js → CircularProgress.stories-BI1KFT4i.js} +1 -1
- package/dist/storybook/assets/{ClipboardMixin.stories-0jnZ0Drs.js → ClipboardMixin.stories-DLqRNEnd.js} +1 -1
- package/dist/storybook/assets/{Color-6BZIO3FS-C6ecAOER.js → Color-6BZIO3FS-BYF_b3cm.js} +1 -1
- package/dist/storybook/assets/{Colors.stories-DcbIlkPs.js → Colors.stories-DymlImN1.js} +1 -1
- package/dist/storybook/assets/{CombinedEffects.stories-CU-hwRPT.js → CombinedEffects.stories-BcAx9THm.js} +1 -1
- package/dist/storybook/assets/{ComponentStatesMixin-Dcz-J-hg.js → ComponentStatesMixin-D77sglBs.js} +1 -1
- package/dist/storybook/assets/{ComponentStatesMixin.stories-orhdmIUX.js → ComponentStatesMixin.stories-BFUmXPbv.js} +1 -1
- package/dist/storybook/assets/{CopyToClipboard.stories-D1R2yCQL.js → CopyToClipboard.stories-CLP60X8y.js} +1 -1
- package/dist/storybook/assets/{Debounce.stories-6z8aEn7O.js → Debounce.stories-CDlv8D8Q.js} +1 -1
- package/dist/storybook/assets/{DocsRenderer-LL677BLK-B-fTNYB5.js → DocsRenderer-LL677BLK-DU2JYRwe.js} +3 -3
- package/dist/storybook/assets/{Dropdown.stories-CeVpVPrP.js → Dropdown.stories-CJ-QjUYp.js} +1 -1
- package/dist/storybook/assets/{EmptyState.stories-DdCyApUP.js → EmptyState.stories-HQi_rzX2.js} +1 -1
- package/dist/storybook/assets/{EscaAvatar.stories-DNK85ssI.js → EscaAvatar.stories-BLqoZyr7.js} +1 -1
- package/dist/storybook/assets/{Events.stories-B1qeq2wy.js → Events.stories-CvSn4RPH.js} +1 -1
- package/dist/storybook/assets/{Heading.stories-DRu5hUyJ.js → Heading.stories-MR-daawc.js} +1 -1
- package/dist/storybook/assets/{HueRipple.stories-D3zqVZWM.js → HueRipple.stories-P4LiNUpZ.js} +1 -1
- package/dist/storybook/assets/{Icon.stories-CKG5fIIH.js → Icon.stories-h5P6rJQP.js} +1 -1
- package/dist/storybook/assets/{IconButton.stories-B3RZKBqV.js → IconButton.stories-Cc0vzr28.js} +1 -1
- package/dist/storybook/assets/{LinearProgress.stories-BPvFKGi0.js → LinearProgress.stories-yTIIcK9O.js} +1 -1
- package/dist/storybook/assets/{Message.stories-Dq3YDccT.js → Message.stories-BbFPAVCt.js} +1 -1
- package/dist/storybook/assets/{OnFindMixin.stories-qKTooUKN.js → OnFindMixin.stories-BAWi3mlB.js} +1 -1
- package/dist/storybook/assets/{Pagination.stories-BaFWcckS.js → Pagination.stories-DJ-6-aNd.js} +1 -1
- package/dist/storybook/assets/{Popover.stories-DlHlfWrk.js → Popover.stories-D9CilGw-.js} +1 -1
- package/dist/storybook/assets/{ReadyMixin-BQ-q8NO4.js → ReadyMixin-B6XKdlIG.js} +1 -1
- package/dist/storybook/assets/{RovingTabindexMixin.stories-CQkteE6h.js → RovingTabindexMixin.stories-CPJ_6oiA.js} +1 -1
- package/dist/storybook/assets/{Rtc.stories-BWBDrPM8.js → Rtc.stories-DcWHMr_7.js} +1 -1
- package/dist/storybook/assets/{ScrollShadow.stories-BtM7Q6Ys.js → ScrollShadow.stories-DH6wJQFV.js} +1 -1
- package/dist/storybook/assets/{Switch.stories-Ys6MzOf7.js → Switch.stories-Cl9xPGbR.js} +1 -1
- package/dist/storybook/assets/{Tab.stories-CNIDOscR.js → Tab.stories-BAhU8vUi.js} +1 -1
- package/dist/storybook/assets/{Tabs.stories-oAxuRqKE.js → Tabs.stories-CLRPMg6P.js} +1 -1
- package/dist/storybook/assets/{Throttle.stories-D2nPrZEL.js → Throttle.stories-BbONS-V4.js} +1 -1
- package/dist/storybook/assets/{Tooltip.stories-DJhjWYNV.js → Tooltip.stories-B6s8TQSb.js} +1 -1
- package/dist/storybook/assets/{Upload.stories-DBveASQF.js → Upload.stories-D0C25uui.js} +1 -1
- package/dist/storybook/assets/{UploadItem.stories-Co5bGJs6.js → UploadItem.stories-DL6N7vsq.js} +1 -1
- package/dist/storybook/assets/{Welcome.stories-Cls_kv8A.js → Welcome.stories-BK4n0XMp.js} +1 -1
- package/dist/storybook/assets/{Widget.stories-CXpqw5z8.js → Widget.stories-Cy9frwq3.js} +1 -1
- package/dist/storybook/assets/{WithTooltip-65CFNBJE-Ik6o5Ygb.js → WithTooltip-65CFNBJE-BuwTEXTQ.js} +1 -1
- package/dist/storybook/assets/{blocks-DjXAnVrm.js → blocks-BLujz-58.js} +5 -5
- package/dist/storybook/assets/{formatter-EIJCOSYU-CQXaWVan.js → formatter-EIJCOSYU-B1sNuUky.js} +1 -1
- package/dist/storybook/assets/if-defined-D7P78rGH.js +1 -0
- package/dist/storybook/assets/{iframe-D43T7JCn.js → iframe-D1g1spfw.js} +3 -3
- package/dist/storybook/assets/{index-DIk8fbbl.js → index-C6O8j27b.js} +1 -1
- package/dist/storybook/assets/onFind-ZJa5FYZA.js +1 -0
- package/dist/storybook/assets/{onFind.stories-DgxMtTTG.js → onFind.stories-rDFDR12f.js} +16 -16
- package/dist/storybook/assets/{onRemove.stories-DltMfNLX.js → onRemove.stories-Cmk4GOI5.js} +1 -1
- package/dist/storybook/assets/{onVisible.stories-x3VhGAuF.js → onVisible.stories-RZ3Q87MG.js} +1 -1
- package/dist/storybook/assets/{style-map-C5J-rKx9.js → style-map-DS-2jfV3.js} +1 -1
- package/dist/storybook/assets/{syntaxhighlighter-ED5Y7EFY-CphVNry2.js → syntaxhighlighter-ED5Y7EFY-C5m4nzeD.js} +1 -1
- package/dist/storybook/iframe.html +1 -1
- package/dist/storybook/project.json +1 -1
- package/dist/util/onFind.d.ts.map +1 -1
- package/dist/util/onFind.js +18 -5
- package/dist/util/onFind.js.map +1 -1
- package/package.json +1 -1
- package/src/legacy/tool-ui/src/ContentEdit.css +1 -1
- package/src/legacy/tool-ui/src/ContentInputGroup.css +15 -13
- package/src/legacy/tool-ui/src/Conversation.ts +130 -136
- package/src/legacy/tool-ui/src/Entry.ts +35 -0
- package/src/legacy/tool-ui/src/Page.css +4 -2
- package/src/legacy/tool-ui/src/Widget.css +2 -2
- package/src/legacy/tool-ui/src/dom/onFind.ts +22 -5
- package/src/legacy/tool-ui/src/main/webapp/dist/4795.beae23779e30c55c6f6a.js +1 -0
- package/src/legacy/tool-ui/src/main/webapp/dist/Appetizeio.73eedd6a3761e060bc96.js +1 -0
- package/src/legacy/tool-ui/src/main/webapp/dist/CISpectrum.934683148936d8e35f1d.js +1 -0
- package/src/legacy/tool-ui/src/main/webapp/dist/RTEProseMirror.9313166310108234934c.js +500 -0
- package/src/legacy/tool-ui/src/main/webapp/dist/TimedContent.e7c0eb6a9e39982cd58f.js +1 -0
- package/src/legacy/tool-ui/src/main/webapp/dist/{v4.623480353a5aac2beab1.js → v4.f659cae67f92dbc8160f.js} +4 -4
- package/src/legacy/tool-ui/src/main/webapp/dist/v5.5eac97ec93d474fa6085.css +5 -0
- package/src/legacy/tool-ui/src/main/webapp/dist/{v5.1283d26d374a3deb15a2.js → v5.9d58fa5b144e53cef35a.js} +5 -5
- package/src/legacy/tool-ui/src/v5.ts +5 -0
- package/dist/storybook/assets/if-defined-BVO6TNCy.js +0 -1
- package/dist/storybook/assets/onFind-CamigPPi.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/dist/4795.034ebc93a67b7a3d6536.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/dist/Appetizeio.185641211f7c0e42a455.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/dist/CISpectrum.74db7dc80b3a6797a167.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/dist/RTEProseMirror.1b453045ff46203bbf72.js +0 -500
- package/src/legacy/tool-ui/src/main/webapp/dist/TimedContent.4bb4dc83ffbe4019dd7b.js +0 -1
- package/src/legacy/tool-ui/src/main/webapp/dist/v5.cb6c1a38c5ba7fa9ea93.css +0 -5
- /package/src/legacy/tool-ui/src/main/webapp/dist/{RTEProseMirror.1b453045ff46203bbf72.js.LICENSE.txt → RTEProseMirror.9313166310108234934c.js.LICENSE.txt} +0 -0
- /package/src/legacy/tool-ui/src/main/webapp/dist/{v4.623480353a5aac2beab1.js.LICENSE.txt → v4.f659cae67f92dbc8160f.js.LICENSE.txt} +0 -0
- /package/src/legacy/tool-ui/src/main/webapp/dist/{v5.1283d26d374a3deb15a2.js.LICENSE.txt → v5.9d58fa5b144e53cef35a.js.LICENSE.txt} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as f}from"./iframe-
|
|
1
|
+
import{x as f}from"./iframe-D1g1spfw.js";import{l as P,o as p}from"./onFind-ZJa5FYZA.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:[],triggerContainers:new Set,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(a=>a.indexOf(",")>-1)?a=>a:a=>`${a}:not([${this.#e}])`).join(","),this.#a=n;const d=e.map(a=>a.trim()).filter(a=>a.indexOf(" ")<0&&a.indexOf(",")<0);d.length===e.length&&(this.#s=d)}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 S=Array.prototype.every,$=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 c=a.target;if(!H(c))switch(a.type){case"attributes":a.oldValue!==c.getAttribute(a.attributeName)&&n.push(a);break;case"childList":(!S.call(a.addedNodes,$)||!S.call(a.removedNodes,$))&&n.push(a);break}}if(n.length===0)return}n.length>500&&(t.triggerAll=!0);const d=t.triggerContainers??(t.triggerContainers=new Set);if(!t.triggerAll)if(e)for(const a of n){const c=a.target;switch(a.type){case"attributes":t.triggerElements.push(c);break;case"childList":d.add(c);break}}else t.triggerAll=!0;(t.triggerAll||t.triggerElements.length>0||d.size>0)&&!t.triggerFrame&&(t.triggerFrame=window.requestAnimationFrame(()=>{let a;if(!t.triggerAll){for(const c of d)if(c instanceof Element)for(const u of t.callbacks)u.addTriggerElements(t.triggerElements,c);a=t.triggerElements}t.triggerAll=!1,t.triggerElements=[],t.triggerContainers=new Set,t.triggerFrame=0,t.callbacks.forEach(c=>c.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 b(s,t,e){D();let n,d;typeof e<"u"?(n=s,d=t):(n=document,d=s,e=t);const a=new O(n,d,e);return a.trigger(),v().callbacks.push(a),()=>{const{callbacks:c}=v(),u=c.indexOf(a);u!==-1&&c.splice(u,1)}}b.triggerCallbacks=C;b.pause=()=>{v().triggerPaused=!0};b.resume=()=>{const s=v();s.triggerPaused=!1,s.triggerOnResume&&(s.triggerOnResume=!1,setTimeout(C,100))};b.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:i,userEvent:r,waitFor:g,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"}},h={render:s=>{const t=`onfind-${Math.random().toString(36).substring(2,9)}`,e=`.dynamic-item-${t}`;let n=0,d=0;const a=()=>{const o=document.getElementById(`${t}-items-count`),l=document.getElementById(`${t}-found-count`);o&&(o.textContent=String(n)),l&&(l.textContent=String(d))};return p(e,o=>{d++,a(),o.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,10 +8,10 @@ import{x as f}from"./iframe-D43T7JCn.js";import{l as P,o as p}from"./onFind-Cami
|
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
10
|
<div class="flex gap-2">
|
|
11
|
-
<button data-testid="add-item" @click=${()=>{n++;const
|
|
11
|
+
<button data-testid="add-item" @click=${()=>{n++;const o=document.getElementById(`${t}-container`);if(o){const l=document.createElement("div");l.className=`dynamic-item-${t} rounded border bg-white p-4`,l.textContent=`Item ${n}`,o.appendChild(l)}a()}} class="btu-button btu-button-primary btu-button-sm">
|
|
12
12
|
Add Item
|
|
13
13
|
</button>
|
|
14
|
-
<button data-testid="clear-items" @click=${()=>{n=0,
|
|
14
|
+
<button data-testid="clear-items" @click=${()=>{n=0,d=0;const o=document.getElementById(`${t}-container`);o&&(o.innerHTML=""),a()}} class="btu-button btu-button-gray btu-button-sm">
|
|
15
15
|
Clear All
|
|
16
16
|
</button>
|
|
17
17
|
</div>
|
|
@@ -35,7 +35,7 @@ import{x as f}from"./iframe-D43T7JCn.js";import{l as P,o as p}from"./onFind-Cami
|
|
|
35
35
|
</div>
|
|
36
36
|
</div>
|
|
37
37
|
</div>
|
|
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 r.click(e.getByTestId("add-item")),await
|
|
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 r.click(e.getByTestId("add-item")),await g(()=>i(e.getByTestId("found-count")).toHaveTextContent("1"))}),await t("Detects multiple elements",async()=>{await r.click(e.getByTestId("add-item")),await r.click(e.getByTestId("add-item")),await g(()=>i(e.getByTestId("found-count")).toHaveTextContent("3"))}),await t("Clear resets counts",async()=>{await r.click(e.getByTestId("clear-items")),i(e.getByTestId("items-count")).toHaveTextContent("0"),i(e.getByTestId("found-count")).toHaveTextContent("0")}),await t("Detection resumes after clear",async()=>{await r.click(e.getByTestId("add-item")),await g(()=>i(e.getByTestId("found-count")).toHaveTextContent("1"))})}},B={render:()=>{const s="onfind-ignore-demo",t=".ignore-demo-item",e="ignore-demo-zone";let n=0,d=0;const a=()=>{const o=document.getElementById(`${s}-found-count`);o&&(o.textContent=String(n))};return p.ignore(`.${e}`),p(t,o=>{n++,a(),o.classList.add("ring-2","ring-success-500")}),f`
|
|
39
39
|
<div class="space-y-4">
|
|
40
40
|
<p class="text-base">
|
|
41
41
|
Elements added inside the <strong>ignored zone</strong> are skipped by onFind callbacks. Elements added
|
|
@@ -43,10 +43,10 @@ import{x as f}from"./iframe-D43T7JCn.js";import{l as P,o as p}from"./onFind-Cami
|
|
|
43
43
|
</p>
|
|
44
44
|
|
|
45
45
|
<div class="flex gap-2">
|
|
46
|
-
<button data-testid="add-outside" @click=${()=>{
|
|
46
|
+
<button data-testid="add-outside" @click=${()=>{d++;const o=document.getElementById(`${s}-outside`);if(o){const l=document.createElement("div");l.className=`${t.slice(1)} rounded border bg-white p-4`,l.textContent=`Outside ${d}`,o.appendChild(l)}}} class="btu-button btu-button-primary btu-button-sm">
|
|
47
47
|
Add Outside
|
|
48
48
|
</button>
|
|
49
|
-
<button data-testid="add-inside" @click=${()=>{
|
|
49
|
+
<button data-testid="add-inside" @click=${()=>{d++;const o=document.getElementById(`${s}-inside`);if(o){const l=document.createElement("div");l.className=`${t.slice(1)} rounded border bg-white p-4`,l.textContent=`Inside ${d}`,o.appendChild(l)}}} class="btu-button btu-button-gray btu-button-sm">
|
|
50
50
|
Add Inside Ignored
|
|
51
51
|
</button>
|
|
52
52
|
</div>
|
|
@@ -80,7 +80,7 @@ import{x as f}from"./iframe-D43T7JCn.js";import{l as P,o as p}from"./onFind-Cami
|
|
|
80
80
|
</div>
|
|
81
81
|
</div>
|
|
82
82
|
</div>
|
|
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 r.click(e.getByTestId("add-outside")),await
|
|
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 r.click(e.getByTestId("add-outside")),await g(()=>i(e.getByTestId("ignore-found-count")).toHaveTextContent("1"))}),await t("Skips inside ignored zone",async()=>{await r.click(e.getByTestId("add-inside")),await new Promise(n=>requestAnimationFrame(()=>requestAnimationFrame(n))),i(e.getByTestId("ignore-found-count")).toHaveTextContent("1")}),await t("Continues detecting outside",async()=>{await r.click(e.getByTestId("add-outside")),await g(()=>i(e.getByTestId("ignore-found-count")).toHaveTextContent("2"))})}},w={render:()=>{const s="onfind-pause-demo",t=".pause-demo-item";let e=0,n=0;const d=()=>{const o=document.getElementById(`${s}-found-count`);o&&(o.textContent=String(e))};p(t,o=>{e++,d(),o.classList.add("ring-2","ring-success-500")});const a=()=>{n++;const o=document.getElementById(`${s}-container`);if(o){const l=document.createElement("div");l.className=`${t.slice(1)} rounded border bg-white p-4`,l.textContent=`Item ${n}`,o.appendChild(l)}};let c=!1;return f`
|
|
84
84
|
<div class="space-y-4">
|
|
85
85
|
<p class="text-base">
|
|
86
86
|
Use <code>onFind.pause()</code> to temporarily stop detection and <code>onFind.resume()</code> to restart it.
|
|
@@ -88,10 +88,10 @@ import{x as f}from"./iframe-D43T7JCn.js";import{l as P,o as p}from"./onFind-Cami
|
|
|
88
88
|
</p>
|
|
89
89
|
|
|
90
90
|
<div class="flex gap-2">
|
|
91
|
-
<button data-testid="pause-add" @click=${
|
|
91
|
+
<button data-testid="pause-add" @click=${a} class="btu-button btu-button-primary btu-button-sm">
|
|
92
92
|
Add Item
|
|
93
93
|
</button>
|
|
94
|
-
<button data-testid="toggle-pause" @click=${()=>{c=!c,c?p.pause():p.resume();const
|
|
94
|
+
<button data-testid="toggle-pause" @click=${()=>{c=!c,c?p.pause():p.resume();const o=document.querySelector('[data-testid="toggle-pause"]');o&&(o.textContent=c?"Resume":"Pause",o.className=c?"btu-button btu-button-success btu-button-sm":"btu-button btu-button-warning btu-button-sm")}} class="btu-button btu-button-warning btu-button-sm">
|
|
95
95
|
Pause
|
|
96
96
|
</button>
|
|
97
97
|
</div>
|
|
@@ -111,7 +111,7 @@ import{x as f}from"./iframe-D43T7JCn.js";import{l as P,o as p}from"./onFind-Cami
|
|
|
111
111
|
</div>
|
|
112
112
|
</div>
|
|
113
113
|
</div>
|
|
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 r.click(e.getByTestId("pause-add")),await
|
|
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 r.click(e.getByTestId("pause-add")),await g(()=>i(e.getByTestId("pause-found-count")).toHaveTextContent("1"))}),await t("Pause stops detection",async()=>{await r.click(e.getByTestId("toggle-pause")),await r.click(e.getByTestId("pause-add")),await new Promise(n=>setTimeout(n,200)),i(e.getByTestId("pause-found-count")).toHaveTextContent("1")}),await t("Resume triggers pending detection",async()=>{await r.click(e.getByTestId("toggle-pause")),await g(()=>i(e.getByTestId("pause-found-count")).toHaveTextContent("2"),{timeout:2e3})})}},I={render:()=>{const s=p,t=".singleton-item-a",e=".singleton-item-b";let n=0,d=0;const a=()=>{const m=document.getElementById("singleton-count-a"),x=document.getElementById("singleton-count-b");m&&(m.textContent=String(n)),x&&(x.textContent=String(d))};s.ignore(".singleton-ignored-zone"),s(t,m=>{n++,a(),m.classList.add("ring-2","ring-blue-500")}),b(e,m=>{d++,a(),m.classList.add("ring-2","ring-purple-500")});const c=(m,x,M)=>{const A=document.getElementById(M);if(A){const E=document.createElement("div");E.className=`${m.slice(1)} rounded border bg-white p-4`,E.textContent=x,A.appendChild(E)}};let u=!1;return f`
|
|
115
115
|
<div class="space-y-4">
|
|
116
116
|
<p class="text-base">
|
|
117
117
|
Two separate ES module instances of <code>onFind</code> (each with its own <code>_state</code> cache) share
|
|
@@ -121,7 +121,7 @@ import{x as f}from"./iframe-D43T7JCn.js";import{l as P,o as p}from"./onFind-Cami
|
|
|
121
121
|
<div class="flex items-center gap-4">
|
|
122
122
|
<button
|
|
123
123
|
data-testid="singleton-toggle-pause"
|
|
124
|
-
@click=${()=>{
|
|
124
|
+
@click=${()=>{u=!u,u?s.pause():s.resume();const m=document.querySelector('[data-testid="singleton-toggle-pause"]');m&&(m.textContent=u?"Resume":"Pause",m.className=u?"btu-button btu-button-success btu-button-sm":"btu-button btu-button-warning btu-button-sm")}}
|
|
125
125
|
class="btu-button btu-button-warning btu-button-sm"
|
|
126
126
|
>
|
|
127
127
|
Pause
|
|
@@ -203,7 +203,7 @@ import{x as f}from"./iframe-D43T7JCn.js";import{l as P,o as p}from"./onFind-Cami
|
|
|
203
203
|
</div>
|
|
204
204
|
</div>
|
|
205
205
|
</div>
|
|
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 r.click(e.getByTestId("singleton-add-a")),await
|
|
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 r.click(e.getByTestId("singleton-add-a")),await g(()=>i(e.getByTestId("singleton-count-a")).toHaveTextContent("1")),await r.click(e.getByTestId("singleton-add-b")),await g(()=>i(e.getByTestId("singleton-count-b")).toHaveTextContent("1"))}),await t("Cross-zone detection fires correct callback",async()=>{await r.click(e.getByTestId("singleton-zone-a-add-b")),await g(()=>i(e.getByTestId("singleton-count-b")).toHaveTextContent("2")),i(e.getByTestId("singleton-count-a")).toHaveTextContent("1"),await r.click(e.getByTestId("singleton-zone-b-add-a")),await g(()=>i(e.getByTestId("singleton-count-a")).toHaveTextContent("2")),i(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,d=e.getByTestId("singleton-count-b").textContent;await r.click(e.getByTestId("singleton-add-ignored")),await new Promise(a=>requestAnimationFrame(()=>requestAnimationFrame(a))),i(e.getByTestId("singleton-count-a")).toHaveTextContent(n),i(e.getByTestId("singleton-count-b")).toHaveTextContent(d)}),await t("Ignore lists are merged and deduped across bundles",async()=>{const n=globalThis[Symbol.for("brightspot.onFind")],d=n.blacklist.length;b.ignore(".singleton-ignored-zone"),i(n.blacklist.length).toBe(d),b.ignore(".bundle-b-ignored"),i(n.blacklist).toContain(".singleton-ignored-zone"),i(n.blacklist).toContain(".bundle-b-ignored"),i(n.blacklist.length).toBe(d+1)}),await t("Shared pause/resume: Bundle A pause() stops Bundle B detection",async()=>{await r.click(e.getByTestId("singleton-toggle-pause")),await r.click(e.getByTestId("singleton-add-a")),await r.click(e.getByTestId("singleton-add-b")),await new Promise(n=>setTimeout(n,200)),i(e.getByTestId("singleton-count-a")).toHaveTextContent("2"),i(e.getByTestId("singleton-count-b")).toHaveTextContent("2"),await r.click(e.getByTestId("singleton-toggle-pause")),await g(()=>i(e.getByTestId("singleton-count-a")).toHaveTextContent("3"),{timeout:2e3}),await g(()=>i(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"),d=new Set;n.forEach(a=>{a.getAttributeNames().filter(c=>c.startsWith("data-ofc")).forEach(c=>d.add(c))}),i(d.size).toBeGreaterThanOrEqual(2)}),await t("Singleton state: both bundles share the same globalThis object",async()=>{const n=globalThis[Symbol.for("brightspot.onFind")];i(n).toBeDefined(),i(n.callbacks).toBeDefined(),i(Array.isArray(n.callbacks)).toBe(!0),i(n.initialized).toBe(!0),i(p.pause).not.toBe(b.pause),i(p.resume).not.toBe(b.resume)})}},T={render:()=>f`
|
|
207
207
|
<div class="space-y-4 text-sm">
|
|
208
208
|
<div>
|
|
209
209
|
<h3 class="mb-2 font-bold">Basic Usage</h3>
|
|
@@ -556,7 +556,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
556
556
|
await waitFor(() => expect(canvas.getByTestId('ignore-found-count')).toHaveTextContent('2'));
|
|
557
557
|
});
|
|
558
558
|
}
|
|
559
|
-
}`,...B.parameters?.docs?.source}}};
|
|
559
|
+
}`,...B.parameters?.docs?.source}}};w.parameters={...w.parameters,docs:{...w.parameters?.docs,source:{originalSource:`{
|
|
560
560
|
render: () => {
|
|
561
561
|
const instanceId = 'onfind-pause-demo';
|
|
562
562
|
const itemSelector = '.pause-demo-item';
|
|
@@ -659,7 +659,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
659
659
|
});
|
|
660
660
|
});
|
|
661
661
|
}
|
|
662
|
-
}`,...
|
|
662
|
+
}`,...w.parameters?.docs?.source}}};I.parameters={...I.parameters,docs:{...I.parameters?.docs,source:{originalSource:`{
|
|
663
663
|
render: () => {
|
|
664
664
|
const onFindA = onFind;
|
|
665
665
|
const selectorA = '.singleton-item-a';
|
|
@@ -900,7 +900,7 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
900
900
|
expect(onFind.resume).not.toBe(onFindB.resume);
|
|
901
901
|
});
|
|
902
902
|
}
|
|
903
|
-
}`,...
|
|
903
|
+
}`,...I.parameters?.docs?.source}}};T.parameters={...T.parameters,docs:{...T.parameters?.docs,source:{originalSource:`{
|
|
904
904
|
render: () => html\`
|
|
905
905
|
<div class="space-y-4 text-sm">
|
|
906
906
|
<div>
|
|
@@ -1042,4 +1042,4 @@ onFind.ignore('.ProseMirror', '.RichTextEditor')
|
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
1044
|
}
|
|
1045
|
-
}`,...T.parameters?.docs?.source}}};const U=["Interactive","Ignore","PauseResume","Singleton","UsageExample"];export{B as Ignore,h as Interactive,
|
|
1045
|
+
}`,...T.parameters?.docs?.source}}};const U=["Interactive","Ignore","PauseResume","Singleton","UsageExample"];export{B as Ignore,h as Interactive,w as PauseResume,I 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-D1g1spfw.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">
|
package/dist/storybook/assets/{onVisible.stories-x3VhGAuF.js → onVisible.stories-RZ3Q87MG.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{x as d}from"./iframe-
|
|
1
|
+
import{x as d}from"./iframe-D1g1spfw.js";import{o as g}from"./onFind-ZJa5FYZA.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">
|
|
@@ -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-D1g1spfw.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};
|