@wordpress/block-editor 12.6.0 → 12.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.
Files changed (199) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +2 -2
  3. package/build/autocompleters/block.js +6 -2
  4. package/build/autocompleters/block.js.map +1 -1
  5. package/build/components/block-editing-mode/index.js +1 -1
  6. package/build/components/block-editing-mode/index.js.map +1 -1
  7. package/build/components/block-list/block.js +4 -2
  8. package/build/components/block-list/block.js.map +1 -1
  9. package/build/components/block-list/index.js +2 -4
  10. package/build/components/block-list/index.js.map +1 -1
  11. package/build/components/block-parent-selector/index.js +6 -21
  12. package/build/components/block-parent-selector/index.js.map +1 -1
  13. package/build/components/block-preview/auto.js +6 -1
  14. package/build/components/block-preview/auto.js.map +1 -1
  15. package/build/components/block-settings-menu/block-settings-dropdown.js +3 -17
  16. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  17. package/build/components/block-toolbar/index.js +4 -34
  18. package/build/components/block-toolbar/index.js.map +1 -1
  19. package/build/components/block-toolbar/utils.js +56 -51
  20. package/build/components/block-toolbar/utils.js.map +1 -1
  21. package/build/components/block-tools/block-contextual-toolbar.js +4 -2
  22. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  23. package/build/components/block-variation-picker/index.native.js +10 -20
  24. package/build/components/block-variation-picker/index.native.js.map +1 -1
  25. package/build/components/editor-styles/index.js +2 -2
  26. package/build/components/editor-styles/index.js.map +1 -1
  27. package/build/components/font-sizes/fluid-utils.js +11 -11
  28. package/build/components/font-sizes/fluid-utils.js.map +1 -1
  29. package/build/components/global-styles/behaviors-panel.js +66 -0
  30. package/build/components/global-styles/behaviors-panel.js.map +1 -0
  31. package/build/components/global-styles/hooks.js +118 -4
  32. package/build/components/global-styles/hooks.js.map +1 -1
  33. package/build/components/global-styles/index.js +20 -0
  34. package/build/components/global-styles/index.js.map +1 -1
  35. package/build/components/global-styles/typography-utils.js +4 -4
  36. package/build/components/global-styles/typography-utils.js.map +1 -1
  37. package/build/components/global-styles/utils.js +1 -1
  38. package/build/components/global-styles/utils.js.map +1 -1
  39. package/build/components/inserter/hooks/use-block-types-state.js +6 -2
  40. package/build/components/inserter/hooks/use-block-types-state.js.map +1 -1
  41. package/build/components/inserter/hooks/use-debounced-input.js +5 -7
  42. package/build/components/inserter/hooks/use-debounced-input.js.map +1 -1
  43. package/build/components/inserter/hooks/use-patterns-state.js +3 -2
  44. package/build/components/inserter/hooks/use-patterns-state.js.map +1 -1
  45. package/build/components/inserter/reusable-blocks-tab.js +3 -2
  46. package/build/components/inserter/reusable-blocks-tab.js.map +1 -1
  47. package/build/components/inserter-list-item/index.js +1 -1
  48. package/build/components/inserter-list-item/index.js.map +1 -1
  49. package/build/components/link-control/index.js +47 -6
  50. package/build/components/link-control/index.js.map +1 -1
  51. package/build/components/link-control/link-preview.js +3 -3
  52. package/build/components/link-control/link-preview.js.map +1 -1
  53. package/build/components/list-view/use-list-view-drop-zone.js +6 -1
  54. package/build/components/list-view/use-list-view-drop-zone.js.map +1 -1
  55. package/build/components/media-replace-flow/index.native.js +15 -3
  56. package/build/components/media-replace-flow/index.native.js.map +1 -1
  57. package/build/components/rich-text/format-edit.js +57 -28
  58. package/build/components/rich-text/format-edit.js.map +1 -1
  59. package/build/components/rich-text/get-rich-text-values.js +11 -18
  60. package/build/components/rich-text/get-rich-text-values.js.map +1 -1
  61. package/build/components/spacing-sizes-control/utils.js +2 -2
  62. package/build/components/spacing-sizes-control/utils.js.map +1 -1
  63. package/build/hooks/behaviors.js +5 -12
  64. package/build/hooks/behaviors.js.map +1 -1
  65. package/build/hooks/border.js +2 -1
  66. package/build/hooks/border.js.map +1 -1
  67. package/build/hooks/style.js +11 -2
  68. package/build/hooks/style.js.map +1 -1
  69. package/build/private-apis.js +4 -1
  70. package/build/private-apis.js.map +1 -1
  71. package/build/store/actions.js +2 -3
  72. package/build/store/actions.js.map +1 -1
  73. package/build/store/selectors.js +4 -71
  74. package/build/store/selectors.js.map +1 -1
  75. package/build-module/autocompleters/block.js +7 -3
  76. package/build-module/autocompleters/block.js.map +1 -1
  77. package/build-module/components/block-editing-mode/index.js +1 -1
  78. package/build-module/components/block-editing-mode/index.js.map +1 -1
  79. package/build-module/components/block-list/block.js +4 -2
  80. package/build-module/components/block-list/block.js.map +1 -1
  81. package/build-module/components/block-list/index.js +2 -3
  82. package/build-module/components/block-list/index.js.map +1 -1
  83. package/build-module/components/block-parent-selector/index.js +7 -22
  84. package/build-module/components/block-parent-selector/index.js.map +1 -1
  85. package/build-module/components/block-preview/auto.js +6 -1
  86. package/build-module/components/block-preview/auto.js.map +1 -1
  87. package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -18
  88. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  89. package/build-module/components/block-toolbar/index.js +6 -36
  90. package/build-module/components/block-toolbar/index.js.map +1 -1
  91. package/build-module/components/block-toolbar/utils.js +54 -49
  92. package/build-module/components/block-toolbar/utils.js.map +1 -1
  93. package/build-module/components/block-tools/block-contextual-toolbar.js +4 -2
  94. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  95. package/build-module/components/block-variation-picker/index.native.js +13 -23
  96. package/build-module/components/block-variation-picker/index.native.js.map +1 -1
  97. package/build-module/components/editor-styles/index.js +2 -2
  98. package/build-module/components/editor-styles/index.js.map +1 -1
  99. package/build-module/components/font-sizes/fluid-utils.js +11 -11
  100. package/build-module/components/font-sizes/fluid-utils.js.map +1 -1
  101. package/build-module/components/global-styles/behaviors-panel.js +57 -0
  102. package/build-module/components/global-styles/behaviors-panel.js.map +1 -0
  103. package/build-module/components/global-styles/hooks.js +115 -5
  104. package/build-module/components/global-styles/hooks.js.map +1 -1
  105. package/build-module/components/global-styles/index.js +2 -1
  106. package/build-module/components/global-styles/index.js.map +1 -1
  107. package/build-module/components/global-styles/typography-utils.js +4 -4
  108. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  109. package/build-module/components/global-styles/utils.js +1 -1
  110. package/build-module/components/global-styles/utils.js.map +1 -1
  111. package/build-module/components/inserter/hooks/use-block-types-state.js +7 -3
  112. package/build-module/components/inserter/hooks/use-block-types-state.js.map +1 -1
  113. package/build-module/components/inserter/hooks/use-debounced-input.js +5 -7
  114. package/build-module/components/inserter/hooks/use-debounced-input.js.map +1 -1
  115. package/build-module/components/inserter/hooks/use-patterns-state.js +3 -2
  116. package/build-module/components/inserter/hooks/use-patterns-state.js.map +1 -1
  117. package/build-module/components/inserter/reusable-blocks-tab.js +3 -2
  118. package/build-module/components/inserter/reusable-blocks-tab.js.map +1 -1
  119. package/build-module/components/inserter-list-item/index.js +1 -1
  120. package/build-module/components/inserter-list-item/index.js.map +1 -1
  121. package/build-module/components/link-control/index.js +45 -6
  122. package/build-module/components/link-control/index.js.map +1 -1
  123. package/build-module/components/link-control/link-preview.js +3 -3
  124. package/build-module/components/link-control/link-preview.js.map +1 -1
  125. package/build-module/components/list-view/use-list-view-drop-zone.js +6 -1
  126. package/build-module/components/list-view/use-list-view-drop-zone.js.map +1 -1
  127. package/build-module/components/media-replace-flow/index.native.js +15 -3
  128. package/build-module/components/media-replace-flow/index.native.js.map +1 -1
  129. package/build-module/components/rich-text/format-edit.js +51 -26
  130. package/build-module/components/rich-text/format-edit.js.map +1 -1
  131. package/build-module/components/rich-text/get-rich-text-values.js +13 -18
  132. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -1
  133. package/build-module/components/spacing-sizes-control/utils.js +2 -2
  134. package/build-module/components/spacing-sizes-control/utils.js.map +1 -1
  135. package/build-module/hooks/behaviors.js +5 -12
  136. package/build-module/hooks/behaviors.js.map +1 -1
  137. package/build-module/hooks/border.js +2 -1
  138. package/build-module/hooks/border.js.map +1 -1
  139. package/build-module/hooks/style.js +11 -2
  140. package/build-module/hooks/style.js.map +1 -1
  141. package/build-module/private-apis.js +3 -1
  142. package/build-module/private-apis.js.map +1 -1
  143. package/build-module/store/actions.js +2 -3
  144. package/build-module/store/actions.js.map +1 -1
  145. package/build-module/store/selectors.js +4 -69
  146. package/build-module/store/selectors.js.map +1 -1
  147. package/build-style/style-rtl.css +18 -5
  148. package/build-style/style.css +18 -5
  149. package/package.json +31 -31
  150. package/src/autocompleters/block.js +21 -6
  151. package/src/components/block-draggable/test/index.native.js +2 -3
  152. package/src/components/block-editing-mode/index.js +1 -1
  153. package/src/components/block-list/block.js +6 -1
  154. package/src/components/block-list/index.js +3 -6
  155. package/src/components/block-list/test/block-invalid-warning.native.js +8 -1
  156. package/src/components/block-mover/test/__snapshots__/index.native.js.snap +24 -0
  157. package/src/components/block-parent-selector/index.js +30 -42
  158. package/src/components/block-preview/auto.js +8 -1
  159. package/src/components/block-preview/style.scss +2 -1
  160. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -13
  161. package/src/components/block-toolbar/index.js +36 -63
  162. package/src/components/block-toolbar/utils.js +57 -45
  163. package/src/components/block-tools/block-contextual-toolbar.js +43 -35
  164. package/src/components/block-tools/style.scss +17 -5
  165. package/src/components/block-variation-picker/index.native.js +52 -72
  166. package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
  167. package/src/components/editor-styles/index.js +2 -2
  168. package/src/components/font-sizes/fluid-utils.js +17 -17
  169. package/src/components/font-sizes/test/fluid-utils.js +6 -6
  170. package/src/components/global-styles/behaviors-panel.js +71 -0
  171. package/src/components/global-styles/hooks.js +114 -5
  172. package/src/components/global-styles/index.js +3 -0
  173. package/src/components/global-styles/test/typography-utils.js +6 -6
  174. package/src/components/global-styles/typography-utils.js +4 -4
  175. package/src/components/global-styles/utils.js +2 -1
  176. package/src/components/inserter/hooks/use-block-types-state.js +15 -6
  177. package/src/components/inserter/hooks/use-debounced-input.js +8 -7
  178. package/src/components/inserter/hooks/use-patterns-state.js +2 -1
  179. package/src/components/inserter/reusable-blocks-tab.js +4 -1
  180. package/src/components/inserter-list-item/index.js +3 -1
  181. package/src/components/link-control/README.md +12 -3
  182. package/src/components/link-control/index.js +43 -6
  183. package/src/components/link-control/link-preview.js +6 -4
  184. package/src/components/link-control/style.scss +3 -2
  185. package/src/components/link-control/test/index.js +2 -1
  186. package/src/components/list-view/use-list-view-drop-zone.js +5 -1
  187. package/src/components/media-replace-flow/index.native.js +12 -3
  188. package/src/components/media-upload/test/index.native.js +1 -0
  189. package/src/components/rich-text/format-edit.js +62 -38
  190. package/src/components/rich-text/get-rich-text-values.js +22 -28
  191. package/src/components/spacing-sizes-control/test/utils.js +9 -1
  192. package/src/components/spacing-sizes-control/utils.js +2 -2
  193. package/src/hooks/behaviors.js +10 -16
  194. package/src/hooks/border.js +2 -1
  195. package/src/hooks/style.js +7 -3
  196. package/src/private-apis.js +2 -0
  197. package/src/store/actions.js +22 -28
  198. package/src/store/selectors.js +3 -80
  199. package/src/store/test/selectors.js +7 -6
