@wordpress/block-editor 15.6.1 → 15.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/background-image-control/index.js +2 -2
- package/build/components/background-image-control/index.js.map +2 -2
- package/build/components/block-quick-navigation/index.js +1 -0
- package/build/components/block-quick-navigation/index.js.map +2 -2
- package/build/components/block-toolbar/switch-section-style.js +2 -5
- package/build/components/block-toolbar/switch-section-style.js.map +2 -2
- package/build/components/global-styles/border-panel.js +2 -1
- package/build/components/global-styles/border-panel.js.map +2 -2
- package/build/components/global-styles/color-panel.js +2 -1
- package/build/components/global-styles/color-panel.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +3 -2
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/filters-panel.js +2 -1
- package/build/components/global-styles/filters-panel.js.map +2 -2
- package/build/components/global-styles/hooks.js +0 -179
- package/build/components/global-styles/hooks.js.map +3 -3
- package/build/components/global-styles/index.js +0 -29
- package/build/components/global-styles/index.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +2 -1
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/global-styles/typography-utils.js +2 -49
- package/build/components/global-styles/typography-utils.js.map +2 -2
- package/build/components/global-styles/utils.js +0 -396
- package/build/components/global-styles/utils.js.map +3 -3
- package/build/components/inserter/media-tab/media-tab.js +33 -1
- package/build/components/inserter/media-tab/media-tab.js.map +3 -3
- package/build/components/inserter/tips.js +0 -2
- package/build/components/inserter/tips.js.map +2 -2
- package/build/components/media-placeholder/index.js +31 -1
- package/build/components/media-placeholder/index.js.map +3 -3
- package/build/components/media-replace-flow/index.js +29 -1
- package/build/components/media-replace-flow/index.js.map +3 -3
- package/build/components/{global-styles/context.js → media-upload-modal/index.js} +8 -23
- package/build/components/media-upload-modal/index.js.map +7 -0
- package/build/hooks/allowed-blocks.js +3 -8
- package/build/hooks/allowed-blocks.js.map +3 -3
- package/build/hooks/block-style-variation.js +10 -23
- package/build/hooks/block-style-variation.js.map +2 -2
- package/build/hooks/duotone.js +3 -3
- package/build/hooks/duotone.js.map +2 -2
- package/build/hooks/fit-text.js +2 -2
- package/build/hooks/fit-text.js.map +2 -2
- package/build/hooks/font-size.js +2 -2
- package/build/hooks/font-size.js.map +2 -2
- package/build/hooks/use-typography-props.js +2 -2
- package/build/hooks/use-typography-props.js.map +2 -2
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +3 -3
- package/build-module/components/background-image-control/index.js +1 -1
- package/build-module/components/background-image-control/index.js.map +2 -2
- package/build-module/components/block-quick-navigation/index.js +1 -0
- package/build-module/components/block-quick-navigation/index.js.map +2 -2
- package/build-module/components/block-toolbar/switch-section-style.js +2 -5
- package/build-module/components/block-toolbar/switch-section-style.js.map +2 -2
- package/build-module/components/global-styles/border-panel.js +2 -1
- package/build-module/components/global-styles/border-panel.js.map +2 -2
- package/build-module/components/global-styles/color-panel.js +2 -1
- package/build-module/components/global-styles/color-panel.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +2 -1
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/filters-panel.js +2 -1
- package/build-module/components/global-styles/filters-panel.js.map +2 -2
- package/build-module/components/global-styles/hooks.js +1 -167
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/index.js +1 -29
- package/build-module/components/global-styles/index.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +2 -1
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/global-styles/typography-utils.js +1 -49
- package/build-module/components/global-styles/typography-utils.js.map +2 -2
- package/build-module/components/global-styles/utils.js +0 -372
- package/build-module/components/global-styles/utils.js.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.js +34 -2
- package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
- package/build-module/components/inserter/tips.js +0 -2
- package/build-module/components/inserter/tips.js.map +2 -2
- package/build-module/components/media-placeholder/index.js +31 -1
- package/build-module/components/media-placeholder/index.js.map +2 -2
- package/build-module/components/media-replace-flow/index.js +29 -1
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- package/build-module/components/media-upload-modal/index.js +7 -0
- package/build-module/components/media-upload-modal/index.js.map +7 -0
- package/build-module/hooks/allowed-blocks.js +3 -8
- package/build-module/hooks/allowed-blocks.js.map +2 -2
- package/build-module/hooks/block-style-variation.js +8 -25
- package/build-module/hooks/block-style-variation.js.map +2 -2
- package/build-module/hooks/duotone.js +3 -3
- package/build-module/hooks/duotone.js.map +2 -2
- package/build-module/hooks/fit-text.js +2 -2
- package/build-module/hooks/fit-text.js.map +2 -2
- package/build-module/hooks/font-size.js +1 -1
- package/build-module/hooks/font-size.js.map +2 -2
- package/build-module/hooks/use-typography-props.js +1 -1
- package/build-module/hooks/use-typography-props.js.map +2 -2
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +2 -2
- package/build-style/style-rtl.css +10 -6
- package/build-style/style.css +10 -6
- package/package.json +36 -35
- package/src/components/background-image-control/index.js +1 -1
- package/src/components/block-card/style.scss +1 -1
- package/src/components/block-navigation/style.scss +1 -1
- package/src/components/block-quick-navigation/index.js +1 -0
- package/src/components/block-quick-navigation/style.scss +5 -0
- package/src/components/block-switcher/style.scss +1 -1
- package/src/components/block-toolbar/switch-section-style.js +2 -5
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/global-styles/border-panel.js +2 -1
- package/src/components/global-styles/color-panel.js +2 -1
- package/src/components/global-styles/color-panel.native.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +2 -1
- package/src/components/global-styles/filters-panel.js +2 -1
- package/src/components/global-styles/hooks.js +1 -200
- package/src/components/global-styles/index.js +1 -17
- package/src/components/global-styles/test/typography-utils.js +0 -806
- package/src/components/global-styles/typography-panel.js +2 -1
- package/src/components/global-styles/typography-utils.js +0 -133
- package/src/components/global-styles/utils.js +0 -568
- package/src/components/inserter/media-tab/media-tab.js +44 -2
- package/src/components/inserter/style.scss +2 -2
- package/src/components/inserter/tips.js +0 -2
- package/src/components/media-placeholder/index.js +41 -1
- package/src/components/media-replace-flow/index.js +39 -1
- package/src/components/media-upload-modal/index.js +18 -0
- package/src/components/multi-selection-inspector/style.scss +1 -1
- package/src/hooks/allowed-blocks.js +3 -11
- package/src/hooks/block-style-variation.js +8 -28
- package/src/hooks/duotone.js +3 -3
- package/src/hooks/fit-text.js +2 -2
- package/src/hooks/font-size.js +1 -1
- package/src/hooks/use-typography-props.js +1 -1
- package/src/private-apis.js +2 -0
- package/src/style.scss +1 -0
- package/tsconfig.json +2 -0
- package/build/components/global-styles/context.js.map +0 -7
- package/build/components/global-styles/get-block-css-selector.js +0 -78
- package/build/components/global-styles/get-block-css-selector.js.map +0 -7
- package/build/components/global-styles/get-global-styles-changes.js +0 -216
- package/build/components/global-styles/get-global-styles-changes.js.map +0 -7
- package/build/components/global-styles/use-global-styles-output.js +0 -998
- package/build/components/global-styles/use-global-styles-output.js.map +0 -7
- package/build-module/components/global-styles/context.js +0 -17
- package/build-module/components/global-styles/context.js.map +0 -7
- package/build-module/components/global-styles/get-block-css-selector.js +0 -54
- package/build-module/components/global-styles/get-block-css-selector.js.map +0 -7
- package/build-module/components/global-styles/get-global-styles-changes.js +0 -182
- package/build-module/components/global-styles/get-global-styles-changes.js.map +0 -7
- package/build-module/components/global-styles/use-global-styles-output.js +0 -979
- package/build-module/components/global-styles/use-global-styles-output.js.map +0 -7
- package/src/components/global-styles/README.md +0 -190
- package/src/components/global-styles/context.js +0 -16
- package/src/components/global-styles/get-block-css-selector.js +0 -114
- package/src/components/global-styles/get-global-styles-changes.js +0 -252
- package/src/components/global-styles/test/get-global-styles-changes.js +0 -290
- package/src/components/global-styles/test/use-global-styles-output.js +0 -1131
- package/src/components/global-styles/test/utils.js +0 -499
- package/src/components/global-styles/use-global-styles-output.js +0 -1487
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/global-styles/filters-panel.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalHStack as HStack,\n\t__experimentalZStack as ZStack,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n\tMenuGroup,\n\tColorIndicator,\n\tDuotonePicker,\n\tDuotoneSwatch,\n\tDropdown,\n\tFlex,\n\tFlexItem,\n\tButton,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useCallback, useMemo, useRef } from '@wordpress/element';\nimport { reset as resetIcon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport {
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n\t__experimentalHStack as HStack,\n\t__experimentalZStack as ZStack,\n\t__experimentalDropdownContentWrapper as DropdownContentWrapper,\n\tMenuGroup,\n\tColorIndicator,\n\tDuotonePicker,\n\tDuotoneSwatch,\n\tDropdown,\n\tFlex,\n\tFlexItem,\n\tButton,\n} from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useCallback, useMemo, useRef } from '@wordpress/element';\nimport { reset as resetIcon } from '@wordpress/icons';\nimport { getValueFromVariable } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport { useToolsPanelDropdownMenuProps } from './utils';\nimport { setImmutably } from '../../utils/object';\n\nconst EMPTY_ARRAY = [];\nfunction useMultiOriginColorPresets(\n\tsettings,\n\t{ presetSetting, defaultSetting }\n) {\n\tconst disableDefault = ! settings?.color?.[ defaultSetting ];\n\tconst userPresets =\n\t\tsettings?.color?.[ presetSetting ]?.custom || EMPTY_ARRAY;\n\tconst themePresets =\n\t\tsettings?.color?.[ presetSetting ]?.theme || EMPTY_ARRAY;\n\tconst defaultPresets =\n\t\tsettings?.color?.[ presetSetting ]?.default || EMPTY_ARRAY;\n\treturn useMemo(\n\t\t() => [\n\t\t\t...userPresets,\n\t\t\t...themePresets,\n\t\t\t...( disableDefault ? EMPTY_ARRAY : defaultPresets ),\n\t\t],\n\t\t[ disableDefault, userPresets, themePresets, defaultPresets ]\n\t);\n}\n\nexport function useHasFiltersPanel( settings ) {\n\treturn useHasDuotoneControl( settings );\n}\n\nfunction useHasDuotoneControl( settings ) {\n\treturn (\n\t\tsettings.color.customDuotone ||\n\t\tsettings.color.defaultDuotone ||\n\t\tsettings.color.duotone.length > 0\n\t);\n}\n\nfunction FiltersToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n} ) {\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ _x( 'Filters', 'Name for applying graphical effects' ) }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n\nconst DEFAULT_CONTROLS = {\n\tduotone: true,\n};\n\nconst popoverProps = {\n\tplacement: 'left-start',\n\toffset: 36,\n\tshift: true,\n\tclassName: 'block-editor-duotone-control__popover',\n\theaderTitle: __( 'Duotone' ),\n};\n\nconst LabeledColorIndicator = ( { indicator, label } ) => (\n\t<HStack justify=\"flex-start\">\n\t\t<ZStack isLayered={ false } offset={ -8 }>\n\t\t\t<Flex expanded={ false }>\n\t\t\t\t{ indicator === 'unset' || ! indicator ? (\n\t\t\t\t\t<ColorIndicator className=\"block-editor-duotone-control__unset-indicator\" />\n\t\t\t\t) : (\n\t\t\t\t\t<DuotoneSwatch values={ indicator } />\n\t\t\t\t) }\n\t\t\t</Flex>\n\t\t</ZStack>\n\t\t<FlexItem title={ label }>{ label }</FlexItem>\n\t</HStack>\n);\n\nconst renderToggle =\n\t( duotone, resetDuotone ) =>\n\t( { onToggle, isOpen } ) => {\n\t\tconst duotoneButtonRef = useRef( undefined );\n\n\t\tconst toggleProps = {\n\t\t\tonClick: onToggle,\n\t\t\tclassName: clsx(\n\t\t\t\t'block-editor-global-styles-filters-panel__dropdown-toggle',\n\t\t\t\t{ 'is-open': isOpen }\n\t\t\t),\n\t\t\t'aria-expanded': isOpen,\n\t\t\tref: duotoneButtonRef,\n\t\t};\n\n\t\tconst removeButtonProps = {\n\t\t\tonClick: () => {\n\t\t\t\tif ( isOpen ) {\n\t\t\t\t\tonToggle();\n\t\t\t\t}\n\t\t\t\tresetDuotone();\n\t\t\t\t// Return focus to parent button.\n\t\t\t\tduotoneButtonRef.current?.focus();\n\t\t\t},\n\t\t\tclassName: 'block-editor-panel-duotone-settings__reset',\n\t\t\tlabel: __( 'Reset' ),\n\t\t};\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<Button __next40pxDefaultSize { ...toggleProps }>\n\t\t\t\t\t<LabeledColorIndicator\n\t\t\t\t\t\tindicator={ duotone }\n\t\t\t\t\t\tlabel={ __( 'Duotone' ) }\n\t\t\t\t\t/>\n\t\t\t\t</Button>\n\t\t\t\t{ duotone && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\ticon={ resetIcon }\n\t\t\t\t\t\t{ ...removeButtonProps }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t};\n\nexport default function FiltersPanel( {\n\tas: Wrapper = FiltersToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\tsettings,\n\tpanelId,\n\tdefaultControls = DEFAULT_CONTROLS,\n} ) {\n\tconst decodeValue = ( rawValue ) =>\n\t\tgetValueFromVariable( { settings }, '', rawValue );\n\n\t// Duotone\n\tconst hasDuotoneEnabled = useHasDuotoneControl( settings );\n\tconst duotonePalette = useMultiOriginColorPresets( settings, {\n\t\tpresetSetting: 'duotone',\n\t\tdefaultSetting: 'defaultDuotone',\n\t} );\n\tconst colorPalette = useMultiOriginColorPresets( settings, {\n\t\tpresetSetting: 'palette',\n\t\tdefaultSetting: 'defaultPalette',\n\t} );\n\tconst duotone = decodeValue( inheritedValue?.filter?.duotone );\n\tconst setDuotone = ( newValue ) => {\n\t\tconst duotonePreset = duotonePalette.find( ( { colors } ) => {\n\t\t\treturn colors === newValue;\n\t\t} );\n\t\tconst duotoneValue = duotonePreset\n\t\t\t? `var:preset|duotone|${ duotonePreset.slug }`\n\t\t\t: newValue;\n\t\tonChange(\n\t\t\tsetImmutably( value, [ 'filter', 'duotone' ], duotoneValue )\n\t\t);\n\t};\n\tconst hasDuotone = () => !! value?.filter?.duotone;\n\tconst resetDuotone = () => setDuotone( undefined );\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\tfilter: {\n\t\t\t\t...previousValue.filter,\n\t\t\t\tduotone: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t{ hasDuotoneEnabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Duotone' ) }\n\t\t\t\t\thasValue={ hasDuotone }\n\t\t\t\t\tonDeselect={ resetDuotone }\n\t\t\t\t\tisShownByDefault={ defaultControls.duotone }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<Dropdown\n\t\t\t\t\t\tpopoverProps={ popoverProps }\n\t\t\t\t\t\tclassName=\"block-editor-global-styles-filters-panel__dropdown\"\n\t\t\t\t\t\trenderToggle={ renderToggle( duotone, resetDuotone ) }\n\t\t\t\t\t\trenderContent={ () => (\n\t\t\t\t\t\t\t<DropdownContentWrapper paddingSize=\"small\">\n\t\t\t\t\t\t\t\t<MenuGroup label={ __( 'Duotone' ) }>\n\t\t\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'Create a two-tone color effect without losing your original image.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t<DuotonePicker\n\t\t\t\t\t\t\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\t\t\t\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\t\t\t\t\t\t\t// TODO: Re-enable both when custom colors are supported for block-level styles.\n\t\t\t\t\t\t\t\t\t\tdisableCustomColors\n\t\t\t\t\t\t\t\t\t\tdisableCustomDuotone\n\t\t\t\t\t\t\t\t\t\tvalue={ duotone }\n\t\t\t\t\t\t\t\t\t\tonChange={ setDuotone }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t</DropdownContentWrapper>\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</Wrapper>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAkFE,SAmEC,UAnED,KAwBD,YAxBC;AA/EF,OAAO,UAAU;AAKjB;AAAA,EACC,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,EAChC,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,wCAAwC;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,IAAI,UAAU;AACvB,SAAS,aAAa,SAA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A;AAAA,oBACA;AAAA,oBAEA,qBAAmB;AAAA,oBACnB,sBAAoB;AAAA,oBACpB,OAAQ;AAAA,oBACR,UAAW;AAAA;AAAA,gBACZ;AAAA,iBACD,GACD;AAAA;AAAA,UAEF;AAAA;AAAA,MACD;AAAA;AAAA,EAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,171 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useContext, useCallback, useMemo } from "@wordpress/element";
|
|
1
|
+
import { useMemo } from "@wordpress/element";
|
|
3
2
|
import { useSelect } from "@wordpress/data";
|
|
4
3
|
import { store as blocksStore } from "@wordpress/blocks";
|
|
5
4
|
import { _x } from "@wordpress/i18n";
|
|
6
|
-
import { getValueFromVariable, getPresetVariableFromValue } from "./utils";
|
|
7
|
-
import { getValueFromObjectPath, setImmutably } from "../../utils/object";
|
|
8
|
-
import { GlobalStylesContext } from "./context";
|
|
9
5
|
import { unlock } from "../../lock-unlock";
|
|
10
|
-
const EMPTY_CONFIG = { settings: {}, styles: {} };
|
|
11
|
-
const VALID_SETTINGS = [
|
|
12
|
-
"appearanceTools",
|
|
13
|
-
"useRootPaddingAwareAlignments",
|
|
14
|
-
"background.backgroundImage",
|
|
15
|
-
"background.backgroundRepeat",
|
|
16
|
-
"background.backgroundSize",
|
|
17
|
-
"background.backgroundPosition",
|
|
18
|
-
"border.color",
|
|
19
|
-
"border.radius",
|
|
20
|
-
"border.style",
|
|
21
|
-
"border.width",
|
|
22
|
-
"border.radiusSizes",
|
|
23
|
-
"shadow.presets",
|
|
24
|
-
"shadow.defaultPresets",
|
|
25
|
-
"color.background",
|
|
26
|
-
"color.button",
|
|
27
|
-
"color.caption",
|
|
28
|
-
"color.custom",
|
|
29
|
-
"color.customDuotone",
|
|
30
|
-
"color.customGradient",
|
|
31
|
-
"color.defaultDuotone",
|
|
32
|
-
"color.defaultGradients",
|
|
33
|
-
"color.defaultPalette",
|
|
34
|
-
"color.duotone",
|
|
35
|
-
"color.gradients",
|
|
36
|
-
"color.heading",
|
|
37
|
-
"color.link",
|
|
38
|
-
"color.palette",
|
|
39
|
-
"color.text",
|
|
40
|
-
"custom",
|
|
41
|
-
"dimensions.aspectRatio",
|
|
42
|
-
"dimensions.minHeight",
|
|
43
|
-
"layout.contentSize",
|
|
44
|
-
"layout.definitions",
|
|
45
|
-
"layout.wideSize",
|
|
46
|
-
"lightbox.enabled",
|
|
47
|
-
"lightbox.allowEditing",
|
|
48
|
-
"position.fixed",
|
|
49
|
-
"position.sticky",
|
|
50
|
-
"spacing.customSpacingSize",
|
|
51
|
-
"spacing.defaultSpacingSizes",
|
|
52
|
-
"spacing.spacingSizes",
|
|
53
|
-
"spacing.spacingScale",
|
|
54
|
-
"spacing.blockGap",
|
|
55
|
-
"spacing.margin",
|
|
56
|
-
"spacing.padding",
|
|
57
|
-
"spacing.units",
|
|
58
|
-
"typography.fluid",
|
|
59
|
-
"typography.customFontSize",
|
|
60
|
-
"typography.defaultFontSizes",
|
|
61
|
-
"typography.dropCap",
|
|
62
|
-
"typography.fontFamilies",
|
|
63
|
-
"typography.fontSizes",
|
|
64
|
-
"typography.fontStyle",
|
|
65
|
-
"typography.fontWeight",
|
|
66
|
-
"typography.letterSpacing",
|
|
67
|
-
"typography.lineHeight",
|
|
68
|
-
"typography.textAlign",
|
|
69
|
-
"typography.textColumns",
|
|
70
|
-
"typography.textDecoration",
|
|
71
|
-
"typography.textTransform",
|
|
72
|
-
"typography.writingMode"
|
|
73
|
-
];
|
|
74
|
-
const useGlobalStylesReset = () => {
|
|
75
|
-
const { user, setUserConfig } = useContext(GlobalStylesContext);
|
|
76
|
-
const config = {
|
|
77
|
-
settings: user.settings,
|
|
78
|
-
styles: user.styles
|
|
79
|
-
};
|
|
80
|
-
const canReset = !!config && !fastDeepEqual(config, EMPTY_CONFIG);
|
|
81
|
-
return [
|
|
82
|
-
canReset,
|
|
83
|
-
useCallback(() => setUserConfig(EMPTY_CONFIG), [setUserConfig])
|
|
84
|
-
];
|
|
85
|
-
};
|
|
86
|
-
function useGlobalSetting(propertyPath, blockName, source = "all") {
|
|
87
|
-
const { setUserConfig, ...configs } = useContext(GlobalStylesContext);
|
|
88
|
-
const appendedBlockPath = blockName ? ".blocks." + blockName : "";
|
|
89
|
-
const appendedPropertyPath = propertyPath ? "." + propertyPath : "";
|
|
90
|
-
const contextualPath = `settings${appendedBlockPath}${appendedPropertyPath}`;
|
|
91
|
-
const globalPath = `settings${appendedPropertyPath}`;
|
|
92
|
-
const sourceKey = source === "all" ? "merged" : source;
|
|
93
|
-
const settingValue = useMemo(() => {
|
|
94
|
-
const configToUse = configs[sourceKey];
|
|
95
|
-
if (!configToUse) {
|
|
96
|
-
throw "Unsupported source";
|
|
97
|
-
}
|
|
98
|
-
if (propertyPath) {
|
|
99
|
-
return getValueFromObjectPath(configToUse, contextualPath) ?? getValueFromObjectPath(configToUse, globalPath);
|
|
100
|
-
}
|
|
101
|
-
let result = {};
|
|
102
|
-
VALID_SETTINGS.forEach((setting) => {
|
|
103
|
-
const value = getValueFromObjectPath(
|
|
104
|
-
configToUse,
|
|
105
|
-
`settings${appendedBlockPath}.${setting}`
|
|
106
|
-
) ?? getValueFromObjectPath(configToUse, `settings.${setting}`);
|
|
107
|
-
if (value !== void 0) {
|
|
108
|
-
result = setImmutably(result, setting.split("."), value);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
return result;
|
|
112
|
-
}, [
|
|
113
|
-
configs,
|
|
114
|
-
sourceKey,
|
|
115
|
-
propertyPath,
|
|
116
|
-
contextualPath,
|
|
117
|
-
globalPath,
|
|
118
|
-
appendedBlockPath
|
|
119
|
-
]);
|
|
120
|
-
const setSetting = (newValue) => {
|
|
121
|
-
setUserConfig(
|
|
122
|
-
(currentConfig) => setImmutably(currentConfig, contextualPath.split("."), newValue)
|
|
123
|
-
);
|
|
124
|
-
};
|
|
125
|
-
return [settingValue, setSetting];
|
|
126
|
-
}
|
|
127
|
-
function useGlobalStyle(path, blockName, source = "all", { shouldDecodeEncode = true } = {}) {
|
|
128
|
-
const {
|
|
129
|
-
merged: mergedConfig,
|
|
130
|
-
base: baseConfig,
|
|
131
|
-
user: userConfig,
|
|
132
|
-
setUserConfig
|
|
133
|
-
} = useContext(GlobalStylesContext);
|
|
134
|
-
const appendedPath = path ? "." + path : "";
|
|
135
|
-
const finalPath = !blockName ? `styles${appendedPath}` : `styles.blocks.${blockName}${appendedPath}`;
|
|
136
|
-
const setStyle = (newValue) => {
|
|
137
|
-
setUserConfig(
|
|
138
|
-
(currentConfig) => setImmutably(
|
|
139
|
-
currentConfig,
|
|
140
|
-
finalPath.split("."),
|
|
141
|
-
shouldDecodeEncode ? getPresetVariableFromValue(
|
|
142
|
-
mergedConfig.settings,
|
|
143
|
-
blockName,
|
|
144
|
-
path,
|
|
145
|
-
newValue
|
|
146
|
-
) : newValue
|
|
147
|
-
)
|
|
148
|
-
);
|
|
149
|
-
};
|
|
150
|
-
let rawResult, result;
|
|
151
|
-
switch (source) {
|
|
152
|
-
case "all":
|
|
153
|
-
rawResult = getValueFromObjectPath(mergedConfig, finalPath);
|
|
154
|
-
result = shouldDecodeEncode ? getValueFromVariable(mergedConfig, blockName, rawResult) : rawResult;
|
|
155
|
-
break;
|
|
156
|
-
case "user":
|
|
157
|
-
rawResult = getValueFromObjectPath(userConfig, finalPath);
|
|
158
|
-
result = shouldDecodeEncode ? getValueFromVariable(mergedConfig, blockName, rawResult) : rawResult;
|
|
159
|
-
break;
|
|
160
|
-
case "base":
|
|
161
|
-
rawResult = getValueFromObjectPath(baseConfig, finalPath);
|
|
162
|
-
result = shouldDecodeEncode ? getValueFromVariable(baseConfig, blockName, rawResult) : rawResult;
|
|
163
|
-
break;
|
|
164
|
-
default:
|
|
165
|
-
throw "Unsupported source";
|
|
166
|
-
}
|
|
167
|
-
return [result, setStyle];
|
|
168
|
-
}
|
|
169
6
|
function useSettingsForBlockElement(parentSettings, blockName, element) {
|
|
170
7
|
const { supportedStyles, supports } = useSelect(
|
|
171
8
|
(select) => {
|
|
@@ -379,9 +216,6 @@ function useGradientsPerOrigin(settings) {
|
|
|
379
216
|
}
|
|
380
217
|
export {
|
|
381
218
|
useColorsPerOrigin,
|
|
382
|
-
useGlobalSetting,
|
|
383
|
-
useGlobalStyle,
|
|
384
|
-
useGlobalStylesReset,
|
|
385
219
|
useGradientsPerOrigin,
|
|
386
220
|
useSettingsForBlockElement
|
|
387
221
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/global-styles/hooks.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useContext, useCallback, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getValueFromVariable, getPresetVariableFromValue } from './utils';\nimport { getValueFromObjectPath, setImmutably } from '../../utils/object';\nimport { GlobalStylesContext } from './context';\nimport { unlock } from '../../lock-unlock';\n\nconst EMPTY_CONFIG = { settings: {}, styles: {} };\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'background.backgroundImage',\n\t'background.backgroundRepeat',\n\t'background.backgroundSize',\n\t'background.backgroundPosition',\n\t'border.color',\n\t'border.radius',\n\t'border.style',\n\t'border.width',\n\t'border.radiusSizes',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.aspectRatio',\n\t'dimensions.minHeight',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'lightbox.enabled',\n\t'lightbox.allowEditing',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.defaultSpacingSizes',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.defaultFontSizes',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textAlign',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textTransform',\n\t'typography.writingMode',\n];\n\nexport const useGlobalStylesReset = () => {\n\tconst { user, setUserConfig } = useContext( GlobalStylesContext );\n\tconst config = {\n\t\tsettings: user.settings,\n\t\tstyles: user.styles,\n\t};\n\tconst canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );\n\treturn [\n\t\tcanReset,\n\t\tuseCallback( () => setUserConfig( EMPTY_CONFIG ), [ setUserConfig ] ),\n\t];\n};\n\nexport function useGlobalSetting( propertyPath, blockName, source = 'all' ) {\n\tconst { setUserConfig, ...configs } = useContext( GlobalStylesContext );\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = propertyPath ? '.' + propertyPath : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\tconst sourceKey = source === 'all' ? 'merged' : source;\n\n\tconst settingValue = useMemo( () => {\n\t\tconst configToUse = configs[ sourceKey ];\n\t\tif ( ! configToUse ) {\n\t\t\tthrow 'Unsupported source';\n\t\t}\n\n\t\tif ( propertyPath ) {\n\t\t\treturn (\n\t\t\t\tgetValueFromObjectPath( configToUse, contextualPath ) ??\n\t\t\t\tgetValueFromObjectPath( configToUse, globalPath )\n\t\t\t);\n\t\t}\n\n\t\tlet result = {};\n\t\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\t\tconst value =\n\t\t\t\tgetValueFromObjectPath(\n\t\t\t\t\tconfigToUse,\n\t\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t\t) ??\n\t\t\t\tgetValueFromObjectPath( configToUse, `settings.${ setting }` );\n\t\t\tif ( value !== undefined ) {\n\t\t\t\tresult = setImmutably( result, setting.split( '.' ), value );\n\t\t\t}\n\t\t} );\n\t\treturn result;\n\t}, [\n\t\tconfigs,\n\t\tsourceKey,\n\t\tpropertyPath,\n\t\tcontextualPath,\n\t\tglobalPath,\n\t\tappendedBlockPath,\n\t] );\n\n\tconst setSetting = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) =>\n\t\t\tsetImmutably( currentConfig, contextualPath.split( '.' ), newValue )\n\t\t);\n\t};\n\treturn [ settingValue, setSetting ];\n}\n\nexport function useGlobalStyle(\n\tpath,\n\tblockName,\n\tsource = 'all',\n\t{ shouldDecodeEncode = true } = {}\n) {\n\tconst {\n\t\tmerged: mergedConfig,\n\t\tbase: baseConfig,\n\t\tuser: userConfig,\n\t\tsetUserConfig,\n\t} = useContext( GlobalStylesContext );\n\tconst appendedPath = path ? '.' + path : '';\n\tconst finalPath = ! blockName\n\t\t? `styles${ appendedPath }`\n\t\t: `styles.blocks.${ blockName }${ appendedPath }`;\n\n\tconst setStyle = ( newValue ) => {\n\t\tsetUserConfig( ( currentConfig ) =>\n\t\t\tsetImmutably(\n\t\t\t\tcurrentConfig,\n\t\t\t\tfinalPath.split( '.' ),\n\t\t\t\tshouldDecodeEncode\n\t\t\t\t\t? getPresetVariableFromValue(\n\t\t\t\t\t\t\tmergedConfig.settings,\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tpath,\n\t\t\t\t\t\t\tnewValue\n\t\t\t\t\t )\n\t\t\t\t\t: newValue\n\t\t\t)\n\t\t);\n\t};\n\n\tlet rawResult, result;\n\tswitch ( source ) {\n\t\tcase 'all':\n\t\t\trawResult = getValueFromObjectPath( mergedConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'user':\n\t\t\trawResult = getValueFromObjectPath( userConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( mergedConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tcase 'base':\n\t\t\trawResult = getValueFromObjectPath( baseConfig, finalPath );\n\t\t\tresult = shouldDecodeEncode\n\t\t\t\t? getValueFromVariable( baseConfig, blockName, rawResult )\n\t\t\t\t: rawResult;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthrow 'Unsupported source';\n\t}\n\n\treturn [ result, setStyle ];\n}\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t\tdefaultFontSizes: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\tupdatedSettings.color = {\n\t\t\t...updatedSettings.color,\n\t\t\ttext:\n\t\t\t\tupdatedSettings.color?.text &&\n\t\t\t\tsupportedStyles.includes( 'color' ),\n\t\t\tbackground:\n\t\t\t\tupdatedSettings.color?.background &&\n\t\t\t\t( supportedStyles.includes( 'background' ) ||\n\t\t\t\t\tsupportedStyles.includes( 'backgroundColor' ) ),\n\t\t\tbutton:\n\t\t\t\tupdatedSettings.color?.button &&\n\t\t\t\tsupportedStyles.includes( 'buttonColor' ),\n\t\t\theading:\n\t\t\t\tupdatedSettings.color?.heading &&\n\t\t\t\tsupportedStyles.includes( 'headingColor' ),\n\t\t\tlink:\n\t\t\t\tupdatedSettings.color?.link &&\n\t\t\t\tsupportedStyles.includes( 'linkColor' ),\n\t\t\tcaption:\n\t\t\t\tupdatedSettings.color?.caption &&\n\t\t\t\tsupportedStyles.includes( 'captionColor' ),\n\t\t};\n\n\t\t// Some blocks can enable background colors but disable gradients.\n\t\tif ( ! supportedStyles.includes( 'background' ) ) {\n\t\t\tupdatedSettings.color.gradients = [];\n\t\t\tupdatedSettings.color.customGradient = false;\n\t\t}\n\n\t\t// If filters are not supported by the block/element, disable duotone.\n\t\tif ( ! supportedStyles.includes( 'filter' ) ) {\n\t\t\tupdatedSettings.color.defaultDuotone = false;\n\t\t\tupdatedSettings.color.customDuotone = false;\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textAlign',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t\t'writingMode',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\t// Check if spacing type is supported before adding sides.\n\t\t\tif ( sides?.length && updatedSettings.spacing?.[ key ] ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'aspectRatio', 'minHeight' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'backgroundImage', 'backgroundSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.background = {\n\t\t\t\t\t...updatedSettings.background,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tupdatedSettings.shadow = supportedStyles.includes( 'shadow' )\n\t\t\t? updatedSettings.shadow\n\t\t\t: false;\n\n\t\t// Text alignment is only available for blocks.\n\t\tif ( element ) {\n\t\t\tupdatedSettings.typography.textAlign = false;\n\t\t}\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports, element ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n\nexport function useGradientsPerOrigin( settings ) {\n\tconst customGradients = settings?.color?.gradients?.custom;\n\tconst themeGradients = settings?.color?.gradients?.theme;\n\tconst defaultGradients = settings?.color?.gradients?.default;\n\tconst shouldDisplayDefaultGradients = settings?.color?.defaultGradients;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n}\n"],
|
|
5
|
-
"mappings": "AAGA,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\n/**\n * React hook that overrides a global settings object with block and element specific settings.\n *\n * @param {Object} parentSettings Settings object.\n * @param {blockName?} blockName Block name.\n * @param {element?} element Element name.\n *\n * @return {Object} Merge of settings and supports.\n */\nexport function useSettingsForBlockElement(\n\tparentSettings,\n\tblockName,\n\telement\n) {\n\tconst { supportedStyles, supports } = useSelect(\n\t\t( select ) => {\n\t\t\treturn {\n\t\t\t\tsupportedStyles: unlock(\n\t\t\t\t\tselect( blocksStore )\n\t\t\t\t).getSupportedStyles( blockName, element ),\n\t\t\t\tsupports:\n\t\t\t\t\tselect( blocksStore ).getBlockType( blockName )?.supports,\n\t\t\t};\n\t\t},\n\t\t[ blockName, element ]\n\t);\n\n\treturn useMemo( () => {\n\t\tconst updatedSettings = { ...parentSettings };\n\n\t\tif ( ! supportedStyles.includes( 'fontSize' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontSizes: {},\n\t\t\t\tcustomFontSize: false,\n\t\t\t\tdefaultFontSizes: false,\n\t\t\t};\n\t\t}\n\n\t\tif ( ! supportedStyles.includes( 'fontFamily' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\tfontFamilies: {},\n\t\t\t};\n\t\t}\n\n\t\tupdatedSettings.color = {\n\t\t\t...updatedSettings.color,\n\t\t\ttext:\n\t\t\t\tupdatedSettings.color?.text &&\n\t\t\t\tsupportedStyles.includes( 'color' ),\n\t\t\tbackground:\n\t\t\t\tupdatedSettings.color?.background &&\n\t\t\t\t( supportedStyles.includes( 'background' ) ||\n\t\t\t\t\tsupportedStyles.includes( 'backgroundColor' ) ),\n\t\t\tbutton:\n\t\t\t\tupdatedSettings.color?.button &&\n\t\t\t\tsupportedStyles.includes( 'buttonColor' ),\n\t\t\theading:\n\t\t\t\tupdatedSettings.color?.heading &&\n\t\t\t\tsupportedStyles.includes( 'headingColor' ),\n\t\t\tlink:\n\t\t\t\tupdatedSettings.color?.link &&\n\t\t\t\tsupportedStyles.includes( 'linkColor' ),\n\t\t\tcaption:\n\t\t\t\tupdatedSettings.color?.caption &&\n\t\t\t\tsupportedStyles.includes( 'captionColor' ),\n\t\t};\n\n\t\t// Some blocks can enable background colors but disable gradients.\n\t\tif ( ! supportedStyles.includes( 'background' ) ) {\n\t\t\tupdatedSettings.color.gradients = [];\n\t\t\tupdatedSettings.color.customGradient = false;\n\t\t}\n\n\t\t// If filters are not supported by the block/element, disable duotone.\n\t\tif ( ! supportedStyles.includes( 'filter' ) ) {\n\t\t\tupdatedSettings.color.defaultDuotone = false;\n\t\t\tupdatedSettings.color.customDuotone = false;\n\t\t}\n\n\t\t[\n\t\t\t'lineHeight',\n\t\t\t'fontStyle',\n\t\t\t'fontWeight',\n\t\t\t'letterSpacing',\n\t\t\t'textAlign',\n\t\t\t'textTransform',\n\t\t\t'textDecoration',\n\t\t\t'writingMode',\n\t\t].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.typography = {\n\t\t\t\t\t...updatedSettings.typography,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t// The column-count style is named text column to reduce confusion with\n\t\t// the columns block and manage expectations from the support.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/33587\n\t\tif ( ! supportedStyles.includes( 'columnCount' ) ) {\n\t\t\tupdatedSettings.typography = {\n\t\t\t\t...updatedSettings.typography,\n\t\t\t\ttextColumns: false,\n\t\t\t};\n\t\t}\n\n\t\t[ 'contentSize', 'wideSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.layout = {\n\t\t\t\t\t...updatedSettings.layout,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'padding', 'margin', 'blockGap' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst sides = Array.isArray( supports?.spacing?.[ key ] )\n\t\t\t\t? supports?.spacing?.[ key ]\n\t\t\t\t: supports?.spacing?.[ key ]?.sides;\n\t\t\t// Check if spacing type is supported before adding sides.\n\t\t\tif ( sides?.length && updatedSettings.spacing?.[ key ] ) {\n\t\t\t\tupdatedSettings.spacing = {\n\t\t\t\t\t...updatedSettings.spacing,\n\t\t\t\t\t[ key ]: {\n\t\t\t\t\t\t...updatedSettings.spacing?.[ key ],\n\t\t\t\t\t\tsides,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'aspectRatio', 'minHeight' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.dimensions = {\n\t\t\t\t\t...updatedSettings.dimensions,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'radius', 'color', 'style', 'width' ].forEach( ( key ) => {\n\t\t\tif (\n\t\t\t\t! supportedStyles.includes(\n\t\t\t\t\t'border' + key.charAt( 0 ).toUpperCase() + key.slice( 1 )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tupdatedSettings.border = {\n\t\t\t\t\t...updatedSettings.border,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\t[ 'backgroundImage', 'backgroundSize' ].forEach( ( key ) => {\n\t\t\tif ( ! supportedStyles.includes( key ) ) {\n\t\t\t\tupdatedSettings.background = {\n\t\t\t\t\t...updatedSettings.background,\n\t\t\t\t\t[ key ]: false,\n\t\t\t\t};\n\t\t\t}\n\t\t} );\n\n\t\tupdatedSettings.shadow = supportedStyles.includes( 'shadow' )\n\t\t\t? updatedSettings.shadow\n\t\t\t: false;\n\n\t\t// Text alignment is only available for blocks.\n\t\tif ( element ) {\n\t\t\tupdatedSettings.typography.textAlign = false;\n\t\t}\n\n\t\treturn updatedSettings;\n\t}, [ parentSettings, supportedStyles, supports, element ] );\n}\n\nexport function useColorsPerOrigin( settings ) {\n\tconst customColors = settings?.color?.palette?.custom;\n\tconst themeColors = settings?.color?.palette?.theme;\n\tconst defaultColors = settings?.color?.palette?.default;\n\tconst shouldDisplayDefaultColors = settings?.color?.defaultPalette;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeColors && themeColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tcolors: themeColors,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultColors &&\n\t\t\tdefaultColors &&\n\t\t\tdefaultColors.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tcolors: defaultColors,\n\t\t\t} );\n\t\t}\n\t\tif ( customColors && customColors.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tcolors: customColors,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomColors,\n\t\tthemeColors,\n\t\tdefaultColors,\n\t\tshouldDisplayDefaultColors,\n\t] );\n}\n\nexport function useGradientsPerOrigin( settings ) {\n\tconst customGradients = settings?.color?.gradients?.custom;\n\tconst themeGradients = settings?.color?.gradients?.theme;\n\tconst defaultGradients = settings?.color?.gradients?.default;\n\tconst shouldDisplayDefaultGradients = settings?.color?.defaultGradients;\n\n\treturn useMemo( () => {\n\t\tconst result = [];\n\t\tif ( themeGradients && themeGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Theme',\n\t\t\t\t\t'Indicates this palette comes from the theme.'\n\t\t\t\t),\n\t\t\t\tgradients: themeGradients,\n\t\t\t} );\n\t\t}\n\t\tif (\n\t\t\tshouldDisplayDefaultGradients &&\n\t\t\tdefaultGradients &&\n\t\t\tdefaultGradients.length\n\t\t) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Default',\n\t\t\t\t\t'Indicates this palette comes from WordPress.'\n\t\t\t\t),\n\t\t\t\tgradients: defaultGradients,\n\t\t\t} );\n\t\t}\n\t\tif ( customGradients && customGradients.length ) {\n\t\t\tresult.push( {\n\t\t\t\tname: _x(\n\t\t\t\t\t'Custom',\n\t\t\t\t\t'Indicates this palette is created by the user.'\n\t\t\t\t),\n\t\t\t\tgradients: customGradients,\n\t\t\t} );\n\t\t}\n\t\treturn result;\n\t}, [\n\t\tcustomGradients,\n\t\tthemeGradients,\n\t\tdefaultGradients,\n\t\tshouldDisplayDefaultGradients,\n\t] );\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,mBAAmB;AACrC,SAAS,UAAU;AAKnB,SAAS,cAAc;AAWhB,SAAS,2BACf,gBACA,WACA,SACC;AACD,QAAM,EAAE,iBAAiB,SAAS,IAAI;AAAA,IACrC,CAAE,WAAY;AACb,aAAO;AAAA,QACN,iBAAiB;AAAA,UAChB,OAAQ,WAAY;AAAA,QACrB,EAAE,mBAAoB,WAAW,OAAQ;AAAA,QACzC,UACC,OAA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ACD;AAAA,QACA,QAAQ;AAAA,MACT,CAAE;AAAA,IACH;AACA,QAAK,gBAAgB,aAAa,QAAS;AAC1C,aAAO,KAAM;AAAA,QACZ,MAAM;AAAA,UACL;AAAA,UACA;AAAA,QACD;AAAA,QACA,QAAQ;AAAA,MACT,CAAE;AAAA,IACH;AACA,WAAO;AAAA,EACR,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;AAEO,SAAS,sBAAuB,UAAW;AACjD,QAAM,kBAAkB,UAAU,OAAO,WAAW;AACpD,QAAM,iBAAiB,UAAU,OAAO,WAAW;AACnD,QAAM,mBAAmB,UAAU,OAAO,WAAW;AACrD,QAAM,gCAAgC,UAAU,OAAO;AAEvD,SAAO,QAAS,MAAM;AACrB,UAAM,SAAS,CAAC;AAChB,QAAK,kBAAkB,eAAe,QAAS;AAC9C,aAAO,KAAM;AAAA,QACZ,MAAM;AAAA,UACL;AAAA,UACA;AAAA,QACD;AAAA,QACA,WAAW;AAAA,MACZ,CAAE;AAAA,IACH;AACA,QACC,iCACA,oBACA,iBAAiB,QAChB;AACD,aAAO,KAAM;AAAA,QACZ,MAAM;AAAA,UACL;AAAA,UACA;AAAA,QACD;AAAA,QACA,WAAW;AAAA,MACZ,CAAE;AAAA,IACH;AACA,QAAK,mBAAmB,gBAAgB,QAAS;AAChD,aAAO,KAAM;AAAA,QACZ,MAAM;AAAA,UACL;AAAA,UACA;AAAA,QACD;AAAA,QACA,WAAW;AAAA,MACZ,CAAE;AAAA,IACH;AACA,WAAO;AAAA,EACR,GAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useGlobalStylesReset,
|
|
3
|
-
useGlobalSetting,
|
|
4
|
-
useGlobalStyle,
|
|
5
|
-
useSettingsForBlockElement
|
|
6
|
-
} from "./hooks";
|
|
7
|
-
import { getBlockCSSSelector } from "./get-block-css-selector";
|
|
8
|
-
import {
|
|
9
|
-
getLayoutStyles,
|
|
10
|
-
getBlockSelectors,
|
|
11
|
-
toStyles,
|
|
12
|
-
useGlobalStylesOutput,
|
|
13
|
-
useGlobalStylesOutputWithConfig
|
|
14
|
-
} from "./use-global-styles-output";
|
|
15
|
-
import { GlobalStylesContext } from "./context";
|
|
1
|
+
import { useSettingsForBlockElement } from "./hooks";
|
|
16
2
|
import {
|
|
17
3
|
default as default2,
|
|
18
4
|
useHasTypographyPanel
|
|
@@ -37,8 +23,6 @@ import {
|
|
|
37
23
|
default as default9,
|
|
38
24
|
useHasBackgroundPanel
|
|
39
25
|
} from "./background-panel";
|
|
40
|
-
import { areGlobalStyleConfigsEqual } from "./utils";
|
|
41
|
-
import { default as default10 } from "./get-global-styles-changes";
|
|
42
26
|
export {
|
|
43
27
|
default8 as AdvancedPanel,
|
|
44
28
|
default9 as BackgroundPanel,
|
|
@@ -46,20 +30,8 @@ export {
|
|
|
46
30
|
default5 as ColorPanel,
|
|
47
31
|
default3 as DimensionsPanel,
|
|
48
32
|
default6 as FiltersPanel,
|
|
49
|
-
GlobalStylesContext,
|
|
50
33
|
default7 as ImageSettingsPanel,
|
|
51
34
|
default2 as TypographyPanel,
|
|
52
|
-
areGlobalStyleConfigsEqual,
|
|
53
|
-
getBlockCSSSelector,
|
|
54
|
-
getBlockSelectors,
|
|
55
|
-
default10 as getGlobalStylesChanges,
|
|
56
|
-
getLayoutStyles,
|
|
57
|
-
toStyles,
|
|
58
|
-
useGlobalSetting,
|
|
59
|
-
useGlobalStyle,
|
|
60
|
-
useGlobalStylesOutput,
|
|
61
|
-
useGlobalStylesOutputWithConfig,
|
|
62
|
-
useGlobalStylesReset,
|
|
63
35
|
useHasBackgroundPanel,
|
|
64
36
|
useHasBorderPanel,
|
|
65
37
|
useHasBorderPanelControls,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/global-styles/index.js"],
|
|
4
|
-
"sourcesContent": ["export {
|
|
5
|
-
"mappings": "AAAA
|
|
4
|
+
"sourcesContent": ["export { useSettingsForBlockElement } from './hooks';\nexport {\n\tdefault as TypographyPanel,\n\tuseHasTypographyPanel,\n} from './typography-panel';\nexport {\n\tdefault as DimensionsPanel,\n\tuseHasDimensionsPanel,\n} from './dimensions-panel';\nexport {\n\tdefault as BorderPanel,\n\tuseHasBorderPanel,\n\tuseHasBorderPanelControls,\n} from './border-panel';\nexport { default as ColorPanel, useHasColorPanel } from './color-panel';\nexport { default as FiltersPanel, useHasFiltersPanel } from './filters-panel';\nexport {\n\tdefault as ImageSettingsPanel,\n\tuseHasImageSettingsPanel,\n} from './image-settings-panel';\nexport { default as AdvancedPanel } from './advanced-panel';\nexport {\n\tdefault as BackgroundPanel,\n\tuseHasBackgroundPanel,\n} from './background-panel';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,kCAAkC;AAC3C;AAAA,EACY,WAAXA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACY,WAAXA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACY,WAAXA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAoB,WAAXA,UAAuB,wBAAwB;AACxD,SAAoB,WAAXA,UAAyB,0BAA0B;AAC5D;AAAA,EACY,WAAXA;AAAA,EACA;AAAA,OACM;AACP,SAAoB,WAAXA,gBAAgC;AACzC;AAAA,EACY,WAAXA;AAAA,EACA;AAAA,OACM;",
|
|
6
6
|
"names": ["default"]
|
|
7
7
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from "@wordpress/components";
|
|
8
8
|
import { __ } from "@wordpress/i18n";
|
|
9
9
|
import { useCallback, useMemo, useEffect } from "@wordpress/element";
|
|
10
|
+
import { getValueFromVariable } from "@wordpress/global-styles-engine";
|
|
10
11
|
import FontFamilyControl from "../font-family";
|
|
11
12
|
import FontAppearanceControl from "../font-appearance-control";
|
|
12
13
|
import LineHeightControl from "../line-height-control";
|
|
@@ -15,7 +16,7 @@ import TextAlignmentControl from "../text-alignment-control";
|
|
|
15
16
|
import TextTransformControl from "../text-transform-control";
|
|
16
17
|
import TextDecorationControl from "../text-decoration-control";
|
|
17
18
|
import WritingModeControl from "../writing-mode-control";
|
|
18
|
-
import {
|
|
19
|
+
import { useToolsPanelDropdownMenuProps } from "./utils";
|
|
19
20
|
import { setImmutably } from "../../utils/object";
|
|
20
21
|
import {
|
|
21
22
|
getMergedFontFamiliesAndFontFamilyFaces,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/global-styles/typography-panel.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tFontSizePicker,\n\t__experimentalNumberControl as NumberControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport FontFamilyControl from '../font-family';\nimport FontAppearanceControl from '../font-appearance-control';\nimport LineHeightControl from '../line-height-control';\nimport LetterSpacingControl from '../letter-spacing-control';\nimport TextAlignmentControl from '../text-alignment-control';\nimport TextTransformControl from '../text-transform-control';\nimport TextDecorationControl from '../text-decoration-control';\nimport WritingModeControl from '../writing-mode-control';\nimport { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';\nimport { setImmutably } from '../../utils/object';\nimport {\n\tgetMergedFontFamiliesAndFontFamilyFaces,\n\tfindNearestStyleAndWeight,\n} from './typography-utils';\n\nconst MIN_TEXT_COLUMNS = 1;\nconst MAX_TEXT_COLUMNS = 6;\n\nexport function useHasTypographyPanel( settings ) {\n\tconst hasFontFamily = useHasFontFamilyControl( settings );\n\tconst hasLineHeight = useHasLineHeightControl( settings );\n\tconst hasFontAppearance = useHasAppearanceControl( settings );\n\tconst hasLetterSpacing = useHasLetterSpacingControl( settings );\n\tconst hasTextAlign = useHasTextAlignmentControl( settings );\n\tconst hasTextTransform = useHasTextTransformControl( settings );\n\tconst hasTextDecoration = useHasTextDecorationControl( settings );\n\tconst hasWritingMode = useHasWritingModeControl( settings );\n\tconst hasTextColumns = useHasTextColumnsControl( settings );\n\tconst hasFontSize = useHasFontSizeControl( settings );\n\n\treturn (\n\t\thasFontFamily ||\n\t\thasLineHeight ||\n\t\thasFontAppearance ||\n\t\thasLetterSpacing ||\n\t\thasTextAlign ||\n\t\thasTextTransform ||\n\t\thasFontSize ||\n\t\thasTextDecoration ||\n\t\thasWritingMode ||\n\t\thasTextColumns\n\t);\n}\n\nfunction useHasFontSizeControl( settings ) {\n\treturn (\n\t\t( settings?.typography?.defaultFontSizes !== false &&\n\t\t\tsettings?.typography?.fontSizes?.default?.length ) ||\n\t\tsettings?.typography?.fontSizes?.theme?.length ||\n\t\tsettings?.typography?.fontSizes?.custom?.length ||\n\t\tsettings?.typography?.customFontSize\n\t);\n}\n\nfunction useHasFontFamilyControl( settings ) {\n\treturn [ 'default', 'theme', 'custom' ].some(\n\t\t( key ) => settings?.typography?.fontFamilies?.[ key ]?.length\n\t);\n}\n\nfunction useHasLineHeightControl( settings ) {\n\treturn settings?.typography?.lineHeight;\n}\n\nfunction useHasAppearanceControl( settings ) {\n\treturn settings?.typography?.fontStyle || settings?.typography?.fontWeight;\n}\n\nfunction useAppearanceControlLabel( settings ) {\n\tif ( ! settings?.typography?.fontStyle ) {\n\t\treturn __( 'Font weight' );\n\t}\n\tif ( ! settings?.typography?.fontWeight ) {\n\t\treturn __( 'Font style' );\n\t}\n\treturn __( 'Appearance' );\n}\n\nfunction useHasLetterSpacingControl( settings ) {\n\treturn settings?.typography?.letterSpacing;\n}\n\nfunction useHasTextTransformControl( settings ) {\n\treturn settings?.typography?.textTransform;\n}\n\nfunction useHasTextAlignmentControl( settings ) {\n\treturn settings?.typography?.textAlign;\n}\n\nfunction useHasTextDecorationControl( settings ) {\n\treturn settings?.typography?.textDecoration;\n}\n\nfunction useHasWritingModeControl( settings ) {\n\treturn settings?.typography?.writingMode;\n}\n\nfunction useHasTextColumnsControl( settings ) {\n\treturn settings?.typography?.textColumns;\n}\n\n/**\n * Concatenate all the font sizes into a single list for the font size picker.\n *\n * @param {Object} settings The global styles settings.\n *\n * @return {Array} The merged font sizes.\n */\nfunction getMergedFontSizes( settings ) {\n\tconst fontSizes = settings?.typography?.fontSizes;\n\tconst defaultFontSizesEnabled = !! settings?.typography?.defaultFontSizes;\n\treturn [\n\t\t...( fontSizes?.custom ?? [] ),\n\t\t...( fontSizes?.theme ?? [] ),\n\t\t...( defaultFontSizesEnabled ? fontSizes?.default ?? [] : [] ),\n\t];\n}\n\nfunction TypographyToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n} ) {\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ __( 'Typography' ) }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n\nconst DEFAULT_CONTROLS = {\n\tfontFamily: true,\n\tfontSize: true,\n\tfontAppearance: true,\n\tlineHeight: true,\n\tletterSpacing: true,\n\ttextAlign: true,\n\ttextTransform: true,\n\ttextDecoration: true,\n\twritingMode: true,\n\ttextColumns: true,\n};\n\nexport default function TypographyPanel( {\n\tas: Wrapper = TypographyToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\tsettings,\n\tpanelId,\n\tdefaultControls = DEFAULT_CONTROLS,\n} ) {\n\tconst decodeValue = ( rawValue ) =>\n\t\tgetValueFromVariable( { settings }, '', rawValue );\n\n\t// Font Family\n\tconst hasFontFamilyEnabled = useHasFontFamilyControl( settings );\n\tconst fontFamily = decodeValue( inheritedValue?.typography?.fontFamily );\n\tconst { fontFamilies, fontFamilyFaces } = useMemo( () => {\n\t\treturn getMergedFontFamiliesAndFontFamilyFaces( settings, fontFamily );\n\t}, [ settings, fontFamily ] );\n\n\tconst setFontFamily = ( newValue ) => {\n\t\tconst slug = fontFamilies?.find(\n\t\t\t( { fontFamily: f } ) => f === newValue\n\t\t)?.slug;\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'fontFamily' ],\n\t\t\t\tslug\n\t\t\t\t\t? `var:preset|font-family|${ slug }`\n\t\t\t\t\t: newValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasFontFamily = () => !! value?.typography?.fontFamily;\n\tconst resetFontFamily = () => setFontFamily( undefined );\n\n\t// Font Size\n\tconst hasFontSizeEnabled = useHasFontSizeControl( settings );\n\tconst disableCustomFontSizes = ! settings?.typography?.customFontSize;\n\tconst mergedFontSizes = getMergedFontSizes( settings );\n\n\tconst fontSize = decodeValue( inheritedValue?.typography?.fontSize );\n\n\t// Extract the slug from the CSS custom property if it exists\n\tconst currentFontSizeSlug = ( () => {\n\t\tconst rawValue = inheritedValue?.typography?.fontSize;\n\t\tif ( ! rawValue || typeof rawValue !== 'string' ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Block supports use `var:preset` format.\n\t\tif ( rawValue.startsWith( 'var:preset|font-size|' ) ) {\n\t\t\treturn rawValue.replace( 'var:preset|font-size|', '' );\n\t\t}\n\n\t\t// Global styles data uses `var(--wp--preset)` format.\n\t\tconst cssVarMatch = rawValue.match(\n\t\t\t/^var\\(--wp--preset--font-size--([^)]+)\\)$/\n\t\t);\n\t\tif ( cssVarMatch ) {\n\t\t\treturn cssVarMatch[ 1 ];\n\t\t}\n\n\t\treturn undefined;\n\t} )();\n\n\tconst setFontSize = ( newValue, metadata ) => {\n\t\tconst actualValue = !! metadata?.slug\n\t\t\t? `var:preset|font-size|${ metadata?.slug }`\n\t\t\t: newValue;\n\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'fontSize' ],\n\t\t\t\tactualValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasFontSize = () => !! value?.typography?.fontSize;\n\tconst resetFontSize = () => setFontSize( undefined );\n\n\t// Appearance\n\tconst hasAppearanceControl = useHasAppearanceControl( settings );\n\tconst appearanceControlLabel = useAppearanceControlLabel( settings );\n\tconst hasFontStyles = settings?.typography?.fontStyle;\n\tconst hasFontWeights = settings?.typography?.fontWeight;\n\tconst fontStyle = decodeValue( inheritedValue?.typography?.fontStyle );\n\tconst fontWeight = decodeValue( inheritedValue?.typography?.fontWeight );\n\tconst { nearestFontStyle, nearestFontWeight } = findNearestStyleAndWeight(\n\t\tfontFamilyFaces,\n\t\tfontStyle,\n\t\tfontWeight\n\t);\n\tconst setFontAppearance = useCallback(\n\t\t( { fontStyle: newFontStyle, fontWeight: newFontWeight } ) => {\n\t\t\t// Only update the font style and weight if they have changed.\n\t\t\tif ( newFontStyle !== fontStyle || newFontWeight !== fontWeight ) {\n\t\t\t\tonChange( {\n\t\t\t\t\t...value,\n\t\t\t\t\ttypography: {\n\t\t\t\t\t\t...value?.typography,\n\t\t\t\t\t\tfontStyle: newFontStyle || undefined,\n\t\t\t\t\t\tfontWeight: newFontWeight || undefined,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ fontStyle, fontWeight, onChange, value ]\n\t);\n\tconst hasFontAppearance = () =>\n\t\t!! value?.typography?.fontStyle || !! value?.typography?.fontWeight;\n\tconst resetFontAppearance = useCallback( () => {\n\t\tsetFontAppearance( {} );\n\t}, [ setFontAppearance ] );\n\n\t// Check if previous font style and weight values are available in the new font family.\n\tuseEffect( () => {\n\t\tif ( nearestFontStyle && nearestFontWeight ) {\n\t\t\tsetFontAppearance( {\n\t\t\t\tfontStyle: nearestFontStyle,\n\t\t\t\tfontWeight: nearestFontWeight,\n\t\t\t} );\n\t\t} else {\n\t\t\t// Reset font appearance if there are no available styles or weights.\n\t\t\tresetFontAppearance();\n\t\t}\n\t}, [\n\t\tnearestFontStyle,\n\t\tnearestFontWeight,\n\t\tresetFontAppearance,\n\t\tsetFontAppearance,\n\t] );\n\n\t// Line Height\n\tconst hasLineHeightEnabled = useHasLineHeightControl( settings );\n\tconst lineHeight = decodeValue( inheritedValue?.typography?.lineHeight );\n\tconst setLineHeight = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'lineHeight' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasLineHeight = () => value?.typography?.lineHeight !== undefined;\n\tconst resetLineHeight = () => setLineHeight( undefined );\n\n\t// Letter Spacing\n\tconst hasLetterSpacingControl = useHasLetterSpacingControl( settings );\n\tconst letterSpacing = decodeValue(\n\t\tinheritedValue?.typography?.letterSpacing\n\t);\n\tconst setLetterSpacing = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'letterSpacing' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasLetterSpacing = () => !! value?.typography?.letterSpacing;\n\tconst resetLetterSpacing = () => setLetterSpacing( undefined );\n\n\t// Text Columns\n\tconst hasTextColumnsControl = useHasTextColumnsControl( settings );\n\tconst textColumns = decodeValue( inheritedValue?.typography?.textColumns );\n\tconst setTextColumns = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'textColumns' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasTextColumns = () => !! value?.typography?.textColumns;\n\tconst resetTextColumns = () => setTextColumns( undefined );\n\n\t// Text Transform\n\tconst hasTextTransformControl = useHasTextTransformControl( settings );\n\tconst textTransform = decodeValue(\n\t\tinheritedValue?.typography?.textTransform\n\t);\n\tconst setTextTransform = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'textTransform' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasTextTransform = () => !! value?.typography?.textTransform;\n\tconst resetTextTransform = () => setTextTransform( undefined );\n\n\t// Text Decoration\n\tconst hasTextDecorationControl = useHasTextDecorationControl( settings );\n\tconst textDecoration = decodeValue(\n\t\tinheritedValue?.typography?.textDecoration\n\t);\n\tconst setTextDecoration = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'textDecoration' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasTextDecoration = () => !! value?.typography?.textDecoration;\n\tconst resetTextDecoration = () => setTextDecoration( undefined );\n\n\t// Text Orientation\n\tconst hasWritingModeControl = useHasWritingModeControl( settings );\n\tconst writingMode = decodeValue( inheritedValue?.typography?.writingMode );\n\tconst setWritingMode = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'writingMode' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasWritingMode = () => !! value?.typography?.writingMode;\n\tconst resetWritingMode = () => setWritingMode( undefined );\n\n\t// Text Alignment\n\tconst hasTextAlignmentControl = useHasTextAlignmentControl( settings );\n\n\tconst textAlign = decodeValue( inheritedValue?.typography?.textAlign );\n\tconst setTextAlign = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'textAlign' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasTextAlign = () => !! value?.typography?.textAlign;\n\tconst resetTextAlign = () => setTextAlign( undefined );\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\ttypography: {},\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t{ hasFontFamilyEnabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Font' ) }\n\t\t\t\t\thasValue={ hasFontFamily }\n\t\t\t\t\tonDeselect={ resetFontFamily }\n\t\t\t\t\tisShownByDefault={ defaultControls.fontFamily }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<FontFamilyControl\n\t\t\t\t\t\tfontFamilies={ fontFamilies }\n\t\t\t\t\t\tvalue={ fontFamily }\n\t\t\t\t\t\tonChange={ setFontFamily }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasFontSizeEnabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\t\thasValue={ hasFontSize }\n\t\t\t\t\tonDeselect={ resetFontSize }\n\t\t\t\t\tisShownByDefault={ defaultControls.fontSize }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<FontSizePicker\n\t\t\t\t\t\tvalue={ currentFontSizeSlug || fontSize }\n\t\t\t\t\t\tvalueMode={ currentFontSizeSlug ? 'slug' : 'literal' }\n\t\t\t\t\t\tonChange={ setFontSize }\n\t\t\t\t\t\tfontSizes={ mergedFontSizes }\n\t\t\t\t\t\tdisableCustomFontSizes={ disableCustomFontSizes }\n\t\t\t\t\t\twithReset={ false }\n\t\t\t\t\t\twithSlider\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasAppearanceControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ appearanceControlLabel }\n\t\t\t\t\thasValue={ hasFontAppearance }\n\t\t\t\t\tonDeselect={ resetFontAppearance }\n\t\t\t\t\tisShownByDefault={ defaultControls.fontAppearance }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<FontAppearanceControl\n\t\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t\tfontStyle,\n\t\t\t\t\t\t\tfontWeight,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ setFontAppearance }\n\t\t\t\t\t\thasFontStyles={ hasFontStyles }\n\t\t\t\t\t\thasFontWeights={ hasFontWeights }\n\t\t\t\t\t\tfontFamilyFaces={ fontFamilyFaces }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasLineHeightEnabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Line height' ) }\n\t\t\t\t\thasValue={ hasLineHeight }\n\t\t\t\t\tonDeselect={ resetLineHeight }\n\t\t\t\t\tisShownByDefault={ defaultControls.lineHeight }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<LineHeightControl\n\t\t\t\t\t\t__unstableInputWidth=\"auto\"\n\t\t\t\t\t\tvalue={ lineHeight }\n\t\t\t\t\t\tonChange={ setLineHeight }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasLetterSpacingControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Letter spacing' ) }\n\t\t\t\t\thasValue={ hasLetterSpacing }\n\t\t\t\t\tonDeselect={ resetLetterSpacing }\n\t\t\t\t\tisShownByDefault={ defaultControls.letterSpacing }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<LetterSpacingControl\n\t\t\t\t\t\tvalue={ letterSpacing }\n\t\t\t\t\t\tonChange={ setLetterSpacing }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__unstableInputWidth=\"auto\"\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasTextColumnsControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\thasValue={ hasTextColumns }\n\t\t\t\t\tonDeselect={ resetTextColumns }\n\t\t\t\t\tisShownByDefault={ defaultControls.textColumns }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<NumberControl\n\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\tmax={ MAX_TEXT_COLUMNS }\n\t\t\t\t\t\tmin={ MIN_TEXT_COLUMNS }\n\t\t\t\t\t\tonChange={ setTextColumns }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\tspinControls=\"custom\"\n\t\t\t\t\t\tvalue={ textColumns }\n\t\t\t\t\t\tinitialPosition={ 1 }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasTextDecorationControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Decoration' ) }\n\t\t\t\t\thasValue={ hasTextDecoration }\n\t\t\t\t\tonDeselect={ resetTextDecoration }\n\t\t\t\t\tisShownByDefault={ defaultControls.textDecoration }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<TextDecorationControl\n\t\t\t\t\t\tvalue={ textDecoration }\n\t\t\t\t\t\tonChange={ setTextDecoration }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__unstableInputWidth=\"auto\"\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasWritingModeControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Orientation' ) }\n\t\t\t\t\thasValue={ hasWritingMode }\n\t\t\t\t\tonDeselect={ resetWritingMode }\n\t\t\t\t\tisShownByDefault={ defaultControls.writingMode }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<WritingModeControl\n\t\t\t\t\t\tvalue={ writingMode }\n\t\t\t\t\t\tonChange={ setWritingMode }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasTextTransformControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Letter case' ) }\n\t\t\t\t\thasValue={ hasTextTransform }\n\t\t\t\t\tonDeselect={ resetTextTransform }\n\t\t\t\t\tisShownByDefault={ defaultControls.textTransform }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<TextTransformControl\n\t\t\t\t\t\tvalue={ textTransform }\n\t\t\t\t\t\tonChange={ setTextTransform }\n\t\t\t\t\t\tshowNone\n\t\t\t\t\t\tisBlock\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasTextAlignmentControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Text alignment' ) }\n\t\t\t\t\thasValue={ hasTextAlign }\n\t\t\t\t\tonDeselect={ resetTextAlign }\n\t\t\t\t\tisShownByDefault={ defaultControls.textAlign }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<TextAlignmentControl\n\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\tonChange={ setTextAlign }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</Wrapper>\n\t);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tFontSizePicker,\n\t__experimentalNumberControl as NumberControl,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useEffect } from '@wordpress/element';\nimport { getValueFromVariable } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport FontFamilyControl from '../font-family';\nimport FontAppearanceControl from '../font-appearance-control';\nimport LineHeightControl from '../line-height-control';\nimport LetterSpacingControl from '../letter-spacing-control';\nimport TextAlignmentControl from '../text-alignment-control';\nimport TextTransformControl from '../text-transform-control';\nimport TextDecorationControl from '../text-decoration-control';\nimport WritingModeControl from '../writing-mode-control';\nimport { useToolsPanelDropdownMenuProps } from './utils';\nimport { setImmutably } from '../../utils/object';\nimport {\n\tgetMergedFontFamiliesAndFontFamilyFaces,\n\tfindNearestStyleAndWeight,\n} from './typography-utils';\n\nconst MIN_TEXT_COLUMNS = 1;\nconst MAX_TEXT_COLUMNS = 6;\n\nexport function useHasTypographyPanel( settings ) {\n\tconst hasFontFamily = useHasFontFamilyControl( settings );\n\tconst hasLineHeight = useHasLineHeightControl( settings );\n\tconst hasFontAppearance = useHasAppearanceControl( settings );\n\tconst hasLetterSpacing = useHasLetterSpacingControl( settings );\n\tconst hasTextAlign = useHasTextAlignmentControl( settings );\n\tconst hasTextTransform = useHasTextTransformControl( settings );\n\tconst hasTextDecoration = useHasTextDecorationControl( settings );\n\tconst hasWritingMode = useHasWritingModeControl( settings );\n\tconst hasTextColumns = useHasTextColumnsControl( settings );\n\tconst hasFontSize = useHasFontSizeControl( settings );\n\n\treturn (\n\t\thasFontFamily ||\n\t\thasLineHeight ||\n\t\thasFontAppearance ||\n\t\thasLetterSpacing ||\n\t\thasTextAlign ||\n\t\thasTextTransform ||\n\t\thasFontSize ||\n\t\thasTextDecoration ||\n\t\thasWritingMode ||\n\t\thasTextColumns\n\t);\n}\n\nfunction useHasFontSizeControl( settings ) {\n\treturn (\n\t\t( settings?.typography?.defaultFontSizes !== false &&\n\t\t\tsettings?.typography?.fontSizes?.default?.length ) ||\n\t\tsettings?.typography?.fontSizes?.theme?.length ||\n\t\tsettings?.typography?.fontSizes?.custom?.length ||\n\t\tsettings?.typography?.customFontSize\n\t);\n}\n\nfunction useHasFontFamilyControl( settings ) {\n\treturn [ 'default', 'theme', 'custom' ].some(\n\t\t( key ) => settings?.typography?.fontFamilies?.[ key ]?.length\n\t);\n}\n\nfunction useHasLineHeightControl( settings ) {\n\treturn settings?.typography?.lineHeight;\n}\n\nfunction useHasAppearanceControl( settings ) {\n\treturn settings?.typography?.fontStyle || settings?.typography?.fontWeight;\n}\n\nfunction useAppearanceControlLabel( settings ) {\n\tif ( ! settings?.typography?.fontStyle ) {\n\t\treturn __( 'Font weight' );\n\t}\n\tif ( ! settings?.typography?.fontWeight ) {\n\t\treturn __( 'Font style' );\n\t}\n\treturn __( 'Appearance' );\n}\n\nfunction useHasLetterSpacingControl( settings ) {\n\treturn settings?.typography?.letterSpacing;\n}\n\nfunction useHasTextTransformControl( settings ) {\n\treturn settings?.typography?.textTransform;\n}\n\nfunction useHasTextAlignmentControl( settings ) {\n\treturn settings?.typography?.textAlign;\n}\n\nfunction useHasTextDecorationControl( settings ) {\n\treturn settings?.typography?.textDecoration;\n}\n\nfunction useHasWritingModeControl( settings ) {\n\treturn settings?.typography?.writingMode;\n}\n\nfunction useHasTextColumnsControl( settings ) {\n\treturn settings?.typography?.textColumns;\n}\n\n/**\n * Concatenate all the font sizes into a single list for the font size picker.\n *\n * @param {Object} settings The global styles settings.\n *\n * @return {Array} The merged font sizes.\n */\nfunction getMergedFontSizes( settings ) {\n\tconst fontSizes = settings?.typography?.fontSizes;\n\tconst defaultFontSizesEnabled = !! settings?.typography?.defaultFontSizes;\n\treturn [\n\t\t...( fontSizes?.custom ?? [] ),\n\t\t...( fontSizes?.theme ?? [] ),\n\t\t...( defaultFontSizesEnabled ? fontSizes?.default ?? [] : [] ),\n\t];\n}\n\nfunction TypographyToolsPanel( {\n\tresetAllFilter,\n\tonChange,\n\tvalue,\n\tpanelId,\n\tchildren,\n} ) {\n\tconst dropdownMenuProps = useToolsPanelDropdownMenuProps();\n\tconst resetAll = () => {\n\t\tconst updatedValue = resetAllFilter( value );\n\t\tonChange( updatedValue );\n\t};\n\n\treturn (\n\t\t<ToolsPanel\n\t\t\tlabel={ __( 'Typography' ) }\n\t\t\tresetAll={ resetAll }\n\t\t\tpanelId={ panelId }\n\t\t\tdropdownMenuProps={ dropdownMenuProps }\n\t\t>\n\t\t\t{ children }\n\t\t</ToolsPanel>\n\t);\n}\n\nconst DEFAULT_CONTROLS = {\n\tfontFamily: true,\n\tfontSize: true,\n\tfontAppearance: true,\n\tlineHeight: true,\n\tletterSpacing: true,\n\ttextAlign: true,\n\ttextTransform: true,\n\ttextDecoration: true,\n\twritingMode: true,\n\ttextColumns: true,\n};\n\nexport default function TypographyPanel( {\n\tas: Wrapper = TypographyToolsPanel,\n\tvalue,\n\tonChange,\n\tinheritedValue = value,\n\tsettings,\n\tpanelId,\n\tdefaultControls = DEFAULT_CONTROLS,\n} ) {\n\tconst decodeValue = ( rawValue ) =>\n\t\tgetValueFromVariable( { settings }, '', rawValue );\n\n\t// Font Family\n\tconst hasFontFamilyEnabled = useHasFontFamilyControl( settings );\n\tconst fontFamily = decodeValue( inheritedValue?.typography?.fontFamily );\n\tconst { fontFamilies, fontFamilyFaces } = useMemo( () => {\n\t\treturn getMergedFontFamiliesAndFontFamilyFaces( settings, fontFamily );\n\t}, [ settings, fontFamily ] );\n\n\tconst setFontFamily = ( newValue ) => {\n\t\tconst slug = fontFamilies?.find(\n\t\t\t( { fontFamily: f } ) => f === newValue\n\t\t)?.slug;\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'fontFamily' ],\n\t\t\t\tslug\n\t\t\t\t\t? `var:preset|font-family|${ slug }`\n\t\t\t\t\t: newValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasFontFamily = () => !! value?.typography?.fontFamily;\n\tconst resetFontFamily = () => setFontFamily( undefined );\n\n\t// Font Size\n\tconst hasFontSizeEnabled = useHasFontSizeControl( settings );\n\tconst disableCustomFontSizes = ! settings?.typography?.customFontSize;\n\tconst mergedFontSizes = getMergedFontSizes( settings );\n\n\tconst fontSize = decodeValue( inheritedValue?.typography?.fontSize );\n\n\t// Extract the slug from the CSS custom property if it exists\n\tconst currentFontSizeSlug = ( () => {\n\t\tconst rawValue = inheritedValue?.typography?.fontSize;\n\t\tif ( ! rawValue || typeof rawValue !== 'string' ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\t// Block supports use `var:preset` format.\n\t\tif ( rawValue.startsWith( 'var:preset|font-size|' ) ) {\n\t\t\treturn rawValue.replace( 'var:preset|font-size|', '' );\n\t\t}\n\n\t\t// Global styles data uses `var(--wp--preset)` format.\n\t\tconst cssVarMatch = rawValue.match(\n\t\t\t/^var\\(--wp--preset--font-size--([^)]+)\\)$/\n\t\t);\n\t\tif ( cssVarMatch ) {\n\t\t\treturn cssVarMatch[ 1 ];\n\t\t}\n\n\t\treturn undefined;\n\t} )();\n\n\tconst setFontSize = ( newValue, metadata ) => {\n\t\tconst actualValue = !! metadata?.slug\n\t\t\t? `var:preset|font-size|${ metadata?.slug }`\n\t\t\t: newValue;\n\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'fontSize' ],\n\t\t\t\tactualValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasFontSize = () => !! value?.typography?.fontSize;\n\tconst resetFontSize = () => setFontSize( undefined );\n\n\t// Appearance\n\tconst hasAppearanceControl = useHasAppearanceControl( settings );\n\tconst appearanceControlLabel = useAppearanceControlLabel( settings );\n\tconst hasFontStyles = settings?.typography?.fontStyle;\n\tconst hasFontWeights = settings?.typography?.fontWeight;\n\tconst fontStyle = decodeValue( inheritedValue?.typography?.fontStyle );\n\tconst fontWeight = decodeValue( inheritedValue?.typography?.fontWeight );\n\tconst { nearestFontStyle, nearestFontWeight } = findNearestStyleAndWeight(\n\t\tfontFamilyFaces,\n\t\tfontStyle,\n\t\tfontWeight\n\t);\n\tconst setFontAppearance = useCallback(\n\t\t( { fontStyle: newFontStyle, fontWeight: newFontWeight } ) => {\n\t\t\t// Only update the font style and weight if they have changed.\n\t\t\tif ( newFontStyle !== fontStyle || newFontWeight !== fontWeight ) {\n\t\t\t\tonChange( {\n\t\t\t\t\t...value,\n\t\t\t\t\ttypography: {\n\t\t\t\t\t\t...value?.typography,\n\t\t\t\t\t\tfontStyle: newFontStyle || undefined,\n\t\t\t\t\t\tfontWeight: newFontWeight || undefined,\n\t\t\t\t\t},\n\t\t\t\t} );\n\t\t\t}\n\t\t},\n\t\t[ fontStyle, fontWeight, onChange, value ]\n\t);\n\tconst hasFontAppearance = () =>\n\t\t!! value?.typography?.fontStyle || !! value?.typography?.fontWeight;\n\tconst resetFontAppearance = useCallback( () => {\n\t\tsetFontAppearance( {} );\n\t}, [ setFontAppearance ] );\n\n\t// Check if previous font style and weight values are available in the new font family.\n\tuseEffect( () => {\n\t\tif ( nearestFontStyle && nearestFontWeight ) {\n\t\t\tsetFontAppearance( {\n\t\t\t\tfontStyle: nearestFontStyle,\n\t\t\t\tfontWeight: nearestFontWeight,\n\t\t\t} );\n\t\t} else {\n\t\t\t// Reset font appearance if there are no available styles or weights.\n\t\t\tresetFontAppearance();\n\t\t}\n\t}, [\n\t\tnearestFontStyle,\n\t\tnearestFontWeight,\n\t\tresetFontAppearance,\n\t\tsetFontAppearance,\n\t] );\n\n\t// Line Height\n\tconst hasLineHeightEnabled = useHasLineHeightControl( settings );\n\tconst lineHeight = decodeValue( inheritedValue?.typography?.lineHeight );\n\tconst setLineHeight = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'lineHeight' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasLineHeight = () => value?.typography?.lineHeight !== undefined;\n\tconst resetLineHeight = () => setLineHeight( undefined );\n\n\t// Letter Spacing\n\tconst hasLetterSpacingControl = useHasLetterSpacingControl( settings );\n\tconst letterSpacing = decodeValue(\n\t\tinheritedValue?.typography?.letterSpacing\n\t);\n\tconst setLetterSpacing = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'letterSpacing' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasLetterSpacing = () => !! value?.typography?.letterSpacing;\n\tconst resetLetterSpacing = () => setLetterSpacing( undefined );\n\n\t// Text Columns\n\tconst hasTextColumnsControl = useHasTextColumnsControl( settings );\n\tconst textColumns = decodeValue( inheritedValue?.typography?.textColumns );\n\tconst setTextColumns = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'textColumns' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasTextColumns = () => !! value?.typography?.textColumns;\n\tconst resetTextColumns = () => setTextColumns( undefined );\n\n\t// Text Transform\n\tconst hasTextTransformControl = useHasTextTransformControl( settings );\n\tconst textTransform = decodeValue(\n\t\tinheritedValue?.typography?.textTransform\n\t);\n\tconst setTextTransform = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'textTransform' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasTextTransform = () => !! value?.typography?.textTransform;\n\tconst resetTextTransform = () => setTextTransform( undefined );\n\n\t// Text Decoration\n\tconst hasTextDecorationControl = useHasTextDecorationControl( settings );\n\tconst textDecoration = decodeValue(\n\t\tinheritedValue?.typography?.textDecoration\n\t);\n\tconst setTextDecoration = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'textDecoration' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasTextDecoration = () => !! value?.typography?.textDecoration;\n\tconst resetTextDecoration = () => setTextDecoration( undefined );\n\n\t// Text Orientation\n\tconst hasWritingModeControl = useHasWritingModeControl( settings );\n\tconst writingMode = decodeValue( inheritedValue?.typography?.writingMode );\n\tconst setWritingMode = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'writingMode' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasWritingMode = () => !! value?.typography?.writingMode;\n\tconst resetWritingMode = () => setWritingMode( undefined );\n\n\t// Text Alignment\n\tconst hasTextAlignmentControl = useHasTextAlignmentControl( settings );\n\n\tconst textAlign = decodeValue( inheritedValue?.typography?.textAlign );\n\tconst setTextAlign = ( newValue ) => {\n\t\tonChange(\n\t\t\tsetImmutably(\n\t\t\t\tvalue,\n\t\t\t\t[ 'typography', 'textAlign' ],\n\t\t\t\tnewValue || undefined\n\t\t\t)\n\t\t);\n\t};\n\tconst hasTextAlign = () => !! value?.typography?.textAlign;\n\tconst resetTextAlign = () => setTextAlign( undefined );\n\n\tconst resetAllFilter = useCallback( ( previousValue ) => {\n\t\treturn {\n\t\t\t...previousValue,\n\t\t\ttypography: {},\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Wrapper\n\t\t\tresetAllFilter={ resetAllFilter }\n\t\t\tvalue={ value }\n\t\t\tonChange={ onChange }\n\t\t\tpanelId={ panelId }\n\t\t>\n\t\t\t{ hasFontFamilyEnabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Font' ) }\n\t\t\t\t\thasValue={ hasFontFamily }\n\t\t\t\t\tonDeselect={ resetFontFamily }\n\t\t\t\t\tisShownByDefault={ defaultControls.fontFamily }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<FontFamilyControl\n\t\t\t\t\t\tfontFamilies={ fontFamilies }\n\t\t\t\t\t\tvalue={ fontFamily }\n\t\t\t\t\t\tonChange={ setFontFamily }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasFontSizeEnabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Size' ) }\n\t\t\t\t\thasValue={ hasFontSize }\n\t\t\t\t\tonDeselect={ resetFontSize }\n\t\t\t\t\tisShownByDefault={ defaultControls.fontSize }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<FontSizePicker\n\t\t\t\t\t\tvalue={ currentFontSizeSlug || fontSize }\n\t\t\t\t\t\tvalueMode={ currentFontSizeSlug ? 'slug' : 'literal' }\n\t\t\t\t\t\tonChange={ setFontSize }\n\t\t\t\t\t\tfontSizes={ mergedFontSizes }\n\t\t\t\t\t\tdisableCustomFontSizes={ disableCustomFontSizes }\n\t\t\t\t\t\twithReset={ false }\n\t\t\t\t\t\twithSlider\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasAppearanceControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ appearanceControlLabel }\n\t\t\t\t\thasValue={ hasFontAppearance }\n\t\t\t\t\tonDeselect={ resetFontAppearance }\n\t\t\t\t\tisShownByDefault={ defaultControls.fontAppearance }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<FontAppearanceControl\n\t\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t\tfontStyle,\n\t\t\t\t\t\t\tfontWeight,\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonChange={ setFontAppearance }\n\t\t\t\t\t\thasFontStyles={ hasFontStyles }\n\t\t\t\t\t\thasFontWeights={ hasFontWeights }\n\t\t\t\t\t\tfontFamilyFaces={ fontFamilyFaces }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasLineHeightEnabled && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Line height' ) }\n\t\t\t\t\thasValue={ hasLineHeight }\n\t\t\t\t\tonDeselect={ resetLineHeight }\n\t\t\t\t\tisShownByDefault={ defaultControls.lineHeight }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<LineHeightControl\n\t\t\t\t\t\t__unstableInputWidth=\"auto\"\n\t\t\t\t\t\tvalue={ lineHeight }\n\t\t\t\t\t\tonChange={ setLineHeight }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasLetterSpacingControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Letter spacing' ) }\n\t\t\t\t\thasValue={ hasLetterSpacing }\n\t\t\t\t\tonDeselect={ resetLetterSpacing }\n\t\t\t\t\tisShownByDefault={ defaultControls.letterSpacing }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<LetterSpacingControl\n\t\t\t\t\t\tvalue={ letterSpacing }\n\t\t\t\t\t\tonChange={ setLetterSpacing }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__unstableInputWidth=\"auto\"\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasTextColumnsControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\thasValue={ hasTextColumns }\n\t\t\t\t\tonDeselect={ resetTextColumns }\n\t\t\t\t\tisShownByDefault={ defaultControls.textColumns }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<NumberControl\n\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\tmax={ MAX_TEXT_COLUMNS }\n\t\t\t\t\t\tmin={ MIN_TEXT_COLUMNS }\n\t\t\t\t\t\tonChange={ setTextColumns }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\tspinControls=\"custom\"\n\t\t\t\t\t\tvalue={ textColumns }\n\t\t\t\t\t\tinitialPosition={ 1 }\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasTextDecorationControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Decoration' ) }\n\t\t\t\t\thasValue={ hasTextDecoration }\n\t\t\t\t\tonDeselect={ resetTextDecoration }\n\t\t\t\t\tisShownByDefault={ defaultControls.textDecoration }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<TextDecorationControl\n\t\t\t\t\t\tvalue={ textDecoration }\n\t\t\t\t\t\tonChange={ setTextDecoration }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__unstableInputWidth=\"auto\"\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasWritingModeControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tclassName=\"single-column\"\n\t\t\t\t\tlabel={ __( 'Orientation' ) }\n\t\t\t\t\thasValue={ hasWritingMode }\n\t\t\t\t\tonDeselect={ resetWritingMode }\n\t\t\t\t\tisShownByDefault={ defaultControls.writingMode }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<WritingModeControl\n\t\t\t\t\t\tvalue={ writingMode }\n\t\t\t\t\t\tonChange={ setWritingMode }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasTextTransformControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Letter case' ) }\n\t\t\t\t\thasValue={ hasTextTransform }\n\t\t\t\t\tonDeselect={ resetTextTransform }\n\t\t\t\t\tisShownByDefault={ defaultControls.textTransform }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<TextTransformControl\n\t\t\t\t\t\tvalue={ textTransform }\n\t\t\t\t\t\tonChange={ setTextTransform }\n\t\t\t\t\t\tshowNone\n\t\t\t\t\t\tisBlock\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t\t{ hasTextAlignmentControl && (\n\t\t\t\t<ToolsPanelItem\n\t\t\t\t\tlabel={ __( 'Text alignment' ) }\n\t\t\t\t\thasValue={ hasTextAlign }\n\t\t\t\t\tonDeselect={ resetTextAlign }\n\t\t\t\t\tisShownByDefault={ defaultControls.textAlign }\n\t\t\t\t\tpanelId={ panelId }\n\t\t\t\t>\n\t\t\t\t\t<TextAlignmentControl\n\t\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\t\tonChange={ setTextAlign }\n\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t/>\n\t\t\t\t</ToolsPanelItem>\n\t\t\t) }\n\t\t</Wrapper>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAqJE,cAsRA,YAtRA;AAlJF;AAAA,EACC;AAAA,EACA,+BAA+B;AAAA,EAC/B,4BAA4B;AAAA,EAC5B,gCAAgC;AAAA,OAC1B;AACP,SAAS,UAAU;AACnB,SAAS,aAAa,SAAS,iBAAiB;AAChD,SAAS,4BAA4B;AAKrC,OAAO,uBAAuB;AAC9B,OAAO,2BAA2B;AAClC,OAAO,uBAAuB;AAC9B,OAAO,0BAA0B;AACjC,OAAO,0BAA0B;AACjC,OAAO,0BAA0B;AACjC,OAAO,2BAA2B;AAClC,OAAO,wBAAwB;AAC/B,SAAS,sCAAsC;AAC/C,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,OACM;AAEP,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AAElB,SAAS,sBAAuB,UAAW;AACjD,QAAM,gBAAgB,wBAAyB,QAAS;AACxD,QAAM,gBAAgB,wBAAyB,QAAS;AACxD,QAAM,oBAAoB,wBAAyB,QAAS;AAC5D,QAAM,mBAAmB,2BAA4B,QAAS;AAC9D,QAAM,eAAe,2BAA4B,QAAS;AAC1D,QAAM,mBAAmB,2BAA4B,QAAS;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gBACR,UAAW;AAAA,gBACX,UAAQ;AAAA,gBACR,SAAO;AAAA,gBACP,MAAK;AAAA,gBACL,yBAAuB;AAAA;AAAA,YACxB;AAAA;AAAA,QACD;AAAA,QAEC,2BACD;AAAA,UAAC;AAAA;AAAA,YACA,OAAQ,GAAI,gBAAiB;AAAA,YAC7B,UAAW;AAAA,YACX,YAAa;AAAA,YACb,kBAAmB,gBAAgB;AAAA,YACnC;AAAA,YAEA;AAAA,cAAC;AAAA;AAAA,gBACA,OAAQ;AAAA,gBACR,UAAW;AAAA,gBACX,MAAK;AAAA,gBACL,yBAAuB;AAAA;AAAA,YACxB;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EAEF;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,50 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getComputedFluidTypographyValue,
|
|
3
|
-
getTypographyValueAndUnit
|
|
4
|
-
} from "../font-sizes/fluid-utils";
|
|
5
1
|
import { getFontStylesAndWeights } from "../../utils/get-font-styles-and-weights";
|
|
6
|
-
function getTypographyFontSizeValue(preset, settings) {
|
|
7
|
-
const { size: defaultSize } = preset;
|
|
8
|
-
if (!defaultSize || "0" === defaultSize || false === preset?.fluid) {
|
|
9
|
-
return defaultSize;
|
|
10
|
-
}
|
|
11
|
-
if (!isFluidTypographyEnabled(settings?.typography) && !isFluidTypographyEnabled(preset)) {
|
|
12
|
-
return defaultSize;
|
|
13
|
-
}
|
|
14
|
-
let fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings);
|
|
15
|
-
fluidTypographySettings = typeof fluidTypographySettings?.fluid === "object" ? fluidTypographySettings?.fluid : {};
|
|
16
|
-
const fluidFontSizeValue = getComputedFluidTypographyValue({
|
|
17
|
-
minimumFontSize: preset?.fluid?.min,
|
|
18
|
-
maximumFontSize: preset?.fluid?.max,
|
|
19
|
-
fontSize: defaultSize,
|
|
20
|
-
minimumFontSizeLimit: fluidTypographySettings?.minFontSize,
|
|
21
|
-
maximumViewportWidth: fluidTypographySettings?.maxViewportWidth,
|
|
22
|
-
minimumViewportWidth: fluidTypographySettings?.minViewportWidth
|
|
23
|
-
});
|
|
24
|
-
if (!!fluidFontSizeValue) {
|
|
25
|
-
return fluidFontSizeValue;
|
|
26
|
-
}
|
|
27
|
-
return defaultSize;
|
|
28
|
-
}
|
|
29
|
-
function isFluidTypographyEnabled(typographySettings) {
|
|
30
|
-
const fluidSettings = typographySettings?.fluid;
|
|
31
|
-
return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0;
|
|
32
|
-
}
|
|
33
|
-
function getFluidTypographyOptionsFromSettings(settings) {
|
|
34
|
-
const typographySettings = settings?.typography;
|
|
35
|
-
const layoutSettings = settings?.layout;
|
|
36
|
-
const defaultMaxViewportWidth = getTypographyValueAndUnit(
|
|
37
|
-
layoutSettings?.wideSize
|
|
38
|
-
) ? layoutSettings?.wideSize : null;
|
|
39
|
-
return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? {
|
|
40
|
-
fluid: {
|
|
41
|
-
maxViewportWidth: defaultMaxViewportWidth,
|
|
42
|
-
...typographySettings.fluid
|
|
43
|
-
}
|
|
44
|
-
} : {
|
|
45
|
-
fluid: typographySettings?.fluid
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
2
|
function getMergedFontFamiliesAndFontFamilyFaces(settings, selectedFontFamily) {
|
|
49
3
|
const fontFamiliesFromSettings = settings?.typography?.fontFamilies;
|
|
50
4
|
const fontFamilies = ["default", "theme", "custom"].flatMap(
|
|
@@ -121,8 +75,6 @@ export {
|
|
|
121
75
|
findNearestFontStyle,
|
|
122
76
|
findNearestFontWeight,
|
|
123
77
|
findNearestStyleAndWeight,
|
|
124
|
-
|
|
125
|
-
getMergedFontFamiliesAndFontFamilyFaces,
|
|
126
|
-
getTypographyFontSizeValue
|
|
78
|
+
getMergedFontFamiliesAndFontFamilyFaces
|
|
127
79
|
};
|
|
128
80
|
//# sourceMappingURL=typography-utils.js.map
|