@wordpress/components 19.1.0 → 19.1.1

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.
@@ -138,6 +138,7 @@ function ColorPalette(_ref5) {
138
138
  spacing: 3,
139
139
  className: className
140
140
  }, !disableCustomColors && (0, _element.createElement)(_dropdown.default, {
141
+ contentClassName: "components-color-palette__custom-color-dropdown-content",
141
142
  renderContent: renderCustomColorPicker,
142
143
  renderToggle: _ref6 => {
143
144
  let {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/color-palette/index.js"],"names":["namesPlugin","a11yPlugin","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","color","name","colordColor","fill","contrast","backgroundColor","MultiplePalettes","map","index","colorPalette","length","ColorPalette","clearable","disableCustomColors","enableAlpha","__experimentalHasMultipleOrigins","undefined","Component","renderCustomColorPicker","isOpen","onToggle","background"],"mappings":";;;;;;;;;AAYA;;AATA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;;AAMA;AACA;AACA;;AAIA;AACA;AACA;AAOA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;;AAEA,SAASC,aAAT,OAOI;AAAA,MAPoB;AACvBC,IAAAA,SADuB;AAEvBC,IAAAA,UAFuB;AAGvBC,IAAAA,MAHuB;AAIvBC,IAAAA,QAJuB;AAKvBC,IAAAA,KALuB;AAMvBC,IAAAA;AANuB,GAOpB;AACH,QAAMC,YAAY,GAAG,sBAAS,MAAM;AACnC,WAAO,iBAAKJ,MAAL,EAAa,SAAuB;AAAA,UAArB;AAAEK,QAAAA,KAAF;AAASC,QAAAA;AAAT,OAAqB;AAC1C,YAAMC,WAAW,GAAG,oBAAQF,KAAR,CAApB;AACA,aACC,4BAAC,6BAAD,CAAsB,MAAtB;AACC,QAAA,GAAG,EAAGA,KADP;AAEC,QAAA,UAAU,EAAGH,KAAK,KAAKG,KAFxB;AA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Y,EAAG;AAAA,UAAE;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd;AACC,QAAA,SAAS,EAAC,wCADX;AAEC,yBAAgBD,MAFjB;AAGC,yBAAc,MAHf;AAIC,QAAA,OAAO,EAAGC,QAJX;AAKC,sBAAa,cAAI,qBAAJ,CALd;AAMC,QAAA,KAAK,EAAG;AAAEC,UAAAA,UAAU,EAAExB;AAAd;AANT,SAQGA,KARH,CADc;AAAA;AAFhB,IAFF,EAkBC,4BAAC,SAAD;AACC,IAAA,SAAS,EAAGe,SADb;AAEC,IAAA,UAAU,EAAGlB,UAFd;AAGC,IAAA,MAAM,EAAGC,MAHV;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,KAAK,EAAGC,KALT;AAMC,IAAA,OAAO,EACN,CAAC,CAAEe,SAAH,IACC,4BAAC,6BAAD,CAAsB,YAAtB;AACC,MAAA,OAAO,EAAGlB;AADX,OAGG,cAAI,OAAJ,CAHH;AARH,IAlBD,CADD;AAqCA","sourcesContent":["/**\n * External dependencies\n */\nimport { map } from 'lodash';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Dropdown from '../dropdown';\nimport { ColorPicker } from '../color-picker';\nimport CircularOptionPicker from '../circular-option-picker';\nimport { VStack } from '../v-stack';\nimport { ColorHeading } from './styles';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction SinglePalette( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\tconst colorOptions = useMemo( () => {\n\t\treturn map( colors, ( { color, name } ) => {\n\t\t\tconst colordColor = colord( color );\n\t\t\treturn (\n\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\tkey={ color }\n\t\t\t\t\tisSelected={ value === color }\n\t\t\t\t\tselectedIconProps={\n\t\t\t\t\t\tvalue === color\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tfill:\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t}\n\t\t\t\t\ttooltipText={\n\t\t\t\t\t\tname ||\n\t\t\t\t\t\t// translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\tsprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tvalue === color ? clearColor : () => onChange( color )\n\t\t\t\t\t}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tname\n\t\t\t\t\t\t\t? // translators: %s: The name of the color e.g: \"vivid red\".\n\t\t\t\t\t\t\t sprintf( __( 'Color: %s' ), name )\n\t\t\t\t\t\t\t: // translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\t\t sprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ colors, value, onChange, clearColor ] );\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\tclassName={ className }\n\t\t\toptions={ colorOptions }\n\t\t\tactions={ actions }\n\t\t/>\n\t);\n}\n\nfunction MultiplePalettes( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ colors.map( ( { name, colors: colorPalette }, index ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 2 } key={ index }>\n\t\t\t\t\t\t<ColorHeading>{ name }</ColorHeading>\n\t\t\t\t\t\t<SinglePalette\n\t\t\t\t\t\t\tclearColor={ clearColor }\n\t\t\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\tcolors.length === index + 1 ? actions : null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\nexport default function ColorPalette( {\n\tclearable = true,\n\tclassName,\n\tcolors,\n\tdisableCustomColors = false,\n\tenableAlpha,\n\tonChange,\n\tvalue,\n\t__experimentalHasMultipleOrigins = false,\n} ) {\n\tconst clearColor = useCallback( () => onChange( undefined ), [ onChange ] );\n\tconst Component = __experimentalHasMultipleOrigins\n\t\t? MultiplePalettes\n\t\t: SinglePalette;\n\n\tconst renderCustomColorPicker = () => (\n\t\t<ColorPicker\n\t\t\tcolor={ value }\n\t\t\tonChange={ ( color ) => onChange( color ) }\n\t\t\tenableAlpha={ enableAlpha }\n\t\t/>\n\t);\n\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ ! disableCustomColors && (\n\t\t\t\t<Dropdown\n\t\t\t\t\trenderContent={ renderCustomColorPicker }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ __( 'Custom color picker' ) }\n\t\t\t\t\t\t\tstyle={ { background: value } }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ value }\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<Component\n\t\t\t\tclearable={ clearable }\n\t\t\t\tclearColor={ clearColor }\n\t\t\t\tcolors={ colors }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ value }\n\t\t\t\tactions={\n\t\t\t\t\t!! clearable && (\n\t\t\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\t\t\tonClick={ clearColor }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/color-palette/index.js"],"names":["namesPlugin","a11yPlugin","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","color","name","colordColor","fill","contrast","backgroundColor","MultiplePalettes","map","index","colorPalette","length","ColorPalette","clearable","disableCustomColors","enableAlpha","__experimentalHasMultipleOrigins","undefined","Component","renderCustomColorPicker","isOpen","onToggle","background"],"mappings":";;;;;;;;;AAYA;;AATA;;AACA;;AACA;;AACA;;AAKA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;;AAMA;AACA;AACA;;AAIA;AACA;AACA;AAOA,oBAAQ,CAAEA,cAAF,EAAeC,aAAf,CAAR;;AAEA,SAASC,aAAT,OAOI;AAAA,MAPoB;AACvBC,IAAAA,SADuB;AAEvBC,IAAAA,UAFuB;AAGvBC,IAAAA,MAHuB;AAIvBC,IAAAA,QAJuB;AAKvBC,IAAAA,KALuB;AAMvBC,IAAAA;AANuB,GAOpB;AACH,QAAMC,YAAY,GAAG,sBAAS,MAAM;AACnC,WAAO,iBAAKJ,MAAL,EAAa,SAAuB;AAAA,UAArB;AAAEK,QAAAA,KAAF;AAASC,QAAAA;AAAT,OAAqB;AAC1C,YAAMC,WAAW,GAAG,oBAAQF,KAAR,CAApB;AACA,aACC,4BAAC,6BAAD,CAAsB,MAAtB;AACC,QAAA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,IACD,4BAAC,iBAAD;AACC,IAAA,gBAAgB,EAAC,yDADlB;AAEC,IAAA,aAAa,EAAGK,uBAFjB;AAGC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd;AACC,QAAA,SAAS,EAAC,wCADX;AAEC,yBAAgBD,MAFjB;AAGC,yBAAc,MAHf;AAIC,QAAA,OAAO,EAAGC,QAJX;AAKC,sBAAa,cAAI,qBAAJ,CALd;AAMC,QAAA,KAAK,EAAG;AAAEC,UAAAA,UAAU,EAAExB;AAAd;AANT,SAQGA,KARH,CADc;AAAA;AAHhB,IAFF,EAmBC,4BAAC,SAAD;AACC,IAAA,SAAS,EAAGe,SADb;AAEC,IAAA,UAAU,EAAGlB,UAFd;AAGC,IAAA,MAAM,EAAGC,MAHV;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,KAAK,EAAGC,KALT;AAMC,IAAA,OAAO,EACN,CAAC,CAAEe,SAAH,IACC,4BAAC,6BAAD,CAAsB,YAAtB;AACC,MAAA,OAAO,EAAGlB;AADX,OAGG,cAAI,OAAJ,CAHH;AARH,IAnBD,CADD;AAsCA","sourcesContent":["/**\n * External dependencies\n */\nimport { map } from 'lodash';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Dropdown from '../dropdown';\nimport { ColorPicker } from '../color-picker';\nimport CircularOptionPicker from '../circular-option-picker';\nimport { VStack } from '../v-stack';\nimport { ColorHeading } from './styles';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction SinglePalette( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\tconst colorOptions = useMemo( () => {\n\t\treturn map( colors, ( { color, name } ) => {\n\t\t\tconst colordColor = colord( color );\n\t\t\treturn (\n\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\tkey={ color }\n\t\t\t\t\tisSelected={ value === color }\n\t\t\t\t\tselectedIconProps={\n\t\t\t\t\t\tvalue === color\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tfill:\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t}\n\t\t\t\t\ttooltipText={\n\t\t\t\t\t\tname ||\n\t\t\t\t\t\t// translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\tsprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tvalue === color ? clearColor : () => onChange( color )\n\t\t\t\t\t}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tname\n\t\t\t\t\t\t\t? // translators: %s: The name of the color e.g: \"vivid red\".\n\t\t\t\t\t\t\t sprintf( __( 'Color: %s' ), name )\n\t\t\t\t\t\t\t: // translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\t\t sprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ colors, value, onChange, clearColor ] );\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\tclassName={ className }\n\t\t\toptions={ colorOptions }\n\t\t\tactions={ actions }\n\t\t/>\n\t);\n}\n\nfunction MultiplePalettes( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ colors.map( ( { name, colors: colorPalette }, index ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 2 } key={ index }>\n\t\t\t\t\t\t<ColorHeading>{ name }</ColorHeading>\n\t\t\t\t\t\t<SinglePalette\n\t\t\t\t\t\t\tclearColor={ clearColor }\n\t\t\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\tcolors.length === index + 1 ? actions : null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\nexport default function ColorPalette( {\n\tclearable = true,\n\tclassName,\n\tcolors,\n\tdisableCustomColors = false,\n\tenableAlpha,\n\tonChange,\n\tvalue,\n\t__experimentalHasMultipleOrigins = false,\n} ) {\n\tconst clearColor = useCallback( () => onChange( undefined ), [ onChange ] );\n\tconst Component = __experimentalHasMultipleOrigins\n\t\t? MultiplePalettes\n\t\t: SinglePalette;\n\n\tconst renderCustomColorPicker = () => (\n\t\t<ColorPicker\n\t\t\tcolor={ value }\n\t\t\tonChange={ ( color ) => onChange( color ) }\n\t\t\tenableAlpha={ enableAlpha }\n\t\t/>\n\t);\n\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ ! disableCustomColors && (\n\t\t\t\t<Dropdown\n\t\t\t\t\tcontentClassName=\"components-color-palette__custom-color-dropdown-content\"\n\t\t\t\t\trenderContent={ renderCustomColorPicker }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ __( 'Custom color picker' ) }\n\t\t\t\t\t\t\tstyle={ { background: value } }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ value }\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<Component\n\t\t\t\tclearable={ clearable }\n\t\t\t\tclearColor={ clearColor }\n\t\t\t\tcolors={ colors }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ value }\n\t\t\t\tactions={\n\t\t\t\t\t!! clearable && (\n\t\t\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\t\t\tonClick={ clearColor }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"]}
@@ -34,6 +34,7 @@ var _utils = require("./utils");
34
34
  */
35
35
  function DuotonePicker(_ref) {
36
36
  let {
37
+ clearable = true,
37
38
  colorPalette,
38
39
  duotonePalette,
39
40
  disableCustomColors,
@@ -70,7 +71,7 @@ function DuotonePicker(_ref) {
70
71
  }
71
72
  });
72
73
  }),
73
- actions: (0, _element.createElement)(_circularOptionPicker.default.ButtonAction, {
74
+ actions: !!clearable && (0, _element.createElement)(_circularOptionPicker.default.ButtonAction, {
74
75
  onClick: () => onChange(undefined)
75
76
  }, (0, _i18n.__)('Clear'))
76
77
  }, !disableCustomColors && !disableCustomDuotone && (0, _element.createElement)(_customDuotoneBar.default, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/duotone-picker/duotone-picker.js"],"names":["DuotonePicker","colorPalette","duotonePalette","disableCustomColors","disableCustomDuotone","value","onChange","defaultDark","defaultLight","map","colors","slug","name","style","background","color","tooltipText","label","isSelected","undefined","newColors","newValue","length"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AAKA;;AACA;;AAEA;;AACA;;AAlBA;AACA;AACA;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AlCS,CADX;AAoCC,IAAA,OAAO,EACN,4BAAC,6BAAD,CAAsB,YAAtB;AACC,MAAA,OAAO,EAAG,MAAMJ,QAAQ,CAAEa,SAAF;AADzB,OAGG,cAAI,OAAJ,CAHH;AArCF,KA4CG,CAAEhB,mBAAF,IAAyB,CAAEC,oBAA3B,IACD,4BAAC,yBAAD;AAAkB,IAAA,KAAK,EAAGC,KAA1B;AAAkC,IAAA,QAAQ,EAAGC;AAA7C,IA7CF,EA+CG,CAAEF,oBAAF,IACD,4BAAC,wBAAD;AACC,IAAA,MAAM,EAAG,CAAE,cAAI,SAAJ,CAAF,EAAmB,cAAI,YAAJ,CAAnB,CADV;AAEC,IAAA,MAAM,EAAGH,YAFV;AAGC,IAAA,KAAK,EAAGI,KAHT;AAIC,IAAA,mBAAmB,EAAGF,mBAJvB;AAKC,IAAA,WAAW,MALZ;AAMC,IAAA,QAAQ,EAAKiB,SAAF,IAAiB;AAC3B,UAAK,CAAEA,SAAS,CAAE,CAAF,CAAhB,EAAwB;AACvBA,QAAAA,SAAS,CAAE,CAAF,CAAT,GAAiBb,WAAjB;AACA;;AACD,UAAK,CAAEa,SAAS,CAAE,CAAF,CAAhB,EAAwB;AACvBA,QAAAA,SAAS,CAAE,CAAF,CAAT,GAAiBZ,YAAjB;AACA;;AACD,YAAMa,QAAQ,GACbD,SAAS,CAACE,MAAV,IAAoB,CAApB,GAAwBF,SAAxB,GAAoCD,SADrC;AAEAb,MAAAA,QAAQ,CAAEe,QAAF,CAAR;AACA;AAhBF,IAhDF,CADD;AAsEA;;eAEcrB,a","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ColorListPicker from '../color-list-picker';\nimport CircularOptionPicker from '../circular-option-picker';\n\nimport CustomDuotoneBar from './custom-duotone-bar';\nimport { getDefaultColors, getGradientFromCSSColors } from './utils';\n\nfunction DuotonePicker( {\n\tcolorPalette,\n\tduotonePalette,\n\tdisableCustomColors,\n\tdisableCustomDuotone,\n\tvalue,\n\tonChange,\n} ) {\n\tconst [ defaultDark, defaultLight ] = useMemo(\n\t\t() => getDefaultColors( colorPalette ),\n\t\t[ colorPalette ]\n\t);\n\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\toptions={ duotonePalette.map( ( { colors, slug, name } ) => {\n\t\t\t\tconst style = {\n\t\t\t\t\tbackground: getGradientFromCSSColors( colors, '135deg' ),\n\t\t\t\t\tcolor: 'transparent',\n\t\t\t\t};\n\t\t\t\tconst tooltipText =\n\t\t\t\t\tname ??\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: duotone code e.g: \"dark-grayscale\" or \"7f7f7f-ffffff\".\n\t\t\t\t\t\t__( 'Duotone code: %s' ),\n\t\t\t\t\t\tslug\n\t\t\t\t\t);\n\t\t\t\tconst label = name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the option e.g: \"Dark grayscale\".\n\t\t\t\t\t\t\t__( 'Duotone: %s' ),\n\t\t\t\t\t\t\tname\n\t\t\t\t\t )\n\t\t\t\t\t: tooltipText;\n\t\t\t\tconst isSelected = isEqual( colors, value );\n\n\t\t\t\treturn (\n\t\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\tvalue={ colors }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\ttooltipText={ tooltipText }\n\t\t\t\t\t\tstyle={ style }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChange( isSelected ? undefined : colors );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\tactions={\n\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\tonClick={ () => onChange( undefined ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t}\n\t\t>\n\t\t\t{ ! disableCustomColors && ! disableCustomDuotone && (\n\t\t\t\t<CustomDuotoneBar value={ value } onChange={ onChange } />\n\t\t\t) }\n\t\t\t{ ! disableCustomDuotone && (\n\t\t\t\t<ColorListPicker\n\t\t\t\t\tlabels={ [ __( 'Shadows' ), __( 'Highlights' ) ] }\n\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha\n\t\t\t\t\tonChange={ ( newColors ) => {\n\t\t\t\t\t\tif ( ! newColors[ 0 ] ) {\n\t\t\t\t\t\t\tnewColors[ 0 ] = defaultDark;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! newColors[ 1 ] ) {\n\t\t\t\t\t\t\tnewColors[ 1 ] = defaultLight;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst newValue =\n\t\t\t\t\t\t\tnewColors.length >= 2 ? newColors : undefined;\n\t\t\t\t\t\tonChange( newValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</CircularOptionPicker>\n\t);\n}\n\nexport default DuotonePicker;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/duotone-picker/duotone-picker.js"],"names":["DuotonePicker","clearable","colorPalette","duotonePalette","disableCustomColors","disableCustomDuotone","value","onChange","defaultDark","defaultLight","map","colors","slug","name","style","background","color","tooltipText","label","isSelected","undefined","newColors","newValue","length"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AAKA;;AACA;;AAEA;;AACA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAOA,SAASA,aAAT,OAQI;AAAA,MARoB;AACvBC,IAAAA,SAAS,GAAG,IADW;AAEvBC,IAAAA,YAFuB;AAGvBC,IAAAA,cAHuB;AAIvBC,IAAAA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Ea,SAAF;AADzB,OAGG,cAAI,OAAJ,CAHH;AAtCH,KA8CG,CAAEhB,mBAAF,IAAyB,CAAEC,oBAA3B,IACD,4BAAC,yBAAD;AAAkB,IAAA,KAAK,EAAGC,KAA1B;AAAkC,IAAA,QAAQ,EAAGC;AAA7C,IA/CF,EAiDG,CAAEF,oBAAF,IACD,4BAAC,wBAAD;AACC,IAAA,MAAM,EAAG,CAAE,cAAI,SAAJ,CAAF,EAAmB,cAAI,YAAJ,CAAnB,CADV;AAEC,IAAA,MAAM,EAAGH,YAFV;AAGC,IAAA,KAAK,EAAGI,KAHT;AAIC,IAAA,mBAAmB,EAAGF,mBAJvB;AAKC,IAAA,WAAW,MALZ;AAMC,IAAA,QAAQ,EAAKiB,SAAF,IAAiB;AAC3B,UAAK,CAAEA,SAAS,CAAE,CAAF,CAAhB,EAAwB;AACvBA,QAAAA,SAAS,CAAE,CAAF,CAAT,GAAiBb,WAAjB;AACA;;AACD,UAAK,CAAEa,SAAS,CAAE,CAAF,CAAhB,EAAwB;AACvBA,QAAAA,SAAS,CAAE,CAAF,CAAT,GAAiBZ,YAAjB;AACA;;AACD,YAAMa,QAAQ,GACbD,SAAS,CAACE,MAAV,IAAoB,CAApB,GAAwBF,SAAxB,GAAoCD,SADrC;AAEAb,MAAAA,QAAQ,CAAEe,QAAF,CAAR;AACA;AAhBF,IAlDF,CADD;AAwEA;;eAEctB,a","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ColorListPicker from '../color-list-picker';\nimport CircularOptionPicker from '../circular-option-picker';\n\nimport CustomDuotoneBar from './custom-duotone-bar';\nimport { getDefaultColors, getGradientFromCSSColors } from './utils';\n\nfunction DuotonePicker( {\n\tclearable = true,\n\tcolorPalette,\n\tduotonePalette,\n\tdisableCustomColors,\n\tdisableCustomDuotone,\n\tvalue,\n\tonChange,\n} ) {\n\tconst [ defaultDark, defaultLight ] = useMemo(\n\t\t() => getDefaultColors( colorPalette ),\n\t\t[ colorPalette ]\n\t);\n\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\toptions={ duotonePalette.map( ( { colors, slug, name } ) => {\n\t\t\t\tconst style = {\n\t\t\t\t\tbackground: getGradientFromCSSColors( colors, '135deg' ),\n\t\t\t\t\tcolor: 'transparent',\n\t\t\t\t};\n\t\t\t\tconst tooltipText =\n\t\t\t\t\tname ??\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: duotone code e.g: \"dark-grayscale\" or \"7f7f7f-ffffff\".\n\t\t\t\t\t\t__( 'Duotone code: %s' ),\n\t\t\t\t\t\tslug\n\t\t\t\t\t);\n\t\t\t\tconst label = name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the option e.g: \"Dark grayscale\".\n\t\t\t\t\t\t\t__( 'Duotone: %s' ),\n\t\t\t\t\t\t\tname\n\t\t\t\t\t )\n\t\t\t\t\t: tooltipText;\n\t\t\t\tconst isSelected = isEqual( colors, value );\n\n\t\t\t\treturn (\n\t\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\tvalue={ colors }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\ttooltipText={ tooltipText }\n\t\t\t\t\t\tstyle={ style }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChange( isSelected ? undefined : colors );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\tactions={\n\t\t\t\t!! clearable && (\n\t\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\t\tonClick={ () => onChange( undefined ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t{ ! disableCustomColors && ! disableCustomDuotone && (\n\t\t\t\t<CustomDuotoneBar value={ value } onChange={ onChange } />\n\t\t\t) }\n\t\t\t{ ! disableCustomDuotone && (\n\t\t\t\t<ColorListPicker\n\t\t\t\t\tlabels={ [ __( 'Shadows' ), __( 'Highlights' ) ] }\n\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha\n\t\t\t\t\tonChange={ ( newColors ) => {\n\t\t\t\t\t\tif ( ! newColors[ 0 ] ) {\n\t\t\t\t\t\t\tnewColors[ 0 ] = defaultDark;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! newColors[ 1 ] ) {\n\t\t\t\t\t\t\tnewColors[ 1 ] = defaultLight;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst newValue =\n\t\t\t\t\t\t\tnewColors.length >= 2 ? newColors : undefined;\n\t\t\t\t\t\tonChange( newValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</CircularOptionPicker>\n\t);\n}\n\nexport default DuotonePicker;\n"]}
@@ -120,6 +120,7 @@ export default function ColorPalette(_ref5) {
120
120
  spacing: 3,
121
121
  className: className
122
122
  }, !disableCustomColors && createElement(Dropdown, {
123
+ contentClassName: "components-color-palette__custom-color-dropdown-content",
123
124
  renderContent: renderCustomColorPicker,
124
125
  renderToggle: _ref6 => {
125
126
  let {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/color-palette/index.js"],"names":["map","colord","extend","namesPlugin","a11yPlugin","__","sprintf","useCallback","useMemo","Dropdown","ColorPicker","CircularOptionPicker","VStack","ColorHeading","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","color","name","colordColor","fill","contrast","backgroundColor","MultiplePalettes","index","colorPalette","length","ColorPalette","clearable","disableCustomColors","enableAlpha","__experimentalHasMultipleOrigins","undefined","Component","renderCustomColorPicker","isOpen","onToggle","background"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AACA,OAAOC,UAAP,MAAuB,qBAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AACA,SAASC,MAAT,QAAuB,YAAvB;AACA,SAASC,YAAT,QAA6B,UAA7B;AAEAX,MAAM,CAAE,CAAEC,WAAF,EAAeC,UAAf,CAAF,CAAN;;AAEA,SAASU,aAAT,OAOI;AAAA,MAPoB;AACvBC,IAAAA,SADuB;AAEvBC,IAAAA,UAFuB;AAGvBC,IAAAA,MAHuB;AAIvBC,IAAAA,QAJuB;AAKvBC,IAAAA,KALuB;AAMvBC,IAAAA;AANuB,GAOpB;AACH,QAAMC,YAAY,GAAGb,OAAO,CAAE,MAAM;AACnC,WAAOR,GAAG,CAAEiB,MAAF,EAAU,SAAuB;AAAA,UAArB;AAAEK,QAAAA,KAAF;AAASC,QAAAA;AAAT,OAAqB;AAC1C,YAAMC,WAAW,GAAGvB,MAAM,CAAEqB,KAAF,CAA1B;AACA,aACC,cAAC,oBAAD,CAAsB,MAAtB;AACC,QAAA,GAAG,EAAGA,KADP;AAEC,QAAA,UAAU,EAAGH,KAAK,KAAKG,KAFxB;AAGC,QAAA,iBAAiB,EAChBH,KAAK,KAAKG,KAAV,GACG;AACAG,UAAAA,IAAI,EACHD,WAAW,CAACE,QAAZ,KACAF,WAAW,CAACE,QAAZ,CAAsB,MAAtB,CADA,GAEG,MAFH,GAGG;AALJ,SADH,GA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,wCADX;AAEC,yBAAgBD,MAFjB;AAGC,yBAAc,MAHf;AAIC,QAAA,OAAO,EAAGC,QAJX;AAKC,sBAAapC,EAAE,CAAE,qBAAF,CALhB;AAMC,QAAA,KAAK,EAAG;AAAEqC,UAAAA,UAAU,EAAEvB;AAAd;AANT,SAQGA,KARH,CADc;AAAA;AAFhB,IAFF,EAkBC,cAAC,SAAD;AACC,IAAA,SAAS,EAAGc,SADb;AAEC,IAAA,UAAU,EAAGjB,UAFd;AAGC,IAAA,MAAM,EAAGC,MAHV;AAIC,IAAA,QAAQ,EAAGC,QAJZ;AAKC,IAAA,KAAK,EAAGC,KALT;AAMC,IAAA,OAAO,EACN,CAAC,CAAEc,SAAH,IACC,cAAC,oBAAD,CAAsB,YAAtB;AACC,MAAA,OAAO,EAAGjB;AADX,OAGGX,EAAE,CAAE,OAAF,CAHL;AARH,IAlBD,CADD;AAqCA","sourcesContent":["/**\n * External dependencies\n */\nimport { map } from 'lodash';\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Dropdown from '../dropdown';\nimport { ColorPicker } from '../color-picker';\nimport CircularOptionPicker from '../circular-option-picker';\nimport { VStack } from '../v-stack';\nimport { ColorHeading } from './styles';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction SinglePalette( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\tconst colorOptions = useMemo( () => {\n\t\treturn map( colors, ( { color, name } ) => {\n\t\t\tconst colordColor = colord( color );\n\t\t\treturn (\n\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\tkey={ color }\n\t\t\t\t\tisSelected={ value === color }\n\t\t\t\t\tselectedIconProps={\n\t\t\t\t\t\tvalue === color\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tfill:\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t}\n\t\t\t\t\ttooltipText={\n\t\t\t\t\t\tname ||\n\t\t\t\t\t\t// translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\tsprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tvalue === color ? clearColor : () => onChange( color )\n\t\t\t\t\t}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tname\n\t\t\t\t\t\t\t? // translators: %s: The name of the color e.g: \"vivid red\".\n\t\t\t\t\t\t\t sprintf( __( 'Color: %s' ), name )\n\t\t\t\t\t\t\t: // translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\t\t sprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ colors, value, onChange, clearColor ] );\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\tclassName={ className }\n\t\t\toptions={ colorOptions }\n\t\t\tactions={ actions }\n\t\t/>\n\t);\n}\n\nfunction MultiplePalettes( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ colors.map( ( { name, colors: colorPalette }, index ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 2 } key={ index }>\n\t\t\t\t\t\t<ColorHeading>{ name }</ColorHeading>\n\t\t\t\t\t\t<SinglePalette\n\t\t\t\t\t\t\tclearColor={ clearColor }\n\t\t\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\tcolors.length === index + 1 ? actions : null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\nexport default function ColorPalette( {\n\tclearable = true,\n\tclassName,\n\tcolors,\n\tdisableCustomColors = false,\n\tenableAlpha,\n\tonChange,\n\tvalue,\n\t__experimentalHasMultipleOrigins = false,\n} ) {\n\tconst clearColor = useCallback( () => onChange( undefined ), [ onChange ] );\n\tconst Component = __experimentalHasMultipleOrigins\n\t\t? MultiplePalettes\n\t\t: SinglePalette;\n\n\tconst renderCustomColorPicker = () => (\n\t\t<ColorPicker\n\t\t\tcolor={ value }\n\t\t\tonChange={ ( color ) => onChange( color ) }\n\t\t\tenableAlpha={ enableAlpha }\n\t\t/>\n\t);\n\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ ! disableCustomColors && (\n\t\t\t\t<Dropdown\n\t\t\t\t\trenderContent={ renderCustomColorPicker }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ __( 'Custom color picker' ) }\n\t\t\t\t\t\t\tstyle={ { background: value } }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ value }\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<Component\n\t\t\t\tclearable={ clearable }\n\t\t\t\tclearColor={ clearColor }\n\t\t\t\tcolors={ colors }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ value }\n\t\t\t\tactions={\n\t\t\t\t\t!! clearable && (\n\t\t\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\t\t\tonClick={ clearColor }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/color-palette/index.js"],"names":["map","colord","extend","namesPlugin","a11yPlugin","__","sprintf","useCallback","useMemo","Dropdown","ColorPicker","CircularOptionPicker","VStack","ColorHeading","SinglePalette","className","clearColor","colors","onChange","value","actions","colorOptions","color","name","colordColor","fill","contrast","backgroundColor","MultiplePalettes","index","colorPalette","length","ColorPalette","clearable","disableCustomColors","enableAlpha","__experimentalHasMultipleOrigins","undefined","Component","renderCustomColorPicker","isOpen","onToggle","background"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AACA,SAASC,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AACA,OAAOC,UAAP,MAAuB,qBAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AACA,SAASC,MAAT,QAAuB,YAAvB;AACA,SAASC,YAAT,QAA6B,UAA7B;AAEAX,MAAM,CAAE,CAAEC,WAAF,EAAeC,UAAf,CAAF,CAAN;;AAEA,SAASU,aAAT,OAOI;AAAA,MAPoB;AACvBC,IAAAA,SADuB;AAEvBC,IAAAA,UAFuB;AAGvBC,IAAAA,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Plugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport Dropdown from '../dropdown';\nimport { ColorPicker } from '../color-picker';\nimport CircularOptionPicker from '../circular-option-picker';\nimport { VStack } from '../v-stack';\nimport { ColorHeading } from './styles';\n\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction SinglePalette( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\tconst colorOptions = useMemo( () => {\n\t\treturn map( colors, ( { color, name } ) => {\n\t\t\tconst colordColor = colord( color );\n\t\t\treturn (\n\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\tkey={ color }\n\t\t\t\t\tisSelected={ value === color }\n\t\t\t\t\tselectedIconProps={\n\t\t\t\t\t\tvalue === color\n\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\tfill:\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast() >\n\t\t\t\t\t\t\t\t\t\tcolordColor.contrast( '#000' )\n\t\t\t\t\t\t\t\t\t\t\t? '#fff'\n\t\t\t\t\t\t\t\t\t\t\t: '#000',\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t: {}\n\t\t\t\t\t}\n\t\t\t\t\ttooltipText={\n\t\t\t\t\t\tname ||\n\t\t\t\t\t\t// translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\tsprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t\tstyle={ { backgroundColor: color, color } }\n\t\t\t\t\tonClick={\n\t\t\t\t\t\tvalue === color ? clearColor : () => onChange( color )\n\t\t\t\t\t}\n\t\t\t\t\taria-label={\n\t\t\t\t\t\tname\n\t\t\t\t\t\t\t? // translators: %s: The name of the color e.g: \"vivid red\".\n\t\t\t\t\t\t\t sprintf( __( 'Color: %s' ), name )\n\t\t\t\t\t\t\t: // translators: %s: color hex code e.g: \"#f00\".\n\t\t\t\t\t\t\t sprintf( __( 'Color code: %s' ), color )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t} );\n\t}, [ colors, value, onChange, clearColor ] );\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\tclassName={ className }\n\t\t\toptions={ colorOptions }\n\t\t\tactions={ actions }\n\t\t/>\n\t);\n}\n\nfunction MultiplePalettes( {\n\tclassName,\n\tclearColor,\n\tcolors,\n\tonChange,\n\tvalue,\n\tactions,\n} ) {\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ colors.map( ( { name, colors: colorPalette }, index ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<VStack spacing={ 2 } key={ index }>\n\t\t\t\t\t\t<ColorHeading>{ name }</ColorHeading>\n\t\t\t\t\t\t<SinglePalette\n\t\t\t\t\t\t\tclearColor={ clearColor }\n\t\t\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t\tcolors.length === index + 1 ? actions : null\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</VStack>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</VStack>\n\t);\n}\n\nexport default function ColorPalette( {\n\tclearable = true,\n\tclassName,\n\tcolors,\n\tdisableCustomColors = false,\n\tenableAlpha,\n\tonChange,\n\tvalue,\n\t__experimentalHasMultipleOrigins = false,\n} ) {\n\tconst clearColor = useCallback( () => onChange( undefined ), [ onChange ] );\n\tconst Component = __experimentalHasMultipleOrigins\n\t\t? MultiplePalettes\n\t\t: SinglePalette;\n\n\tconst renderCustomColorPicker = () => (\n\t\t<ColorPicker\n\t\t\tcolor={ value }\n\t\t\tonChange={ ( color ) => onChange( color ) }\n\t\t\tenableAlpha={ enableAlpha }\n\t\t/>\n\t);\n\n\treturn (\n\t\t<VStack spacing={ 3 } className={ className }>\n\t\t\t{ ! disableCustomColors && (\n\t\t\t\t<Dropdown\n\t\t\t\t\tcontentClassName=\"components-color-palette__custom-color-dropdown-content\"\n\t\t\t\t\trenderContent={ renderCustomColorPicker }\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<button\n\t\t\t\t\t\t\tclassName=\"components-color-palette__custom-color\"\n\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\taria-haspopup=\"true\"\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\taria-label={ __( 'Custom color picker' ) }\n\t\t\t\t\t\t\tstyle={ { background: value } }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ value }\n\t\t\t\t\t\t</button>\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<Component\n\t\t\t\tclearable={ clearable }\n\t\t\t\tclearColor={ clearColor }\n\t\t\t\tcolors={ colors }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tvalue={ value }\n\t\t\t\tactions={\n\t\t\t\t\t!! clearable && (\n\t\t\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\t\t\tonClick={ clearColor }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t</VStack>\n\t);\n}\n"]}
@@ -21,6 +21,7 @@ import { getDefaultColors, getGradientFromCSSColors } from './utils';
21
21
 
22
22
  function DuotonePicker(_ref) {
23
23
  let {
24
+ clearable = true,
24
25
  colorPalette,
25
26
  duotonePalette,
26
27
  disableCustomColors,
@@ -57,7 +58,7 @@ function DuotonePicker(_ref) {
57
58
  }
58
59
  });
59
60
  }),
60
- actions: createElement(CircularOptionPicker.ButtonAction, {
61
+ actions: !!clearable && createElement(CircularOptionPicker.ButtonAction, {
61
62
  onClick: () => onChange(undefined)
62
63
  }, __('Clear'))
63
64
  }, !disableCustomColors && !disableCustomDuotone && createElement(CustomDuotoneBar, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/duotone-picker/duotone-picker.js"],"names":["isEqual","useMemo","__","sprintf","ColorListPicker","CircularOptionPicker","CustomDuotoneBar","getDefaultColors","getGradientFromCSSColors","DuotonePicker","colorPalette","duotonePalette","disableCustomColors","disableCustomDuotone","value","onChange","defaultDark","defaultLight","map","colors","slug","name","style","background","color","tooltipText","label","isSelected","undefined","newColors","newValue","length"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AAEA,OAAOC,gBAAP,MAA6B,sBAA7B;AACA,SAASC,gBAAT,EAA2BC,wBAA3B,QAA2D,SAA3D;;AAEA,SAASC,aAAT,OAOI;AAAA,MAPoB;AACvBC,IAAAA,YADuB;AAEvBC,IAAAA,cAFuB;AAGvBC,IAAAA,mBAHuB;AAIvBC,IAAAA,oBAJuB;AAKvBC,IAAAA,KALuB;AAMvBC,IAAAA;AANuB,GAOpB;AACH,QAAM,CAAEC,WAAF,EAAeC,YAAf,IAAgChB,OAAO,CAC5C,MAAMM,gBAAgB,CAAEG,YAAF,CADsB,EAE5C,CAAEA,YAAF,CAF4C,CAA7C;AAKA,SACC,cAAC,oBAAD;AACC,IAAA,OAAO,EAAGC,cAAc,CAACO,GAAf,CAAoB,SAA8B;AAAA,UAA5B;AAAEC,QAAAA,MAAF;AAAUC,QAAAA,IAAV;AAAgBC,QAAAA;AAAhB,OAA4B;AAC3D,YAAMC,KAAK,GAAG;AACbC,QAAAA,UAAU,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T;AAIC,IAAA,mBAAmB,EAAGF,mBAJvB;AAKC,IAAA,WAAW,MALZ;AAMC,IAAA,QAAQ,EAAKiB,SAAF,IAAiB;AAC3B,UAAK,CAAEA,SAAS,CAAE,CAAF,CAAhB,EAAwB;AACvBA,QAAAA,SAAS,CAAE,CAAF,CAAT,GAAiBb,WAAjB;AACA;;AACD,UAAK,CAAEa,SAAS,CAAE,CAAF,CAAhB,EAAwB;AACvBA,QAAAA,SAAS,CAAE,CAAF,CAAT,GAAiBZ,YAAjB;AACA;;AACD,YAAMa,QAAQ,GACbD,SAAS,CAACE,MAAV,IAAoB,CAApB,GAAwBF,SAAxB,GAAoCD,SADrC;AAEAb,MAAAA,QAAQ,CAAEe,QAAF,CAAR;AACA;AAhBF,IAhDF,CADD;AAsEA;;AAED,eAAerB,aAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ColorListPicker from '../color-list-picker';\nimport CircularOptionPicker from '../circular-option-picker';\n\nimport CustomDuotoneBar from './custom-duotone-bar';\nimport { getDefaultColors, getGradientFromCSSColors } from './utils';\n\nfunction DuotonePicker( {\n\tcolorPalette,\n\tduotonePalette,\n\tdisableCustomColors,\n\tdisableCustomDuotone,\n\tvalue,\n\tonChange,\n} ) {\n\tconst [ defaultDark, defaultLight ] = useMemo(\n\t\t() => getDefaultColors( colorPalette ),\n\t\t[ colorPalette ]\n\t);\n\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\toptions={ duotonePalette.map( ( { colors, slug, name } ) => {\n\t\t\t\tconst style = {\n\t\t\t\t\tbackground: getGradientFromCSSColors( colors, '135deg' ),\n\t\t\t\t\tcolor: 'transparent',\n\t\t\t\t};\n\t\t\t\tconst tooltipText =\n\t\t\t\t\tname ??\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: duotone code e.g: \"dark-grayscale\" or \"7f7f7f-ffffff\".\n\t\t\t\t\t\t__( 'Duotone code: %s' ),\n\t\t\t\t\t\tslug\n\t\t\t\t\t);\n\t\t\t\tconst label = name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the option e.g: \"Dark grayscale\".\n\t\t\t\t\t\t\t__( 'Duotone: %s' ),\n\t\t\t\t\t\t\tname\n\t\t\t\t\t )\n\t\t\t\t\t: tooltipText;\n\t\t\t\tconst isSelected = isEqual( colors, value );\n\n\t\t\t\treturn (\n\t\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\tvalue={ colors }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\ttooltipText={ tooltipText }\n\t\t\t\t\t\tstyle={ style }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChange( isSelected ? undefined : colors );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\tactions={\n\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\tonClick={ () => onChange( undefined ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t}\n\t\t>\n\t\t\t{ ! disableCustomColors && ! disableCustomDuotone && (\n\t\t\t\t<CustomDuotoneBar value={ value } onChange={ onChange } />\n\t\t\t) }\n\t\t\t{ ! disableCustomDuotone && (\n\t\t\t\t<ColorListPicker\n\t\t\t\t\tlabels={ [ __( 'Shadows' ), __( 'Highlights' ) ] }\n\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha\n\t\t\t\t\tonChange={ ( newColors ) => {\n\t\t\t\t\t\tif ( ! newColors[ 0 ] ) {\n\t\t\t\t\t\t\tnewColors[ 0 ] = defaultDark;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! newColors[ 1 ] ) {\n\t\t\t\t\t\t\tnewColors[ 1 ] = defaultLight;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst newValue =\n\t\t\t\t\t\t\tnewColors.length >= 2 ? newColors : undefined;\n\t\t\t\t\t\tonChange( newValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</CircularOptionPicker>\n\t);\n}\n\nexport default DuotonePicker;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/duotone-picker/duotone-picker.js"],"names":["isEqual","useMemo","__","sprintf","ColorListPicker","CircularOptionPicker","CustomDuotoneBar","getDefaultColors","getGradientFromCSSColors","DuotonePicker","clearable","colorPalette","duotonePalette","disableCustomColors","disableCustomDuotone","value","onChange","defaultDark","defaultLight","map","colors","slug","name","style","background","color","tooltipText","label","isSelected","undefined","newColors","newValue","length"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AACA,OAAOC,oBAAP,MAAiC,2BAAjC;AAEA,OAAOC,gBAAP,MAA6B,sBAA7B;AACA,SAASC,gBAAT,EAA2BC,wBAA3B,QAA2D,SAA3D;;AAEA,SAASC,aAAT,OAQI;AAAA,MARoB;AACvBC,IAAAA,SAAS,GAAG,IADW;AAEvBC,IAAAA,YAFuB;AAGvBC,IAAAA,cAHuB;AAIvBC,IAAAA,mBAJuB;AAKvBC,IAAAA,oBALuB;AAMvBC,IAAAA,KANuB;AAOvBC,IAAAA;AAPuB,GAQpB;AACH,QAAM,CAAEC,WAAF,EAAeC,YAAf,IAAgCjB,OAAO,CAC5C,MAAMM,gBAAgB,CAAEI,YAAF,CADsB,E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D;AAAkB,IAAA,KAAK,EAAGC,KAA1B;AAAkC,IAAA,QAAQ,EAAGC;AAA7C,IA/CF,EAiDG,CAAEF,oBAAF,IACD,cAAC,eAAD;AACC,IAAA,MAAM,EAAG,CAAEZ,EAAE,CAAE,SAAF,CAAJ,EAAmBA,EAAE,CAAE,YAAF,CAArB,CADV;AAEC,IAAA,MAAM,EAAGS,YAFV;AAGC,IAAA,KAAK,EAAGI,KAHT;AAIC,IAAA,mBAAmB,EAAGF,mBAJvB;AAKC,IAAA,WAAW,MALZ;AAMC,IAAA,QAAQ,EAAKiB,SAAF,IAAiB;AAC3B,UAAK,CAAEA,SAAS,CAAE,CAAF,CAAhB,EAAwB;AACvBA,QAAAA,SAAS,CAAE,CAAF,CAAT,GAAiBb,WAAjB;AACA;;AACD,UAAK,CAAEa,SAAS,CAAE,CAAF,CAAhB,EAAwB;AACvBA,QAAAA,SAAS,CAAE,CAAF,CAAT,GAAiBZ,YAAjB;AACA;;AACD,YAAMa,QAAQ,GACbD,SAAS,CAACE,MAAV,IAAoB,CAApB,GAAwBF,SAAxB,GAAoCD,SADrC;AAEAb,MAAAA,QAAQ,CAAEe,QAAF,CAAR;AACA;AAhBF,IAlDF,CADD;AAwEA;;AAED,eAAetB,aAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { isEqual } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ColorListPicker from '../color-list-picker';\nimport CircularOptionPicker from '../circular-option-picker';\n\nimport CustomDuotoneBar from './custom-duotone-bar';\nimport { getDefaultColors, getGradientFromCSSColors } from './utils';\n\nfunction DuotonePicker( {\n\tclearable = true,\n\tcolorPalette,\n\tduotonePalette,\n\tdisableCustomColors,\n\tdisableCustomDuotone,\n\tvalue,\n\tonChange,\n} ) {\n\tconst [ defaultDark, defaultLight ] = useMemo(\n\t\t() => getDefaultColors( colorPalette ),\n\t\t[ colorPalette ]\n\t);\n\n\treturn (\n\t\t<CircularOptionPicker\n\t\t\toptions={ duotonePalette.map( ( { colors, slug, name } ) => {\n\t\t\t\tconst style = {\n\t\t\t\t\tbackground: getGradientFromCSSColors( colors, '135deg' ),\n\t\t\t\t\tcolor: 'transparent',\n\t\t\t\t};\n\t\t\t\tconst tooltipText =\n\t\t\t\t\tname ??\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// translators: %s: duotone code e.g: \"dark-grayscale\" or \"7f7f7f-ffffff\".\n\t\t\t\t\t\t__( 'Duotone code: %s' ),\n\t\t\t\t\t\tslug\n\t\t\t\t\t);\n\t\t\t\tconst label = name\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: The name of the option e.g: \"Dark grayscale\".\n\t\t\t\t\t\t\t__( 'Duotone: %s' ),\n\t\t\t\t\t\t\tname\n\t\t\t\t\t )\n\t\t\t\t\t: tooltipText;\n\t\t\t\tconst isSelected = isEqual( colors, value );\n\n\t\t\t\treturn (\n\t\t\t\t\t<CircularOptionPicker.Option\n\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\tvalue={ colors }\n\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\taria-label={ label }\n\t\t\t\t\t\ttooltipText={ tooltipText }\n\t\t\t\t\t\tstyle={ style }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tonChange( isSelected ? undefined : colors );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t\tactions={\n\t\t\t\t!! clearable && (\n\t\t\t\t\t<CircularOptionPicker.ButtonAction\n\t\t\t\t\t\tonClick={ () => onChange( undefined ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Clear' ) }\n\t\t\t\t\t</CircularOptionPicker.ButtonAction>\n\t\t\t\t)\n\t\t\t}\n\t\t>\n\t\t\t{ ! disableCustomColors && ! disableCustomDuotone && (\n\t\t\t\t<CustomDuotoneBar value={ value } onChange={ onChange } />\n\t\t\t) }\n\t\t\t{ ! disableCustomDuotone && (\n\t\t\t\t<ColorListPicker\n\t\t\t\t\tlabels={ [ __( 'Shadows' ), __( 'Highlights' ) ] }\n\t\t\t\t\tcolors={ colorPalette }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\t\tenableAlpha\n\t\t\t\t\tonChange={ ( newColors ) => {\n\t\t\t\t\t\tif ( ! newColors[ 0 ] ) {\n\t\t\t\t\t\t\tnewColors[ 0 ] = defaultDark;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ( ! newColors[ 1 ] ) {\n\t\t\t\t\t\t\tnewColors[ 1 ] = defaultLight;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst newValue =\n\t\t\t\t\t\t\tnewColors.length >= 2 ? newColors : undefined;\n\t\t\t\t\t\tonChange( newValue );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</CircularOptionPicker>\n\t);\n}\n\nexport default DuotonePicker;\n"]}
@@ -890,6 +890,15 @@ input.components-combobox-control__input[type=text]:focus {
890
890
  cursor: pointer;
891
891
  }
892
892
 
893
+ .components-dropdown__content.components-color-palette__custom-color-dropdown-content .components-popover__content {
894
+ overflow: visible;
895
+ box-shadow: 0 4px 4px rgba(0, 0, 0, 0.05);
896
+ border: none;
897
+ }
898
+ .components-dropdown__content.components-color-palette__custom-color-dropdown-content .components-popover__content > div {
899
+ padding: 0;
900
+ }
901
+
893
902
  .components-custom-gradient-picker__gradient-bar:not(.has-gradient) {
894
903
  opacity: 0.4;
895
904
  }
@@ -890,6 +890,15 @@ input.components-combobox-control__input[type=text]:focus {
890
890
  cursor: pointer;
891
891
  }
892
892
 
893
+ .components-dropdown__content.components-color-palette__custom-color-dropdown-content .components-popover__content {
894
+ overflow: visible;
895
+ box-shadow: 0 4px 4px rgba(0, 0, 0, 0.05);
896
+ border: none;
897
+ }
898
+ .components-dropdown__content.components-color-palette__custom-color-dropdown-content .components-popover__content > div {
899
+ padding: 0;
900
+ }
901
+
893
902
  .components-custom-gradient-picker__gradient-bar:not(.has-gradient) {
894
903
  opacity: 0.4;
895
904
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/components",
3
- "version": "19.1.0",
3
+ "version": "19.1.1",
4
4
  "description": "UI components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -74,5 +74,5 @@
74
74
  "publishConfig": {
75
75
  "access": "public"
76
76
  },
77
- "gitHead": "6d3bd917064b4b194677233ee426f5988fa441b9"
77
+ "gitHead": "49c7be0ff5dc493fc9e5a861e18273dd1f3fce8c"
78
78
  }
@@ -135,6 +135,7 @@ export default function ColorPalette( {
135
135
  <VStack spacing={ 3 } className={ className }>
136
136
  { ! disableCustomColors && (
137
137
  <Dropdown
138
+ contentClassName="components-color-palette__custom-color-dropdown-content"
138
139
  renderContent={ renderCustomColorPicker }
139
140
  renderToggle={ ( { isOpen, onToggle } ) => (
140
141
  <button
@@ -16,3 +16,12 @@
16
16
  color: $white;
17
17
  cursor: pointer;
18
18
  }
19
+
20
+ .components-dropdown__content.components-color-palette__custom-color-dropdown-content .components-popover__content {
21
+ overflow: visible;
22
+ box-shadow: 0 4px 4px rgba(0, 0, 0, 0.05);
23
+ border: none;
24
+ & > div {
25
+ padding: 0;
26
+ }
27
+ }
@@ -26,6 +26,7 @@ exports[`ColorPalette Dropdown .renderToggle should render dropdown content 1`]
26
26
 
27
27
  exports[`ColorPalette Dropdown should render it correctly 1`] = `
28
28
  <Dropdown
29
+ contentClassName="components-color-palette__custom-color-dropdown-content"
29
30
  key=".0"
30
31
  renderContent={[Function]}
31
32
  renderToggle={[Function]}
@@ -177,6 +178,7 @@ exports[`ColorPalette should render a dynamic toolbar of colors 1`] = `
177
178
  data-wp-component="VStack"
178
179
  >
179
180
  <Dropdown
181
+ contentClassName="components-color-palette__custom-color-dropdown-content"
180
182
  key=".0"
181
183
  renderContent={[Function]}
182
184
  renderToggle={[Function]}
@@ -19,6 +19,7 @@ import CustomDuotoneBar from './custom-duotone-bar';
19
19
  import { getDefaultColors, getGradientFromCSSColors } from './utils';
20
20
 
21
21
  function DuotonePicker( {
22
+ clearable = true,
22
23
  colorPalette,
23
24
  duotonePalette,
24
25
  disableCustomColors,
@@ -69,11 +70,13 @@ function DuotonePicker( {
69
70
  );
70
71
  } ) }
71
72
  actions={
72
- <CircularOptionPicker.ButtonAction
73
- onClick={ () => onChange( undefined ) }
74
- >
75
- { __( 'Clear' ) }
76
- </CircularOptionPicker.ButtonAction>
73
+ !! clearable && (
74
+ <CircularOptionPicker.ButtonAction
75
+ onClick={ () => onChange( undefined ) }
76
+ >
77
+ { __( 'Clear' ) }
78
+ </CircularOptionPicker.ButtonAction>
79
+ )
77
80
  }
78
81
  >
79
82
  { ! disableCustomColors && ! disableCustomDuotone && (