@@ -8,13 +8,12 @@ import { ScrollView, View, Text, TouchableWithoutFeedback, Platform } from 'reac
8
8
  * WordPress dependencies
9
9
  */
10
10
 
11
- import { withSelect, useDispatch } from '@wordpress/data';
12
- import { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';
13
- import { createBlocksFromInnerBlocksTemplate, store as blocksStore } from '@wordpress/blocks';
11
+ import { useDispatch } from '@wordpress/data';
12
+ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
13
+ import { createBlocksFromInnerBlocksTemplate } from '@wordpress/blocks';
14
14
  import { __ } from '@wordpress/i18n';
15
15
  import { PanelBody, BottomSheet, FooterMessageControl, InserterButton } from '@wordpress/components';
16
16
  import { Icon, close } from '@wordpress/icons';
17
- import { useMemo } from '@wordpress/element';
18
17
  /**
19
18
  * Internal dependencies
20
19
  */
@@ -39,7 +38,7 @@ function BlockVariationPicker({
39
38
  } = useDispatch(blockEditorStore);
40
39
  const isIOS = Platform.OS === 'ios';
41
40
  const cancelButtonStyle = usePreferredColorSchemeStyle(styles.cancelButton, styles.cancelButtonDark);
42
- const leftButton = useMemo(() => createElement(TouchableWithoutFeedback, {
41
+ const leftButton = createElement(TouchableWithoutFeedback, {
43
42
  onPress: onClose,
44
43
  hitSlop: hitSlop
45
44
  }, createElement(View, null, isIOS ? createElement(Text, {
@@ -49,14 +48,14 @@ function BlockVariationPicker({
49
48
  icon: close,
50
49
  size: 24,
51
50
  style: styles.closeIcon
52
- }))), [onClose, cancelButtonStyle]);
51
+ })));
53
52
 
54
53
  const onVariationSelect = variation => {
55
54
  replaceInnerBlocks(clientId, createBlocksFromInnerBlocksTemplate(variation.innerBlocks));
56
55
  onClose();
57
56
  };
58
57
 
59
- return useMemo(() => createElement(BottomSheet, {
58
+ return createElement(BottomSheet, {
60
59
  isVisible: isVisible,
61
60
  onClose: onClose,
62
61
  title: __('Select a layout'),
@@ -68,23 +67,14 @@ function BlockVariationPicker({
68
67
  showsHorizontalScrollIndicator: false,
69
68
  contentContainerStyle: styles.contentContainerStyle,
70
69
  style: styles.containerStyle
71
- }, variations.map(v => {
72
- return createElement(InserterButton, {
73
- item: v,
74
- key: v.name,
75
- onSelect: () => onVariationSelect(v)
76
- });
77
- })), createElement(PanelBody, null, createElement(FooterMessageControl, {
70
+ }, variations.map(v => createElement(InserterButton, {
71
+ item: v,
72
+ key: v.name,
73
+ onSelect: () => onVariationSelect(v)
74
+ }))), createElement(PanelBody, null, createElement(FooterMessageControl, {
78
75
  label: __('Note: Column layout may vary between themes and screen sizes')
79
- }))), [variations, isVisible, onClose]);
76
+ })));
80
77
  }
81
78
 
82
- export default compose(withSelect((select, {}) => {
83
- const {
84
- getBlockVariations
85
- } = select(blocksStore);
86
- return {
87
- date: getBlockVariations('core/columns', 'block')
88
- };
89
- }))(BlockVariationPicker);
79
+ export default BlockVariationPicker;
90
80
  //# sourceMappingURL=index.native.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-variation-picker/index.native.js"],"names":["ScrollView","View","Text","TouchableWithoutFeedback","Platform","withSelect","useDispatch","compose","usePreferredColorSchemeStyle","createBlocksFromInnerBlocksTemplate","store","blocksStore","__","PanelBody","BottomSheet","FooterMessageControl","InserterButton","Icon","close","useMemo","styles","blockEditorStore","hitSlop","top","bottom","left","right","BlockVariationPicker","isVisible","onClose","clientId","variations","replaceInnerBlocks","isIOS","OS","cancelButtonStyle","cancelButton","cancelButtonDark","leftButton","closeIcon","onVariationSelect","variation","innerBlocks","contentStyle","contentContainerStyle","containerStyle","map","v","name","select","getBlockVariations","date"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,UADD,EAECC,IAFD,EAGCC,IAHD,EAICC,wBAJD,EAKCC,QALD,QAMO,cANP;AAQA;AACA;AACA;;AACA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,iBAAxC;AACA,SAASC,OAAT,EAAkBC,4BAAlB,QAAsD,oBAAtD;AACA,SACCC,mCADD,EAECC,KAAK,IAAIC,WAFV,QAGO,mBAHP;AAIA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,SADD,EAECC,WAFD,EAGCC,oBAHD,EAICC,cAJD,QAKO,uBALP;AAMA,SAASC,IAAT,EAAeC,KAAf,QAA4B,kBAA5B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAOC,MAAP,MAAmB,cAAnB;AACA,SAASV,KAAK,IAAIW,gBAAlB,QAA0C,aAA1C;AAEA,MAAMC,OAAO,GAAG;AAAEC,EAAAA,GAAG,EAAE,EAAP;AAAWC,EAAAA,MAAM,EAAE,EAAnB;AAAuBC,EAAAA,IAAI,EAAE,EAA7B;AAAiCC,EAAAA,KAAK,EAAE;AAAxC,CAAhB;;AAEA,SAASC,oBAAT,CAA+B;AAAEC,EAAAA,SAAF;AAAaC,EAAAA,OAAb;AAAsBC,EAAAA,QAAtB;AAAgCC,EAAAA;AAAhC,CAA/B,EAA8E;AAC7E,QAAM;AAAEC,IAAAA;AAAF,MAAyB1B,WAAW,CAAEe,gBAAF,CAA1C;AACA,QAAMY,KAAK,GAAG7B,QAAQ,CAAC8B,EAAT,KAAgB,KAA9B;AAEA,QAAMC,iB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AAI,EAAGA,CADR;AAEC,MAAA,GAAG,EAAGA,CAAC,CAACC,IAFT;AAGC,MAAA,QAAQ,EAAG,MAAMR,iBAAiB,CAAEO,CAAF;AAHnC,MADD;AAOA,GARC,CANH,CARD,EAwBC,cAAC,SAAD,QACC,cAAC,oBAAD;AACC,IAAA,KAAK,EAAGnC,EAAE,CACT,8DADS;AADX,IADD,CAxBD,CAFY,EAmCb,CAAEmB,UAAF,EAAcH,SAAd,EAAyBC,OAAzB,CAnCa,CAAd;AAqCA;;AAED,eAAetB,OAAO,CACrBF,UAAU,CAAE,CAAE4C,MAAF,EAAU,EAAV,KAAkB;AAC7B,QAAM;AAAEC,IAAAA;AAAF,MAAyBD,MAAM,CAAEtC,WAAF,CAArC;AAEA,SAAO;AACNwC,IAAAA,IAAI,EAAED,kBAAkB,CAAE,cAAF,EAAkB,OAAlB;AADlB,GAAP;AAGA,CANS,CADW,CAAP,CAQZvB,oBARY,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tScrollView,\n\tView,\n\tText,\n\tTouchableWithoutFeedback,\n\tPlatform,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { withSelect, useDispatch } from '@wordpress/data';\nimport { compose, usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPanelBody,\n\tBottomSheet,\n\tFooterMessageControl,\n\tInserterButton,\n} from '@wordpress/components';\nimport { Icon, close } from '@wordpress/icons';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport { store as blockEditorStore } from '../../store';\n\nconst hitSlop = { top: 22, bottom: 22, left: 22, right: 22 };\n\nfunction BlockVariationPicker( { isVisible, onClose, clientId, variations } ) {\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst isIOS = Platform.OS === 'ios';\n\n\tconst cancelButtonStyle = usePreferredColorSchemeStyle(\n\t\tstyles.cancelButton,\n\t\tstyles.cancelButtonDark\n\t);\n\n\tconst leftButton = useMemo(\n\t\t() => (\n\t\t\t<TouchableWithoutFeedback onPress={ onClose } hitSlop={ hitSlop }>\n\t\t\t\t<View>\n\t\t\t\t\t{ isIOS ? (\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tstyle={ cancelButtonStyle }\n\t\t\t\t\t\t\tmaxFontSizeMultiplier={ 2 }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\t\tstyle={ styles.closeIcon }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</View>\n\t\t\t</TouchableWithoutFeedback>\n\t\t),\n\t\t[ onClose, cancelButtonStyle ]\n\t);\n\n\tconst onVariationSelect = ( variation ) => {\n\t\treplaceInnerBlocks(\n\t\t\tclientId,\n\t\t\tcreateBlocksFromInnerBlocksTemplate( variation.innerBlocks )\n\t\t);\n\t\tonClose();\n\t};\n\n\treturn useMemo(\n\t\t() => (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ isVisible }\n\t\t\t\tonClose={ onClose }\n\t\t\t\ttitle={ __( 'Select a layout' ) }\n\t\t\t\tcontentStyle={ styles.contentStyle }\n\t\t\t\tleftButton={ leftButton }\n\t\t\t\ttestID=\"block-variation-modal\"\n\t\t\t>\n\t\t\t\t<ScrollView\n\t\t\t\t\thorizontal\n\t\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\t\tcontentContainerStyle={ styles.contentContainerStyle }\n\t\t\t\t\tstyle={ styles.containerStyle }\n\t\t\t\t>\n\t\t\t\t\t{ variations.map( ( v ) => {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<InserterButton\n\t\t\t\t\t\t\t\titem={ v }\n\t\t\t\t\t\t\t\tkey={ v.name }\n\t\t\t\t\t\t\t\tonSelect={ () => onVariationSelect( v ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</ScrollView>\n\t\t\t\t<PanelBody>\n\t\t\t\t\t<FooterMessageControl\n\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t'Note: Column layout may vary between themes and screen sizes'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</BottomSheet>\n\t\t),\n\t\t[ variations, isVisible, onClose ]\n\t);\n}\n\nexport default compose(\n\twithSelect( ( select, {} ) => {\n\t\tconst { getBlockVariations } = select( blocksStore );\n\n\t\treturn {\n\t\t\tdate: getBlockVariations( 'core/columns', 'block' ),\n\t\t};\n\t} )\n)( BlockVariationPicker );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-variation-picker/index.native.js"],"names":["ScrollView","View","Text","TouchableWithoutFeedback","Platform","useDispatch","usePreferredColorSchemeStyle","createBlocksFromInnerBlocksTemplate","__","PanelBody","BottomSheet","FooterMessageControl","InserterButton","Icon","close","styles","store","blockEditorStore","hitSlop","top","bottom","left","right","BlockVariationPicker","isVisible","onClose","clientId","variations","replaceInnerBlocks","isIOS","OS","cancelButtonStyle","cancelButton","cancelButtonDark","leftButton","closeIcon","onVariationSelect","variation","innerBlocks","contentStyle","contentContainerStyle","containerStyle","map","v","name"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,UADD,EAECC,IAFD,EAGCC,IAHD,EAICC,wBAJD,EAKCC,QALD,QAMO,cANP;AAQA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,4BAAT,QAA6C,oBAA7C;AACA,SAASC,mCAAT,QAAoD,mBAApD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,SADD,EAECC,WAFD,EAGCC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CAAlB;AAIAb,IAAAA,OAAO;AACP,GAND;;AAQA,SACC,cAAC,WAAD;AACC,IAAA,SAAS,EAAGD,SADb;AAEC,IAAA,OAAO,EAAGC,OAFX;AAGC,IAAA,KAAK,EAAGjB,EAAE,CAAE,iBAAF,CAHX;AAIC,IAAA,YAAY,EAAGO,MAAM,CAACwB,YAJvB;AAKC,IAAA,UAAU,EAAGL,UALd;AAMC,IAAA,MAAM,EAAC;AANR,KAQC,cAAC,UAAD;AACC,IAAA,UAAU,MADX;AAEC,IAAA,8BAA8B,EAAG,KAFlC;AAGC,IAAA,qBAAqB,EAAGnB,MAAM,CAACyB,qBAHhC;AAIC,IAAA,KAAK,EAAGzB,MAAM,CAAC0B;AAJhB,KAMGd,UAAU,CAACe,GAAX,CAAkBC,CAAF,IACjB,cAAC,cAAD;AACC,IAAA,IAAI,EAAGA,CADR;AAEC,IAAA,GAAG,EAAGA,CAAC,CAACC,IAFT;AAGC,IAAA,QAAQ,EAAG,MAAMR,iBAAiB,CAAEO,CAAF;AAHnC,IADC,CANH,CARD,EAsBC,cAAC,SAAD,QACC,cAAC,oBAAD;AACC,IAAA,KAAK,EAAGnC,EAAE,CACT,8DADS;AADX,IADD,CAtBD,CADD;AAgCA;;AAED,eAAee,oBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tScrollView,\n\tView,\n\tText,\n\tTouchableWithoutFeedback,\n\tPlatform,\n} from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { usePreferredColorSchemeStyle } from '@wordpress/compose';\nimport { createBlocksFromInnerBlocksTemplate } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tPanelBody,\n\tBottomSheet,\n\tFooterMessageControl,\n\tInserterButton,\n} from '@wordpress/components';\nimport { Icon, close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\nimport { store as blockEditorStore } from '../../store';\n\nconst hitSlop = { top: 22, bottom: 22, left: 22, right: 22 };\n\nfunction BlockVariationPicker( { isVisible, onClose, clientId, variations } ) {\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst isIOS = Platform.OS === 'ios';\n\n\tconst cancelButtonStyle = usePreferredColorSchemeStyle(\n\t\tstyles.cancelButton,\n\t\tstyles.cancelButtonDark\n\t);\n\n\tconst leftButton = (\n\t\t<TouchableWithoutFeedback onPress={ onClose } hitSlop={ hitSlop }>\n\t\t\t<View>\n\t\t\t\t{ isIOS ? (\n\t\t\t\t\t<Text\n\t\t\t\t\t\tstyle={ cancelButtonStyle }\n\t\t\t\t\t\tmaxFontSizeMultiplier={ 2 }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Text>\n\t\t\t\t) : (\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ close }\n\t\t\t\t\t\tsize={ 24 }\n\t\t\t\t\t\tstyle={ styles.closeIcon }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</View>\n\t\t</TouchableWithoutFeedback>\n\t);\n\n\tconst onVariationSelect = ( variation ) => {\n\t\treplaceInnerBlocks(\n\t\t\tclientId,\n\t\t\tcreateBlocksFromInnerBlocksTemplate( variation.innerBlocks )\n\t\t);\n\t\tonClose();\n\t};\n\n\treturn (\n\t\t<BottomSheet\n\t\t\tisVisible={ isVisible }\n\t\t\tonClose={ onClose }\n\t\t\ttitle={ __( 'Select a layout' ) }\n\t\t\tcontentStyle={ styles.contentStyle }\n\t\t\tleftButton={ leftButton }\n\t\t\ttestID=\"block-variation-modal\"\n\t\t>\n\t\t\t<ScrollView\n\t\t\t\thorizontal\n\t\t\t\tshowsHorizontalScrollIndicator={ false }\n\t\t\t\tcontentContainerStyle={ styles.contentContainerStyle }\n\t\t\t\tstyle={ styles.containerStyle }\n\t\t\t>\n\t\t\t\t{ variations.map( ( v ) => (\n\t\t\t\t\t<InserterButton\n\t\t\t\t\t\titem={ v }\n\t\t\t\t\t\tkey={ v.name }\n\t\t\t\t\t\tonSelect={ () => onVariationSelect( v ) }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t</ScrollView>\n\t\t\t<PanelBody>\n\t\t\t\t<FooterMessageControl\n\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t'Note: Column layout may vary between themes and screen sizes'\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</BottomSheet>\n\t);\n}\n\nexport default BlockVariationPicker;\n"]}
@@ -43,10 +43,10 @@ function useDarkThemeBodyClassName(styles) {
43
43
  const tempCanvas = ownerDocument.createElement('div');
44
44
  tempCanvas.classList.add('editor-styles-wrapper');
45
45
  body.appendChild(tempCanvas);
46
- backgroundColor = defaultView.getComputedStyle(tempCanvas, null).getPropertyValue('background-color');
46
+ backgroundColor = defaultView?.getComputedStyle(tempCanvas, null).getPropertyValue('background-color');
47
47
  body.removeChild(tempCanvas);
48
48
  } else {
49
- backgroundColor = defaultView.getComputedStyle(canvas, null).getPropertyValue('background-color');
49
+ backgroundColor = defaultView?.getComputedStyle(canvas, null).getPropertyValue('background-color');
50
50
  }
51
51
 
52
52
  const colordBackgroundColor = colord(backgroundColor); // If background is transparent, it should be treated as light color.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/editor-styles/index.js"],"names":["colord","extend","namesPlugin","a11yPlugin","SVG","useCallback","useMemo","transformStyles","EDITOR_STYLES_SELECTOR","useDarkThemeBodyClassName","styles","node","ownerDocument","defaultView","body","canvas","querySelector","backgroundColor","tempCanvas","createElement","classList","add","appendChild","getComputedStyle","getPropertyValue","removeChild","colordBackgroundColor","luminance","alpha","remove","EditorStyles","stylesArray","Object","values","transformedStyles","filter","style","css","transformedSvgs","__unstableType","map","assets","join","index","visibility","position","left","overflow","__html"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;A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,IAAI,EAAC,MALN;AAMC,IAAA,KAAK,EAAG;AACPO,MAAAA,UAAU,EAAE,QADL;AAEPC,MAAAA,QAAQ,EAAE,UAFH;AAGPC,MAAAA,IAAI,EAAE,SAHC;AAIPC,MAAAA,QAAQ,EAAE;AAJH,KANT;AAYC,IAAA,uBAAuB,EAAG;AAAEC,MAAAA,MAAM,EAAEV;AAAV;AAZ3B,IAPD,CADD;AAwBA","sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { SVG } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport transformStyles from '../../utils/transform-styles';\n\nconst EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction useDarkThemeBodyClassName( styles ) {\n\treturn useCallback(\n\t\t( node ) => {\n\t\t\tif ( ! node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView, body } = ownerDocument;\n\t\t\tconst canvas = ownerDocument.querySelector(\n\t\t\t\tEDITOR_STYLES_SELECTOR\n\t\t\t);\n\n\t\t\tlet backgroundColor;\n\n\t\t\tif ( ! canvas ) {\n\t\t\t\t// The real .editor-styles-wrapper element might not exist in the\n\t\t\t\t// DOM, so calculate the background color by creating a fake\n\t\t\t\t// wrapper.\n\t\t\t\tconst tempCanvas = ownerDocument.createElement( 'div' );\n\t\t\t\ttempCanvas.classList.add( 'editor-styles-wrapper' );\n\t\t\t\tbody.appendChild( tempCanvas );\n\n\t\t\t\tbackgroundColor = defaultView\n\t\t\t\t\t.getComputedStyle( tempCanvas, null )\n\t\t\t\t\t.getPropertyValue( 'background-color' );\n\n\t\t\t\tbody.removeChild( tempCanvas );\n\t\t\t} else {\n\t\t\t\tbackgroundColor = defaultView\n\t\t\t\t\t.getComputedStyle( canvas, null )\n\t\t\t\t\t.getPropertyValue( 'background-color' );\n\t\t\t}\n\t\t\tconst colordBackgroundColor = colord( backgroundColor );\n\t\t\t// If background is transparent, it should be treated as light color.\n\t\t\tif (\n\t\t\t\tcolordBackgroundColor.luminance() > 0.5 ||\n\t\t\t\tcolordBackgroundColor.alpha() === 0\n\t\t\t) {\n\t\t\t\tbody.classList.remove( 'is-dark-theme' );\n\t\t\t} else {\n\t\t\t\tbody.classList.add( 'is-dark-theme' );\n\t\t\t}\n\t\t},\n\t\t[ styles ]\n\t);\n}\n\nexport default function EditorStyles( { styles } ) {\n\tconst stylesArray = useMemo(\n\t\t() => Object.values( styles ?? [] ),\n\t\t[ styles ]\n\t);\n\tconst transformedStyles = useMemo(\n\t\t() =>\n\t\t\ttransformStyles(\n\t\t\t\tstylesArray.filter( ( style ) => style?.css ),\n\t\t\t\tEDITOR_STYLES_SELECTOR\n\t\t\t),\n\t\t[ stylesArray ]\n\t);\n\n\tconst transformedSvgs = useMemo(\n\t\t() =>\n\t\t\tstylesArray\n\t\t\t\t.filter( ( style ) => style.__unstableType === 'svgs' )\n\t\t\t\t.map( ( style ) => style.assets )\n\t\t\t\t.join( '' ),\n\t\t[ stylesArray ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ /* Use an empty style element to have a document reference,\n\t\t\t but this could be any element. */ }\n\t\t\t<style ref={ useDarkThemeBodyClassName( stylesArray ) } />\n\t\t\t{ transformedStyles.map( ( css, index ) => (\n\t\t\t\t<style key={ index }>{ css }</style>\n\t\t\t) ) }\n\t\t\t<SVG\n\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\tviewBox=\"0 0 0 0\"\n\t\t\t\twidth=\"0\"\n\t\t\t\theight=\"0\"\n\t\t\t\trole=\"none\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tleft: '-9999px',\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t} }\n\t\t\t\tdangerouslySetInnerHTML={ { __html: transformedSvgs } }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/editor-styles/index.js"],"names":["colord","extend","namesPlugin","a11yPlugin","SVG","useCallback","useMemo","transformStyles","EDITOR_STYLES_SELECTOR","useDarkThemeBodyClassName","styles","node","ownerDocument","defaultView","body","canvas","querySelector","backgroundColor","tempCanvas","createElement","classList","add","appendChild","getComputedStyle","getPropertyValue","removeChild","colordBackgroundColor","luminance","alpha","remove","EditorStyles","stylesArray","Object","values","transformedStyles","filter","style","css","transformedSvgs","__unstableType","map","assets","join","index","visibility","position","left","overflow","__html"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,MAAjB,QAA+B,QAA/B;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AACA,OAAOC,UAAP,MAAuB,qBAAvB;AAEA;AACA;AACA;;AACA,SAASC,GAAT,QAAoB,uBAApB;AACA,SAASC,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,OAAOC,eAAP,MAA4B,8BAA5B;AAEA,MAAMC,sBAAsB,GAAG,wBAA/B;AACAP,MAAM,CAAE,CAAEC,WAAF,EAAeC,UAAf,CAAF,CAAN;;AAEA,SAASM,yBAAT,CAAoCC,MAApC,EAA6C;AAC5C,SAAOL,WAAW,CACfM,IAAF,IAAY;AACX,QAAK,CAAEA,IAAP,EAAc;AACb;AACA;;AAED,UAAM;AAAEC,MAAAA;AAAF,QAAoBD,IAA1B;AACA,UAAM;AAAEE,MAAAA,WAAF;AAAeC,MAAAA;AAAf,QAAwBF,aAA9B;AACA,UAAMG,MAAM,GAAGH,aAAa,CAACI,aAAd,CACdR,sBADc,CAAf;AAIA,QAAIS,eAAJ;;AAEA,QAAK,CAAEF,MAAP,EAAgB;AACf;AACA;AACA;AACA,YAAMG,UAAU,GAAGN,aAA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C,OAAO,CAC9B,MACCyB,WAAW,CACTI,MADF,CACYC,KAAF,IAAaA,KAAK,CAACG,cAAN,KAAyB,MADhD,EAEEC,GAFF,CAESJ,KAAF,IAAaA,KAAK,CAACK,MAF1B,EAGEC,IAHF,CAGQ,EAHR,CAF6B,EAM9B,CAAEX,WAAF,CAN8B,CAA/B;AASA,SACC,8BAGC;AAAO,IAAA,GAAG,EAAGtB,yBAAyB,CAAEsB,WAAF;AAAtC,IAHD,EAIGG,iBAAiB,CAACM,GAAlB,CAAuB,CAAEH,GAAF,EAAOM,KAAP,KACxB;AAAO,IAAA,GAAG,EAAGA;AAAb,KAAuBN,GAAvB,CADC,CAJH,EAOC,cAAC,GAAD;AACC,IAAA,KAAK,EAAC,4BADP;AAEC,IAAA,OAAO,EAAC,SAFT;AAGC,IAAA,KAAK,EAAC,GAHP;AAIC,IAAA,MAAM,EAAC,GAJR;AAKC,IAAA,IAAI,EAAC,MALN;AAMC,IAAA,KAAK,EAAG;AACPO,MAAAA,UAAU,EAAE,QADL;AAEPC,MAAAA,QAAQ,EAAE,UAFH;AAGPC,MAAAA,IAAI,EAAE,SAHC;AAIPC,MAAAA,QAAQ,EAAE;AAJH,KANT;AAYC,IAAA,uBAAuB,EAAG;AAAEC,MAAAA,MAAM,EAAEV;AAAV;AAZ3B,IAPD,CADD;AAwBA","sourcesContent":["/**\n * External dependencies\n */\nimport { colord, extend } from 'colord';\nimport namesPlugin from 'colord/plugins/names';\nimport a11yPlugin from 'colord/plugins/a11y';\n\n/**\n * WordPress dependencies\n */\nimport { SVG } from '@wordpress/components';\nimport { useCallback, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport transformStyles from '../../utils/transform-styles';\n\nconst EDITOR_STYLES_SELECTOR = '.editor-styles-wrapper';\nextend( [ namesPlugin, a11yPlugin ] );\n\nfunction useDarkThemeBodyClassName( styles ) {\n\treturn useCallback(\n\t\t( node ) => {\n\t\t\tif ( ! node ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView, body } = ownerDocument;\n\t\t\tconst canvas = ownerDocument.querySelector(\n\t\t\t\tEDITOR_STYLES_SELECTOR\n\t\t\t);\n\n\t\t\tlet backgroundColor;\n\n\t\t\tif ( ! canvas ) {\n\t\t\t\t// The real .editor-styles-wrapper element might not exist in the\n\t\t\t\t// DOM, so calculate the background color by creating a fake\n\t\t\t\t// wrapper.\n\t\t\t\tconst tempCanvas = ownerDocument.createElement( 'div' );\n\t\t\t\ttempCanvas.classList.add( 'editor-styles-wrapper' );\n\t\t\t\tbody.appendChild( tempCanvas );\n\n\t\t\t\tbackgroundColor = defaultView\n\t\t\t\t\t?.getComputedStyle( tempCanvas, null )\n\t\t\t\t\t.getPropertyValue( 'background-color' );\n\n\t\t\t\tbody.removeChild( tempCanvas );\n\t\t\t} else {\n\t\t\t\tbackgroundColor = defaultView\n\t\t\t\t\t?.getComputedStyle( canvas, null )\n\t\t\t\t\t.getPropertyValue( 'background-color' );\n\t\t\t}\n\t\t\tconst colordBackgroundColor = colord( backgroundColor );\n\t\t\t// If background is transparent, it should be treated as light color.\n\t\t\tif (\n\t\t\t\tcolordBackgroundColor.luminance() > 0.5 ||\n\t\t\t\tcolordBackgroundColor.alpha() === 0\n\t\t\t) {\n\t\t\t\tbody.classList.remove( 'is-dark-theme' );\n\t\t\t} else {\n\t\t\t\tbody.classList.add( 'is-dark-theme' );\n\t\t\t}\n\t\t},\n\t\t[ styles ]\n\t);\n}\n\nexport default function EditorStyles( { styles } ) {\n\tconst stylesArray = useMemo(\n\t\t() => Object.values( styles ?? [] ),\n\t\t[ styles ]\n\t);\n\tconst transformedStyles = useMemo(\n\t\t() =>\n\t\t\ttransformStyles(\n\t\t\t\tstylesArray.filter( ( style ) => style?.css ),\n\t\t\t\tEDITOR_STYLES_SELECTOR\n\t\t\t),\n\t\t[ stylesArray ]\n\t);\n\n\tconst transformedSvgs = useMemo(\n\t\t() =>\n\t\t\tstylesArray\n\t\t\t\t.filter( ( style ) => style.__unstableType === 'svgs' )\n\t\t\t\t.map( ( style ) => style.assets )\n\t\t\t\t.join( '' ),\n\t\t[ stylesArray ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ /* Use an empty style element to have a document reference,\n\t\t\t but this could be any element. */ }\n\t\t\t<style ref={ useDarkThemeBodyClassName( stylesArray ) } />\n\t\t\t{ transformedStyles.map( ( css, index ) => (\n\t\t\t\t<style key={ index }>{ css }</style>\n\t\t\t) ) }\n\t\t\t<SVG\n\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\tviewBox=\"0 0 0 0\"\n\t\t\t\twidth=\"0\"\n\t\t\t\theight=\"0\"\n\t\t\t\trole=\"none\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tleft: '-9999px',\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t} }\n\t\t\t\tdangerouslySetInnerHTML={ { __html: transformedSvgs } }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
@@ -30,8 +30,8 @@ const DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';
30
30
  * ```
31
31
  *
32
32
  * @param {Object} args
33
- * @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.
34
- * @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.
33
+ * @param {?string} args.minimumViewportWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.
34
+ * @param {?string} args.maximumViewportWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.
35
35
  * @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.
36
36
  * @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.
37
37
  * @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.
@@ -45,8 +45,8 @@ export function getComputedFluidTypographyValue({
45
45
  minimumFontSize,
46
46
  maximumFontSize,
47
47
  fontSize,
48
- minimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
49
- maximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
48
+ minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
49
+ maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
50
50
  scaleFactor = DEFAULT_SCALE_FACTOR,
51
51
  minimumFontSizeLimit
52
52
  }) {
@@ -131,24 +131,24 @@ export function getComputedFluidTypographyValue({
131
131
  coerceTo: 'rem'
132
132
  }); // Viewport widths defined for fluid typography. Normalize units
133
133
 
134
- const maximumViewPortWidthParsed = getTypographyValueAndUnit(maximumViewPortWidth, {
134
+ const maximumViewportWidthParsed = getTypographyValueAndUnit(maximumViewportWidth, {
135
135
  coerceTo: fontSizeUnit
136
136
  });
137
- const minumumViewPortWidthParsed = getTypographyValueAndUnit(minimumViewPortWidth, {
137
+ const minimumViewportWidthParsed = getTypographyValueAndUnit(minimumViewportWidth, {
138
138
  coerceTo: fontSizeUnit
139
139
  }); // Protect against unsupported units.
140
140
 
141
- if (!maximumViewPortWidthParsed || !minumumViewPortWidthParsed || !minimumFontSizeRem) {
141
+ if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) {
142
142
  return null;
143
143
  } // Build CSS rule.
144
144
  // Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.
145
145
 
146
146
 
147
- const minViewPortWidthOffsetValue = roundToPrecision(minumumViewPortWidthParsed.value / 100, 3);
148
- const viewPortWidthOffset = roundToPrecision(minViewPortWidthOffsetValue, 3) + fontSizeUnit;
149
- const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / (maximumViewPortWidthParsed.value - minumumViewPortWidthParsed.value));
147
+ const minViewportWidthOffsetValue = roundToPrecision(minimumViewportWidthParsed.value / 100, 3);
148
+ const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit;
149
+ const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / (maximumViewportWidthParsed.value - minimumViewportWidthParsed.value));
150
150
  const linearFactorScaled = roundToPrecision((linearFactor || 1) * scaleFactor, 3);
151
- const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewPortWidthOffset}) * ${linearFactorScaled})`;
151
+ const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewportWidthOffset}) * ${linearFactorScaled})`;
152
152
  return `clamp(${minimumFontSize}, ${fluidTargetFontSize}, ${maximumFontSize})`;
153
153
  }
154
154
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/font-sizes/fluid-utils.js"],"names":["DEFAULT_MAXIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_VIEWPORT_WIDTH","DEFAULT_SCALE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN","DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX","DEFAULT_MINIMUM_FONT_SIZE_LIMIT","getComputedFluidTypographyValue","minimumFontSize","maximumFontSize","fontSize","minimumViewPortWidth","maximumViewPortWidth","scaleFactor","minimumFontSizeLimit","getTypographyValueAndUnit","fontSizeParsed","unit","minimumFontSizeLimitParsed","coerceTo","value","fontSizeValueInPx","minimumFontSizeFactor","Math","min","max","log2","calculatedMinimumFontSize","roundToPrecision","minimumFontSizeParsed","fontSizeUnit","maximumFontSizeParsed","minimumFontSizeRem","maximumViewPortWidthParsed","minumumViewPortWidthParsed","minViewPortWidthOffsetValue","viewPortWidthOffset","linearFactor","linearFactorScaled","fluidTargetFontSize","rawValue","options","isFinite","rootSizeValue","acceptableUnits","acceptableUnitsGroup","join","regexUnits","RegExp","matches","match","length","returnValue","parseFloat","digits","base","pow","Number","round","undefined"],"mappings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,IAAI,GAAGE,QAAP;AACA;;AAED,MAAK,SAASF,IAAT,KAAmB,SAASE,QAAT,IAAqB,UAAUA,QAAlD,CAAL,EAAoE;AACnEiC,IAAAA,WAAW,GAAGA,WAAW,GAAGT,aAA5B;AACA1B,IAAAA,IAAI,GAAGE,QAAP;AACA;AAED;AACD;AACA;AACA;AACA;;;AACC,MACC,CAAE,SAASA,QAAT,IAAqB,UAAUA,QAAjC,MACE,SAASF,IAAT,IAAiB,UAAUA,IAD7B,CADD,EAGE;AACDA,IAAAA,IAAI,GAAGE,QAAP;AACA;;AAED,SAAO;AACNC,IAAAA,KAAK,EAAEQ,gBAAgB,CAAEwB,WAAF,EAAe,CAAf,CADjB;AAENnC,IAAAA;AAFM,GAAP;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASW,gBAAT,CAA2BR,KAA3B,EAAkCkC,MAAM,GAAG,CAA3C,EAA+C;AACrD,QAAMC,IAAI,GAAGhC,IAAI,CAACiC,GAAL,CAAU,EAAV,EAAcF,MAAd,CAAb;AACA,SAAOG,MAAM,CAACf,QAAP,CAAiBtB,KAAjB,IACJiC,UAAU,CAAE9B,IAAI,CAACmC,KAAL,CAAYtC,KAAK,GAAGmC,IAApB,IAA6BA,IAA/B,CADN,GAEJI,SAFH;AAGA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n// Defaults.\nconst DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';\nconst DEFAULT_MINIMUM_VIEWPORT_WIDTH = '320px';\nconst DEFAULT_SCALE_FACTOR = 1;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;\nconst DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';\n\n/**\n * Computes a fluid font-size value that uses clamp(). A minimum and maximum\n * font size OR a single font size can be specified.\n *\n * If a single font size is specified, it is scaled up and down using a logarithmic scale.\n *\n * @example\n * ```js\n * // Calculate fluid font-size value from a minimum and maximum value.\n * const fontSize = getComputedFluidTypographyValue( {\n * minimumFontSize: '20px',\n * maximumFontSize: '45px'\n * } );\n * // Calculate fluid font-size value from a single font size.\n * const fontSize = getComputedFluidTypographyValue( {\n * fontSize: '30px',\n * } );\n * ```\n *\n * @param {Object} args\n * @param {?string} args.minimumViewPortWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.\n * @param {?string} args.maximumViewPortWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.\n * @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.\n * @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.\n * @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.\n * @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.\n *\n * @return {string|null} A font-size value using clamp().\n */\nexport function getComputedFluidTypographyValue( {\n\tminimumFontSize,\n\tmaximumFontSize,\n\tfontSize,\n\tminimumViewPortWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,\n\tmaximumViewPortWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,\n\tscaleFactor = DEFAULT_SCALE_FACTOR,\n\tminimumFontSizeLimit,\n} ) {\n\t// Validate incoming settings and set defaults.\n\tminimumFontSizeLimit = !! getTypographyValueAndUnit( minimumFontSizeLimit )\n\t\t? minimumFontSizeLimit\n\t\t: DEFAULT_MINIMUM_FONT_SIZE_LIMIT;\n\n\t/*\n\t * Calculates missing minimumFontSize and maximumFontSize from\n\t * defaultFontSize if provided.\n\t */\n\tif ( fontSize ) {\n\t\t// Parses default font size.\n\t\tconst fontSizeParsed = getTypographyValueAndUnit( fontSize );\n\n\t\t// Protect against invalid units.\n\t\tif ( ! fontSizeParsed?.unit ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parses the minimum font size limit, so we can perform checks using it.\n\t\tconst minimumFontSizeLimitParsed = getTypographyValueAndUnit(\n\t\t\tminimumFontSizeLimit,\n\t\t\t{\n\t\t\t\tcoerceTo: fontSizeParsed.unit,\n\t\t\t}\n\t\t);\n\n\t\t// Don't enforce minimum font size if a font size has explicitly set a min and max value.\n\t\tif (\n\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t! minimumFontSize &&\n\t\t\t! maximumFontSize\n\t\t) {\n\t\t\t/*\n\t\t\t * If a minimum size was not passed to this function\n\t\t\t * and the user-defined font size is lower than $minimum_font_size_limit,\n\t\t\t * do not calculate a fluid value.\n\t\t\t */\n\t\t\tif ( fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\t// If no fluid max font size is available use the incoming value.\n\t\tif ( ! maximumFontSize ) {\n\t\t\tmaximumFontSize = `${ fontSizeParsed.value }${ fontSizeParsed.unit }`;\n\t\t}\n\n\t\t/*\n\t\t * If no minimumFontSize is provided, create one using\n\t\t * the given font size multiplied by the min font size scale factor.\n\t\t */\n\t\tif ( ! minimumFontSize ) {\n\t\t\tconst fontSizeValueInPx =\n\t\t\t\tfontSizeParsed.unit === 'px'\n\t\t\t\t\t? fontSizeParsed.value\n\t\t\t\t\t: fontSizeParsed.value * 16;\n\n\t\t\t/*\n\t\t\t * The scale factor is a multiplier that affects how quickly the curve will move towards the minimum,\n\t\t\t * that is, how quickly the size factor reaches 0 given increasing font size values.\n\t\t\t * For a - b * log2(), lower values of b will make the curve move towards the minimum faster.\n\t\t\t * The scale factor is constrained between min and max values.\n\t\t\t */\n\t\t\tconst minimumFontSizeFactor = Math.min(\n\t\t\t\tMath.max(\n\t\t\t\t\t1 - 0.075 * Math.log2( fontSizeValueInPx ),\n\t\t\t\t\tDEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN\n\t\t\t\t),\n\t\t\t\tDEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX\n\t\t\t);\n\n\t\t\t// Calculates the minimum font size.\n\t\t\tconst calculatedMinimumFontSize = roundToPrecision(\n\t\t\t\tfontSizeParsed.value * minimumFontSizeFactor,\n\t\t\t\t3\n\t\t\t);\n\n\t\t\t// Only use calculated min font size if it's > $minimum_font_size_limit value.\n\t\t\tif (\n\t\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t\tcalculatedMinimumFontSize < minimumFontSizeLimitParsed?.value\n\t\t\t) {\n\t\t\t\tminimumFontSize = `${ minimumFontSizeLimitParsed.value }${ minimumFontSizeLimitParsed.unit }`;\n\t\t\t} else {\n\t\t\t\tminimumFontSize = `${ calculatedMinimumFontSize }${ fontSizeParsed.unit }`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Grab the minimum font size and normalize it in order to use the value for calculations.\n\tconst minimumFontSizeParsed = getTypographyValueAndUnit( minimumFontSize );\n\n\t// We get a 'preferred' unit to keep units consistent when calculating,\n\t// otherwise the result will not be accurate.\n\tconst fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';\n\n\t// Grabs the maximum font size and normalize it in order to use the value for calculations.\n\tconst maximumFontSizeParsed = getTypographyValueAndUnit( maximumFontSize, {\n\t\tcoerceTo: fontSizeUnit,\n\t} );\n\n\t// Checks for mandatory min and max sizes, and protects against unsupported units.\n\tif ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {\n\t\treturn null;\n\t}\n\n\t// Uses rem for accessible fluid target font scaling.\n\tconst minimumFontSizeRem = getTypographyValueAndUnit( minimumFontSize, {\n\t\tcoerceTo: 'rem',\n\t} );\n\n\t// Viewport widths defined for fluid typography. Normalize units\n\tconst maximumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tmaximumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\tconst minumumViewPortWidthParsed = getTypographyValueAndUnit(\n\t\tminimumViewPortWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\n\t// Protect against unsupported units.\n\tif (\n\t\t! maximumViewPortWidthParsed ||\n\t\t! minumumViewPortWidthParsed ||\n\t\t! minimumFontSizeRem\n\t) {\n\t\treturn null;\n\t}\n\n\t// Build CSS rule.\n\t// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.\n\tconst minViewPortWidthOffsetValue = roundToPrecision(\n\t\tminumumViewPortWidthParsed.value / 100,\n\t\t3\n\t);\n\n\tconst viewPortWidthOffset =\n\t\troundToPrecision( minViewPortWidthOffsetValue, 3 ) + fontSizeUnit;\n\tconst linearFactor =\n\t\t100 *\n\t\t( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /\n\t\t\t( maximumViewPortWidthParsed.value -\n\t\t\t\tminumumViewPortWidthParsed.value ) );\n\tconst linearFactorScaled = roundToPrecision(\n\t\t( linearFactor || 1 ) * scaleFactor,\n\t\t3\n\t);\n\tconst fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewPortWidthOffset }) * ${ linearFactorScaled })`;\n\n\treturn `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;\n}\n\n/**\n * Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].\n * A raw font size of `value + unit` is expected. If the value is an integer, it will convert to `value + 'px'`.\n *\n * @param {string|number} rawValue Raw size value from theme.json.\n * @param {Object|undefined} options Calculation options.\n *\n * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.\n */\nexport function getTypographyValueAndUnit( rawValue, options = {} ) {\n\tif ( typeof rawValue !== 'string' && typeof rawValue !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Converts numeric values to pixel values by default.\n\tif ( isFinite( rawValue ) ) {\n\t\trawValue = `${ rawValue }px`;\n\t}\n\n\tconst { coerceTo, rootSizeValue, acceptableUnits } = {\n\t\tcoerceTo: '',\n\t\t// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( \"html\" ) ).fontSize`.\n\t\trootSizeValue: 16,\n\t\tacceptableUnits: [ 'rem', 'px', 'em' ],\n\t\t...options,\n\t};\n\n\tconst acceptableUnitsGroup = acceptableUnits?.join( '|' );\n\tconst regexUnits = new RegExp(\n\t\t`^(\\\\d*\\\\.?\\\\d+)(${ acceptableUnitsGroup }){1,1}$`\n\t);\n\n\tconst matches = rawValue.match( regexUnits );\n\n\t// We need a number value and a unit.\n\tif ( ! matches || matches.length < 3 ) {\n\t\treturn null;\n\t}\n\n\tlet [ , value, unit ] = matches;\n\n\tlet returnValue = parseFloat( value );\n\n\tif ( 'px' === coerceTo && ( 'em' === unit || 'rem' === unit ) ) {\n\t\treturnValue = returnValue * rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\tif ( 'px' === unit && ( 'em' === coerceTo || 'rem' === coerceTo ) ) {\n\t\treturnValue = returnValue / rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\t/*\n\t * No calculation is required if swapping between em and rem yet,\n\t * since we assume a root size value. Later we might like to differentiate between\n\t * :root font size (rem) and parent element font size (em) relativity.\n\t */\n\tif (\n\t\t( 'em' === coerceTo || 'rem' === coerceTo ) &&\n\t\t( 'em' === unit || 'rem' === unit )\n\t) {\n\t\tunit = coerceTo;\n\t}\n\n\treturn {\n\t\tvalue: roundToPrecision( returnValue, 3 ),\n\t\tunit,\n\t};\n}\n\n/**\n * Returns a value rounded to defined precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {number} value Raw value.\n * @param {number} digits The number of digits to appear after the decimal point\n *\n * @return {number|undefined} Value rounded to standard precision.\n */\nexport function roundToPrecision( value, digits = 3 ) {\n\tconst base = Math.pow( 10, digits );\n\treturn Number.isFinite( value )\n\t\t? parseFloat( Math.round( value * base ) / base )\n\t\t: undefined;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/font-sizes/fluid-utils.js"],"names":["DEFAULT_MAXIMUM_VIEWPORT_WIDTH","DEFAULT_MINIMUM_VIEWPORT_WIDTH","DEFAULT_SCALE_FACTOR","DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN","DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX","DEFAULT_MINIMUM_FONT_SIZE_LIMIT","getComputedFluidTypographyValue","minimumFontSize","maximumFontSize","fontSize","minimumViewportWidth","maximumViewportWidth","scaleFactor","minimumFontSizeLimit","getTypographyValueAndUnit","fontSizeParsed","unit","minimumFontSizeLimitParsed","coerceTo","value","fontSizeValueInPx","minimumFontSizeFactor","Math","min","max","log2","calculatedMinimumFontSize","roundToPrecision","minimumFontSizeParsed","fontSizeUnit","maximumFontSizeParsed","minimumFontSizeRem","maximumViewportWidthParsed","minimumViewportWidthParsed","minViewportWidthOffsetValue","viewportWidthOffset","linearFactor","linearFactorScaled","fluidTargetFontSize","rawValue","options","isFinite","rootSizeValue","acceptableUnits","acceptableUnitsGroup","join","regexUnits","RegExp","matches","match","length","returnValue","parseFloat","digits","base","pow","Number","round","undefined"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA;AACA,MAAMA,8BAA8B,GAAG,QAAvC;AACA,MAAMC,8BAA8B,GAAG,OAAvC;AACA,MAAMC,oBAAoB,GAAG,CAA7B;AACA,MAAMC,oCAAoC,GAAG,IAA7C;AACA,MAAMC,oCAAoC,GAAG,IAA7C;AACA,MAAMC,+BAA+B,GAAG,MAAxC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,+BAAT,CAA0C;AAChDC,EAAAA,eADgD;AAEhDC,EAAAA,eAFgD;AAGhDC,EAAAA,QAHgD;AAIhDC,EAAAA,oBAAoB,GAAGT,8BAJyB;AAKhDU,EAAAA,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CAA2BR,KAA3B,EAAkCkC,MAAM,GAAG,CAA3C,EAA+C;AACrD,QAAMC,IAAI,GAAGhC,IAAI,CAACiC,GAAL,CAAU,EAAV,EAAcF,MAAd,CAAb;AACA,SAAOG,MAAM,CAACf,QAAP,CAAiBtB,KAAjB,IACJiC,UAAU,CAAE9B,IAAI,CAACmC,KAAL,CAAYtC,KAAK,GAAGmC,IAApB,IAA6BA,IAA/B,CADN,GAEJI,SAFH;AAGA","sourcesContent":["/**\n * The fluid utilities must match the backend equivalent.\n * See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php\n * ---------------------------------------------------------------\n */\n\n// Defaults.\nconst DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';\nconst DEFAULT_MINIMUM_VIEWPORT_WIDTH = '320px';\nconst DEFAULT_SCALE_FACTOR = 1;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;\nconst DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;\nconst DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';\n\n/**\n * Computes a fluid font-size value that uses clamp(). A minimum and maximum\n * font size OR a single font size can be specified.\n *\n * If a single font size is specified, it is scaled up and down using a logarithmic scale.\n *\n * @example\n * ```js\n * // Calculate fluid font-size value from a minimum and maximum value.\n * const fontSize = getComputedFluidTypographyValue( {\n * minimumFontSize: '20px',\n * maximumFontSize: '45px'\n * } );\n * // Calculate fluid font-size value from a single font size.\n * const fontSize = getComputedFluidTypographyValue( {\n * fontSize: '30px',\n * } );\n * ```\n *\n * @param {Object} args\n * @param {?string} args.minimumViewportWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.\n * @param {?string} args.maximumViewportWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.\n * @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.\n * @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.\n * @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.\n * @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.\n * @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.\n *\n * @return {string|null} A font-size value using clamp().\n */\nexport function getComputedFluidTypographyValue( {\n\tminimumFontSize,\n\tmaximumFontSize,\n\tfontSize,\n\tminimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,\n\tmaximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,\n\tscaleFactor = DEFAULT_SCALE_FACTOR,\n\tminimumFontSizeLimit,\n} ) {\n\t// Validate incoming settings and set defaults.\n\tminimumFontSizeLimit = !! getTypographyValueAndUnit( minimumFontSizeLimit )\n\t\t? minimumFontSizeLimit\n\t\t: DEFAULT_MINIMUM_FONT_SIZE_LIMIT;\n\n\t/*\n\t * Calculates missing minimumFontSize and maximumFontSize from\n\t * defaultFontSize if provided.\n\t */\n\tif ( fontSize ) {\n\t\t// Parses default font size.\n\t\tconst fontSizeParsed = getTypographyValueAndUnit( fontSize );\n\n\t\t// Protect against invalid units.\n\t\tif ( ! fontSizeParsed?.unit ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Parses the minimum font size limit, so we can perform checks using it.\n\t\tconst minimumFontSizeLimitParsed = getTypographyValueAndUnit(\n\t\t\tminimumFontSizeLimit,\n\t\t\t{\n\t\t\t\tcoerceTo: fontSizeParsed.unit,\n\t\t\t}\n\t\t);\n\n\t\t// Don't enforce minimum font size if a font size has explicitly set a min and max value.\n\t\tif (\n\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t! minimumFontSize &&\n\t\t\t! maximumFontSize\n\t\t) {\n\t\t\t/*\n\t\t\t * If a minimum size was not passed to this function\n\t\t\t * and the user-defined font size is lower than $minimum_font_size_limit,\n\t\t\t * do not calculate a fluid value.\n\t\t\t */\n\t\t\tif ( fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\n\t\t// If no fluid max font size is available use the incoming value.\n\t\tif ( ! maximumFontSize ) {\n\t\t\tmaximumFontSize = `${ fontSizeParsed.value }${ fontSizeParsed.unit }`;\n\t\t}\n\n\t\t/*\n\t\t * If no minimumFontSize is provided, create one using\n\t\t * the given font size multiplied by the min font size scale factor.\n\t\t */\n\t\tif ( ! minimumFontSize ) {\n\t\t\tconst fontSizeValueInPx =\n\t\t\t\tfontSizeParsed.unit === 'px'\n\t\t\t\t\t? fontSizeParsed.value\n\t\t\t\t\t: fontSizeParsed.value * 16;\n\n\t\t\t/*\n\t\t\t * The scale factor is a multiplier that affects how quickly the curve will move towards the minimum,\n\t\t\t * that is, how quickly the size factor reaches 0 given increasing font size values.\n\t\t\t * For a - b * log2(), lower values of b will make the curve move towards the minimum faster.\n\t\t\t * The scale factor is constrained between min and max values.\n\t\t\t */\n\t\t\tconst minimumFontSizeFactor = Math.min(\n\t\t\t\tMath.max(\n\t\t\t\t\t1 - 0.075 * Math.log2( fontSizeValueInPx ),\n\t\t\t\t\tDEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN\n\t\t\t\t),\n\t\t\t\tDEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX\n\t\t\t);\n\n\t\t\t// Calculates the minimum font size.\n\t\t\tconst calculatedMinimumFontSize = roundToPrecision(\n\t\t\t\tfontSizeParsed.value * minimumFontSizeFactor,\n\t\t\t\t3\n\t\t\t);\n\n\t\t\t// Only use calculated min font size if it's > $minimum_font_size_limit value.\n\t\t\tif (\n\t\t\t\t!! minimumFontSizeLimitParsed?.value &&\n\t\t\t\tcalculatedMinimumFontSize < minimumFontSizeLimitParsed?.value\n\t\t\t) {\n\t\t\t\tminimumFontSize = `${ minimumFontSizeLimitParsed.value }${ minimumFontSizeLimitParsed.unit }`;\n\t\t\t} else {\n\t\t\t\tminimumFontSize = `${ calculatedMinimumFontSize }${ fontSizeParsed.unit }`;\n\t\t\t}\n\t\t}\n\t}\n\n\t// Grab the minimum font size and normalize it in order to use the value for calculations.\n\tconst minimumFontSizeParsed = getTypographyValueAndUnit( minimumFontSize );\n\n\t// We get a 'preferred' unit to keep units consistent when calculating,\n\t// otherwise the result will not be accurate.\n\tconst fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';\n\n\t// Grabs the maximum font size and normalize it in order to use the value for calculations.\n\tconst maximumFontSizeParsed = getTypographyValueAndUnit( maximumFontSize, {\n\t\tcoerceTo: fontSizeUnit,\n\t} );\n\n\t// Checks for mandatory min and max sizes, and protects against unsupported units.\n\tif ( ! minimumFontSizeParsed || ! maximumFontSizeParsed ) {\n\t\treturn null;\n\t}\n\n\t// Uses rem for accessible fluid target font scaling.\n\tconst minimumFontSizeRem = getTypographyValueAndUnit( minimumFontSize, {\n\t\tcoerceTo: 'rem',\n\t} );\n\n\t// Viewport widths defined for fluid typography. Normalize units\n\tconst maximumViewportWidthParsed = getTypographyValueAndUnit(\n\t\tmaximumViewportWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\tconst minimumViewportWidthParsed = getTypographyValueAndUnit(\n\t\tminimumViewportWidth,\n\t\t{ coerceTo: fontSizeUnit }\n\t);\n\n\t// Protect against unsupported units.\n\tif (\n\t\t! maximumViewportWidthParsed ||\n\t\t! minimumViewportWidthParsed ||\n\t\t! minimumFontSizeRem\n\t) {\n\t\treturn null;\n\t}\n\n\t// Build CSS rule.\n\t// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.\n\tconst minViewportWidthOffsetValue = roundToPrecision(\n\t\tminimumViewportWidthParsed.value / 100,\n\t\t3\n\t);\n\n\tconst viewportWidthOffset =\n\t\troundToPrecision( minViewportWidthOffsetValue, 3 ) + fontSizeUnit;\n\tconst linearFactor =\n\t\t100 *\n\t\t( ( maximumFontSizeParsed.value - minimumFontSizeParsed.value ) /\n\t\t\t( maximumViewportWidthParsed.value -\n\t\t\t\tminimumViewportWidthParsed.value ) );\n\tconst linearFactorScaled = roundToPrecision(\n\t\t( linearFactor || 1 ) * scaleFactor,\n\t\t3\n\t);\n\tconst fluidTargetFontSize = `${ minimumFontSizeRem.value }${ minimumFontSizeRem.unit } + ((1vw - ${ viewportWidthOffset }) * ${ linearFactorScaled })`;\n\n\treturn `clamp(${ minimumFontSize }, ${ fluidTargetFontSize }, ${ maximumFontSize })`;\n}\n\n/**\n * Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].\n * A raw font size of `value + unit` is expected. If the value is an integer, it will convert to `value + 'px'`.\n *\n * @param {string|number} rawValue Raw size value from theme.json.\n * @param {Object|undefined} options Calculation options.\n *\n * @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.\n */\nexport function getTypographyValueAndUnit( rawValue, options = {} ) {\n\tif ( typeof rawValue !== 'string' && typeof rawValue !== 'number' ) {\n\t\treturn null;\n\t}\n\n\t// Converts numeric values to pixel values by default.\n\tif ( isFinite( rawValue ) ) {\n\t\trawValue = `${ rawValue }px`;\n\t}\n\n\tconst { coerceTo, rootSizeValue, acceptableUnits } = {\n\t\tcoerceTo: '',\n\t\t// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( \"html\" ) ).fontSize`.\n\t\trootSizeValue: 16,\n\t\tacceptableUnits: [ 'rem', 'px', 'em' ],\n\t\t...options,\n\t};\n\n\tconst acceptableUnitsGroup = acceptableUnits?.join( '|' );\n\tconst regexUnits = new RegExp(\n\t\t`^(\\\\d*\\\\.?\\\\d+)(${ acceptableUnitsGroup }){1,1}$`\n\t);\n\n\tconst matches = rawValue.match( regexUnits );\n\n\t// We need a number value and a unit.\n\tif ( ! matches || matches.length < 3 ) {\n\t\treturn null;\n\t}\n\n\tlet [ , value, unit ] = matches;\n\n\tlet returnValue = parseFloat( value );\n\n\tif ( 'px' === coerceTo && ( 'em' === unit || 'rem' === unit ) ) {\n\t\treturnValue = returnValue * rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\tif ( 'px' === unit && ( 'em' === coerceTo || 'rem' === coerceTo ) ) {\n\t\treturnValue = returnValue / rootSizeValue;\n\t\tunit = coerceTo;\n\t}\n\n\t/*\n\t * No calculation is required if swapping between em and rem yet,\n\t * since we assume a root size value. Later we might like to differentiate between\n\t * :root font size (rem) and parent element font size (em) relativity.\n\t */\n\tif (\n\t\t( 'em' === coerceTo || 'rem' === coerceTo ) &&\n\t\t( 'em' === unit || 'rem' === unit )\n\t) {\n\t\tunit = coerceTo;\n\t}\n\n\treturn {\n\t\tvalue: roundToPrecision( returnValue, 3 ),\n\t\tunit,\n\t};\n}\n\n/**\n * Returns a value rounded to defined precision.\n * Returns `undefined` if the value is not a valid finite number.\n *\n * @param {number} value Raw value.\n * @param {number} digits The number of digits to appear after the decimal point\n *\n * @return {number|undefined} Value rounded to standard precision.\n */\nexport function roundToPrecision( value, digits = 3 ) {\n\tconst base = Math.pow( 10, digits );\n\treturn Number.isFinite( value )\n\t\t? parseFloat( Math.round( value * base ) / base )\n\t\t: undefined;\n}\n"]}
@@ -0,0 +1,57 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { SelectControl } from '@wordpress/components';
7
+ import { __ } from '@wordpress/i18n';
8
+ export default function ({
9
+ onChange,
10
+ value,
11
+ behaviors
12
+ }) {
13
+ const defaultBehaviors = {
14
+ default: {
15
+ value: 'default',
16
+ label: __('Default')
17
+ },
18
+ noBehaviors: {
19
+ value: '',
20
+ label: __('No behaviors')
21
+ }
22
+ };
23
+ const behaviorsOptions = Object.entries(behaviors).map(([behaviorName]) => ({
24
+ value: behaviorName,
25
+ // Capitalize the first letter of the behavior name.
26
+ label: `${behaviorName.charAt(0).toUpperCase()}${behaviorName.slice(1).toLowerCase()}`
27
+ }));
28
+ const options = [...Object.values(defaultBehaviors), ...behaviorsOptions];
29
+ const animations = [{
30
+ value: 'zoom',
31
+ label: __('Zoom')
32
+ }, {
33
+ value: 'fade',
34
+ label: __('Fade')
35
+ }];
36
+ return createElement("div", {
37
+ style: {
38
+ marginTop: '2rem'
39
+ }
40
+ }, createElement(SelectControl, {
41
+ label: __('Behaviors') // At the moment we are only supporting one behavior (Lightbox)
42
+ ,
43
+ value: value,
44
+ options: options,
45
+ onChange: onChange,
46
+ hideCancelButton: true,
47
+ size: "__unstable-large"
48
+ }), value === 'lightbox' && createElement(SelectControl, {
49
+ label: __('Animation'),
50
+ value: behaviors?.lightbox.animation ? behaviors?.lightbox.animation : '',
51
+ options: animations,
52
+ onChange: onChange,
53
+ hideCancelButton: false,
54
+ size: "__unstable-large"
55
+ }));
56
+ }
57
+ //# sourceMappingURL=behaviors-panel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/global-styles/behaviors-panel.js"],"names":["SelectControl","__","onChange","value","behaviors","defaultBehaviors","default","label","noBehaviors","behaviorsOptions","Object","entries","map","behaviorName","charAt","toUpperCase","slice","toLowerCase","options","values","animations","marginTop","lightbox","animation"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,QAA8B,uBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA,eAAe,UAAW;AAAEC,EAAAA,QAAF;AAAYC,EAAAA,KAAZ;AAAmBC,EAAAA;AAAnB,CAAX,EAA4C;AAC1D,QAAMC,gBAAgB,GAAG;AACxBC,IAAAA,OAAO,EAAE;AACRH,MAAAA,KAAK,EAAE,SADC;AAERI,MAAAA,KAAK,EAAEN,EAAE,CAAE,SAAF;AAFD,KADe;AAKxBO,IAAAA,WAAW,EAAE;AACZL,MAAAA,KAAK,EAAE,EADK;AAEZI,MAAAA,KAAK,EAAEN,EAAE,CAAE,cAAF;AAFG;AALW,GAAzB;AAWA,QAAMQ,gBAAgB,GAAGC,MAAM,CAACC,OAAP,CAAgBP,SAAhB,EAA4BQ,GAA5B,CACxB,CAAE,CAAEC,YAAF,CAAF,MAA0B;AACzBV,IAAAA,KAAK,EAAEU,YADkB;AAEzB;AACAN,IAAAA,KAAK,EAAG,GAAGM,YAAY,CAACC,MAAb,CAAqB,CAArB,EAAyBC,WAAzB,EAAwC,GAAGF,YAAY,CAChEG,KADoD,CAC7C,CAD6C,EAEpDC,WAFoD,EAErC;AALQ,GAA1B,CADwB,CAAzB;AAUA,QAAMC,OAAO,GAAG,CACf,GAAGR,MAAM,CAACS,MAAP,CAAed,gBAAf,CADY,EAEf,GAAGI,gBAFY,CAAhB;AAKA,QAAMW,UAAU,GAAG,CAClB;AACCjB,IAAAA,KAAK,EAAE,MADR;AAECI,IAAAA,KAAK,EAAEN,EAAE,CAAE,MAAF;AAFV,GADkB,EAKlB;AACCE,IAAAA,KAAK,EAAE,MADR;AAECI,IAAAA,KAAK,EAAEN,EAAE,CAAE,MAAF;AAFV,GALkB,CAAnB;AAUA,SACC;AAAK,IAAA,KAAK,EAAG;AAAEoB,MAAAA,SAAS,EAAE;AAAb;AAAb,KACC,cAAC,aAAD;AACC,IAAA,KAAK,EAAGpB,EAAE,CAAE,WAAF,CADX,CAEC;AAFD;AAGC,IAAA,KAAK,EAAGE,KAHT;AAIC,IAAA,OAAO,EAAGe,OAJX;AAKC,IAAA,QAAQ,EAAGhB,QALZ;AAMC,IAAA,gBAAgB,EAAG,IANpB;AAOC,IAAA,IAAI,EAAC;AAPN,IADD,EAUGC,KAAK,KAAK,UAAV,IACD,cAAC,aAAD;AACC,IAAA,KAAK,EAAGF,EAAE,CAAE,WAAF,CADX;AAEC,IAAA,KAAK,EACJG,SAAS,EAAEkB,QAAX,CAAoBC,SAApB,GACGnB,SAAS,EAAEkB,QAAX,CAAoBC,SADvB,GAEG,EALL;AAOC,IAAA,OAAO,EAAGH,UAPX;AAQC,IAAA,QAAQ,EAAGlB,QARZ;AASC,IAAA,gBAAgB,EAAG,KATpB;AAUC,IAAA,IAAI,EAAC;AAVN,IAXF,CADD;AA2BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function ( { onChange, value, behaviors } ) {\n\tconst defaultBehaviors = {\n\t\tdefault: {\n\t\t\tvalue: 'default',\n\t\t\tlabel: __( 'Default' ),\n\t\t},\n\t\tnoBehaviors: {\n\t\t\tvalue: '',\n\t\t\tlabel: __( 'No behaviors' ),\n\t\t},\n\t};\n\n\tconst behaviorsOptions = Object.entries( behaviors ).map(\n\t\t( [ behaviorName ] ) => ( {\n\t\t\tvalue: behaviorName,\n\t\t\t// Capitalize the first letter of the behavior name.\n\t\t\tlabel: `${ behaviorName.charAt( 0 ).toUpperCase() }${ behaviorName\n\t\t\t\t.slice( 1 )\n\t\t\t\t.toLowerCase() }`,\n\t\t} )\n\t);\n\n\tconst options = [\n\t\t...Object.values( defaultBehaviors ),\n\t\t...behaviorsOptions,\n\t];\n\n\tconst animations = [\n\t\t{\n\t\t\tvalue: 'zoom',\n\t\t\tlabel: __( 'Zoom' ),\n\t\t},\n\t\t{\n\t\t\tvalue: 'fade',\n\t\t\tlabel: __( 'Fade' ),\n\t\t},\n\t];\n\treturn (\n\t\t<div style={ { marginTop: '2rem' } }>\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Behaviors' ) }\n\t\t\t\t// At the moment we are only supporting one behavior (Lightbox)\n\t\t\t\tvalue={ value }\n\t\t\t\toptions={ options }\n\t\t\t\tonChange={ onChange }\n\t\t\t\thideCancelButton={ true }\n\t\t\t\tsize=\"__unstable-large\"\n\t\t\t/>\n\t\t\t{ value === 'lightbox' && (\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'Animation' ) }\n\t\t\t\t\tvalue={\n\t\t\t\t\t\tbehaviors?.lightbox.animation\n\t\t\t\t\t\t\t? behaviors?.lightbox.animation\n\t\t\t\t\t\t\t: ''\n\t\t\t\t\t}\n\t\t\t\t\toptions={ animations }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\thideCancelButton={ false }\n\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
@@ -8,7 +8,7 @@ import fastDeepEqual from 'fast-deep-equal/es6';
8
8
 
