@salesforce/design-system-react 11.0.0-alpha.7 → 11.0.0-alpha.8
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/cjs/components/color-picker/color-picker.cjs +1 -1
- package/dist/cjs/components/color-picker/color-picker.cjs.map +1 -1
- package/dist/cjs/components/combobox/combobox.cjs +1 -1
- package/dist/cjs/components/combobox/combobox.cjs.map +1 -1
- package/dist/cjs/components/filter/filter.cjs +1 -1
- package/dist/cjs/components/filter/filter.cjs.map +1 -1
- package/dist/cjs/components/modal/check-props.cjs +2 -0
- package/dist/cjs/components/modal/check-props.cjs.map +1 -0
- package/dist/cjs/components/modal/component.cjs +2 -0
- package/dist/cjs/components/modal/component.cjs.map +1 -0
- package/dist/cjs/components/modal/index.cjs +1 -1
- package/dist/cjs/components/modal/index.cjs.map +1 -1
- package/dist/cjs/components/popover/component.cjs +2 -0
- package/dist/cjs/components/popover/component.cjs.map +1 -0
- package/dist/cjs/components/popover/edit-dialog.cjs +1 -1
- package/dist/cjs/components/popover/edit-dialog.cjs.map +1 -1
- package/dist/cjs/components/popover/popover.cjs +1 -1
- package/dist/cjs/components/popover/popover.cjs.map +1 -1
- package/dist/cjs/components/slider/check-props.cjs +1 -1
- package/dist/cjs/components/slider/check-props.cjs.map +1 -1
- package/dist/cjs/components/slider/index.cjs +1 -1
- package/dist/cjs/components/slider/index.cjs.map +1 -1
- package/dist/cjs/components/spinner/check-props.cjs +2 -0
- package/dist/cjs/components/spinner/check-props.cjs.map +1 -0
- package/dist/cjs/components/spinner/component.cjs +2 -0
- package/dist/cjs/components/spinner/component.cjs.map +1 -0
- package/dist/cjs/components/spinner/index.cjs +1 -1
- package/dist/cjs/components/spinner/index.cjs.map +1 -1
- package/dist/cjs/components/tree/check-props.cjs +1 -1
- package/dist/cjs/components/tree/check-props.cjs.map +1 -1
- package/dist/cjs/components/tree/tree.cjs +1 -1
- package/dist/cjs/components/tree/tree.cjs.map +1 -1
- package/dist/cjs/components/vertical-navigation/index.cjs +1 -1
- package/dist/cjs/components/vertical-navigation/index.cjs.map +1 -1
- package/dist/cjs/components/welcome-mat/index.cjs +1 -1
- package/dist/cjs/components/welcome-mat/index.cjs.map +1 -1
- package/dist/es/components/color-picker/color-picker.js +1 -1
- package/dist/es/components/color-picker/color-picker.js.map +1 -1
- package/dist/es/components/combobox/combobox.js +2 -2
- package/dist/es/components/combobox/combobox.js.map +1 -1
- package/dist/es/components/filter/filter.js +1 -1
- package/dist/es/components/filter/filter.js.map +1 -1
- package/dist/es/components/modal/check-props.js +22 -0
- package/dist/es/components/modal/check-props.js.map +1 -0
- package/dist/es/components/modal/component.js +35 -0
- package/dist/es/components/modal/component.js.map +1 -0
- package/dist/es/components/modal/index.js +118 -104
- package/dist/es/components/modal/index.js.map +1 -1
- package/dist/es/components/popover/component.js +59 -0
- package/dist/es/components/popover/component.js.map +1 -0
- package/dist/es/components/popover/edit-dialog.js +1 -1
- package/dist/es/components/popover/edit-dialog.js.map +1 -1
- package/dist/es/components/popover/popover.js +235 -191
- package/dist/es/components/popover/popover.js.map +1 -1
- package/dist/es/components/slider/check-props.js +1 -1
- package/dist/es/components/slider/check-props.js.map +1 -1
- package/dist/es/components/slider/index.js +63 -60
- package/dist/es/components/slider/index.js.map +1 -1
- package/dist/es/components/spinner/check-props.js +13 -0
- package/dist/es/components/spinner/check-props.js.map +1 -0
- package/dist/es/components/spinner/component.js +17 -0
- package/dist/es/components/spinner/component.js.map +1 -0
- package/dist/es/components/spinner/index.js +43 -29
- package/dist/es/components/spinner/index.js.map +1 -1
- package/dist/es/components/tree/check-props.js +1 -1
- package/dist/es/components/tree/check-props.js.map +1 -1
- package/dist/es/components/tree/tree.js +79 -73
- package/dist/es/components/tree/tree.js.map +1 -1
- package/dist/es/components/vertical-navigation/index.js +17 -16
- package/dist/es/components/vertical-navigation/index.js.map +1 -1
- package/dist/es/components/welcome-mat/index.js +51 -50
- package/dist/es/components/welcome-mat/index.js.map +1 -1
- package/dist/types/components/color-picker/color-picker.d.ts.map +1 -1
- package/dist/types/components/modal/check-props.d.ts +3 -0
- package/dist/types/components/modal/check-props.d.ts.map +1 -0
- package/dist/types/components/modal/index.d.ts +21 -13
- package/dist/types/components/modal/index.d.ts.map +1 -1
- package/dist/types/components/popover/popover.d.ts +24 -14
- package/dist/types/components/popover/popover.d.ts.map +1 -1
- package/dist/types/components/slider/check-props.d.ts.map +1 -1
- package/dist/types/components/slider/index.d.ts +9 -7
- package/dist/types/components/slider/index.d.ts.map +1 -1
- package/dist/types/components/spinner/check-props.d.ts +3 -0
- package/dist/types/components/spinner/check-props.d.ts.map +1 -0
- package/dist/types/components/spinner/index.d.ts +18 -9
- package/dist/types/components/spinner/index.d.ts.map +1 -1
- package/dist/types/components/tree/check-props.d.ts.map +1 -1
- package/dist/types/components/tree/tree.d.ts +8 -4
- package/dist/types/components/tree/tree.d.ts.map +1 -1
- package/dist/types/components/vertical-navigation/index.d.ts +7 -7
- package/dist/types/components/vertical-navigation/index.d.ts.map +1 -1
- package/dist/types/components/welcome-mat/index.d.ts +5 -6
- package/dist/types/components/welcome-mat/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/constants.cjs"),n=require("../../utilities/generate-id.cjs"),r=require("../button/index.cjs"),i=require("../input/index.cjs"),a=require("./check-props.cjs"),ee=require("./private/swatch.cjs"),o=require("../../utilities/color.cjs"),s=require("./private/custom-color.cjs"),te=require("./private/swatch-picker.cjs"),c=require("../tabs/index.cjs"),l=require("../tabs/panel.cjs"),u=require("../popover/index.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("classnames");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m={blueAbbreviated:`B`,cancelButton:`Cancel`,customTab:`Custom`,customTabActiveWorkingColorSwatch:`Working Color`,customTabTransparentSwatch:`Transparent Swatch`,greenAbbreviated:`G`,hexLabel:`Hex`,invalidColor:`The color entered is invalid`,invalidComponent:`The value needs to be an integer from 0-255`,redAbbreviated:`R`,submitButton:`Done`,swatchTab:`Default`,swatchTabTransparentSwatch:`Transparent Swatch`},h={saturationValueGrid:`Use arrow keys to select a saturation and brightness, on an x and y axis.`,hueSlider:`Select Hue`},g=`#e3abec.#c2dbf7.#9fd6ff.#9de7da.#9df0c0.#fff099.#fed49a.#d073e0.#86baf3.#5ebbff.#44d8be.#3be282.#ffe654.#ffb758.#bd35bd.#5779c1.#5679c0.#00aea9.#3cba4c.#f5bc25.#f99221.#580d8c.#001970.#0a2399.#0b7477.#0b6b50.#b67e11.#b85d0d.`.split(`.`),_=({assistiveText:e,className:_,classNameMenu:v,id:y,disabled:b=!1,errorText:x,errorTextWorkingColor:S,events:C={},hasStaticAlignment:w,hideInput:T=!1,isOpen:E,labels:D,menuPosition:O=`absolute`,swatchColors:k=g,defaultSelectedTab:A=`swatches`,variant:j=`base`,value:M,valueWorking:N,onClose:ne,onOpen:re,onRequestClose:P,onRequestOpen:F})=>{let I=(0,d.useMemo)(()=>({...m,...D}),[D]),L=(0,d.useMemo)(()=>({...h,...e}),[e]),ie=(0,d.useRef)(y||n.default()),R=y||ie.current,ae=(0,d.useRef)(null),z=(0,d.useCallback)(()=>o.default.getNewColor({hex:N||M},C.onValidateWorkingColor),[N,M,C.onValidateWorkingColor]),[B,V]=(0,d.useState)(M??``),[H,U]=(0,d.useState)(E||!1),[W,G]=(0,d.useState)(z),[K,q]=(0,d.useState)(z),[J,Y]=(0,d.useState)(x||``);(0,d.useEffect)(()=>{a.default(t.COLOR_PICKER,{assistiveText:e,className:_,classNameMenu:v,id:y,disabled:b,errorText:x,errorTextWorkingColor:S,events:C,hasStaticAlignment:w,hideInput:T,isOpen:E,labels:D,menuPosition:O,swatchColors:k,defaultSelectedTab:A,variant:j,value:M,valueWorking:N},{})},[]),(0,d.useEffect)(()=>{M!==void 0&&V(M)},[M]),(0,d.useEffect)(()=>{N!==void 0&&G(o.default.getNewColor({hex:N},C.onValidateWorkingColor))},[N,C.onValidateWorkingColor]),(0,d.useEffect)(()=>{E!==void 0&&U(E)},[E]);let X=(0,d.useCallback)((e,t)=>{let n=o.default.getNewColor(t,C.onValidateWorkingColor,W);q(W),G(n),C.onWorkingColorChange&&C.onWorkingColorChange(e,{color:n})},[C,W]),oe=(0,d.useCallback)(e=>{X(e,{hex:e.target.value})},[X]),Z=(0,d.useCallback)(()=>{let e=o.default.getNewColor({hex:B},C.onValidateWorkingColor);U(!1),G(e),q(e)},[B,C.onValidateWorkingColor]),se=(0,d.useCallback)((e,t)=>{(t.trigger===`clickOutside`||t.trigger===`cancel`)&&Z(),P&&P(e,t)},[Z,P]),ce=(0,d.useCallback)(e=>{Z(),P&&P(e,{trigger:`cancel`})},[Z,P]),Q=(0,d.useCallback)(e=>(t,n)=>{let r={};r[e]=n.value,X(t,r)},[X]),le=(0,d.useCallback)(e=>{X(e,{hue:e.target.value})},[X]),ue=(0,d.useCallback)((e,t)=>{let n=t.value,r=o.default.getHexFromNamedColor(n),i=!1;i=C.onValidateColor?C.onValidateColor(n):r?!0:o.default.isValidHex(n),V(n),G(o.default.getNewColor({hex:r||n,name:r?n.toLowerCase():null},C.onValidateWorkingColor)),Y(i?``:I.invalidColor||``),C.onChange&&C.onChange(e,{color:n,isValid:i})},[C,I.invalidColor]),$=(0,d.useCallback)(e=>(t,n)=>{let r={};r[e]=n.delta;let i=o.default.getDeltaColor(r,C.onValidateWorkingColor,W);q(W),G(i),C.onWorkingColorChange&&C.onWorkingColorChange(t,{color:i})},[C,W]),de=(0,d.useCallback)((e,t)=>{X(e,{saturation:t.saturation,value:t.value})},[X]),fe=(0,d.useCallback)(e=>{U(!1),V(W.hex),Y(``),C.onChange&&C.onChange(e,{color:W.hex,isValid:!0})},[C,W.hex]),pe=(0,d.useCallback)(()=>{let e=o.default.getNewColor({hex:W.hex},C.onValidateWorkingColor);U(e=>!e),G(e),F&&F()},[C.onValidateWorkingColor,F,W.hex]),me=(0,d.useCallback)((e,t)=>{X(e,{hex:t.hex})},[X]),he=()=>T?null:(0,p.jsx)(i.default,{"aria-describedby":!H&&J?`color-picker-summary-error-${R}`:void 0,className:(0,f.default)(`slds-color-picker__summary-input`,`slds-align-top`,{"slds-has-error":!!J}),disabled:b,id:`color-picker-summary-input-${R}`,onChange:ue,value:B}),ge=(0,p.jsxs)(c.default,{id:`color-picker-tabs-${R}`,defaultSelectedIndex:+(A===`custom`),children:[j!==`base`&&j!==`swatches`?null:(0,p.jsx)(l.default,{label:I.swatchTab??``,children:(0,p.jsx)(te.default,{color:W,labels:I,onSelect:me,swatchColors:k})}),j!==`base`&&j!==`custom`?null:(0,p.jsx)(l.default,{label:I.customTab??``,children:(0,p.jsx)(s.default,{assistiveText:L,id:R,color:W,errorTextWorkingColor:S,previousColor:K,labels:I,onBlueChange:Q(`blue`),onGreenChange:Q(`green`),onHexChange:Q(`hex`),onHueChange:le,onRedChange:Q(`red`),onSwatchChange:oe,onSaturationValueChange:de,onSaturationNavigate:$(`saturation`),onValueNavigate:$(`value`)})})]}),_e=(0,p.jsxs)(`div`,{className:`slds-color-picker__selector-footer`,children:[(0,p.jsx)(r.default,{className:`slds-color-picker__selector-cancel`,id:`color-picker-footer-cancel-${R}`,label:I.cancelButton,onClick:ce,variant:`neutral`}),(0,p.jsx)(r.default,{className:`slds-color-picker__selector-submit`,disabled:Object.keys(W.errors||{}).length>0,id:`color-picker-footer-submit-${R}`,label:I.submitButton,onClick:fe,variant:`brand`})]});return(0,p.jsx)(`div`,{className:(0,f.default)(`slds-color-picker`,_),ref:ae,children:(0,p.jsxs)(`div`,{className:`slds-color-picker__summary`,children:[(0,p.jsx)(`label`,{className:(0,f.default)(`slds-color-picker__summary-label`,L.label?`slds-assistive-text`:``),htmlFor:T?void 0:`color-picker-summary-input-${R}`,id:`color-picker-label-${R}`,children:L.label?L.label:I.label}),(0,p.jsx)(u.default,{ariaLabelledby:`color-picker-label-${R}`,align:`bottom left`,body:ge,
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/constants.cjs"),n=require("../../utilities/generate-id.cjs"),r=require("../button/index.cjs"),i=require("../input/index.cjs"),a=require("./check-props.cjs"),ee=require("./private/swatch.cjs"),o=require("../../utilities/color.cjs"),s=require("./private/custom-color.cjs"),te=require("./private/swatch-picker.cjs"),c=require("../tabs/index.cjs"),l=require("../tabs/panel.cjs"),u=require("../popover/index.cjs");let d=require("react");d=e.__toESM(d,1);let f=require("classnames");f=e.__toESM(f,1);let p=require("react/jsx-runtime");var m={blueAbbreviated:`B`,cancelButton:`Cancel`,customTab:`Custom`,customTabActiveWorkingColorSwatch:`Working Color`,customTabTransparentSwatch:`Transparent Swatch`,greenAbbreviated:`G`,hexLabel:`Hex`,invalidColor:`The color entered is invalid`,invalidComponent:`The value needs to be an integer from 0-255`,redAbbreviated:`R`,submitButton:`Done`,swatchTab:`Default`,swatchTabTransparentSwatch:`Transparent Swatch`},h={saturationValueGrid:`Use arrow keys to select a saturation and brightness, on an x and y axis.`,hueSlider:`Select Hue`},g=`#e3abec.#c2dbf7.#9fd6ff.#9de7da.#9df0c0.#fff099.#fed49a.#d073e0.#86baf3.#5ebbff.#44d8be.#3be282.#ffe654.#ffb758.#bd35bd.#5779c1.#5679c0.#00aea9.#3cba4c.#f5bc25.#f99221.#580d8c.#001970.#0a2399.#0b7477.#0b6b50.#b67e11.#b85d0d.`.split(`.`),_=({assistiveText:e,className:_,classNameMenu:v,id:y,disabled:b=!1,errorText:x,errorTextWorkingColor:S,events:C={},hasStaticAlignment:w,hideInput:T=!1,isOpen:E,labels:D,menuPosition:O=`absolute`,swatchColors:k=g,defaultSelectedTab:A=`swatches`,variant:j=`base`,value:M,valueWorking:N,onClose:ne,onOpen:re,onRequestClose:P,onRequestOpen:F})=>{let I=(0,d.useMemo)(()=>({...m,...D}),[D]),L=(0,d.useMemo)(()=>({...h,...e}),[e]),ie=(0,d.useRef)(y||n.default()),R=y||ie.current,ae=(0,d.useRef)(null),z=(0,d.useCallback)(()=>o.default.getNewColor({hex:N||M},C.onValidateWorkingColor),[N,M,C.onValidateWorkingColor]),[B,V]=(0,d.useState)(M??``),[H,U]=(0,d.useState)(E||!1),[W,G]=(0,d.useState)(z),[K,q]=(0,d.useState)(z),[J,Y]=(0,d.useState)(x||``);(0,d.useEffect)(()=>{a.default(t.COLOR_PICKER,{assistiveText:e,className:_,classNameMenu:v,id:y,disabled:b,errorText:x,errorTextWorkingColor:S,events:C,hasStaticAlignment:w,hideInput:T,isOpen:E,labels:D,menuPosition:O,swatchColors:k,defaultSelectedTab:A,variant:j,value:M,valueWorking:N},{})},[]),(0,d.useEffect)(()=>{M!==void 0&&V(M)},[M]),(0,d.useEffect)(()=>{N!==void 0&&G(o.default.getNewColor({hex:N},C.onValidateWorkingColor))},[N,C.onValidateWorkingColor]),(0,d.useEffect)(()=>{E!==void 0&&U(E)},[E]);let X=(0,d.useCallback)((e,t)=>{let n=o.default.getNewColor(t,C.onValidateWorkingColor,W);q(W),G(n),C.onWorkingColorChange&&C.onWorkingColorChange(e,{color:n})},[C,W]),oe=(0,d.useCallback)(e=>{X(e,{hex:e.target.value})},[X]),Z=(0,d.useCallback)(()=>{let e=o.default.getNewColor({hex:B},C.onValidateWorkingColor);U(!1),G(e),q(e)},[B,C.onValidateWorkingColor]),se=(0,d.useCallback)((e,t)=>{(t.trigger===`clickOutside`||t.trigger===`cancel`)&&Z(),P&&P(e,t)},[Z,P]),ce=(0,d.useCallback)(e=>{Z(),P&&P(e,{trigger:`cancel`})},[Z,P]),Q=(0,d.useCallback)(e=>(t,n)=>{let r={};r[e]=n.value,X(t,r)},[X]),le=(0,d.useCallback)(e=>{X(e,{hue:e.target.value})},[X]),ue=(0,d.useCallback)((e,t)=>{let n=t.value,r=o.default.getHexFromNamedColor(n),i=!1;i=C.onValidateColor?C.onValidateColor(n):r?!0:o.default.isValidHex(n),V(n),G(o.default.getNewColor({hex:r||n,name:r?n.toLowerCase():null},C.onValidateWorkingColor)),Y(i?``:I.invalidColor||``),C.onChange&&C.onChange(e,{color:n,isValid:i})},[C,I.invalidColor]),$=(0,d.useCallback)(e=>(t,n)=>{let r={};r[e]=n.delta;let i=o.default.getDeltaColor(r,C.onValidateWorkingColor,W);q(W),G(i),C.onWorkingColorChange&&C.onWorkingColorChange(t,{color:i})},[C,W]),de=(0,d.useCallback)((e,t)=>{X(e,{saturation:t.saturation,value:t.value})},[X]),fe=(0,d.useCallback)(e=>{U(!1),V(W.hex),Y(``),C.onChange&&C.onChange(e,{color:W.hex,isValid:!0})},[C,W.hex]),pe=(0,d.useCallback)(()=>{let e=o.default.getNewColor({hex:W.hex},C.onValidateWorkingColor);U(e=>!e),G(e),F&&F()},[C.onValidateWorkingColor,F,W.hex]),me=(0,d.useCallback)((e,t)=>{X(e,{hex:t.hex})},[X]),he=()=>T?null:(0,p.jsx)(i.default,{"aria-describedby":!H&&J?`color-picker-summary-error-${R}`:void 0,className:(0,f.default)(`slds-color-picker__summary-input`,`slds-align-top`,{"slds-has-error":!!J}),disabled:b,id:`color-picker-summary-input-${R}`,onChange:ue,value:B}),ge=(0,p.jsxs)(c.default,{id:`color-picker-tabs-${R}`,defaultSelectedIndex:+(A===`custom`),children:[j!==`base`&&j!==`swatches`?null:(0,p.jsx)(l.default,{label:I.swatchTab??``,children:(0,p.jsx)(te.default,{color:W,labels:I,onSelect:me,swatchColors:k})}),j!==`base`&&j!==`custom`?null:(0,p.jsx)(l.default,{label:I.customTab??``,children:(0,p.jsx)(s.default,{assistiveText:L,id:R,color:W,errorTextWorkingColor:S,previousColor:K,labels:I,onBlueChange:Q(`blue`),onGreenChange:Q(`green`),onHexChange:Q(`hex`),onHueChange:le,onRedChange:Q(`red`),onSwatchChange:oe,onSaturationValueChange:de,onSaturationNavigate:$(`saturation`),onValueNavigate:$(`value`)})})]}),_e=(0,p.jsxs)(`div`,{className:`slds-color-picker__selector-footer`,children:[(0,p.jsx)(r.default,{className:`slds-color-picker__selector-cancel`,id:`color-picker-footer-cancel-${R}`,label:I.cancelButton,onClick:ce,variant:`neutral`}),(0,p.jsx)(r.default,{className:`slds-color-picker__selector-submit`,disabled:Object.keys(W.errors||{}).length>0,id:`color-picker-footer-submit-${R}`,label:I.submitButton,onClick:fe,variant:`brand`})]});return(0,p.jsx)(`div`,{className:(0,f.default)(`slds-color-picker`,_),ref:ae,children:(0,p.jsxs)(`div`,{className:`slds-color-picker__summary`,children:[(0,p.jsx)(`label`,{className:(0,f.default)(`slds-color-picker__summary-label`,L.label?`slds-assistive-text`:``),htmlFor:T?void 0:`color-picker-summary-input-${R}`,id:`color-picker-label-${R}`,children:L.label?L.label:I.label}),(0,p.jsx)(u.default,{ariaLabelledby:`color-picker-label-${R}`,align:`bottom left`,body:ge,classNameDialog:(0,f.default)(`slds-color-picker__selector`,v),footer:_e,hasNoCloseButton:!0,hasNoNubbin:!0,hasStaticAlignment:w,id:`slds-color-picker__selector-${R}`,isOpen:H,onClose:ne,onOpen:re,onRequestClose:se,position:O,children:(0,p.jsx)(r.default,{className:`slds-color-picker__summary-button`,disabled:b,iconClassName:`slds-m-left_xx-small`,iconPosition:`right`,iconVariant:`more`,id:`slds-color-picker__summary-button-${R}`,label:(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`span`,{className:`slds-assistive-text`,children:L.label?L.label:I.label}),(0,p.jsx)(ee.default,{color:B,labels:I})]}),onClick:pe,variant:`icon`})}),he(),!H&&J&&(0,p.jsx)(`p`,{className:`slds-form-error`,id:`color-picker-summary-error-${R}`,children:J})]})})};_.displayName=t.COLOR_PICKER,exports.default=_;
|
|
2
2
|
//# sourceMappingURL=color-picker.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-picker.cjs","names":[],"sources":["../../../../components/color-picker/color-picker.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport React, {\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n\tuseMemo,\n} from 'react';\nimport classNames from 'classnames';\n\nimport checkProps from './check-props';\n\nimport CustomColor from './private/custom-color';\nimport Swatch from './private/swatch';\nimport SwatchPicker from './private/swatch-picker';\n\nimport Button from '../button';\nimport Input, { type InputChangeData } from '../input';\nimport Tabs from '../tabs';\nimport TabsPanel from '../tabs/panel';\nimport Popover from '../popover';\n\nimport ColorUtils from '../../utilities/color';\nimport { COLOR_PICKER } from '../../utilities/constants';\nimport generateId from '../../utilities/generate-id';\n\nimport {\n\tWorkingColor,\n\tColorPickerAssistiveText,\n\tColorPickerLabels,\n\tColorPickerEvents,\n} from './types';\n\ninterface ColorPickerBaseProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: ColorPickerAssistiveText;\n\t/** CSS classes for the color-picker container */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** CSS classes for the popover menu */\n\tclassNameMenu?: string | string[] | Record<string, boolean>;\n\t/** Unique ID for the component */\n\tid?: string;\n\t/** Disables the input and button */\n\tdisabled?: boolean;\n\t/** Error message for the outer input */\n\terrorText?: string;\n\t/** Error message for the custom tab working color input */\n\terrorTextWorkingColor?: string;\n\t/** Event callbacks */\n\tevents?: ColorPickerEvents;\n\t/** Disable flip behavior for popover alignment */\n\thasStaticAlignment?: boolean;\n\t/** Hides the text input */\n\thideInput?: boolean;\n\t/** Controlled popover open state */\n\tisOpen?: boolean;\n\t/** Text labels for internationalization */\n\tlabels?: ColorPickerLabels;\n\t/** Popover position strategy */\n\tmenuPosition?: 'absolute' | 'overflowBoundaryElement' | 'relative';\n\t/** Current color in hexadecimal string */\n\tvalue?: string;\n\t/** Current working color in hexadecimal string */\n\tvalueWorking?: string;\n\t/** Callback when popover closes */\n\tonClose?: (\n\t\tevent: React.SyntheticEvent,\n\t\tdata: { trigger?: string; componentWillUnmount?: boolean }\n\t) => void;\n\t/** Callback when popover opens */\n\tonOpen?: (\n\t\tevent: React.SyntheticEvent,\n\t\tdata: { portal?: HTMLElement }\n\t) => void;\n\t/** Callback when user requests close */\n\tonRequestClose?: (\n\t\tevent: React.SyntheticEvent,\n\t\tdata: { trigger: string }\n\t) => void;\n\t/** Callback when popover requests to open */\n\tonRequestOpen?: () => void;\n}\n\n/**\n * `variant` sets which tabs are present. `swatchColors` needs the swatch tab\n * and `defaultSelectedTab` only applies when both tabs are present.\n */\nexport type ColorPickerVariantProps =\n\t| {\n\t\t\t/** Both the swatch and custom tabs */\n\t\t\tvariant?: 'base';\n\t\t\t/** Array of hex color values for swatch options */\n\t\t\tswatchColors?: string[];\n\t\t\t/** Which tab is visible when dialog opens */\n\t\t\tdefaultSelectedTab?: 'swatches' | 'custom';\n\t }\n\t| {\n\t\t\t/** Only the swatch tab */\n\t\t\tvariant: 'swatches';\n\t\t\t/** Array of hex color values for swatch options */\n\t\t\tswatchColors?: string[];\n\t\t\tdefaultSelectedTab?: never;\n\t }\n\t| {\n\t\t\t/** Only the custom tab */\n\t\t\tvariant: 'custom';\n\t\t\tswatchColors?: never;\n\t\t\tdefaultSelectedTab?: never;\n\t };\n\nexport type ColorPickerProps = ColorPickerBaseProps & ColorPickerVariantProps;\n\nconst defaultLabels: ColorPickerLabels = {\n\tblueAbbreviated: 'B',\n\tcancelButton: 'Cancel',\n\tcustomTab: 'Custom',\n\tcustomTabActiveWorkingColorSwatch: 'Working Color',\n\tcustomTabTransparentSwatch: 'Transparent Swatch',\n\tgreenAbbreviated: 'G',\n\thexLabel: 'Hex',\n\tinvalidColor: 'The color entered is invalid',\n\tinvalidComponent: 'The value needs to be an integer from 0-255',\n\tredAbbreviated: 'R',\n\tsubmitButton: 'Done',\n\tswatchTab: 'Default',\n\tswatchTabTransparentSwatch: 'Transparent Swatch',\n};\n\nconst defaultAssistiveText: ColorPickerAssistiveText = {\n\tsaturationValueGrid:\n\t\t'Use arrow keys to select a saturation and brightness, on an x and y axis.',\n\thueSlider: 'Select Hue',\n};\n\nconst defaultSwatchColors = [\n\t'#e3abec',\n\t'#c2dbf7',\n\t'#9fd6ff',\n\t'#9de7da',\n\t'#9df0c0',\n\t'#fff099',\n\t'#fed49a',\n\t'#d073e0',\n\t'#86baf3',\n\t'#5ebbff',\n\t'#44d8be',\n\t'#3be282',\n\t'#ffe654',\n\t'#ffb758',\n\t'#bd35bd',\n\t'#5779c1',\n\t'#5679c0',\n\t'#00aea9',\n\t'#3cba4c',\n\t'#f5bc25',\n\t'#f99221',\n\t'#580d8c',\n\t'#001970',\n\t'#0a2399',\n\t'#0b7477',\n\t'#0b6b50',\n\t'#b67e11',\n\t'#b85d0d',\n\t'',\n];\n\n/**\n * The Unified Color Picker component allows for a fully accessible and\n * configurable color picker, allowing the user to pick from a set of\n * predefined colors (swatches), or to pick a custom color using a HSB\n * selection interface.\n */\nconst ColorPicker: React.FC<ColorPickerProps> = ({\n\tassistiveText: assistiveTextProp,\n\tclassName,\n\tclassNameMenu,\n\tid: idProp,\n\tdisabled = false,\n\terrorText: errorTextProp,\n\terrorTextWorkingColor,\n\tevents = {},\n\thasStaticAlignment,\n\thideInput = false,\n\tisOpen: isOpenProp,\n\tlabels: labelsProp,\n\tmenuPosition = 'absolute',\n\tswatchColors = defaultSwatchColors,\n\tdefaultSelectedTab = 'swatches',\n\tvariant = 'base',\n\tvalue: valueProp,\n\tvalueWorking: valueWorkingProp,\n\tonClose,\n\tonOpen,\n\tonRequestClose,\n\tonRequestOpen,\n}) => {\n\t// Merge labels and assistive text with defaults\n\tconst labels = useMemo(\n\t\t() => ({ ...defaultLabels, ...labelsProp }),\n\t\t[labelsProp]\n\t);\n\tconst assistiveText = useMemo(\n\t\t() => ({ ...defaultAssistiveText, ...assistiveTextProp }),\n\t\t[assistiveTextProp]\n\t);\n\n\t// Generate stable ID\n\tconst generatedId = useRef(idProp || generateId());\n\tconst componentId = idProp || generatedId.current;\n\n\t// Refs\n\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\t// Initialize working color from props\n\tconst getInitialWorkingColor = useCallback((): WorkingColor => {\n\t\treturn ColorUtils.getNewColor(\n\t\t\t{ hex: valueWorkingProp || valueProp },\n\t\t\tevents.onValidateWorkingColor\n\t\t) as WorkingColor;\n\t}, [valueWorkingProp, valueProp, events.onValidateWorkingColor]);\n\n\t// State\n\tconst [currentColor, setCurrentColor] = useState<string>(\n\t\tvalueProp != null ? valueProp : ''\n\t);\n\tconst [isOpen, setIsOpen] = useState<boolean>(isOpenProp || false);\n\tconst [workingColor, setWorkingColor] = useState<WorkingColor>(\n\t\tgetInitialWorkingColor\n\t);\n\tconst [previousWorkingColor, setPreviousWorkingColor] =\n\t\tuseState<WorkingColor>(getInitialWorkingColor);\n\tconst [colorErrorMessage, setColorErrorMessage] = useState<string>(\n\t\terrorTextProp || ''\n\t);\n\n\t// Check props on mount (development only)\n\tuseEffect(() => {\n\t\t// checkProps is a no-op in production\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t(checkProps as any)(\n\t\t\tCOLOR_PICKER,\n\t\t\t{\n\t\t\t\tassistiveText: assistiveTextProp,\n\t\t\t\tclassName,\n\t\t\t\tclassNameMenu,\n\t\t\t\tid: idProp,\n\t\t\t\tdisabled,\n\t\t\t\terrorText: errorTextProp,\n\t\t\t\terrorTextWorkingColor,\n\t\t\t\tevents,\n\t\t\t\thasStaticAlignment,\n\t\t\t\thideInput,\n\t\t\t\tisOpen: isOpenProp,\n\t\t\t\tlabels: labelsProp,\n\t\t\t\tmenuPosition,\n\t\t\t\tswatchColors,\n\t\t\t\tdefaultSelectedTab,\n\t\t\t\tvariant,\n\t\t\t\tvalue: valueProp,\n\t\t\t\tvalueWorking: valueWorkingProp,\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\t// Sync props to state when they change externally\n\tuseEffect(() => {\n\t\tif (valueProp !== undefined) {\n\t\t\tsetCurrentColor(valueProp);\n\t\t}\n\t}, [valueProp]);\n\n\tuseEffect(() => {\n\t\tif (valueWorkingProp !== undefined) {\n\t\t\tsetWorkingColor(\n\t\t\t\tColorUtils.getNewColor(\n\t\t\t\t\t{ hex: valueWorkingProp },\n\t\t\t\t\tevents.onValidateWorkingColor\n\t\t\t\t) as WorkingColor\n\t\t\t);\n\t\t}\n\t}, [valueWorkingProp, events.onValidateWorkingColor]);\n\n\tuseEffect(() => {\n\t\tif (isOpenProp !== undefined) {\n\t\t\tsetIsOpen(isOpenProp);\n\t\t}\n\t}, [isOpenProp]);\n\n\t// Helper to update working color\n\tconst updateWorkingColor = useCallback(\n\t\t(\n\t\t\tevent: React.SyntheticEvent,\n\t\t\tcolorOptions: {\n\t\t\t\thex?: string;\n\t\t\t\tred?: string | number;\n\t\t\t\tgreen?: string | number;\n\t\t\t\tblue?: string | number;\n\t\t\t\thue?: number | string;\n\t\t\t\tsaturation?: number;\n\t\t\t\tvalue?: number;\n\t\t\t}\n\t\t) => {\n\t\t\tconst newColor = ColorUtils.getNewColor(\n\t\t\t\tcolorOptions,\n\t\t\t\tevents.onValidateWorkingColor,\n\t\t\t\tworkingColor\n\t\t\t) as WorkingColor;\n\t\t\tsetPreviousWorkingColor(workingColor);\n\t\t\tsetWorkingColor(newColor);\n\n\t\t\tif (events.onWorkingColorChange) {\n\t\t\t\tevents.onWorkingColorChange(event, { color: newColor });\n\t\t\t}\n\t\t},\n\t\t[events, workingColor]\n\t);\n\n\t// Event handlers\n\tconst handleSwatchChange = useCallback(\n\t\t(event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\tupdateWorkingColor(event, { hex: event.target.value });\n\t\t},\n\t\t[updateWorkingColor]\n\t);\n\n\tconst handleCancelState = useCallback(() => {\n\t\tconst resetColor = ColorUtils.getNewColor(\n\t\t\t{ hex: currentColor },\n\t\t\tevents.onValidateWorkingColor\n\t\t) as WorkingColor;\n\t\tsetIsOpen(false);\n\t\tsetWorkingColor(resetColor);\n\t\tsetPreviousWorkingColor(resetColor);\n\t}, [currentColor, events.onValidateWorkingColor]);\n\n\tconst handleOnRequestClose = useCallback(\n\t\t(event: React.SyntheticEvent, data: { trigger: string }) => {\n\t\t\tif (data.trigger === 'clickOutside' || data.trigger === 'cancel') {\n\t\t\t\thandleCancelState();\n\t\t\t}\n\n\t\t\tif (onRequestClose) {\n\t\t\t\tonRequestClose(event, data);\n\t\t\t}\n\t\t},\n\t\t[handleCancelState, onRequestClose]\n\t);\n\n\tconst handleCancel = useCallback(\n\t\t(event: React.MouseEvent) => {\n\t\t\thandleCancelState();\n\n\t\t\tif (onRequestClose) {\n\t\t\t\tonRequestClose(event, { trigger: 'cancel' });\n\t\t\t}\n\t\t},\n\t\t[handleCancelState, onRequestClose]\n\t);\n\n\tconst handleColorChange = useCallback(\n\t\t(property: 'hex' | 'red' | 'green' | 'blue') =>\n\t\t\t(event: React.SyntheticEvent, data: InputChangeData) => {\n\t\t\t\tconst colorProperties: Record<string, string | number> = {};\n\t\t\t\tcolorProperties[property] = data.value;\n\t\t\t\tupdateWorkingColor(event, colorProperties);\n\t\t\t},\n\t\t[updateWorkingColor]\n\t);\n\n\tconst handleHueChange = useCallback(\n\t\t(event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\tupdateWorkingColor(event, { hue: event.target.value });\n\t\t},\n\t\t[updateWorkingColor]\n\t);\n\n\tconst handleHexInputChange = useCallback(\n\t\t(event: React.SyntheticEvent, data: InputChangeData) => {\n\t\t\tconst newCurrentColor = data.value;\n\t\t\tconst namedColorHex = ColorUtils.getHexFromNamedColor(newCurrentColor);\n\t\t\tlet isValid = false;\n\n\t\t\tif (events.onValidateColor) {\n\t\t\t\tisValid = events.onValidateColor(newCurrentColor);\n\t\t\t} else {\n\t\t\t\tisValid = namedColorHex ? true : ColorUtils.isValidHex(newCurrentColor);\n\t\t\t}\n\n\t\t\tsetCurrentColor(newCurrentColor);\n\t\t\tsetWorkingColor(\n\t\t\t\tColorUtils.getNewColor(\n\t\t\t\t\t{\n\t\t\t\t\t\thex: namedColorHex || newCurrentColor,\n\t\t\t\t\t\tname: namedColorHex ? newCurrentColor.toLowerCase() : null,\n\t\t\t\t\t} as { hex: string; name?: string | null },\n\t\t\t\t\tevents.onValidateWorkingColor\n\t\t\t\t) as WorkingColor\n\t\t\t);\n\t\t\tsetColorErrorMessage(isValid ? '' : labels.invalidColor || '');\n\n\t\t\tif (events.onChange) {\n\t\t\t\tevents.onChange(event, {\n\t\t\t\t\tcolor: newCurrentColor,\n\t\t\t\t\tisValid,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[events, labels.invalidColor]\n\t);\n\n\tconst handleNavigate = useCallback(\n\t\t(property: 'saturation' | 'value') =>\n\t\t\t(event: React.KeyboardEvent, data: { delta: number }) => {\n\t\t\t\tconst colorProperties: Record<string, number> = {};\n\t\t\t\tcolorProperties[property] = data.delta;\n\t\t\t\tconst newColor = ColorUtils.getDeltaColor(\n\t\t\t\t\tcolorProperties,\n\t\t\t\t\tevents.onValidateWorkingColor,\n\t\t\t\t\tworkingColor\n\t\t\t\t) as WorkingColor;\n\t\t\t\tsetPreviousWorkingColor(workingColor);\n\t\t\t\tsetWorkingColor(newColor);\n\n\t\t\t\tif (events.onWorkingColorChange) {\n\t\t\t\t\tevents.onWorkingColorChange(event, { color: newColor });\n\t\t\t\t}\n\t\t\t},\n\t\t[events, workingColor]\n\t);\n\n\tconst handleSaturationValueChange = useCallback(\n\t\t(\n\t\t\tevent: React.MouseEvent | React.KeyboardEvent,\n\t\t\tdata: { saturation: number; value: number }\n\t\t) => {\n\t\t\tupdateWorkingColor(event, {\n\t\t\t\tsaturation: data.saturation,\n\t\t\t\tvalue: data.value,\n\t\t\t});\n\t\t},\n\t\t[updateWorkingColor]\n\t);\n\n\tconst handleSubmitButtonClick = useCallback(\n\t\t(event: React.MouseEvent) => {\n\t\t\tsetIsOpen(false);\n\t\t\tsetCurrentColor(workingColor.hex);\n\t\t\tsetColorErrorMessage('');\n\n\t\t\tif (events.onChange) {\n\t\t\t\tevents.onChange(event, {\n\t\t\t\t\tcolor: workingColor.hex,\n\t\t\t\t\tisValid: true,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[events, workingColor.hex]\n\t);\n\n\tconst handleSwatchButtonClick = useCallback(() => {\n\t\tconst newWorkingColor = ColorUtils.getNewColor(\n\t\t\t{ hex: workingColor.hex },\n\t\t\tevents.onValidateWorkingColor\n\t\t) as WorkingColor;\n\t\tsetIsOpen((prev) => !prev);\n\t\tsetWorkingColor(newWorkingColor);\n\n\t\tif (onRequestOpen) {\n\t\t\tonRequestOpen();\n\t\t}\n\t}, [events.onValidateWorkingColor, onRequestOpen, workingColor.hex]);\n\n\tconst handleSwatchSelect = useCallback(\n\t\t(event: React.MouseEvent | React.KeyboardEvent, data: { hex: string }) => {\n\t\t\tupdateWorkingColor(event, { hex: data.hex });\n\t\t},\n\t\t[updateWorkingColor]\n\t);\n\n\t// Render helpers\n\tconst renderInput = () => {\n\t\tif (hideInput) return null;\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\taria-describedby={\n\t\t\t\t\t!isOpen && colorErrorMessage\n\t\t\t\t\t\t? `color-picker-summary-error-${componentId}`\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'slds-color-picker__summary-input',\n\t\t\t\t\t'slds-align-top',\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-has-error': !!colorErrorMessage,\n\t\t\t\t\t}\n\t\t\t\t)}\n\t\t\t\tdisabled={disabled}\n\t\t\t\tid={`color-picker-summary-input-${componentId}`}\n\t\t\t\tonChange={handleHexInputChange}\n\t\t\t\tvalue={currentColor}\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst renderDefaultTab = () => {\n\t\tif (variant !== 'base' && variant !== 'swatches') return null;\n\n\t\treturn (\n\t\t\t<TabsPanel label={labels.swatchTab ?? ''}>\n\t\t\t\t<SwatchPicker\n\t\t\t\t\tcolor={workingColor}\n\t\t\t\t\tlabels={labels}\n\t\t\t\t\tonSelect={handleSwatchSelect}\n\t\t\t\t\tswatchColors={swatchColors}\n\t\t\t\t/>\n\t\t\t</TabsPanel>\n\t\t);\n\t};\n\n\tconst renderCustomTab = () => {\n\t\tif (variant !== 'base' && variant !== 'custom') return null;\n\n\t\treturn (\n\t\t\t<TabsPanel label={labels.customTab ?? ''}>\n\t\t\t\t<CustomColor\n\t\t\t\t\tassistiveText={assistiveText}\n\t\t\t\t\tid={componentId}\n\t\t\t\t\tcolor={workingColor}\n\t\t\t\t\terrorTextWorkingColor={errorTextWorkingColor}\n\t\t\t\t\tpreviousColor={previousWorkingColor}\n\t\t\t\t\tlabels={labels}\n\t\t\t\t\tonBlueChange={handleColorChange('blue')}\n\t\t\t\t\tonGreenChange={handleColorChange('green')}\n\t\t\t\t\tonHexChange={handleColorChange('hex')}\n\t\t\t\t\tonHueChange={handleHueChange}\n\t\t\t\t\tonRedChange={handleColorChange('red')}\n\t\t\t\t\tonSwatchChange={handleSwatchChange}\n\t\t\t\t\tonSaturationValueChange={handleSaturationValueChange}\n\t\t\t\t\tonSaturationNavigate={handleNavigate('saturation')}\n\t\t\t\t\tonValueNavigate={handleNavigate('value')}\n\t\t\t\t/>\n\t\t\t</TabsPanel>\n\t\t);\n\t};\n\n\tconst popoverBody = (\n\t\t<Tabs\n\t\t\tid={`color-picker-tabs-${componentId}`}\n\t\t\tdefaultSelectedIndex={defaultSelectedTab === 'custom' ? 1 : 0}\n\t\t>\n\t\t\t{renderDefaultTab()}\n\t\t\t{renderCustomTab()}\n\t\t</Tabs>\n\t);\n\n\tconst popoverFooter = (\n\t\t<div className=\"slds-color-picker__selector-footer\">\n\t\t\t<Button\n\t\t\t\tclassName=\"slds-color-picker__selector-cancel\"\n\t\t\t\tid={`color-picker-footer-cancel-${componentId}`}\n\t\t\t\tlabel={labels.cancelButton}\n\t\t\t\tonClick={handleCancel}\n\t\t\t\tvariant=\"neutral\"\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tclassName=\"slds-color-picker__selector-submit\"\n\t\t\t\tdisabled={Object.keys(workingColor.errors || {}).length > 0}\n\t\t\t\tid={`color-picker-footer-submit-${componentId}`}\n\t\t\t\tlabel={labels.submitButton}\n\t\t\t\tonClick={handleSubmitButtonClick}\n\t\t\t\tvariant=\"brand\"\n\t\t\t/>\n\t\t</div>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames('slds-color-picker', className)}\n\t\t\tref={wrapperRef}\n\t\t>\n\t\t\t<div className=\"slds-color-picker__summary\">\n\t\t\t\t<label\n\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t'slds-color-picker__summary-label',\n\t\t\t\t\t\tassistiveText.label ? 'slds-assistive-text' : ''\n\t\t\t\t\t)}\n\t\t\t\t\thtmlFor={\n\t\t\t\t\t\t!hideInput ? `color-picker-summary-input-${componentId}` : undefined\n\t\t\t\t\t}\n\t\t\t\t\tid={`color-picker-label-${componentId}`}\n\t\t\t\t>\n\t\t\t\t\t{assistiveText.label ? assistiveText.label : labels.label}\n\t\t\t\t</label>\n\t\t\t\t<Popover\n\t\t\t\t\tariaLabelledby={`color-picker-label-${componentId}`}\n\t\t\t\t\talign=\"bottom left\"\n\t\t\t\t\tbody={popoverBody}\n\t\t\t\t\tclassName={classNames('slds-color-picker__selector', classNameMenu)}\n\t\t\t\t\tfooter={popoverFooter}\n\t\t\t\t\thasNoCloseButton\n\t\t\t\t\thasNoNubbin\n\t\t\t\t\thasStaticAlignment={hasStaticAlignment}\n\t\t\t\t\tid={`slds-color-picker__selector-${componentId}`}\n\t\t\t\t\tisOpen={isOpen}\n\t\t\t\t\tonClose={\n\t\t\t\t\t\tonClose as unknown as\n\t\t\t\t\t\t\t| ((\n\t\t\t\t\t\t\t\t\tevent?: unknown,\n\t\t\t\t\t\t\t\t\tdata?: { componentWillUnmount?: boolean }\n\t\t\t\t\t\t\t ) => void)\n\t\t\t\t\t\t\t| undefined\n\t\t\t\t\t}\n\t\t\t\t\tonOpen={\n\t\t\t\t\t\tonOpen as unknown as\n\t\t\t\t\t\t\t| ((event?: unknown, data?: { portal?: HTMLElement }) => void)\n\t\t\t\t\t\t\t| undefined\n\t\t\t\t\t}\n\t\t\t\t\tonRequestClose={\n\t\t\t\t\t\thandleOnRequestClose as unknown as\n\t\t\t\t\t\t\t| ((event?: unknown, data?: { trigger?: string }) => void)\n\t\t\t\t\t\t\t| undefined\n\t\t\t\t\t}\n\t\t\t\t\tposition={menuPosition}\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"slds-color-picker__summary-button\"\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\ticonClassName=\"slds-m-left_xx-small\"\n\t\t\t\t\t\ticonPosition=\"right\"\n\t\t\t\t\t\ticonVariant=\"more\"\n\t\t\t\t\t\tid={`slds-color-picker__summary-button-${componentId}`}\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<span className=\"slds-assistive-text\">\n\t\t\t\t\t\t\t\t\t{assistiveText.label ? assistiveText.label : labels.label}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<Swatch color={currentColor} labels={labels} />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClick={handleSwatchButtonClick}\n\t\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t/>\n\t\t\t\t</Popover>\n\t\t\t\t{renderInput()}\n\t\t\t\t{!isOpen && colorErrorMessage && (\n\t\t\t\t\t<p\n\t\t\t\t\t\tclassName=\"slds-form-error\"\n\t\t\t\t\t\tid={`color-picker-summary-error-${componentId}`}\n\t\t\t\t\t>\n\t\t\t\t\t\t{colorErrorMessage}\n\t\t\t\t\t</p>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nColorPicker.displayName = COLOR_PICKER;\n\nexport default ColorPicker;\n"],"mappings":"omBAgHA,IAAM,EAAmC,CACxC,gBAAiB,IACjB,aAAc,SACd,UAAW,SACX,kCAAmC,gBACnC,2BAA4B,qBAC5B,iBAAkB,IAClB,SAAU,MACV,aAAc,+BACd,iBAAkB,8CAClB,eAAgB,IAChB,aAAc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zB,SAAA,EAAc,MAAQ,EAAc,MAAQ,EAAO,KAC9C,CAAA,GACP,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,eAAgB,sBAAsB,IACtC,MAAM,cACN,KAAM,GACN,WAAA,EAAW,EAAA,QAAA,CAAW,8BAA+B,CAAa,EAClE,OAAQ,GACR,iBAAA,GACA,YAAA,GACoB,qBACpB,GAAI,+BAA+B,IAC3B,SAEP,WAQA,UAID,eACC,GAID,SAAU,EAEV,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,UAAU,oCACA,WACV,cAAc,uBACd,aAAa,QACb,YAAY,OACZ,GAAI,qCAAqC,IACzC,OACC,EAAA,EAAA,KAAA,CAAC,MAAD,CAAA,SAAA,EACC,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,sBACd,SAAA,EAAc,MAAQ,EAAc,MAAQ,EAAO,KAC/C,CAAA,GACN,EAAA,EAAA,IAAA,CAAC,GAAA,QAAD,CAAQ,MAAO,EAAsB,QAAS,CAAA,CAC1C,CAAA,CAAA,EAEN,QAAS,GACT,QAAQ,MACR,CAAA,CACO,CAAA,EACR,GAAY,EACZ,CAAC,GAAU,IACX,EAAA,EAAA,IAAA,CAAC,IAAD,CACC,UAAU,kBACV,GAAI,8BAA8B,IAEjC,SAAA,CACC,CAAA,CAEA,GACD,CAAA,CAEP,EAEA,EAAY,YAAc,EAAA"}
|
|
1
|
+
{"version":3,"file":"color-picker.cjs","names":[],"sources":["../../../../components/color-picker/color-picker.tsx"],"sourcesContent":["/* eslint-disable max-lines */\nimport React, {\n\tuseState,\n\tuseCallback,\n\tuseRef,\n\tuseEffect,\n\tuseMemo,\n} from 'react';\nimport classNames from 'classnames';\n\nimport checkProps from './check-props';\n\nimport CustomColor from './private/custom-color';\nimport Swatch from './private/swatch';\nimport SwatchPicker from './private/swatch-picker';\n\nimport Button from '../button';\nimport Input, { type InputChangeData } from '../input';\nimport Tabs from '../tabs';\nimport TabsPanel from '../tabs/panel';\nimport Popover from '../popover';\n\nimport ColorUtils from '../../utilities/color';\nimport { COLOR_PICKER } from '../../utilities/constants';\nimport generateId from '../../utilities/generate-id';\n\nimport {\n\tWorkingColor,\n\tColorPickerAssistiveText,\n\tColorPickerLabels,\n\tColorPickerEvents,\n} from './types';\n\ninterface ColorPickerBaseProps {\n\t/** Assistive text for accessibility */\n\tassistiveText?: ColorPickerAssistiveText;\n\t/** CSS classes for the color-picker container */\n\tclassName?: string | string[] | Record<string, boolean>;\n\t/** CSS classes for the popover menu */\n\tclassNameMenu?: string | string[] | Record<string, boolean>;\n\t/** Unique ID for the component */\n\tid?: string;\n\t/** Disables the input and button */\n\tdisabled?: boolean;\n\t/** Error message for the outer input */\n\terrorText?: string;\n\t/** Error message for the custom tab working color input */\n\terrorTextWorkingColor?: string;\n\t/** Event callbacks */\n\tevents?: ColorPickerEvents;\n\t/** Disable flip behavior for popover alignment */\n\thasStaticAlignment?: boolean;\n\t/** Hides the text input */\n\thideInput?: boolean;\n\t/** Controlled popover open state */\n\tisOpen?: boolean;\n\t/** Text labels for internationalization */\n\tlabels?: ColorPickerLabels;\n\t/** Popover position strategy */\n\tmenuPosition?: 'absolute' | 'overflowBoundaryElement' | 'relative';\n\t/** Current color in hexadecimal string */\n\tvalue?: string;\n\t/** Current working color in hexadecimal string */\n\tvalueWorking?: string;\n\t/** Callback when popover closes */\n\tonClose?: (\n\t\tevent: React.SyntheticEvent,\n\t\tdata: { trigger?: string; componentWillUnmount?: boolean }\n\t) => void;\n\t/** Callback when popover opens */\n\tonOpen?: (\n\t\tevent: React.SyntheticEvent,\n\t\tdata: { portal?: HTMLElement }\n\t) => void;\n\t/** Callback when user requests close */\n\tonRequestClose?: (\n\t\tevent: React.SyntheticEvent,\n\t\tdata: { trigger: string }\n\t) => void;\n\t/** Callback when popover requests to open */\n\tonRequestOpen?: () => void;\n}\n\n/**\n * `variant` sets which tabs are present. `swatchColors` needs the swatch tab\n * and `defaultSelectedTab` only applies when both tabs are present.\n */\nexport type ColorPickerVariantProps =\n\t| {\n\t\t\t/** Both the swatch and custom tabs */\n\t\t\tvariant?: 'base';\n\t\t\t/** Array of hex color values for swatch options */\n\t\t\tswatchColors?: string[];\n\t\t\t/** Which tab is visible when dialog opens */\n\t\t\tdefaultSelectedTab?: 'swatches' | 'custom';\n\t }\n\t| {\n\t\t\t/** Only the swatch tab */\n\t\t\tvariant: 'swatches';\n\t\t\t/** Array of hex color values for swatch options */\n\t\t\tswatchColors?: string[];\n\t\t\tdefaultSelectedTab?: never;\n\t }\n\t| {\n\t\t\t/** Only the custom tab */\n\t\t\tvariant: 'custom';\n\t\t\tswatchColors?: never;\n\t\t\tdefaultSelectedTab?: never;\n\t };\n\nexport type ColorPickerProps = ColorPickerBaseProps & ColorPickerVariantProps;\n\nconst defaultLabels: ColorPickerLabels = {\n\tblueAbbreviated: 'B',\n\tcancelButton: 'Cancel',\n\tcustomTab: 'Custom',\n\tcustomTabActiveWorkingColorSwatch: 'Working Color',\n\tcustomTabTransparentSwatch: 'Transparent Swatch',\n\tgreenAbbreviated: 'G',\n\thexLabel: 'Hex',\n\tinvalidColor: 'The color entered is invalid',\n\tinvalidComponent: 'The value needs to be an integer from 0-255',\n\tredAbbreviated: 'R',\n\tsubmitButton: 'Done',\n\tswatchTab: 'Default',\n\tswatchTabTransparentSwatch: 'Transparent Swatch',\n};\n\nconst defaultAssistiveText: ColorPickerAssistiveText = {\n\tsaturationValueGrid:\n\t\t'Use arrow keys to select a saturation and brightness, on an x and y axis.',\n\thueSlider: 'Select Hue',\n};\n\nconst defaultSwatchColors = [\n\t'#e3abec',\n\t'#c2dbf7',\n\t'#9fd6ff',\n\t'#9de7da',\n\t'#9df0c0',\n\t'#fff099',\n\t'#fed49a',\n\t'#d073e0',\n\t'#86baf3',\n\t'#5ebbff',\n\t'#44d8be',\n\t'#3be282',\n\t'#ffe654',\n\t'#ffb758',\n\t'#bd35bd',\n\t'#5779c1',\n\t'#5679c0',\n\t'#00aea9',\n\t'#3cba4c',\n\t'#f5bc25',\n\t'#f99221',\n\t'#580d8c',\n\t'#001970',\n\t'#0a2399',\n\t'#0b7477',\n\t'#0b6b50',\n\t'#b67e11',\n\t'#b85d0d',\n\t'',\n];\n\n/**\n * The Unified Color Picker component allows for a fully accessible and\n * configurable color picker, allowing the user to pick from a set of\n * predefined colors (swatches), or to pick a custom color using a HSB\n * selection interface.\n */\nconst ColorPicker: React.FC<ColorPickerProps> = ({\n\tassistiveText: assistiveTextProp,\n\tclassName,\n\tclassNameMenu,\n\tid: idProp,\n\tdisabled = false,\n\terrorText: errorTextProp,\n\terrorTextWorkingColor,\n\tevents = {},\n\thasStaticAlignment,\n\thideInput = false,\n\tisOpen: isOpenProp,\n\tlabels: labelsProp,\n\tmenuPosition = 'absolute',\n\tswatchColors = defaultSwatchColors,\n\tdefaultSelectedTab = 'swatches',\n\tvariant = 'base',\n\tvalue: valueProp,\n\tvalueWorking: valueWorkingProp,\n\tonClose,\n\tonOpen,\n\tonRequestClose,\n\tonRequestOpen,\n}) => {\n\t// Merge labels and assistive text with defaults\n\tconst labels = useMemo(\n\t\t() => ({ ...defaultLabels, ...labelsProp }),\n\t\t[labelsProp]\n\t);\n\tconst assistiveText = useMemo(\n\t\t() => ({ ...defaultAssistiveText, ...assistiveTextProp }),\n\t\t[assistiveTextProp]\n\t);\n\n\t// Generate stable ID\n\tconst generatedId = useRef(idProp || generateId());\n\tconst componentId = idProp || generatedId.current;\n\n\t// Refs\n\tconst wrapperRef = useRef<HTMLDivElement>(null);\n\n\t// Initialize working color from props\n\tconst getInitialWorkingColor = useCallback((): WorkingColor => {\n\t\treturn ColorUtils.getNewColor(\n\t\t\t{ hex: valueWorkingProp || valueProp },\n\t\t\tevents.onValidateWorkingColor\n\t\t) as WorkingColor;\n\t}, [valueWorkingProp, valueProp, events.onValidateWorkingColor]);\n\n\t// State\n\tconst [currentColor, setCurrentColor] = useState<string>(\n\t\tvalueProp != null ? valueProp : ''\n\t);\n\tconst [isOpen, setIsOpen] = useState<boolean>(isOpenProp || false);\n\tconst [workingColor, setWorkingColor] = useState<WorkingColor>(\n\t\tgetInitialWorkingColor\n\t);\n\tconst [previousWorkingColor, setPreviousWorkingColor] =\n\t\tuseState<WorkingColor>(getInitialWorkingColor);\n\tconst [colorErrorMessage, setColorErrorMessage] = useState<string>(\n\t\terrorTextProp || ''\n\t);\n\n\t// Check props on mount (development only)\n\tuseEffect(() => {\n\t\t// checkProps is a no-op in production\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t(checkProps as any)(\n\t\t\tCOLOR_PICKER,\n\t\t\t{\n\t\t\t\tassistiveText: assistiveTextProp,\n\t\t\t\tclassName,\n\t\t\t\tclassNameMenu,\n\t\t\t\tid: idProp,\n\t\t\t\tdisabled,\n\t\t\t\terrorText: errorTextProp,\n\t\t\t\terrorTextWorkingColor,\n\t\t\t\tevents,\n\t\t\t\thasStaticAlignment,\n\t\t\t\thideInput,\n\t\t\t\tisOpen: isOpenProp,\n\t\t\t\tlabels: labelsProp,\n\t\t\t\tmenuPosition,\n\t\t\t\tswatchColors,\n\t\t\t\tdefaultSelectedTab,\n\t\t\t\tvariant,\n\t\t\t\tvalue: valueProp,\n\t\t\t\tvalueWorking: valueWorkingProp,\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, []);\n\n\t// Sync props to state when they change externally\n\tuseEffect(() => {\n\t\tif (valueProp !== undefined) {\n\t\t\tsetCurrentColor(valueProp);\n\t\t}\n\t}, [valueProp]);\n\n\tuseEffect(() => {\n\t\tif (valueWorkingProp !== undefined) {\n\t\t\tsetWorkingColor(\n\t\t\t\tColorUtils.getNewColor(\n\t\t\t\t\t{ hex: valueWorkingProp },\n\t\t\t\t\tevents.onValidateWorkingColor\n\t\t\t\t) as WorkingColor\n\t\t\t);\n\t\t}\n\t}, [valueWorkingProp, events.onValidateWorkingColor]);\n\n\tuseEffect(() => {\n\t\tif (isOpenProp !== undefined) {\n\t\t\tsetIsOpen(isOpenProp);\n\t\t}\n\t}, [isOpenProp]);\n\n\t// Helper to update working color\n\tconst updateWorkingColor = useCallback(\n\t\t(\n\t\t\tevent: React.SyntheticEvent,\n\t\t\tcolorOptions: {\n\t\t\t\thex?: string;\n\t\t\t\tred?: string | number;\n\t\t\t\tgreen?: string | number;\n\t\t\t\tblue?: string | number;\n\t\t\t\thue?: number | string;\n\t\t\t\tsaturation?: number;\n\t\t\t\tvalue?: number;\n\t\t\t}\n\t\t) => {\n\t\t\tconst newColor = ColorUtils.getNewColor(\n\t\t\t\tcolorOptions,\n\t\t\t\tevents.onValidateWorkingColor,\n\t\t\t\tworkingColor\n\t\t\t) as WorkingColor;\n\t\t\tsetPreviousWorkingColor(workingColor);\n\t\t\tsetWorkingColor(newColor);\n\n\t\t\tif (events.onWorkingColorChange) {\n\t\t\t\tevents.onWorkingColorChange(event, { color: newColor });\n\t\t\t}\n\t\t},\n\t\t[events, workingColor]\n\t);\n\n\t// Event handlers\n\tconst handleSwatchChange = useCallback(\n\t\t(event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\tupdateWorkingColor(event, { hex: event.target.value });\n\t\t},\n\t\t[updateWorkingColor]\n\t);\n\n\tconst handleCancelState = useCallback(() => {\n\t\tconst resetColor = ColorUtils.getNewColor(\n\t\t\t{ hex: currentColor },\n\t\t\tevents.onValidateWorkingColor\n\t\t) as WorkingColor;\n\t\tsetIsOpen(false);\n\t\tsetWorkingColor(resetColor);\n\t\tsetPreviousWorkingColor(resetColor);\n\t}, [currentColor, events.onValidateWorkingColor]);\n\n\tconst handleOnRequestClose = useCallback(\n\t\t(event: React.SyntheticEvent, data: { trigger: string }) => {\n\t\t\tif (data.trigger === 'clickOutside' || data.trigger === 'cancel') {\n\t\t\t\thandleCancelState();\n\t\t\t}\n\n\t\t\tif (onRequestClose) {\n\t\t\t\tonRequestClose(event, data);\n\t\t\t}\n\t\t},\n\t\t[handleCancelState, onRequestClose]\n\t);\n\n\tconst handleCancel = useCallback(\n\t\t(event: React.MouseEvent) => {\n\t\t\thandleCancelState();\n\n\t\t\tif (onRequestClose) {\n\t\t\t\tonRequestClose(event, { trigger: 'cancel' });\n\t\t\t}\n\t\t},\n\t\t[handleCancelState, onRequestClose]\n\t);\n\n\tconst handleColorChange = useCallback(\n\t\t(property: 'hex' | 'red' | 'green' | 'blue') =>\n\t\t\t(event: React.SyntheticEvent, data: InputChangeData) => {\n\t\t\t\tconst colorProperties: Record<string, string | number> = {};\n\t\t\t\tcolorProperties[property] = data.value;\n\t\t\t\tupdateWorkingColor(event, colorProperties);\n\t\t\t},\n\t\t[updateWorkingColor]\n\t);\n\n\tconst handleHueChange = useCallback(\n\t\t(event: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\tupdateWorkingColor(event, { hue: event.target.value });\n\t\t},\n\t\t[updateWorkingColor]\n\t);\n\n\tconst handleHexInputChange = useCallback(\n\t\t(event: React.SyntheticEvent, data: InputChangeData) => {\n\t\t\tconst newCurrentColor = data.value;\n\t\t\tconst namedColorHex = ColorUtils.getHexFromNamedColor(newCurrentColor);\n\t\t\tlet isValid = false;\n\n\t\t\tif (events.onValidateColor) {\n\t\t\t\tisValid = events.onValidateColor(newCurrentColor);\n\t\t\t} else {\n\t\t\t\tisValid = namedColorHex ? true : ColorUtils.isValidHex(newCurrentColor);\n\t\t\t}\n\n\t\t\tsetCurrentColor(newCurrentColor);\n\t\t\tsetWorkingColor(\n\t\t\t\tColorUtils.getNewColor(\n\t\t\t\t\t{\n\t\t\t\t\t\thex: namedColorHex || newCurrentColor,\n\t\t\t\t\t\tname: namedColorHex ? newCurrentColor.toLowerCase() : null,\n\t\t\t\t\t} as { hex: string; name?: string | null },\n\t\t\t\t\tevents.onValidateWorkingColor\n\t\t\t\t) as WorkingColor\n\t\t\t);\n\t\t\tsetColorErrorMessage(isValid ? '' : labels.invalidColor || '');\n\n\t\t\tif (events.onChange) {\n\t\t\t\tevents.onChange(event, {\n\t\t\t\t\tcolor: newCurrentColor,\n\t\t\t\t\tisValid,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[events, labels.invalidColor]\n\t);\n\n\tconst handleNavigate = useCallback(\n\t\t(property: 'saturation' | 'value') =>\n\t\t\t(event: React.KeyboardEvent, data: { delta: number }) => {\n\t\t\t\tconst colorProperties: Record<string, number> = {};\n\t\t\t\tcolorProperties[property] = data.delta;\n\t\t\t\tconst newColor = ColorUtils.getDeltaColor(\n\t\t\t\t\tcolorProperties,\n\t\t\t\t\tevents.onValidateWorkingColor,\n\t\t\t\t\tworkingColor\n\t\t\t\t) as WorkingColor;\n\t\t\t\tsetPreviousWorkingColor(workingColor);\n\t\t\t\tsetWorkingColor(newColor);\n\n\t\t\t\tif (events.onWorkingColorChange) {\n\t\t\t\t\tevents.onWorkingColorChange(event, { color: newColor });\n\t\t\t\t}\n\t\t\t},\n\t\t[events, workingColor]\n\t);\n\n\tconst handleSaturationValueChange = useCallback(\n\t\t(\n\t\t\tevent: React.MouseEvent | React.KeyboardEvent,\n\t\t\tdata: { saturation: number; value: number }\n\t\t) => {\n\t\t\tupdateWorkingColor(event, {\n\t\t\t\tsaturation: data.saturation,\n\t\t\t\tvalue: data.value,\n\t\t\t});\n\t\t},\n\t\t[updateWorkingColor]\n\t);\n\n\tconst handleSubmitButtonClick = useCallback(\n\t\t(event: React.MouseEvent) => {\n\t\t\tsetIsOpen(false);\n\t\t\tsetCurrentColor(workingColor.hex);\n\t\t\tsetColorErrorMessage('');\n\n\t\t\tif (events.onChange) {\n\t\t\t\tevents.onChange(event, {\n\t\t\t\t\tcolor: workingColor.hex,\n\t\t\t\t\tisValid: true,\n\t\t\t\t});\n\t\t\t}\n\t\t},\n\t\t[events, workingColor.hex]\n\t);\n\n\tconst handleSwatchButtonClick = useCallback(() => {\n\t\tconst newWorkingColor = ColorUtils.getNewColor(\n\t\t\t{ hex: workingColor.hex },\n\t\t\tevents.onValidateWorkingColor\n\t\t) as WorkingColor;\n\t\tsetIsOpen((prev) => !prev);\n\t\tsetWorkingColor(newWorkingColor);\n\n\t\tif (onRequestOpen) {\n\t\t\tonRequestOpen();\n\t\t}\n\t}, [events.onValidateWorkingColor, onRequestOpen, workingColor.hex]);\n\n\tconst handleSwatchSelect = useCallback(\n\t\t(event: React.MouseEvent | React.KeyboardEvent, data: { hex: string }) => {\n\t\t\tupdateWorkingColor(event, { hex: data.hex });\n\t\t},\n\t\t[updateWorkingColor]\n\t);\n\n\t// Render helpers\n\tconst renderInput = () => {\n\t\tif (hideInput) return null;\n\n\t\treturn (\n\t\t\t<Input\n\t\t\t\taria-describedby={\n\t\t\t\t\t!isOpen && colorErrorMessage\n\t\t\t\t\t\t? `color-picker-summary-error-${componentId}`\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t\tclassName={classNames(\n\t\t\t\t\t'slds-color-picker__summary-input',\n\t\t\t\t\t'slds-align-top',\n\t\t\t\t\t{\n\t\t\t\t\t\t'slds-has-error': !!colorErrorMessage,\n\t\t\t\t\t}\n\t\t\t\t)}\n\t\t\t\tdisabled={disabled}\n\t\t\t\tid={`color-picker-summary-input-${componentId}`}\n\t\t\t\tonChange={handleHexInputChange}\n\t\t\t\tvalue={currentColor}\n\t\t\t/>\n\t\t);\n\t};\n\n\tconst renderDefaultTab = () => {\n\t\tif (variant !== 'base' && variant !== 'swatches') return null;\n\n\t\treturn (\n\t\t\t<TabsPanel label={labels.swatchTab ?? ''}>\n\t\t\t\t<SwatchPicker\n\t\t\t\t\tcolor={workingColor}\n\t\t\t\t\tlabels={labels}\n\t\t\t\t\tonSelect={handleSwatchSelect}\n\t\t\t\t\tswatchColors={swatchColors}\n\t\t\t\t/>\n\t\t\t</TabsPanel>\n\t\t);\n\t};\n\n\tconst renderCustomTab = () => {\n\t\tif (variant !== 'base' && variant !== 'custom') return null;\n\n\t\treturn (\n\t\t\t<TabsPanel label={labels.customTab ?? ''}>\n\t\t\t\t<CustomColor\n\t\t\t\t\tassistiveText={assistiveText}\n\t\t\t\t\tid={componentId}\n\t\t\t\t\tcolor={workingColor}\n\t\t\t\t\terrorTextWorkingColor={errorTextWorkingColor}\n\t\t\t\t\tpreviousColor={previousWorkingColor}\n\t\t\t\t\tlabels={labels}\n\t\t\t\t\tonBlueChange={handleColorChange('blue')}\n\t\t\t\t\tonGreenChange={handleColorChange('green')}\n\t\t\t\t\tonHexChange={handleColorChange('hex')}\n\t\t\t\t\tonHueChange={handleHueChange}\n\t\t\t\t\tonRedChange={handleColorChange('red')}\n\t\t\t\t\tonSwatchChange={handleSwatchChange}\n\t\t\t\t\tonSaturationValueChange={handleSaturationValueChange}\n\t\t\t\t\tonSaturationNavigate={handleNavigate('saturation')}\n\t\t\t\t\tonValueNavigate={handleNavigate('value')}\n\t\t\t\t/>\n\t\t\t</TabsPanel>\n\t\t);\n\t};\n\n\tconst popoverBody = (\n\t\t<Tabs\n\t\t\tid={`color-picker-tabs-${componentId}`}\n\t\t\tdefaultSelectedIndex={defaultSelectedTab === 'custom' ? 1 : 0}\n\t\t>\n\t\t\t{renderDefaultTab()}\n\t\t\t{renderCustomTab()}\n\t\t</Tabs>\n\t);\n\n\tconst popoverFooter = (\n\t\t<div className=\"slds-color-picker__selector-footer\">\n\t\t\t<Button\n\t\t\t\tclassName=\"slds-color-picker__selector-cancel\"\n\t\t\t\tid={`color-picker-footer-cancel-${componentId}`}\n\t\t\t\tlabel={labels.cancelButton}\n\t\t\t\tonClick={handleCancel}\n\t\t\t\tvariant=\"neutral\"\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tclassName=\"slds-color-picker__selector-submit\"\n\t\t\t\tdisabled={Object.keys(workingColor.errors || {}).length > 0}\n\t\t\t\tid={`color-picker-footer-submit-${componentId}`}\n\t\t\t\tlabel={labels.submitButton}\n\t\t\t\tonClick={handleSubmitButtonClick}\n\t\t\t\tvariant=\"brand\"\n\t\t\t/>\n\t\t</div>\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={classNames('slds-color-picker', className)}\n\t\t\tref={wrapperRef}\n\t\t>\n\t\t\t<div className=\"slds-color-picker__summary\">\n\t\t\t\t<label\n\t\t\t\t\tclassName={classNames(\n\t\t\t\t\t\t'slds-color-picker__summary-label',\n\t\t\t\t\t\tassistiveText.label ? 'slds-assistive-text' : ''\n\t\t\t\t\t)}\n\t\t\t\t\thtmlFor={\n\t\t\t\t\t\t!hideInput ? `color-picker-summary-input-${componentId}` : undefined\n\t\t\t\t\t}\n\t\t\t\t\tid={`color-picker-label-${componentId}`}\n\t\t\t\t>\n\t\t\t\t\t{assistiveText.label ? assistiveText.label : labels.label}\n\t\t\t\t</label>\n\t\t\t\t<Popover\n\t\t\t\t\tariaLabelledby={`color-picker-label-${componentId}`}\n\t\t\t\t\talign=\"bottom left\"\n\t\t\t\t\tbody={popoverBody}\n\t\t\t\t\tclassNameDialog={classNames(\n\t\t\t\t\t\t'slds-color-picker__selector',\n\t\t\t\t\t\tclassNameMenu\n\t\t\t\t\t)}\n\t\t\t\t\tfooter={popoverFooter}\n\t\t\t\t\thasNoCloseButton\n\t\t\t\t\thasNoNubbin\n\t\t\t\t\thasStaticAlignment={hasStaticAlignment}\n\t\t\t\t\tid={`slds-color-picker__selector-${componentId}`}\n\t\t\t\t\tisOpen={isOpen}\n\t\t\t\t\tonClose={\n\t\t\t\t\t\tonClose as unknown as\n\t\t\t\t\t\t\t| ((\n\t\t\t\t\t\t\t\t\tevent?: unknown,\n\t\t\t\t\t\t\t\t\tdata?: { componentWillUnmount?: boolean }\n\t\t\t\t\t\t\t ) => void)\n\t\t\t\t\t\t\t| undefined\n\t\t\t\t\t}\n\t\t\t\t\tonOpen={\n\t\t\t\t\t\tonOpen as unknown as\n\t\t\t\t\t\t\t| ((event?: unknown, data?: { portal?: HTMLElement }) => void)\n\t\t\t\t\t\t\t| undefined\n\t\t\t\t\t}\n\t\t\t\t\tonRequestClose={\n\t\t\t\t\t\thandleOnRequestClose as unknown as\n\t\t\t\t\t\t\t| ((event?: unknown, data?: { trigger?: string }) => void)\n\t\t\t\t\t\t\t| undefined\n\t\t\t\t\t}\n\t\t\t\t\tposition={menuPosition}\n\t\t\t\t>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"slds-color-picker__summary-button\"\n\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\ticonClassName=\"slds-m-left_xx-small\"\n\t\t\t\t\t\ticonPosition=\"right\"\n\t\t\t\t\t\ticonVariant=\"more\"\n\t\t\t\t\t\tid={`slds-color-picker__summary-button-${componentId}`}\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<span className=\"slds-assistive-text\">\n\t\t\t\t\t\t\t\t\t{assistiveText.label ? assistiveText.label : labels.label}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t<Swatch color={currentColor} labels={labels} />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonClick={handleSwatchButtonClick}\n\t\t\t\t\t\tvariant=\"icon\"\n\t\t\t\t\t/>\n\t\t\t\t</Popover>\n\t\t\t\t{renderInput()}\n\t\t\t\t{!isOpen && colorErrorMessage && (\n\t\t\t\t\t<p\n\t\t\t\t\t\tclassName=\"slds-form-error\"\n\t\t\t\t\t\tid={`color-picker-summary-error-${componentId}`}\n\t\t\t\t\t>\n\t\t\t\t\t\t{colorErrorMessage}\n\t\t\t\t\t</p>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nColorPicker.displayName = COLOR_PICKER;\n\nexport default ColorPicker;\n"],"mappings":"omBAgHA,IAAM,EAAmC,CACxC,gBAAiB,IACjB,aAAc,SACd,UAAW,SACX,kCAAmC,gBACnC,2BAA4B,qBAC5B,iBAAkB,IAClB,SAAU,MACV,aAAc,+BACd,iBAAkB,8CAClB,eAAgB,IAChB,aAAc,OACd,UAAW,UACX,2BAA4B,oBAC7B,EAEM,EAAiD,CACtD,oBACC,4EACD,UAAW,YACZ,EAEM,EAAsB,4OA8B5B,EAQ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AgB,sBAAsB,IACtC,MAAM,cACN,KAAM,GACN,iBAAA,EAAiB,EAAA,QAAA,CAChB,8BACA,CACD,EACA,OAAQ,GACR,iBAAA,GACA,YAAA,GACoB,qBACpB,GAAI,+BAA+B,IAC3B,SAEP,WAQA,UAID,eACC,GAID,SAAU,EAEV,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CACC,UAAU,oCACA,WACV,cAAc,uBACd,aAAa,QACb,YAAY,OACZ,GAAI,qCAAqC,IACzC,OACC,EAAA,EAAA,KAAA,CAAC,MAAD,CAAA,SAAA,EACC,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,sBACd,SAAA,EAAc,MAAQ,EAAc,MAAQ,EAAO,KAC/C,CAAA,GACN,EAAA,EAAA,IAAA,CAAC,GAAA,QAAD,CAAQ,MAAO,EAAsB,QAAS,CAAA,CAC1C,CAAA,CAAA,EAEN,QAAS,GACT,QAAQ,MACR,CAAA,CACO,CAAA,EACR,GAAY,EACZ,CAAC,GAAU,IACX,EAAA,EAAA,IAAA,CAAC,IAAD,CACC,UAAU,kBACV,GAAI,8BAA8B,IAEjC,SAAA,CACC,CAAA,CAEA,GACD,CAAA,CAEP,EAEA,EAAY,YAAc,EAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/constants.cjs"),n=require("../icon-settings/index.cjs"),r=require("../../utilities/generate-id.cjs"),i=require("../../utilities/key-code.cjs"),a=require("../utilities/dialog/index.cjs"),ee=require("../button/index.cjs"),te=require("../../utilities/key-buffer.cjs"),o=require("../input/private/inner-input.cjs"),ne=require("../tooltip/private/field-level-help-tooltip.cjs"),s=require("../icon/input-icon/index.cjs"),re=require("../popover/index.cjs"),ie=require("./private/menu.cjs"),ae=require("../forms/private/label.cjs"),oe=require("../../utilities/key-callbacks.cjs"),se=require("../pill-container/private/selected-listbox.cjs"),ce=require("../../utilities/key-letter-menu-item-select.cjs"),le=require("../../utilities/menu-item-select-scroll.cjs"),ue=require("./check-props.cjs"),de=require("./component.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime"),fe=require("dequal"),pe=require("lodash.isfunction");pe=e.__toESM(pe,1);let d=require("lodash.assign");d=e.__toESM(d,1);let me=require("lodash.findindex");me=e.__toESM(me,1);let he=require("lodash.find");he=e.__toESM(he,1);let ge=require("lodash.reject");ge=e.__toESM(ge,1);var f,_e=typeof document<`u`,ve=Symbol(`actionItem`),ye=e=>ve in e,be=(e,t)=>({id:e.id||``,icon:e.icon,label:e.label,disabled:e.disabled,type:t,[ve]:e}),xe={label:``,loadingMenuItems:`Loading`,optionSelectedInMenu:`Current Selection:`,popoverLabel:``,removeSingleSelectedOption:`Remove selected option`,removePill:`, Press delete or backspace to remove`,selectedListboxLabel:`Selected Options:`},Se={deselectOption:`None`,label:``,cancelButton:`Cancel`,doneButton:`Done`,multipleOptionsSelected:``,noOptionsFound:`No matches found.`,placeholder:``,placeholderReadOnly:`Select an Option`,removePillTitle:`Remove`,optionDisabledTooltipLabel:`This option is disabled.`,inputIconTitle:``},Ce={},we=e=>{let{assistiveText:we={},"aria-describedby":Te,className:p,classNameContainer:Ee,classNameMenu:De,classNameMenuSubHeader:Oe,defaultValue:m,disabled:ke,entityCombobox:Ae,errorText:h,events:je={},fieldLevelHelpTooltip:Me,hasDeselect:Ne,hasInputSpinner:Pe,hasMenuSpinner:Fe,hasStaticAlignment:Ie,id:Le,inheritWidthOf:Re=`target`,input:ze,inputRef:Be,isOpen:g,labels:Ve={},menuItemVisibleLength:He,menuMaxWidth:Ue,menuPosition:We=`absolute`,multiple:_,onRenderMenuItem:Ge,options:v=[],optionsAddItem:Ke=[],optionsSearchEntity:qe=[],popover:y,predefinedOptionsOnly:b,required:x=!1,selection:S=[],selectedListboxRef:Je,singleInputDisabled:Ye=!1,tooltipMenuItemDisabled:Xe,value:C,variant:w=`base`,renderMenuItem:Ze,menuItem:Qe}=e,T=(0,d.default)({},xe,we),E=(0,d.default)({},Se,Ve),D=(0,d.default)({},Ce,je),$e=(0,c.useContext)(n.IconSettingsContext),O=(0,c.useRef)(null),k=(0,c.useRef)(null),et=(0,c.useRef)(null),tt=(0,c.useRef)(null),nt=(0,c.useRef)(null),rt=(0,c.useRef)(new te.default),it=(0,c.useRef)(r.default()),at=(0,c.useRef)(r.default()),A=(0,c.useCallback)(()=>Le||it.current,[Le]),ot=`${A()}-deselect`,[j,M]=(0,c.useState)(void 0),[N,P]=(0,c.useState)(-1),[F,I]=(0,c.useState)(S?.[0]),[L,R]=(0,c.useState)(0),[z,B]=(0,c.useState)(!1),[V,st]=(0,c.useState)(typeof g==`boolean`&&g),[ct,lt]=(0,c.useState)(!1);(0,c.useEffect)(()=>{ue.default(t.COMBOBOX,e,de.default)},[]);let H=(0,c.useCallback)(()=>!!(typeof g==`boolean`?g:V),[g,V]),ut=(0,c.useCallback)(()=>j&&N!==-1,[j,N]),U=(0,c.useCallback)(()=>Te||h&&at.current,[Te,h]),W=(0,c.useCallback)(()=>{let e={id:ot,label:E.deselectOption,value:``,type:`deselect`},t=qe.map(e=>be(e,`header`)),n=Ke.map(e=>be(e,`footer`));return[...t.length>0?t:[],...Ne?[e]:[],...v&&v.length>0?v:[],...n.length>0?n:[]]},[ot,E.deselectOption,qe,Ke,Ne,v]),dt=(0,c.useCallback)(({selection:e,option:t})=>!!(0,he.default)(e,t),[]),ft=(0,c.useCallback)(({activeOptionIndex:e,offset:t,options:n})=>{let r=e+t,i=n.length>r&&r>=0&&n[r].type===`separator`?r+t:r;return n.length>r&&r>=0?i:e},[]),G=(0,c.useCallback)((e,{trigger:t}={})=>{if(H()){if(f&&f.handleClose===G&&(f=void 0),M(void 0),P(-1),st(!1),w===`popover`&&t===`cancel`){let n=y?.props;n?.onClose&&n.onClose(e,{trigger:t})}D.onClose&&D.onClose(e,{})}},[H,w,y,D]),pt=(0,c.useCallback)((e,t)=>{if(!H())f&&(0,pe.default)(f.handleClose)&&f.handleClose();else if(f={handleClose:G},st(!0),D.onOpen&&D.onOpen(e,t||{}),w===`readonly`){let e=W(),t=(0,me.default)(e,e=>(0,fe.dequal)(e,S[0]));P(t),M(S[0]),k.current!==null&&le.default({container:k.current,focusedIndex:t})}},[H,G,D,w,W,S]),mt=(0,c.useCallback)((e,t)=>{D.onRequestClose&&D.onRequestClose(e,t),H()&&G(e,{trigger:`cancel`})},[D,H,G]),K=(0,c.useCallback)(()=>{D.onRequestOpen?D.onRequestOpen():st(!0)},[D]),ht=(0,c.useCallback)(()=>{(!_&&S.length===0&&w===`inline-listbox`||_||w===`readonly`)&&K()},[_,S.length,w,K]);(0,c.useCallback)(e=>{mt(e,{})},[mt]);let gt=(0,c.useCallback)((e,{selection:t,option:n})=>{if(ye(n)){let t=n[ve],r=e;t.onClick?.(r,{option:t}),D.onSelectActionItem?.(r,{option:t,value:O.current?.value??``}),G();return}let r,i=dt({selection:t,option:n}),a=!_&&!i,ee=_&&!i;r=n.id===ot?[]:a?[n]:ee?[...S,n]:(0,ge.default)(S,n),D.onSelect&&D.onSelect(e,{selection:r}),G()},[dt,_,ot,S,D,G]),q=(0,c.useCallback)(e=>{setTimeout(()=>{let t=_e?document.activeElement:null;t&&t.tagName===`DIV`&&t.id===`${A()}-listbox`?O.current&&O.current.focus():y||G(e)},200),D.onBlur&&D.onBlur(e)},[A,y,G,D]),J=(0,c.useCallback)(e=>{ht(),D.onChange&&D.onChange(e,{value:e.target.value})},[ht,D]),Y=(0,c.useCallback)(e=>{D.onFocus&&D.onFocus(e,{})},[D]),_t=(0,c.useCallback)(e=>{if(j===void 0&&N===-1&&(V?mt(e,{}):e.shiftKey||K()),!j?.disabled){if(j&&!ye(j)&&(j.type===`header`||j.type===`footer`)){j.onClick?.(e);return}ut()?gt(e,{option:j,selection:S}):!b&&e.target.value!==``&&D.onSubmit&&D.onSubmit(e,{value:e.target.value})}},[j,N,V,K,mt,ut,gt,S,b,D]),vt=(0,c.useCallback)((e,{direction:t})=>{let n={next:1,previous:-1},r=W(),i=ft({activeOptionIndex:N,offset:n[t],options:r});H()&&k.current&&le.default({container:k.current,focusedIndex:i}),M(r[i]),P(i)},[W,ft,N,H]),X=(0,c.useCallback)((e,{direction:t})=>{let n={next:1,previous:-1},r=L+1===S.length&&t===`next`,i=L===0&&t===`previous`;if(r)I(S[0]),R(0),B(!0);else if(i)I(S[S.length-1]),R(S.length-1),B(!0);else{let e=ft({activeOptionIndex:L,offset:n[t],options:S});I(S[e]),R(e),B(!0)}},[L,S,ft]),yt=(0,c.useCallback)(e=>{e.shiftKey||K(),w!==`popover`&&vt(e,{direction:`next`})},[K,w,vt]),bt=(0,c.useCallback)(e=>{!e.shiftKey&&H()&&vt(e,{direction:`previous`})},[H,vt]),xt=(0,c.useCallback)(()=>{et.current&&B(!0)},[]),St=(0,c.useCallback)(e=>{let t=W(),n=ce.default({key:e.key,keyBuffer:rt.current,keyCode:e.keyCode,options:t});n!==void 0&&(H()&&k.current&&le.default({container:k.current,focusedIndex:n}),M(t[n]),P(n))},[W,H]),Z=(0,c.useCallback)(e=>{let t={[i.default.DOWN]:{callback:yt},[i.default.ENTER]:{callback:_t},[i.default.ESCAPE]:{callback:G},[i.default.UP]:{callback:bt}};w===`readonly`&&(S.length>2?t[i.default.TAB]={callback:xt}:t[i.default.TAB]=void 0,t.other={callback:St,stopPropagation:!1});let n=H();oe.default(e,{callbacks:t,stopPropagation:n})},[yt,_t,G,bt,w,S.length,xt,St,H]),Ct=(0,c.useCallback)(()=>{B(!1)},[]),wt=(0,c.useCallback)((e,{option:t,index:n})=>{z||(I(t),R(n),B(!0))},[z]),Tt=(0,c.useCallback)((e,{option:t,index:n})=>{e.preventDefault();let r=S.length===1,i=S.length===2&&w===`readonly`&&_,a=n!==void 0&&n+1===S.length;(r||i)&&O.current?O.current.focus():a&&n!==void 0?(I(S[n-1]),R(n-1),B(!0)):n!==void 0&&(I(S[n+1]),R(n),B(!0)),D.onRequestRemoveSelectedOption&&D.onRequestRemoveSelectedOption(e,{selection:(0,ge.default)(S,t)})},[S,w,_,D]),Et=(0,c.useCallback)((e,{ref:t})=>{t&&(tt.current=t,tt.current.focus())},[]),Q=(0,c.useCallback)(e=>{O.current=e,ct||lt(!0),Be&&Be(e)},[ct,Be]),Dt=(0,c.useCallback)(e=>{et.current=e,Je&&Je(e)},[Je]),Ot=(0,c.useCallback)(e=>{k.current=e},[]),kt=(0,c.useCallback)(()=>O.current,[]);(0,c.useEffect)(()=>{typeof g==`boolean`&&(st(g),g||(M(void 0),P(-1)))},[g]),(0,c.useEffect)(()=>{let e=W();if(j){let t=(0,me.default)(e,e=>(0,fe.dequal)(e,j));t===-1?(M(void 0),P(-1)):P(t)}},[v,W,j]),(0,c.useEffect)(()=>{if(S.length===0){F!==void 0&&(I(void 0),R(0));return}if(!F||!S[L]){let e=L>=S.length?S.length-1:L;I(S[e]),R(e)}},[S,F,L]),(0,c.useEffect)(()=>()=>{f&&f.handleClose===G&&(f=void 0)},[G]);let At=(0,c.useCallback)(e=>{let t=(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`slds-assistive-text`,id:`${A()}-label`,children:T.popoverLabel}),e]}),n=(0,u.jsxs)(`div`,{children:[(0,u.jsx)(ee.default,{label:E.cancelButton,onClick:e=>{G(e,{trigger:`cancel`})}}),(0,u.jsx)(ee.default,{label:E.doneButton,variant:`brand`,onClick:G})]}),r={ariaLabelledby:`${A()}-label`,align:`bottom`,body:t,className:`slds-popover_full-width`,footer:n,footerClassName:`slds-popover__footer_form`,hasNoNubbin:!0,id:A(),isOpen:V,hasNoTriggerStyles:!0,onOpen:pt,onClose:G,onRequestClose:G},i=y?.props,a=(0,d.default)(r,i||{});return a.body=t,delete a.children,a},[A,T.popoverLabel,E.cancelButton,E.doneButton,G,V,pt,y]),jt=(0,c.useCallback)(({menuRenderer:e})=>{let t=We;if(!ke&&H()){let n={align:`bottom left`,context:$e,hasStaticAlignment:Ie,inheritWidthOf:Re,onClose:G,onMouseDown:e=>{e.preventDefault()},onOpen:pt,onRequestTargetElement:kt,position:t,containerProps:{id:`${A()}-listbox`,role:`listbox`}};return(0,u.jsx)(a.default,{...n,children:e})}return null},[We,ke,H,$e,Ie,Re,G,pt,kt,A]),Mt=Ge||Qe,Nt;Ze?Nt=e=>Ze({...e,assistiveText:T}):Mt&&(Nt=({isSelected:e,option:t})=>(0,u.jsx)(Mt,{assistiveText:T,selected:e,option:t}));let $=(0,c.useCallback)(()=>{let e={base:`icon-title-subtitle`,"inline-listbox":`icon-title-subtitle`,readonly:`checkbox`},t=w===`readonly`?5:null;return(0,u.jsx)(ie.default,{assistiveText:T,activeOption:j,activeOptionIndex:N,classNameMenu:De,classNameMenuSubHeader:Oe,inheritWidthOf:Re,inputId:A(),inputValue:C,isSelected:dt,itemVisibleLength:He||t,labels:{noOptionsFound:E.noOptionsFound||``},hasMenuSpinner:Fe,menuPosition:We,menuRef:Ot,maxWidth:Ue,options:W(),onSelect:gt,renderMenuItem:Nt,selection:S,tooltipMenuItemDisabled:Xe,variant:e[w]})},[w,T,j,N,De,Oe,Re,A,C,dt,He,E.noOptionsFound,Fe,We,Ot,Ue,W,gt,Nt,S,Xe]),Pt=ze?.props||{},Ft=()=>(0,u.jsxs)(`div`,{className:`slds-form-element__control`,children:[(0,u.jsx)(`div`,{className:`slds-combobox_container`,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`listbox`,"aria-owns":H()?`${A()}-listbox`:void 0,children:[(0,u.jsx)(o.default,{"aria-autocomplete":`list`,"aria-controls":H()?`${A()}-listbox`:void 0,"aria-activedescendant":j?`${A()}-listbox-option-${j.id}`:void 0,"aria-describedby":U(),autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},hasSpinner:Pe,iconRight:(0,u.jsx)(s.default,{category:`utility`,name:`search`,title:E.inputIconTitle}),id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>K(),onChange:J,placeholder:E.placeholder,defaultValue:m,readOnly:!!(b&&j),required:x,role:`textbox`,value:b&&j?.label||C,...Pt}),jt({menuRenderer:$()})]})}),(0,u.jsx)(se.default,{activeOption:F,activeOptionIndex:L,assistiveText:T,events:{onBlurPill:Ct,onPillFocus:wt,onRequestFocus:Et,onRequestFocusOnNextPill:X,onRequestFocusOnPreviousPill:X,onRequestRemove:Tt},id:`${A()}-selected-listbox`,labels:E,selectedListboxRef:Dt,selection:S,listboxHasFocus:z,multiselectable:_}),h&&(0,u.jsx)(`div`,{className:`slds-has-error`,children:(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help slds-has-error`,children:h})})]}),It=()=>(0,u.jsx)(`div`,{className:`slds-form-element__control`,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox_container`,{"slds-has-inline-listbox":S.length}),children:[S.length?(0,u.jsx)(se.default,{activeOption:F,activeOptionIndex:L,assistiveText:T,containerRole:`listbox`,containerAriaOrientation:`horizontal`,listboxRole:`group`,listboxAriaOrientation:null,events:{onBlurPill:Ct,onPillFocus:wt,onRequestFocus:Et,onRequestFocusOnNextPill:X,onRequestFocusOnPreviousPill:X,onRequestRemove:Tt},id:`${A()}-selected-listbox`,labels:E,selectedListboxRef:Dt,selection:S,listboxHasFocus:z,multiselectable:_}):null,(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`listbox`,children:[(0,u.jsx)(o.default,{"aria-autocomplete":`list`,"aria-controls":H()?`${A()}-listbox`:void 0,"aria-activedescendant":j?`${A()}-listbox-option-${j.id}`:void 0,"aria-describedby":U(),defaultValue:m,autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},hasSpinner:Pe,iconRight:(0,u.jsx)(s.default,{category:`utility`,name:`search`,title:E.inputIconTitle}),id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>K(),onChange:J,placeholder:E.placeholder,readOnly:!!(b&&j),required:x,role:`textbox`,value:b&&j?.label||C,...Pt}),jt({menuRenderer:$()}),h&&(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help`,children:h})]})]})}),Lt=()=>{let e=S[0]?.icon,t=e&&c.default.isValidElement(e)?c.default.cloneElement(e,{containerClassName:`slds-combobox__input-entity-icon`}):null,n=S[0]?.label?S[0].label:C;return(0,u.jsxs)(`div`,{className:`slds-form-element__control`,children:[(0,u.jsx)(`div`,{className:(0,l.default)(`slds-combobox_container`,{"slds-has-inline-listbox":S.length}),children:(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`listbox`,children:[(0,u.jsx)(o.default,{defaultValue:m,"aria-autocomplete":`list`,"aria-controls":H()?`${A()}-listbox`:void 0,"aria-activedescendant":j?`${A()}-listbox-option-${j.id}`:void 0,"aria-describedby":U(),autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},disabled:Ye,hasSpinner:Pe,iconRight:S.length?(0,u.jsx)(s.default,{assistiveText:{icon:T.removeSingleSelectedOption},buttonRef:e=>{nt.current=e},category:`utility`,iconPosition:`right`,name:`close`,onClick:e=>{Tt(e,{option:S[0]})}}):(0,u.jsx)(s.default,{category:`utility`,name:`search`}),iconLeft:t,id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>ht(),onChange:e=>{S.length||J(e)},placeholder:E.placeholder,readOnly:!!(b&&j)||!!S.length,required:x,role:`textbox`,value:b?j?.label||C:n,...Pt}),jt({menuRenderer:$()})]})}),h&&(0,u.jsx)(`div`,{className:`slds-has-error`,children:(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help`,children:h})})]})},Rt=()=>{let e=y?.props,t=At(e?.body);return(0,u.jsxs)(`div`,{className:`slds-form-element__control`,children:[(0,u.jsx)(`div`,{className:`slds-combobox_container`,children:(0,u.jsx)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`dialog`,children:(0,u.jsx)(re.default,{...t,children:(0,u.jsx)(o.default,{"aria-autocomplete":`none`,"aria-controls":H()?`${A()}-popover`:void 0,"aria-describedby":U(),autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},iconRight:(0,u.jsx)(s.default,{category:`utility`,name:`down`,variant:`combobox`}),id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>K(),onChange:J,placeholder:E.placeholder,readOnly:!0,required:x,role:`textbox`,value:C})})})}),h&&(0,u.jsx)(`div`,{className:`slds-has-error`,children:(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help slds-has-error`,children:h})})]})},zt=()=>{let e=S.length>1?E.multipleOptionsSelected||`${S.length} options selected`:S[0]?.label||``;return(0,u.jsxs)(`div`,{className:`slds-form-element__control`,children:[(0,u.jsx)(`div`,{className:`slds-combobox_container`,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`listbox`,children:[(0,u.jsx)(o.default,{defaultValue:m,"aria-autocomplete":`list`,"aria-controls":H()?`${A()}-listbox`:void 0,"aria-activedescendant":j?`${A()}-listbox-option-${j.id}`:void 0,"aria-describedby":U(),autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},iconRight:(0,u.jsx)(s.default,{category:`utility`,name:`down`,variant:`combobox`}),id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>ht(),onChange:e=>{S.length||J(e)},placeholder:E.placeholderReadOnly,readOnly:!0,required:x,role:`textbox`,value:e,...Pt}),jt({menuRenderer:$()})]})}),(0,u.jsx)(se.default,{activeOption:F,activeOptionIndex:L,assistiveText:T,events:{onBlurPill:Ct,onPillFocus:wt,onRequestFocus:Et,onRequestFocusOnNextPill:X,onRequestFocusOnPreviousPill:X,onRequestRemove:Tt},id:`${A()}-selected-listbox`,labels:E,selectedListboxRef:Dt,selection:S,listboxHasFocus:z,variant:w,renderAtSelectionLength:2,multiselectable:_}),h&&(0,u.jsx)(`div`,{className:`slds-has-error`,children:(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help slds-has-error`,children:h})})]})},Bt=()=>{let e=j?.label,t=S[0]?.label,n=e||t||``;return S[0]?.value===``&&(n=``),(0,u.jsx)(`div`,{className:`slds-form-element__control`,children:(0,u.jsx)(`div`,{className:`slds-combobox_container`,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`listbox`,children:[(0,u.jsx)(o.default,{defaultValue:m,"aria-autocomplete":`list`,"aria-controls":H()?`${A()}-listbox`:void 0,"aria-activedescendant":j?`${A()}-listbox-option-${j.id}`:void 0,"aria-describedby":U(),autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},disabled:Ye,iconRight:(0,u.jsx)(s.default,{category:`utility`,name:`down`,variant:`combobox`}),id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>ht(),onChange:e=>{S.length||J(e)},placeholder:E.placeholderReadOnly,readOnly:!0,required:x,role:`textbox`,value:n,...Pt}),jt({menuRenderer:$()}),h&&(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help`,children:h})]})})})},Vt=E.label||T?.label,Ht={base:{multiple:Ft,single:Ft},"inline-listbox":{multiple:It,single:Lt},popover:{multiple:Rt,single:Rt},readonly:{multiple:zt,single:Bt}},Ut=_?`multiple`:`single`,Wt=Ht[w]?.[Ut],Gt=(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-form-element`,Ee),children:[Ae?null:(0,u.jsx)(ae.default,{assistiveText:T,htmlFor:A(),label:E.label,required:x}),Me&&Vt?(0,u.jsx)(ne.default,{fieldLevelHelpTooltip:Me}):null,Wt?Wt():Ht.base.multiple()]});return Ae?(0,u.jsxs)(`div`,{className:`slds-form-element`,children:[(0,u.jsx)(ae.default,{assistiveText:T,htmlFor:A(),label:E.label,required:x}),(0,u.jsx)(`div`,{className:`slds-form-element__control`,children:(0,u.jsxs)(`div`,{className:`slds-combobox-group`,children:[(0,u.jsx)(`div`,{className:`slds-combobox_object-switcher slds-combobox-addon_start`,children:Ae}),(0,u.jsx)(`div`,{className:`slds-combobox_container slds-combobox-addon_end`,children:Gt})]})})]}):Gt};we.displayName=t.COMBOBOX,exports.default=we;
|
|
1
|
+
const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../utilities/constants.cjs"),n=require("../icon-settings/index.cjs"),r=require("../../utilities/generate-id.cjs"),i=require("../../utilities/key-code.cjs"),a=require("../utilities/dialog/index.cjs"),ee=require("../button/index.cjs"),te=require("../../utilities/key-buffer.cjs"),o=require("../input/private/inner-input.cjs"),ne=require("../tooltip/private/field-level-help-tooltip.cjs"),s=require("../icon/input-icon/index.cjs"),re=require("../popover/index.cjs"),ie=require("./private/menu.cjs"),ae=require("../forms/private/label.cjs"),oe=require("../../utilities/key-callbacks.cjs"),se=require("../pill-container/private/selected-listbox.cjs"),ce=require("../../utilities/key-letter-menu-item-select.cjs"),le=require("../../utilities/menu-item-select-scroll.cjs"),ue=require("./check-props.cjs"),de=require("./component.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime"),fe=require("dequal"),pe=require("lodash.isfunction");pe=e.__toESM(pe,1);let d=require("lodash.assign");d=e.__toESM(d,1);let me=require("lodash.findindex");me=e.__toESM(me,1);let he=require("lodash.find");he=e.__toESM(he,1);let ge=require("lodash.reject");ge=e.__toESM(ge,1);var f,_e=typeof document<`u`,ve=Symbol(`actionItem`),ye=e=>ve in e,be=(e,t)=>({id:e.id||``,icon:e.icon,label:e.label,disabled:e.disabled,type:t,[ve]:e}),xe={label:``,loadingMenuItems:`Loading`,optionSelectedInMenu:`Current Selection:`,popoverLabel:``,removeSingleSelectedOption:`Remove selected option`,removePill:`, Press delete or backspace to remove`,selectedListboxLabel:`Selected Options:`},Se={deselectOption:`None`,label:``,cancelButton:`Cancel`,doneButton:`Done`,multipleOptionsSelected:``,noOptionsFound:`No matches found.`,placeholder:``,placeholderReadOnly:`Select an Option`,removePillTitle:`Remove`,optionDisabledTooltipLabel:`This option is disabled.`,inputIconTitle:``},Ce={},we=e=>{let{assistiveText:we={},"aria-describedby":Te,className:p,classNameContainer:Ee,classNameMenu:De,classNameMenuSubHeader:Oe,defaultValue:m,disabled:ke,entityCombobox:Ae,errorText:h,events:je={},fieldLevelHelpTooltip:Me,hasDeselect:Ne,hasInputSpinner:Pe,hasMenuSpinner:Fe,hasStaticAlignment:Ie,id:Le,inheritWidthOf:Re=`target`,input:ze,inputRef:Be,isOpen:g,labels:Ve={},menuItemVisibleLength:He,menuMaxWidth:Ue,menuPosition:We=`absolute`,multiple:_,onRenderMenuItem:Ge,options:v=[],optionsAddItem:Ke=[],optionsSearchEntity:qe=[],popover:y,predefinedOptionsOnly:b,required:x=!1,selection:S=[],selectedListboxRef:Je,singleInputDisabled:Ye=!1,tooltipMenuItemDisabled:Xe,value:C,variant:w=`base`,renderMenuItem:Ze,menuItem:Qe}=e,T=(0,d.default)({},xe,we),E=(0,d.default)({},Se,Ve),D=(0,d.default)({},Ce,je),$e=(0,c.useContext)(n.IconSettingsContext),O=(0,c.useRef)(null),k=(0,c.useRef)(null),et=(0,c.useRef)(null),tt=(0,c.useRef)(null),nt=(0,c.useRef)(null),rt=(0,c.useRef)(new te.default),it=(0,c.useRef)(r.default()),at=(0,c.useRef)(r.default()),A=(0,c.useCallback)(()=>Le||it.current,[Le]),ot=`${A()}-deselect`,[j,M]=(0,c.useState)(void 0),[N,P]=(0,c.useState)(-1),[F,I]=(0,c.useState)(S?.[0]),[L,R]=(0,c.useState)(0),[z,B]=(0,c.useState)(!1),[V,st]=(0,c.useState)(typeof g==`boolean`&&g),[ct,lt]=(0,c.useState)(!1);(0,c.useEffect)(()=>{ue.default(t.COMBOBOX,e,de.default)},[]);let H=(0,c.useCallback)(()=>!!(typeof g==`boolean`?g:V),[g,V]),ut=(0,c.useCallback)(()=>j&&N!==-1,[j,N]),U=(0,c.useCallback)(()=>Te||h&&at.current,[Te,h]),W=(0,c.useCallback)(()=>{let e={id:ot,label:E.deselectOption,value:``,type:`deselect`},t=qe.map(e=>be(e,`header`)),n=Ke.map(e=>be(e,`footer`));return[...t.length>0?t:[],...Ne?[e]:[],...v&&v.length>0?v:[],...n.length>0?n:[]]},[ot,E.deselectOption,qe,Ke,Ne,v]),dt=(0,c.useCallback)(({selection:e,option:t})=>!!(0,he.default)(e,t),[]),ft=(0,c.useCallback)(({activeOptionIndex:e,offset:t,options:n})=>{let r=e+t,i=n.length>r&&r>=0&&n[r].type===`separator`?r+t:r;return n.length>r&&r>=0?i:e},[]),G=(0,c.useCallback)((e,{trigger:t}={})=>{if(H()){if(f&&f.handleClose===G&&(f=void 0),M(void 0),P(-1),st(!1),w===`popover`&&t===`cancel`){let n=y?.props;n?.onClose&&n.onClose(e,{trigger:t})}D.onClose&&D.onClose(e,{})}},[H,w,y,D]),pt=(0,c.useCallback)((e,t)=>{if(!H())f&&(0,pe.default)(f.handleClose)&&f.handleClose();else if(f={handleClose:G},st(!0),D.onOpen&&D.onOpen(e,t||{}),w===`readonly`){let e=W(),t=(0,me.default)(e,e=>(0,fe.dequal)(e,S[0]));P(t),M(S[0]),k.current!==null&&le.default({container:k.current,focusedIndex:t})}},[H,G,D,w,W,S]),mt=(0,c.useCallback)((e,t)=>{D.onRequestClose&&D.onRequestClose(e,t),H()&&G(e,{trigger:`cancel`})},[D,H,G]),K=(0,c.useCallback)(()=>{D.onRequestOpen?D.onRequestOpen():st(!0)},[D]),ht=(0,c.useCallback)(()=>{(!_&&S.length===0&&w===`inline-listbox`||_||w===`readonly`)&&K()},[_,S.length,w,K]);(0,c.useCallback)(e=>{mt(e,{})},[mt]);let gt=(0,c.useCallback)((e,{selection:t,option:n})=>{if(ye(n)){let t=n[ve],r=e;t.onClick?.(r,{option:t}),D.onSelectActionItem?.(r,{option:t,value:O.current?.value??``}),G();return}let r,i=dt({selection:t,option:n}),a=!_&&!i,ee=_&&!i;r=n.id===ot?[]:a?[n]:ee?[...S,n]:(0,ge.default)(S,n),D.onSelect&&D.onSelect(e,{selection:r}),G()},[dt,_,ot,S,D,G]),q=(0,c.useCallback)(e=>{setTimeout(()=>{let t=_e?document.activeElement:null;t&&t.tagName===`DIV`&&t.id===`${A()}-listbox`?O.current&&O.current.focus():y||G(e)},200),D.onBlur&&D.onBlur(e)},[A,y,G,D]),J=(0,c.useCallback)(e=>{ht(),D.onChange&&D.onChange(e,{value:e.target.value})},[ht,D]),Y=(0,c.useCallback)(e=>{D.onFocus&&D.onFocus(e,{})},[D]),_t=(0,c.useCallback)(e=>{if(j===void 0&&N===-1&&(V?mt(e,{}):e.shiftKey||K()),!j?.disabled){if(j&&!ye(j)&&(j.type===`header`||j.type===`footer`)){j.onClick?.(e);return}ut()?gt(e,{option:j,selection:S}):!b&&e.target.value!==``&&D.onSubmit&&D.onSubmit(e,{value:e.target.value})}},[j,N,V,K,mt,ut,gt,S,b,D]),vt=(0,c.useCallback)((e,{direction:t})=>{let n={next:1,previous:-1},r=W(),i=ft({activeOptionIndex:N,offset:n[t],options:r});H()&&k.current&&le.default({container:k.current,focusedIndex:i}),M(r[i]),P(i)},[W,ft,N,H]),X=(0,c.useCallback)((e,{direction:t})=>{let n={next:1,previous:-1},r=L+1===S.length&&t===`next`,i=L===0&&t===`previous`;if(r)I(S[0]),R(0),B(!0);else if(i)I(S[S.length-1]),R(S.length-1),B(!0);else{let e=ft({activeOptionIndex:L,offset:n[t],options:S});I(S[e]),R(e),B(!0)}},[L,S,ft]),yt=(0,c.useCallback)(e=>{e.shiftKey||K(),w!==`popover`&&vt(e,{direction:`next`})},[K,w,vt]),bt=(0,c.useCallback)(e=>{!e.shiftKey&&H()&&vt(e,{direction:`previous`})},[H,vt]),xt=(0,c.useCallback)(()=>{et.current&&B(!0)},[]),St=(0,c.useCallback)(e=>{let t=W(),n=ce.default({key:e.key,keyBuffer:rt.current,keyCode:e.keyCode,options:t});n!==void 0&&(H()&&k.current&&le.default({container:k.current,focusedIndex:n}),M(t[n]),P(n))},[W,H]),Z=(0,c.useCallback)(e=>{let t={[i.default.DOWN]:{callback:yt},[i.default.ENTER]:{callback:_t},[i.default.ESCAPE]:{callback:G},[i.default.UP]:{callback:bt}};w===`readonly`&&(S.length>2?t[i.default.TAB]={callback:xt}:t[i.default.TAB]=void 0,t.other={callback:St,stopPropagation:!1});let n=H();oe.default(e,{callbacks:t,stopPropagation:n})},[yt,_t,G,bt,w,S.length,xt,St,H]),Ct=(0,c.useCallback)(()=>{B(!1)},[]),wt=(0,c.useCallback)((e,{option:t,index:n})=>{z||(I(t),R(n),B(!0))},[z]),Tt=(0,c.useCallback)((e,{option:t,index:n})=>{e.preventDefault();let r=S.length===1,i=S.length===2&&w===`readonly`&&_,a=n!==void 0&&n+1===S.length;(r||i)&&O.current?O.current.focus():a&&n!==void 0?(I(S[n-1]),R(n-1),B(!0)):n!==void 0&&(I(S[n+1]),R(n),B(!0)),D.onRequestRemoveSelectedOption&&D.onRequestRemoveSelectedOption(e,{selection:(0,ge.default)(S,t)})},[S,w,_,D]),Et=(0,c.useCallback)((e,{ref:t})=>{t&&(tt.current=t,tt.current.focus())},[]),Q=(0,c.useCallback)(e=>{O.current=e,ct||lt(!0),Be&&Be(e)},[ct,Be]),Dt=(0,c.useCallback)(e=>{et.current=e,Je&&Je(e)},[Je]),Ot=(0,c.useCallback)(e=>{k.current=e},[]),kt=(0,c.useCallback)(()=>O.current,[]);(0,c.useEffect)(()=>{typeof g==`boolean`&&(st(g),g||(M(void 0),P(-1)))},[g]),(0,c.useEffect)(()=>{let e=W();if(j){let t=(0,me.default)(e,e=>(0,fe.dequal)(e,j));t===-1?(M(void 0),P(-1)):P(t)}},[v,W,j]),(0,c.useEffect)(()=>{if(S.length===0){F!==void 0&&(I(void 0),R(0));return}if(!F||!S[L]){let e=L>=S.length?S.length-1:L;I(S[e]),R(e)}},[S,F,L]),(0,c.useEffect)(()=>()=>{f&&f.handleClose===G&&(f=void 0)},[G]);let At=(0,c.useCallback)(e=>{let t=(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`slds-assistive-text`,id:`${A()}-label`,children:T.popoverLabel}),e]}),n=(0,u.jsxs)(`div`,{children:[(0,u.jsx)(ee.default,{label:E.cancelButton,onClick:e=>{G(e,{trigger:`cancel`})}}),(0,u.jsx)(ee.default,{label:E.doneButton,variant:`brand`,onClick:G})]}),r={ariaLabelledby:`${A()}-label`,align:`bottom`,body:t,classNameDialog:`slds-popover_full-width`,footer:n,classNameFooter:`slds-popover__footer_form`,hasNoNubbin:!0,id:A(),isOpen:V,hasNoTriggerStyles:!0,onOpen:pt,onClose:G,onRequestClose:G},i=y?.props,a=(0,d.default)(r,i||{});return a.body=t,delete a.children,a},[A,T.popoverLabel,E.cancelButton,E.doneButton,G,V,pt,y]),jt=(0,c.useCallback)(({menuRenderer:e})=>{let t=We;if(!ke&&H()){let n={align:`bottom left`,context:$e,hasStaticAlignment:Ie,inheritWidthOf:Re,onClose:G,onMouseDown:e=>{e.preventDefault()},onOpen:pt,onRequestTargetElement:kt,position:t,containerProps:{id:`${A()}-listbox`,role:`listbox`}};return(0,u.jsx)(a.default,{...n,children:e})}return null},[We,ke,H,$e,Ie,Re,G,pt,kt,A]),Mt=Ge||Qe,Nt;Ze?Nt=e=>Ze({...e,assistiveText:T}):Mt&&(Nt=({isSelected:e,option:t})=>(0,u.jsx)(Mt,{assistiveText:T,selected:e,option:t}));let $=(0,c.useCallback)(()=>{let e={base:`icon-title-subtitle`,"inline-listbox":`icon-title-subtitle`,readonly:`checkbox`},t=w===`readonly`?5:null;return(0,u.jsx)(ie.default,{assistiveText:T,activeOption:j,activeOptionIndex:N,classNameMenu:De,classNameMenuSubHeader:Oe,inheritWidthOf:Re,inputId:A(),inputValue:C,isSelected:dt,itemVisibleLength:He||t,labels:{noOptionsFound:E.noOptionsFound||``},hasMenuSpinner:Fe,menuPosition:We,menuRef:Ot,maxWidth:Ue,options:W(),onSelect:gt,renderMenuItem:Nt,selection:S,tooltipMenuItemDisabled:Xe,variant:e[w]})},[w,T,j,N,De,Oe,Re,A,C,dt,He,E.noOptionsFound,Fe,We,Ot,Ue,W,gt,Nt,S,Xe]),Pt=ze?.props||{},Ft=()=>(0,u.jsxs)(`div`,{className:`slds-form-element__control`,children:[(0,u.jsx)(`div`,{className:`slds-combobox_container`,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`listbox`,"aria-owns":H()?`${A()}-listbox`:void 0,children:[(0,u.jsx)(o.default,{"aria-autocomplete":`list`,"aria-controls":H()?`${A()}-listbox`:void 0,"aria-activedescendant":j?`${A()}-listbox-option-${j.id}`:void 0,"aria-describedby":U(),autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},hasSpinner:Pe,iconRight:(0,u.jsx)(s.default,{category:`utility`,name:`search`,title:E.inputIconTitle}),id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>K(),onChange:J,placeholder:E.placeholder,defaultValue:m,readOnly:!!(b&&j),required:x,role:`textbox`,value:b&&j?.label||C,...Pt}),jt({menuRenderer:$()})]})}),(0,u.jsx)(se.default,{activeOption:F,activeOptionIndex:L,assistiveText:T,events:{onBlurPill:Ct,onPillFocus:wt,onRequestFocus:Et,onRequestFocusOnNextPill:X,onRequestFocusOnPreviousPill:X,onRequestRemove:Tt},id:`${A()}-selected-listbox`,labels:E,selectedListboxRef:Dt,selection:S,listboxHasFocus:z,multiselectable:_}),h&&(0,u.jsx)(`div`,{className:`slds-has-error`,children:(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help slds-has-error`,children:h})})]}),It=()=>(0,u.jsx)(`div`,{className:`slds-form-element__control`,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox_container`,{"slds-has-inline-listbox":S.length}),children:[S.length?(0,u.jsx)(se.default,{activeOption:F,activeOptionIndex:L,assistiveText:T,containerRole:`listbox`,containerAriaOrientation:`horizontal`,listboxRole:`group`,listboxAriaOrientation:null,events:{onBlurPill:Ct,onPillFocus:wt,onRequestFocus:Et,onRequestFocusOnNextPill:X,onRequestFocusOnPreviousPill:X,onRequestRemove:Tt},id:`${A()}-selected-listbox`,labels:E,selectedListboxRef:Dt,selection:S,listboxHasFocus:z,multiselectable:_}):null,(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`listbox`,children:[(0,u.jsx)(o.default,{"aria-autocomplete":`list`,"aria-controls":H()?`${A()}-listbox`:void 0,"aria-activedescendant":j?`${A()}-listbox-option-${j.id}`:void 0,"aria-describedby":U(),defaultValue:m,autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},hasSpinner:Pe,iconRight:(0,u.jsx)(s.default,{category:`utility`,name:`search`,title:E.inputIconTitle}),id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>K(),onChange:J,placeholder:E.placeholder,readOnly:!!(b&&j),required:x,role:`textbox`,value:b&&j?.label||C,...Pt}),jt({menuRenderer:$()}),h&&(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help`,children:h})]})]})}),Lt=()=>{let e=S[0]?.icon,t=e&&c.default.isValidElement(e)?c.default.cloneElement(e,{containerClassName:`slds-combobox__input-entity-icon`}):null,n=S[0]?.label?S[0].label:C;return(0,u.jsxs)(`div`,{className:`slds-form-element__control`,children:[(0,u.jsx)(`div`,{className:(0,l.default)(`slds-combobox_container`,{"slds-has-inline-listbox":S.length}),children:(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`listbox`,children:[(0,u.jsx)(o.default,{defaultValue:m,"aria-autocomplete":`list`,"aria-controls":H()?`${A()}-listbox`:void 0,"aria-activedescendant":j?`${A()}-listbox-option-${j.id}`:void 0,"aria-describedby":U(),autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},disabled:Ye,hasSpinner:Pe,iconRight:S.length?(0,u.jsx)(s.default,{assistiveText:{icon:T.removeSingleSelectedOption},buttonRef:e=>{nt.current=e},category:`utility`,iconPosition:`right`,name:`close`,onClick:e=>{Tt(e,{option:S[0]})}}):(0,u.jsx)(s.default,{category:`utility`,name:`search`}),iconLeft:t,id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>ht(),onChange:e=>{S.length||J(e)},placeholder:E.placeholder,readOnly:!!(b&&j)||!!S.length,required:x,role:`textbox`,value:b?j?.label||C:n,...Pt}),jt({menuRenderer:$()})]})}),h&&(0,u.jsx)(`div`,{className:`slds-has-error`,children:(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help`,children:h})})]})},Rt=()=>{let e=y?.props,t=At(e?.body);return(0,u.jsxs)(`div`,{className:`slds-form-element__control`,children:[(0,u.jsx)(`div`,{className:`slds-combobox_container`,children:(0,u.jsx)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`dialog`,children:(0,u.jsx)(re.default,{...t,children:(0,u.jsx)(o.default,{"aria-autocomplete":`none`,"aria-controls":H()?`${A()}-popover`:void 0,"aria-describedby":U(),autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},iconRight:(0,u.jsx)(s.default,{category:`utility`,name:`down`,variant:`combobox`}),id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>K(),onChange:J,placeholder:E.placeholder,readOnly:!0,required:x,role:`textbox`,value:C})})})}),h&&(0,u.jsx)(`div`,{className:`slds-has-error`,children:(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help slds-has-error`,children:h})})]})},zt=()=>{let e=S.length>1?E.multipleOptionsSelected||`${S.length} options selected`:S[0]?.label||``;return(0,u.jsxs)(`div`,{className:`slds-form-element__control`,children:[(0,u.jsx)(`div`,{className:`slds-combobox_container`,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`listbox`,children:[(0,u.jsx)(o.default,{defaultValue:m,"aria-autocomplete":`list`,"aria-controls":H()?`${A()}-listbox`:void 0,"aria-activedescendant":j?`${A()}-listbox-option-${j.id}`:void 0,"aria-describedby":U(),autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},iconRight:(0,u.jsx)(s.default,{category:`utility`,name:`down`,variant:`combobox`}),id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>ht(),onChange:e=>{S.length||J(e)},placeholder:E.placeholderReadOnly,readOnly:!0,required:x,role:`textbox`,value:e,...Pt}),jt({menuRenderer:$()})]})}),(0,u.jsx)(se.default,{activeOption:F,activeOptionIndex:L,assistiveText:T,events:{onBlurPill:Ct,onPillFocus:wt,onRequestFocus:Et,onRequestFocusOnNextPill:X,onRequestFocusOnPreviousPill:X,onRequestRemove:Tt},id:`${A()}-selected-listbox`,labels:E,selectedListboxRef:Dt,selection:S,listboxHasFocus:z,variant:w,renderAtSelectionLength:2,multiselectable:_}),h&&(0,u.jsx)(`div`,{className:`slds-has-error`,children:(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help slds-has-error`,children:h})})]})},Bt=()=>{let e=j?.label,t=S[0]?.label,n=e||t||``;return S[0]?.value===``&&(n=``),(0,u.jsx)(`div`,{className:`slds-form-element__control`,children:(0,u.jsx)(`div`,{className:`slds-combobox_container`,children:(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-combobox`,`slds-dropdown-trigger`,`slds-dropdown-trigger_click`,`ignore-react-onclickoutside`,{"slds-is-open":H(),"slds-has-error":h},p),role:`combobox`,"aria-expanded":H(),"aria-haspopup":`listbox`,children:[(0,u.jsx)(o.default,{defaultValue:m,"aria-autocomplete":`list`,"aria-controls":H()?`${A()}-listbox`:void 0,"aria-activedescendant":j?`${A()}-listbox-option-${j.id}`:void 0,"aria-describedby":U(),autoComplete:`off`,className:`slds-combobox__input`,containerProps:{className:`slds-combobox__form-element`,role:`none`},disabled:Ye,iconRight:(0,u.jsx)(s.default,{category:`utility`,name:`down`,variant:`combobox`}),id:A(),onFocus:Y,onBlur:q,onKeyDown:Z,inputRef:Q,onClick:()=>ht(),onChange:e=>{S.length||J(e)},placeholder:E.placeholderReadOnly,readOnly:!0,required:x,role:`textbox`,value:n,...Pt}),jt({menuRenderer:$()}),h&&(0,u.jsx)(`div`,{id:U(),className:`slds-form-element__help`,children:h})]})})})},Vt=E.label||T?.label,Ht={base:{multiple:Ft,single:Ft},"inline-listbox":{multiple:It,single:Lt},popover:{multiple:Rt,single:Rt},readonly:{multiple:zt,single:Bt}},Ut=_?`multiple`:`single`,Wt=Ht[w]?.[Ut],Gt=(0,u.jsxs)(`div`,{className:(0,l.default)(`slds-form-element`,Ee),children:[Ae?null:(0,u.jsx)(ae.default,{assistiveText:T,htmlFor:A(),label:E.label,required:x}),Me&&Vt?(0,u.jsx)(ne.default,{fieldLevelHelpTooltip:Me}):null,Wt?Wt():Ht.base.multiple()]});return Ae?(0,u.jsxs)(`div`,{className:`slds-form-element`,children:[(0,u.jsx)(ae.default,{assistiveText:T,htmlFor:A(),label:E.label,required:x}),(0,u.jsx)(`div`,{className:`slds-form-element__control`,children:(0,u.jsxs)(`div`,{className:`slds-combobox-group`,children:[(0,u.jsx)(`div`,{className:`slds-combobox_object-switcher slds-combobox-addon_start`,children:Ae}),(0,u.jsx)(`div`,{className:`slds-combobox_container slds-combobox-addon_end`,children:Gt})]})})]}):Gt};we.displayName=t.COMBOBOX,exports.default=we;
|
|
2
2
|
//# sourceMappingURL=combobox.cjs.map
|