@scbt-ecom/ui 0.145.1 → 0.146.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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useCallback as
|
|
1
|
+
import{useCallback as m}from"react";import{scrollToElement as a}from"../../../shared/utils/scrollToElement.js";import"../../../../node_modules/classnames/index.js";import{isClient as r}from"../../../shared/utils/isClient.js";const i=c=>m(()=>{var l;switch(c.handler){case"navigate":{const{url:e,target:o,rel:t}=c;r&&(window==null||window.open(e,o,t));break}case"scroll":{const{widgetId:e}=c??"";a({widgetId:e});break}case"dialog":{if(!r)return;const{dialogId:e}=c??{},o=document.getElementById(e);if(!o){console.error("Такого элемента в DOM не существует",e);break}o.show()}}"callback"in c&&((l=c==null?void 0:c.callback)==null||l.call(c))},[c]);export{i as useButtonHandler};
|
|
2
2
|
//# sourceMappingURL=useButtonHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useButtonHandler.js","sources":["../../../../../lib/widgets/buttonWithHandlers/model/useButtonHandler.ts"],"sourcesContent":["'use client'\n\nimport { useCallback } from 'react'\nimport type { ButtonHandlerOptions } from './types'\nimport { isClient, scrollToElement } from '$/shared/utils'\n\nexport const useButtonHandler = (handlerOptions: ButtonHandlerOptions) => {\n const handleClick = useCallback(() => {\n switch (handlerOptions.handler) {\n case 'navigate': {\n const { url, target, rel } = handlerOptions\n if (isClient) {\n window?.open(url, target, rel)\n }\n\n break\n }\n case 'scroll': {\n const { widgetId } = handlerOptions ?? ''\n scrollToElement({ widgetId })\n break\n }\n\n case 'dialog': {\n if (!isClient) return\n\n const { dialogId } = handlerOptions ?? {}\n\n const dialog = document.getElementById(dialogId) as HTMLDialogElement | null\n\n if (!dialog) {\n console.error('Такого элемента в DOM не существует', dialogId)\n break\n }\n\n dialog.show()\n }\n }\n }, [handlerOptions])\n\n return handleClick\n}\n"],"names":["useButtonHandler","handlerOptions","useCallback","url","target","rel","isClient","widgetId","scrollToElement","dialogId","dialog"],"mappings":"iOAMO,MAAMA,EAAoBC,GACXC,EAAY,IAAM,
|
|
1
|
+
{"version":3,"file":"useButtonHandler.js","sources":["../../../../../lib/widgets/buttonWithHandlers/model/useButtonHandler.ts"],"sourcesContent":["'use client'\n\nimport { useCallback } from 'react'\nimport type { ButtonHandlerOptions } from './types'\nimport { isClient, scrollToElement } from '$/shared/utils'\n\nexport const useButtonHandler = (handlerOptions: ButtonHandlerOptions) => {\n const handleClick = useCallback(() => {\n switch (handlerOptions.handler) {\n case 'navigate': {\n const { url, target, rel } = handlerOptions\n if (isClient) {\n window?.open(url, target, rel)\n }\n\n break\n }\n case 'scroll': {\n const { widgetId } = handlerOptions ?? ''\n scrollToElement({ widgetId })\n break\n }\n\n case 'dialog': {\n if (!isClient) return\n\n const { dialogId } = handlerOptions ?? {}\n\n const dialog = document.getElementById(dialogId) as HTMLDialogElement | null\n\n if (!dialog) {\n console.error('Такого элемента в DOM не существует', dialogId)\n break\n }\n\n dialog.show()\n }\n }\n\n if ('callback' in handlerOptions) {\n handlerOptions?.callback?.()\n }\n }, [handlerOptions])\n\n return handleClick\n}\n"],"names":["useButtonHandler","handlerOptions","useCallback","url","target","rel","isClient","widgetId","scrollToElement","dialogId","dialog","_a"],"mappings":"iOAMO,MAAMA,EAAoBC,GACXC,EAAY,IAAM,OACpC,OAAQD,EAAe,QAAA,CACrB,IAAK,WAAY,CACf,KAAM,CAAE,IAAAE,EAAK,OAAAC,EAAQ,IAAAC,CAAA,EAAQJ,EACzBK,IACF,qBAAQ,KAAKH,EAAKC,EAAQC,IAG5B,KACF,CACA,IAAK,SAAU,CACb,KAAM,CAAE,SAAAE,GAAaN,GAAkB,GACvCO,EAAgB,CAAE,SAAAD,EAAU,EAC5B,KACF,CAEA,IAAK,SAAU,CACb,GAAI,CAACD,EAAU,OAEf,KAAM,CAAE,SAAAG,GAAaR,GAAkB,CAAA,EAEjCS,EAAS,SAAS,eAAeD,CAAQ,EAE/C,GAAI,CAACC,EAAQ,CACX,QAAQ,MAAM,sCAAuCD,CAAQ,EAC7D,KACF,CAEAC,EAAO,KAAA,CACT,CAAA,CAGE,aAAcT,KAChBU,EAAAV,GAAA,YAAAA,EAAgB,WAAhB,MAAAU,EAAA,KAAAV,GAEJ,EAAG,CAACA,CAAc,CAAC"}
|