9
9
  import { useContext, useCallback, useMemo } from '@wordpress/element';
10
10
  import { useSelect } from '@wordpress/data';
11
- import { store as blocksStore } from '@wordpress/blocks';
11
+ import { store as blocksStore, hasBlockSupport } from '@wordpress/blocks';
12
12
  import { _x } from '@wordpress/i18n';
13
13
  /**
14
14
  * Internal dependencies
@@ -20,9 +20,10 @@ import { GlobalStylesContext } from './context';
20
20
  import { unlock } from '../../lock-unlock';
21
21
  const EMPTY_CONFIG = {
22
22
  settings: {},
23
- styles: {}
23
+ styles: {},
24
+ behaviors: {}
24
25
  };
25
- const VALID_SETTINGS = ['appearanceTools', 'useRootPaddingAwareAlignments', 'border.color', 'border.radius', 'border.style', 'border.width', 'shadow.presets', 'shadow.defaultPresets', 'color.background', 'color.button', 'color.caption', 'color.custom', 'color.customDuotone', 'color.customGradient', 'color.defaultDuotone', 'color.defaultGradients', 'color.defaultPalette', 'color.duotone', 'color.gradients', 'color.heading', 'color.link', 'color.palette', 'color.text', 'custom', 'dimensions.minHeight', 'layout.contentSize', 'layout.definitions', 'layout.wideSize', 'position.fixed', 'position.sticky', 'spacing.customSpacingSize', 'spacing.spacingSizes', 'spacing.spacingScale', 'spacing.blockGap', 'spacing.margin', 'spacing.padding', 'spacing.units', 'typography.fluid', 'typography.customFontSize', 'typography.dropCap', 'typography.fontFamilies', 'typography.fontSizes', 'typography.fontStyle', 'typography.fontWeight', 'typography.letterSpacing', 'typography.lineHeight', 'typography.textColumns', 'typography.textDecoration', 'typography.textTransform', 'typography.writingMode'];
26
+ const VALID_SETTINGS = ['appearanceTools', 'behaviors', 'useRootPaddingAwareAlignments', 'border.color', 'border.radius', 'border.style', 'border.width', 'shadow.presets', 'shadow.defaultPresets', 'color.background', 'color.button', 'color.caption', 'color.custom', 'color.customDuotone', 'color.customGradient', 'color.defaultDuotone', 'color.defaultGradients', 'color.defaultPalette', 'color.duotone', 'color.gradients', 'color.heading', 'color.link', 'color.palette', 'color.text', 'custom', 'dimensions.minHeight', 'layout.contentSize', 'layout.definitions', 'layout.wideSize', 'position.fixed', 'position.sticky', 'spacing.customSpacingSize', 'spacing.spacingSizes', 'spacing.spacingScale', 'spacing.blockGap', 'spacing.margin', 'spacing.padding', 'spacing.units', 'typography.fluid', 'typography.customFontSize', 'typography.dropCap', 'typography.fontFamilies', 'typography.fontSizes', 'typography.fontStyle', 'typography.fontWeight', 'typography.letterSpacing', 'typography.lineHeight', 'typography.textColumns', 'typography.textDecoration', 'typography.textTransform', 'typography.writingMode'];
26
27
  export const useGlobalStylesReset = () => {
27
28
  const {
28
29
  user: config,
@@ -200,9 +201,9 @@ export function useSettingsForBlockElement(parentSettings, blockName, element) {
200
201
  };
201
202
  }
202
203
 
203
- const sides = Array.isArray(supports?.spacing?.[key]) ? supports?.spacing?.[key] : supports?.spacing?.[key]?.sides;
204
+ const sides = Array.isArray(supports?.spacing?.[key]) ? supports?.spacing?.[key] : supports?.spacing?.[key]?.sides; // Check if spacing type is supported before adding sides.
204
205
 
205
- if (sides?.length) {
206
+ if (sides?.length && updatedSettings.spacing?.[key]) {
206
207
  updatedSettings.spacing = { ...updatedSettings.spacing,
207
208
  [key]: { ...updatedSettings.spacing?.[key],
208
209
  sides
@@ -292,4 +293,113 @@ export function useGradientsPerOrigin(settings) {
292
293
  return result;
293
294
  }, [customGradients, themeGradients, defaultGradients, shouldDisplayDefaultGradients]);
294
295
  }
296
+ export function __experimentalUseGlobalBehaviors(blockName, source = 'all') {
297
+ const {
298
+ merged: mergedConfig,
299
+ base: baseConfig,
300
+ user: userConfig,
301
+ setUserConfig
302
+ } = useContext(GlobalStylesContext);
303
+ const finalPath = !blockName ? `behaviors` : `behaviors.blocks.${blockName}`;
304
+ let rawResult, result;
305
+
306
+ switch (source) {
307
+ case 'all':
308
+ rawResult = getValueFromObjectPath(mergedConfig, finalPath);
309
+ result = getValueFromVariable(mergedConfig, blockName, rawResult);
310
+ break;
311
+
312
+ case 'user':
313
+ rawResult = getValueFromObjectPath(userConfig, finalPath);
314
+ result = getValueFromVariable(mergedConfig, blockName, rawResult);
315
+ break;
316
+
317
+ case 'base':
318
+ rawResult = getValueFromObjectPath(baseConfig, finalPath);
319
+ result = getValueFromVariable(baseConfig, blockName, rawResult);
320
+ break;
321
+
322
+ default:
323
+ throw 'Unsupported source';
324
+ }
325
+
326
+ const animation = result?.lightbox?.animation || 'zoom';
327
+
328
+ const setBehavior = newValue => {
329
+ let newBehavior; // The user saves with Apply Globally option.
330
+
331
+ if (typeof newValue === 'object') {
332
+ newBehavior = newValue;
333
+ } else {
334
+ switch (newValue) {
335
+ case 'lightbox':
336
+ newBehavior = {
337
+ lightbox: {
338
+ enabled: true,
339
+ animation
340
+ }
341
+ };
342
+ break;
343
+
344
+ case 'fade':
345
+ newBehavior = {
346
+ lightbox: {
347
+ enabled: true,
348
+ animation: 'fade'
349
+ }
350
+ };
351
+ break;
352
+
353
+ case 'zoom':
354
+ newBehavior = {
355
+ lightbox: {
356
+ enabled: true,
357
+ animation: 'zoom'
358
+ }
359
+ };
360
+ break;
361
+
362
+ case '':
363
+ newBehavior = {
364
+ lightbox: {
365
+ enabled: false,
366
+ animation
367
+ }
368
+ };
369
+ break;
370
+
371
+ default:
372
+ break;
373
+ }
374
+ }
375
+
376
+ setUserConfig(currentConfig => setImmutably(currentConfig, finalPath.split('.'), newBehavior));
377
+ };
378
+
379
+ let behavior = '';
380
+ if (result === undefined) behavior = 'default';
381
+ if (result?.lightbox.enabled) behavior = 'lightbox';
382
+ return {
383
+ behavior,
384
+ inheritedBehaviors: result,
385
+ setBehavior
386
+ };
387
+ }
388
+ export function __experimentalUseHasBehaviorsPanel(settings, name, {
389
+ blockSupportOnly = false
390
+ } = {}) {
391
+ if (!settings?.behaviors) {
392
+ return false;
393
+ } // If every behavior is disabled on block supports, do not show the behaviors inspector control.
394
+
395
+
396
+ const hasSomeBlockSupport = Object.keys(settings?.behaviors).some(key => hasBlockSupport(name, `behaviors.${key}`));
397
+
398
+ if (blockSupportOnly) {
399
+ return hasSomeBlockSupport;
400
+ } // If every behavior is disabled, do not show the behaviors inspector control.
401
+
402
+
403
+ return Object.values(settings?.behaviors).some(value => value === true && hasSomeBlockSupport);
404
+ }
295
405
  //# sourceMappingURL=hooks.js.map