itmar-block-packages 2.1.2 → 3.0.2

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 (218) hide show
  1. package/README.md +18 -4
  2. package/build/cjs/AnimationBlock.js +61 -92
  3. package/build/cjs/AnimationBlock.js.map +1 -1
  4. package/build/cjs/BlockEditWrapper.js +3 -10
  5. package/build/cjs/BlockEditWrapper.js.map +1 -1
  6. package/build/cjs/BlockPlace.js +277 -482
  7. package/build/cjs/BlockPlace.js.map +1 -1
  8. package/build/cjs/BrockInserter.js +195 -191
  9. package/build/cjs/BrockInserter.js.map +1 -1
  10. package/build/cjs/DateElm.js +254 -281
  11. package/build/cjs/DateElm.js.map +1 -1
  12. package/build/cjs/DraggableBox.js +99 -129
  13. package/build/cjs/DraggableBox.js.map +1 -1
  14. package/build/cjs/GridControls.js +292 -392
  15. package/build/cjs/GridControls.js.map +1 -1
  16. package/build/cjs/IconSelectControl.js +65 -156
  17. package/build/cjs/IconSelectControl.js.map +1 -1
  18. package/build/cjs/JapaneseHolidays.js +67 -76
  19. package/build/cjs/JapaneseHolidays.js.map +1 -1
  20. package/build/cjs/MasonryControl.js +95 -100
  21. package/build/cjs/MasonryControl.js.map +1 -1
  22. package/build/cjs/PseudoElm.js +37 -50
  23. package/build/cjs/PseudoElm.js.map +1 -1
  24. package/build/cjs/ShadowStyle.js +216 -430
  25. package/build/cjs/ShadowStyle.js.map +1 -1
  26. package/build/cjs/SwiperControl.js +240 -241
  27. package/build/cjs/SwiperControl.js.map +1 -1
  28. package/build/cjs/ToggleElement.js +17 -9
  29. package/build/cjs/ToggleElement.js.map +1 -1
  30. package/build/cjs/TypographyControls.js +73 -139
  31. package/build/cjs/TypographyControls.js.map +1 -1
  32. package/build/cjs/UpdateAllPostsBlockAttributes.js +102 -119
  33. package/build/cjs/UpdateAllPostsBlockAttributes.js.map +1 -1
  34. package/build/cjs/ZipAddress.js +27 -23
  35. package/build/cjs/ZipAddress.js.map +1 -1
  36. package/build/cjs/blockStore.js +42 -47
  37. package/build/cjs/blockStore.js.map +1 -1
  38. package/build/cjs/cssPropertes.js +165 -117
  39. package/build/cjs/cssPropertes.js.map +1 -1
  40. package/build/cjs/customHooks.js +277 -0
  41. package/build/cjs/customHooks.js.map +1 -0
  42. package/build/cjs/formatCreate.js +115 -145
  43. package/build/cjs/formatCreate.js.map +1 -1
  44. package/build/cjs/hslToRgb.js +112 -116
  45. package/build/cjs/hslToRgb.js.map +1 -1
  46. package/build/cjs/index.js +15 -11
  47. package/build/cjs/index.js.map +1 -1
  48. package/build/cjs/mediaUpload.js +95 -158
  49. package/build/cjs/mediaUpload.js.map +1 -1
  50. package/build/cjs/node_modules/swiper/shared/ssr-window.esm.js +144 -0
  51. package/build/cjs/node_modules/swiper/shared/ssr-window.esm.js.map +1 -0
  52. package/build/cjs/node_modules/swiper/shared/swiper-core.js +3925 -0
  53. package/build/cjs/node_modules/swiper/shared/swiper-core.js.map +1 -0
  54. package/build/cjs/node_modules/swiper/shared/utils.js +294 -0
  55. package/build/cjs/node_modules/swiper/shared/utils.js.map +1 -0
  56. package/build/cjs/pickupStore.js +56 -54
  57. package/build/cjs/pickupStore.js.map +1 -1
  58. package/build/cjs/shopfiApi.js +127 -138
  59. package/build/cjs/shopfiApi.js.map +1 -1
  60. package/build/cjs/types/AnimationBlock.d.ts +22 -0
  61. package/build/cjs/types/BlockEditWrapper.d.ts +7 -0
  62. package/build/cjs/types/BlockPlace.d.ts +49 -0
  63. package/build/cjs/types/BrockInserter.d.ts +6 -0
  64. package/build/cjs/types/DateElm.d.ts +69 -0
  65. package/build/cjs/types/DraggableBox.d.ts +19 -0
  66. package/build/cjs/types/GridControls.d.ts +27 -0
  67. package/build/cjs/types/IconSelectControl.d.ts +17 -0
  68. package/build/cjs/types/JapaneseHolidays.d.ts +6 -0
  69. package/build/cjs/types/MasonryControl.d.ts +35 -0
  70. package/build/cjs/types/PseudoElm.d.ts +11 -0
  71. package/build/cjs/types/ShadowStyle.d.ts +33 -0
  72. package/build/cjs/types/SwiperControl.d.ts +12 -0
  73. package/build/cjs/types/ToggleElement.d.ts +13 -0
  74. package/build/cjs/types/TypographyControls.d.ts +17 -0
  75. package/build/cjs/types/UpdateAllPostsBlockAttributes.d.ts +10 -0
  76. package/build/cjs/types/ZipAddress.d.ts +18 -0
  77. package/build/cjs/types/blockStore.d.ts +15 -0
  78. package/build/cjs/types/cssPropertes.d.ts +53 -0
  79. package/build/cjs/types/customHooks.d.ts +11 -0
  80. package/build/cjs/types/formatCreate.d.ts +18 -0
  81. package/build/cjs/types/hslToRgb.d.ts +23 -0
  82. package/build/cjs/types/index.d.ts +31 -0
  83. package/build/cjs/types/mediaUpload.d.ts +29 -0
  84. package/build/cjs/types/pickupStore.d.ts +39 -0
  85. package/build/cjs/types/shopfiApi.d.ts +18 -0
  86. package/build/cjs/types/validationCheck.d.ts +5 -0
  87. package/build/cjs/types/wordpressApi.d.ts +99 -0
  88. package/build/cjs/validationCheck.js +15 -9
  89. package/build/cjs/validationCheck.js.map +1 -1
  90. package/build/cjs/wordpressApi.js +364 -576
  91. package/build/cjs/wordpressApi.js.map +1 -1
  92. package/build/esm/AnimationBlock.d.ts +22 -0
  93. package/build/esm/AnimationBlock.js +61 -92
  94. package/build/esm/AnimationBlock.js.map +1 -1
  95. package/build/esm/BlockEditWrapper.d.ts +7 -0
  96. package/build/esm/BlockEditWrapper.js +4 -11
  97. package/build/esm/BlockEditWrapper.js.map +1 -1
  98. package/build/esm/BlockPlace.d.ts +49 -0
  99. package/build/esm/BlockPlace.js +279 -484
  100. package/build/esm/BlockPlace.js.map +1 -1
  101. package/build/esm/BrockInserter.d.ts +6 -0
  102. package/build/esm/BrockInserter.js +195 -191
  103. package/build/esm/BrockInserter.js.map +1 -1
  104. package/build/esm/DateElm.d.ts +69 -0
  105. package/build/esm/DateElm.js +254 -281
  106. package/build/esm/DateElm.js.map +1 -1
  107. package/build/esm/DraggableBox.d.ts +19 -0
  108. package/build/esm/DraggableBox.js +99 -129
  109. package/build/esm/DraggableBox.js.map +1 -1
  110. package/build/esm/GridControls.d.ts +27 -0
  111. package/build/esm/GridControls.js +294 -394
  112. package/build/esm/GridControls.js.map +1 -1
  113. package/build/esm/IconSelectControl.d.ts +17 -0
  114. package/build/esm/IconSelectControl.js +65 -156
  115. package/build/esm/IconSelectControl.js.map +1 -1
  116. package/build/esm/JapaneseHolidays.d.ts +6 -0
  117. package/build/esm/JapaneseHolidays.js +67 -76
  118. package/build/esm/JapaneseHolidays.js.map +1 -1
  119. package/build/esm/MasonryControl.d.ts +35 -0
  120. package/build/esm/MasonryControl.js +95 -100
  121. package/build/esm/MasonryControl.js.map +1 -1
  122. package/build/esm/PseudoElm.d.ts +11 -0
  123. package/build/esm/PseudoElm.js +37 -50
  124. package/build/esm/PseudoElm.js.map +1 -1
  125. package/build/esm/ShadowStyle.d.ts +33 -0
  126. package/build/esm/ShadowStyle.js +217 -431
  127. package/build/esm/ShadowStyle.js.map +1 -1
  128. package/build/esm/SwiperControl.d.ts +12 -0
  129. package/build/esm/SwiperControl.js +240 -241
  130. package/build/esm/SwiperControl.js.map +1 -1
  131. package/build/esm/ToggleElement.d.ts +13 -0
  132. package/build/esm/ToggleElement.js +17 -9
  133. package/build/esm/ToggleElement.js.map +1 -1
  134. package/build/esm/TypographyControls.d.ts +17 -0
  135. package/build/esm/TypographyControls.js +73 -139
  136. package/build/esm/TypographyControls.js.map +1 -1
  137. package/build/esm/UpdateAllPostsBlockAttributes.d.ts +10 -0
  138. package/build/esm/UpdateAllPostsBlockAttributes.js +103 -120
  139. package/build/esm/UpdateAllPostsBlockAttributes.js.map +1 -1
  140. package/build/esm/ZipAddress.d.ts +18 -0
  141. package/build/esm/ZipAddress.js +27 -23
  142. package/build/esm/ZipAddress.js.map +1 -1
  143. package/build/esm/blockStore.d.ts +15 -0
  144. package/build/esm/blockStore.js +42 -47
  145. package/build/esm/blockStore.js.map +1 -1
  146. package/build/esm/cssPropertes.d.ts +53 -0
  147. package/build/esm/cssPropertes.js +165 -117
  148. package/build/esm/cssPropertes.js.map +1 -1
  149. package/build/esm/customHooks.d.ts +11 -0
  150. package/build/esm/customHooks.js +267 -0
  151. package/build/esm/customHooks.js.map +1 -0
  152. package/build/esm/formatCreate.d.ts +18 -0
  153. package/build/esm/formatCreate.js +115 -145
  154. package/build/esm/formatCreate.js.map +1 -1
  155. package/build/esm/hslToRgb.d.ts +23 -0
  156. package/build/esm/hslToRgb.js +112 -116
  157. package/build/esm/hslToRgb.js.map +1 -1
  158. package/build/esm/index.d.ts +27 -0
  159. package/build/esm/index.js +8 -1
  160. package/build/esm/index.js.map +1 -1
  161. package/build/esm/mediaUpload.d.ts +29 -0
  162. package/build/esm/mediaUpload.js +95 -158
  163. package/build/esm/mediaUpload.js.map +1 -1
  164. package/build/esm/node_modules/swiper/shared/ssr-window.esm.js +141 -0
  165. package/build/esm/node_modules/swiper/shared/ssr-window.esm.js.map +1 -0
  166. package/build/esm/node_modules/swiper/shared/swiper-core.js +3922 -0
  167. package/build/esm/node_modules/swiper/shared/swiper-core.js.map +1 -0
  168. package/build/esm/node_modules/swiper/shared/utils.js +274 -0
  169. package/build/esm/node_modules/swiper/shared/utils.js.map +1 -0
  170. package/build/esm/pickupStore.d.ts +39 -0
  171. package/build/esm/pickupStore.js +56 -54
  172. package/build/esm/pickupStore.js.map +1 -1
  173. package/build/esm/shopfiApi.d.ts +18 -0
  174. package/build/esm/shopfiApi.js +127 -138
  175. package/build/esm/shopfiApi.js.map +1 -1
  176. package/build/esm/types/AnimationBlock.d.ts +22 -0
  177. package/build/esm/types/BlockEditWrapper.d.ts +7 -0
  178. package/build/esm/types/BlockPlace.d.ts +49 -0
  179. package/build/esm/types/BrockInserter.d.ts +6 -0
  180. package/build/esm/types/DateElm.d.ts +69 -0
  181. package/build/esm/types/DraggableBox.d.ts +19 -0
  182. package/build/esm/types/GridControls.d.ts +27 -0
  183. package/build/esm/types/IconSelectControl.d.ts +17 -0
  184. package/build/esm/types/JapaneseHolidays.d.ts +6 -0
  185. package/build/esm/types/MasonryControl.d.ts +35 -0
  186. package/build/esm/types/PseudoElm.d.ts +11 -0
  187. package/build/esm/types/ShadowStyle.d.ts +33 -0
  188. package/build/esm/types/SwiperControl.d.ts +12 -0
  189. package/build/esm/types/ToggleElement.d.ts +13 -0
  190. package/build/esm/types/TypographyControls.d.ts +17 -0
  191. package/build/esm/types/UpdateAllPostsBlockAttributes.d.ts +10 -0
  192. package/build/esm/types/ZipAddress.d.ts +18 -0
  193. package/build/esm/types/blockStore.d.ts +15 -0
  194. package/build/esm/types/cssPropertes.d.ts +53 -0
  195. package/build/esm/types/customHooks.d.ts +11 -0
  196. package/build/esm/types/formatCreate.d.ts +18 -0
  197. package/build/esm/types/hslToRgb.d.ts +23 -0
  198. package/build/esm/types/index.d.ts +31 -0
  199. package/build/esm/types/mediaUpload.d.ts +29 -0
  200. package/build/esm/types/pickupStore.d.ts +39 -0
  201. package/build/esm/types/shopfiApi.d.ts +18 -0
  202. package/build/esm/types/validationCheck.d.ts +5 -0
  203. package/build/esm/types/wordpressApi.d.ts +99 -0
  204. package/build/esm/validationCheck.d.ts +5 -0
  205. package/build/esm/validationCheck.js +15 -9
  206. package/build/esm/validationCheck.js.map +1 -1
  207. package/build/esm/wordpressApi.d.ts +99 -0
  208. package/build/esm/wordpressApi.js +365 -577
  209. package/build/esm/wordpressApi.js.map +1 -1
  210. package/package.json +29 -7
  211. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -117
  212. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  213. package/build/cjs/customFooks.js +0 -300
  214. package/build/cjs/customFooks.js.map +0 -1
  215. package/build/esm/_virtual/_rollupPluginBabelHelpers.js +0 -107
  216. package/build/esm/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  217. package/build/esm/customFooks.js +0 -290
  218. package/build/esm/customFooks.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customHooks.js","sources":["../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YACF;QACF;;AAGA,QAAA,kBAAkB,CAAC,OAAO,GAAG,WAAW;IAC1C,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;AAC1D;;;;"}
@@ -0,0 +1,18 @@
1
+ interface FormatSettings {
2
+ userFormat: string;
3
+ freeStrFormat: string;
4
+ decimal: number;
5
+ }
6
+ interface FormatSelectControlProps {
7
+ titleType: "plaine" | "date" | "user" | string;
8
+ userFormat: string;
9
+ freeStrFormat: string;
10
+ decimal: number;
11
+ onFormatChange: (settings: FormatSettings) => void;
12
+ }
13
+ export declare const FormatSelectControl: ({ titleType, userFormat, freeStrFormat, decimal, onFormatChange, }: FormatSelectControlProps) => JSX.Element;
14
+ /**
15
+ * 値を指定されたフォーマットで整形して返す
16
+ */
17
+ export declare const displayFormated: (content: any, userFormat: string | undefined, freeStrFormat: string, decimal: number) => string;
18
+ export {};
@@ -1,156 +1,126 @@
1
- import { objectSpread2 as _objectSpread2 } from './_virtual/_rollupPluginBabelHelpers.js';
1
+ import { createElement, Fragment } from '@wordpress/element';
2
2
  import { __ } from '@wordpress/i18n';
3
3
  import { PanelBody, SelectControl, TextControl, PanelRow, RangeControl } from '@wordpress/components';
4
4
  import { getSettings, format } from '@wordpress/date';
5
5
 
6
6
  //日付のフォーマット
7
- var dateFormats = [{
8
- label: "YYYY-MM-DD HH:mm:ss",
9
- value: "Y-m-d H:i:s"
10
- }, {
11
- label: "MM/DD/YYYY",
12
- value: "m/d/Y"
13
- }, {
14
- label: "DD/MM/YYYY",
15
- value: "d/m/Y"
16
- }, {
17
- label: "MMMM D, YYYY",
18
- value: "F j, Y"
19
- }, {
20
- label: "HH:mm:ss",
21
- value: "H:i:s"
22
- }, {
23
- label: "YYYY.M.D",
24
- value: "Y.n.j"
25
- }, {
26
- label: "Day, MMMM D, YYYY",
27
- value: "l, F j, Y"
28
- }, {
29
- label: "ddd, MMM D, YYYY",
30
- value: "D, M j, Y"
31
- }, {
32
- label: "YYYY年M月D日 (曜日)",
33
- value: "Y年n月j日 (l)"
34
- }];
7
+ const dateFormats = [
8
+ { label: "YYYY-MM-DD HH:mm:ss", value: "Y-m-d H:i:s" },
9
+ { label: "MM/DD/YYYY", value: "m/d/Y" },
10
+ { label: "DD/MM/YYYY", value: "d/m/Y" },
11
+ { label: "MMMM D, YYYY", value: "F j, Y" },
12
+ { label: "HH:mm:ss", value: "H:i:s" },
13
+ { label: "YYYY.M.D", value: "Y.n.j" },
14
+ { label: "Day, MMMM D, YYYY", value: "l, F j, Y" },
15
+ { label: "ddd, MMM D, YYYY", value: "D, M j, Y" },
16
+ { label: "YYYY年M月D日 (曜日)", value: "Y年n月j日 (l)" },
17
+ ];
35
18
  //プレーンのフォーマット
36
- var plaineFormats = [{
37
- key: "str_free",
38
- label: __("Free String", "block-collections"),
39
- value: "%s"
40
- }, {
41
- key: "num_comma",
42
- label: __("Numbers (comma separated)", "block-collections"),
43
- value: {
44
- style: "decimal",
45
- useGrouping: true // カンマ区切り
46
- }
47
- }, {
48
- key: "num_no_comma",
49
- label: __("Numbers (no commas)", "block-collections"),
50
- value: {
51
- style: "decimal",
52
- useGrouping: false
53
- }
54
- }, {
55
- key: "num_amount",
56
- label: __("Amount", "block-collections"),
57
- value: {
58
- style: "currency",
59
- currency: "JPY"
60
- }
61
- }];
62
- var FormatSelectControl = _ref => {
63
- var {
64
- titleType,
65
- userFormat,
66
- freeStrFormat,
67
- decimal,
68
- onFormatChange
69
- } = _ref;
70
- var isPlaine = titleType === "plaine";
71
- var isDate = titleType === "date";
72
- var isUser = titleType === "user";
73
-
74
- //SelectControlのオプションを生成
75
- var options = isDate ? dateFormats : plaineFormats.map(f => ({
76
- label: f.label,
77
- value: f.key
78
- }));
79
- return /*#__PURE__*/React.createElement(PanelBody, {
80
- title: __("Display Format Setting", "block-collections")
81
- }, (isPlaine || isDate) && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SelectControl, {
82
- label: __("Select Format", "block-collections"),
83
- value: userFormat,
84
- options: options,
85
- onChange: newFormat => onFormatChange({
86
- userFormat: newFormat,
87
- freeStrFormat,
88
- decimal
89
- })
90
- }), (userFormat === null || userFormat === void 0 ? void 0 : userFormat.startsWith("str_")) && /*#__PURE__*/React.createElement(TextControl, {
91
- label: __("String Format", "block-collections"),
92
- value: freeStrFormat,
93
- onChange: newFormat => onFormatChange({
94
- userFormat,
95
- freeStrFormat: newFormat,
96
- decimal
97
- })
98
- }), (userFormat === null || userFormat === void 0 ? void 0 : userFormat.startsWith("num_")) && /*#__PURE__*/React.createElement(PanelRow, {
99
- className: "itmar_post_blocks_pannel"
100
- }, /*#__PURE__*/React.createElement(RangeControl, {
101
- value: decimal,
102
- label: __("Decimal Num", "query-blocks"),
103
- max: 5,
104
- min: 0,
105
- onChange: val => onFormatChange({
106
- userFormat,
107
- freeStrFormat,
108
- decimal: val
109
- })
110
- }))), isUser && /*#__PURE__*/React.createElement(TextControl, {
111
- label: __("User Format", "block-collections"),
112
- value: freeStrFormat,
113
- onChange: newFormat => onFormatChange({
114
- userFormat: "str_free",
115
- freeStrFormat: newFormat,
116
- decimal
117
- })
118
- }));
19
+ const plaineFormats = [
20
+ {
21
+ key: "str_free",
22
+ label: __("Free String", "block-collections"),
23
+ value: "%s",
24
+ },
25
+ {
26
+ key: "num_comma",
27
+ label: __("Numbers (comma separated)", "block-collections"),
28
+ value: {
29
+ style: "decimal",
30
+ useGrouping: true, // カンマ区切り
31
+ },
32
+ },
33
+ {
34
+ key: "num_no_comma",
35
+ label: __("Numbers (no commas)", "block-collections"),
36
+ value: {
37
+ style: "decimal",
38
+ useGrouping: false,
39
+ },
40
+ },
41
+ {
42
+ key: "num_amount",
43
+ label: __("Amount", "block-collections"),
44
+ value: {
45
+ style: "currency",
46
+ currency: "JPY",
47
+ },
48
+ },
49
+ ];
50
+ const FormatSelectControl = ({ titleType, userFormat, freeStrFormat, decimal, onFormatChange, }) => {
51
+ const isPlaine = titleType === "plaine";
52
+ const isDate = titleType === "date";
53
+ const isUser = titleType === "user";
54
+ //SelectControlのオプションを生成
55
+ const options = isDate
56
+ ? dateFormats
57
+ : plaineFormats.map((f) => ({ label: f.label, value: f.key }));
58
+ return (createElement(PanelBody, { title: __("Display Format Setting", "block-collections") },
59
+ (isPlaine || isDate) && (createElement(Fragment, null,
60
+ createElement(SelectControl, { label: __("Select Format", "block-collections"), value: userFormat, options: options, onChange: (newFormat) => onFormatChange({
61
+ userFormat: newFormat,
62
+ freeStrFormat,
63
+ decimal,
64
+ }) }),
65
+ userFormat?.startsWith("str_") && (createElement(TextControl, { label: __("String Format", "block-collections"), value: freeStrFormat, onChange: (newFormat) => onFormatChange({
66
+ userFormat,
67
+ freeStrFormat: newFormat,
68
+ decimal,
69
+ }) })),
70
+ userFormat?.startsWith("num_") && (createElement(PanelRow, { className: "itmar_post_blocks_pannel" },
71
+ createElement(RangeControl, { value: decimal, label: __("Decimal Num", "query-blocks"), max: 5, min: 0, onChange: (val) => onFormatChange({
72
+ userFormat,
73
+ freeStrFormat,
74
+ decimal: val ?? 0,
75
+ }) }))))),
76
+ isUser && (createElement(TextControl, { label: __("User Format", "block-collections"), value: freeStrFormat, onChange: (newFormat) => onFormatChange({
77
+ userFormat: "str_free",
78
+ freeStrFormat: newFormat,
79
+ decimal,
80
+ }) }))));
119
81
  };
120
- var displayFormated = (content, userFormat, freeStrFormat, decimal) => {
121
- var _getSettings$l10n, _plaineFormats$find;
122
- // 内部で使用するロケール
123
- var locale = ((_getSettings$l10n = getSettings().l10n) === null || _getSettings$l10n === void 0 ? void 0 : _getSettings$l10n.locale) || "en";
124
-
125
- //日付にフォーマットがあれば、それで書式設定してリターン
126
- var isDateFormat = dateFormats.find(f => f.value === userFormat);
127
- if (isDateFormat) {
128
- var ret_val = format(userFormat, content, getSettings());
129
- return ret_val;
130
- }
131
- //数値や文字列のフォーマット
132
- var selectedFormat = (_plaineFormats$find = plaineFormats.find(f => f.key === userFormat)) === null || _plaineFormats$find === void 0 ? void 0 : _plaineFormats$find.value;
133
- if (typeof selectedFormat === "object") {
134
- // Intl.NumberFormat オプション
135
- try {
136
- var numeric = parseFloat(content);
137
- // `selectedFormat` を元に新しいフォーマット設定を生成(mutateしない)
138
- var options = _objectSpread2({}, selectedFormat);
139
- if (typeof decimal === "number" && decimal > 0) {
140
- options.minimumFractionDigits = decimal;
141
- options.maximumFractionDigits = decimal;
142
- }
143
- var formatter = new Intl.NumberFormat(locale, options);
144
- return formatter.format(numeric);
145
- } catch (e) {
146
- console.warn("Number format failed:", e);
147
- return content;
82
+ /**
83
+ * 値を指定されたフォーマットで整形して返す
84
+ */
85
+ const displayFormated = (content, userFormat, freeStrFormat, decimal) => {
86
+ if (content === undefined || content === null)
87
+ return "";
88
+ // 内部で使用するロケール
89
+ const locale = getSettings().l10n?.locale || "en";
90
+ //日付にフォーマットがあれば、それで書式設定してリターン
91
+ const isDateFormat = dateFormats.find((f) => f.value === userFormat);
92
+ if (isDateFormat && userFormat) {
93
+ // WordPressの format 関数を使用して日付を整形
94
+ return format(userFormat, content);
95
+ }
96
+ //数値や文字列のフォーマット
97
+ const selectedFormat = plaineFormats.find((f) => f.key === userFormat)?.value;
98
+ if (typeof selectedFormat === "object" && selectedFormat !== null) {
99
+ // Intl.NumberFormat オプション
100
+ try {
101
+ const numeric = typeof content === "number" ? content : parseFloat(content);
102
+ if (isNaN(numeric))
103
+ return String(content);
104
+ // `selectedFormat` を元に新しいフォーマット設定を生成(mutateしない)
105
+ // options を型安全に生成
106
+ const options = { ...selectedFormat };
107
+ if (typeof decimal === "number" && decimal > 0) {
108
+ options.minimumFractionDigits = decimal;
109
+ options.maximumFractionDigits = decimal;
110
+ }
111
+ const formatter = new Intl.NumberFormat(locale, options);
112
+ return formatter.format(numeric);
113
+ }
114
+ catch (e) {
115
+ console.warn("Number format failed:", e);
116
+ return String(content);
117
+ }
118
+ }
119
+ else if (typeof selectedFormat === "string") {
120
+ return freeStrFormat.replace("%s", String(content));
148
121
  }
149
- } else if (typeof selectedFormat === "string") {
150
- return freeStrFormat.replace("%s", content);
151
- }
152
- //フォーマットが見つからないときはそのまま返す
153
- return content;
122
+ //フォーマットが見つからないときはそのまま返す
123
+ return content;
154
124
  };
155
125
 
156
126
  export { FormatSelectControl, displayFormated };
@@ -1 +1 @@
1
- {"version":3,"file":"formatCreate.js","sources":["../../src/formatCreate.js"],"sourcesContent":["import { __ } from \"@wordpress/i18n\";\nimport {\n PanelBody,\n PanelRow,\n RangeControl,\n TextControl,\n SelectControl,\n} from \"@wordpress/components\";\nimport { format, getSettings } from \"@wordpress/date\";\n\n//日付のフォーマット\nconst dateFormats = [\n { label: \"YYYY-MM-DD HH:mm:ss\", value: \"Y-m-d H:i:s\" },\n { label: \"MM/DD/YYYY\", value: \"m/d/Y\" },\n { label: \"DD/MM/YYYY\", value: \"d/m/Y\" },\n { label: \"MMMM D, YYYY\", value: \"F j, Y\" },\n { label: \"HH:mm:ss\", value: \"H:i:s\" },\n { label: \"YYYY.M.D\", value: \"Y.n.j\" },\n { label: \"Day, MMMM D, YYYY\", value: \"l, F j, Y\" },\n { label: \"ddd, MMM D, YYYY\", value: \"D, M j, Y\" },\n { label: \"YYYY年M月D日 (曜日)\", value: \"Y年n月j日 (l)\" },\n];\n//プレーンのフォーマット\nconst plaineFormats = [\n {\n key: \"str_free\",\n label: __(\"Free String\", \"block-collections\"),\n value: \"%s\",\n },\n {\n key: \"num_comma\",\n label: __(\"Numbers (comma separated)\", \"block-collections\"),\n value: {\n style: \"decimal\",\n useGrouping: true, // カンマ区切り\n },\n },\n {\n key: \"num_no_comma\",\n label: __(\"Numbers (no commas)\", \"block-collections\"),\n value: {\n style: \"decimal\",\n useGrouping: false,\n },\n },\n {\n key: \"num_amount\",\n label: __(\"Amount\", \"block-collections\"),\n value: {\n style: \"currency\",\n currency: \"JPY\",\n },\n },\n];\n\nexport const FormatSelectControl = ({\n titleType,\n userFormat,\n freeStrFormat,\n decimal,\n onFormatChange,\n}) => {\n const isPlaine = titleType === \"plaine\";\n const isDate = titleType === \"date\";\n const isUser = titleType === \"user\";\n\n //SelectControlのオプションを生成\n const options = isDate\n ? dateFormats\n : plaineFormats.map((f) => ({ label: f.label, value: f.key }));\n\n return (\n <PanelBody title={__(\"Display Format Setting\", \"block-collections\")}>\n {(isPlaine || isDate) && (\n <>\n <SelectControl\n label={__(\"Select Format\", \"block-collections\")}\n value={userFormat}\n options={options}\n onChange={(newFormat) =>\n onFormatChange({\n userFormat: newFormat,\n freeStrFormat,\n decimal,\n })\n }\n />\n\n {userFormat?.startsWith(\"str_\") && (\n <TextControl\n label={__(\"String Format\", \"block-collections\")}\n value={freeStrFormat}\n onChange={(newFormat) =>\n onFormatChange({\n userFormat,\n freeStrFormat: newFormat,\n decimal,\n })\n }\n />\n )}\n {userFormat?.startsWith(\"num_\") && (\n <PanelRow className=\"itmar_post_blocks_pannel\">\n <RangeControl\n value={decimal}\n label={__(\"Decimal Num\", \"query-blocks\")}\n max={5}\n min={0}\n onChange={(val) =>\n onFormatChange({\n userFormat,\n freeStrFormat,\n decimal: val,\n })\n }\n />\n </PanelRow>\n )}\n </>\n )}\n\n {isUser && (\n <TextControl\n label={__(\"User Format\", \"block-collections\")}\n value={freeStrFormat}\n onChange={(newFormat) =>\n onFormatChange({\n userFormat: \"str_free\",\n freeStrFormat: newFormat,\n decimal,\n })\n }\n />\n )}\n </PanelBody>\n );\n};\n\nexport const displayFormated = (\n content,\n userFormat,\n freeStrFormat,\n decimal\n) => {\n // 内部で使用するロケール\n const locale = getSettings().l10n?.locale || \"en\";\n\n //日付にフォーマットがあれば、それで書式設定してリターン\n const isDateFormat = dateFormats.find((f) => f.value === userFormat);\n if (isDateFormat) {\n const ret_val = format(userFormat, content, getSettings());\n return ret_val;\n }\n //数値や文字列のフォーマット\n const selectedFormat = plaineFormats.find((f) => f.key === userFormat)?.value;\n if (typeof selectedFormat === \"object\") {\n // Intl.NumberFormat オプション\n try {\n const numeric = parseFloat(content);\n // `selectedFormat` を元に新しいフォーマット設定を生成(mutateしない)\n const options = { ...selectedFormat };\n\n if (typeof decimal === \"number\" && decimal > 0) {\n options.minimumFractionDigits = decimal;\n options.maximumFractionDigits = decimal;\n }\n\n const formatter = new Intl.NumberFormat(locale, options);\n return formatter.format(numeric);\n } catch (e) {\n console.warn(\"Number format failed:\", e);\n return content;\n }\n } else if (typeof selectedFormat === \"string\") {\n return freeStrFormat.replace(\"%s\", content);\n }\n //フォーマットが見つからないときはそのまま返す\n return content;\n};\n"],"names":["dateFormats","label","value","plaineFormats","key","__","style","useGrouping","currency","FormatSelectControl","_ref","titleType","userFormat","freeStrFormat","decimal","onFormatChange","isPlaine","isDate","isUser","options","map","f","React","createElement","PanelBody","title","Fragment","SelectControl","onChange","newFormat","startsWith","TextControl","PanelRow","className","RangeControl","max","min","val","displayFormated","content","_getSettings$l10n","_plaineFormats$find","locale","getSettings","l10n","isDateFormat","find","ret_val","format","selectedFormat","numeric","parseFloat","_objectSpread","minimumFractionDigits","maximumFractionDigits","formatter","Intl","NumberFormat","e","console","warn","replace"],"mappings":";;;;;AAUA;AACA,IAAMA,WAAW,GAAG,CAClB;AAAEC,EAAAA,KAAK,EAAE,qBAAqB;AAAEC,EAAAA,KAAK,EAAE;AAAc,CAAC,EACtD;AAAED,EAAAA,KAAK,EAAE,YAAY;AAAEC,EAAAA,KAAK,EAAE;AAAQ,CAAC,EACvC;AAAED,EAAAA,KAAK,EAAE,YAAY;AAAEC,EAAAA,KAAK,EAAE;AAAQ,CAAC,EACvC;AAAED,EAAAA,KAAK,EAAE,cAAc;AAAEC,EAAAA,KAAK,EAAE;AAAS,CAAC,EAC1C;AAAED,EAAAA,KAAK,EAAE,UAAU;AAAEC,EAAAA,KAAK,EAAE;AAAQ,CAAC,EACrC;AAAED,EAAAA,KAAK,EAAE,UAAU;AAAEC,EAAAA,KAAK,EAAE;AAAQ,CAAC,EACrC;AAAED,EAAAA,KAAK,EAAE,mBAAmB;AAAEC,EAAAA,KAAK,EAAE;AAAY,CAAC,EACl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interface RGB {
7
+ red: number;
8
+ green: number;
9
+ blue: number;
10
+ }
11
+ /**
12
+ * HSLを16進数カラーコード(#RRGGBB)に変換
13
+ */
14
+ export declare function hslToRgb16(hue: number | string, saturation: number | string, lightness: number | string): string | false;
15
+ /**
16
+ * 16進数カラーコードをHSLオブジェクトに変換
17
+ */
18
+ export declare function rgb16ToHsl(strRgb16: string): HSL | false;
19
+ /**
20
+ * 16進数カラーコードをRGBオブジェクトに変換
21
+ */
22
+ export declare function HexToRGB(strRgb16: string): RGB | false;
23
+ export {};
@@ -1,128 +1,124 @@
1
- var createRGB = inputStr => {
2
- //16進数変換の関数
3
- function componentToHex(c) {
4
- var hex = parseInt(c, 10).toString(16);
5
- return hex.length === 1 ? "0" + hex : hex;
6
- }
7
- var resultStr;
8
- var rgb = [];
9
-
10
- // #000000 形式の場合
11
- if (/^#[0-9a-fA-F]{6}$/.test(inputStr)) {
12
- rgb = [inputStr.slice(1, 3), inputStr.slice(3, 5), inputStr.slice(5, 7)];
13
- }
14
- // rgb(0,0,0) 形式の場合
15
- else if (resultStr = inputStr.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)) {
16
- rgb = [componentToHex(resultStr[1]), componentToHex(resultStr[2]), componentToHex(resultStr[3])];
17
- } else {
18
- // サポートされていない形式の場合はデフォルトの値を設定する
19
- rgb = ["ff", "ff", "ff"];
20
- }
21
- return rgb;
1
+ const createRGB = (inputStr) => {
2
+ //16進数変換の関数
3
+ const componentToHex = (c) => {
4
+ const hex = parseInt(String(c), 10).toString(16);
5
+ return hex.length === 1 ? "0" + hex : hex;
6
+ };
7
+ // デフォルト値(白)
8
+ if (!inputStr)
9
+ return ["ff", "ff", "ff"];
10
+ let rgb;
11
+ // #000000 形式の場合
12
+ if (/^#[0-9a-fA-F]{6}$/.test(inputStr)) {
13
+ rgb = [inputStr.slice(1, 3), inputStr.slice(3, 5), inputStr.slice(5, 7)];
14
+ }
15
+ // rgb(0,0,0) 形式の場合
16
+ else {
17
+ const match = inputStr.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
18
+ if (match) {
19
+ rgb = [
20
+ componentToHex(match[1]),
21
+ componentToHex(match[2]),
22
+ componentToHex(match[3]),
23
+ ];
24
+ }
25
+ else {
26
+ // サポートされていない形式の場合は白を返す
27
+ rgb = ["ff", "ff", "ff"];
28
+ }
29
+ }
30
+ return rgb;
22
31
  };
32
+ /**
33
+ * HSLを16進数カラーコード(#RRGGBB)に変換
34
+ */
23
35
  function hslToRgb16(hue, saturation, lightness) {
24
- var result = false;
25
- if ((hue || hue === 0) && hue <= 360 && (saturation || saturation === 0) && saturation <= 100 && (lightness || lightness === 0) && lightness <= 100) {
26
- var red = 0,
27
- green = 0,
28
- blue = 0,
29
- q = 0,
30
- p = 0,
31
- hueToRgb;
32
- hue = Number(hue) / 360;
33
- saturation = Number(saturation) / 100;
34
- lightness = Number(lightness) / 100;
35
- if (saturation === 0) {
36
- red = lightness;
37
- green = lightness;
38
- blue = lightness;
39
- } else {
40
- hueToRgb = function hueToRgb(p, q, t) {
41
- if (t < 0) t += 1;
42
- if (t > 1) t -= 1;
43
- if (t < 1 / 6) {
44
- p += (q - p) * 6 * t;
45
- } else if (t < 1 / 2) {
46
- p = q;
47
- } else if (t < 2 / 3) {
48
- p += (q - p) * (2 / 3 - t) * 6;
36
+ const h = Number(hue);
37
+ const s = Number(saturation);
38
+ const l = Number(lightness);
39
+ if (h >= 0 && h <= 360 && s >= 0 && s <= 100 && l >= 0 && l <= 100) {
40
+ let red = 0, green = 0, blue = 0;
41
+ const hNorm = h / 360;
42
+ const sNorm = s / 100;
43
+ const lNorm = l / 100;
44
+ if (sNorm === 0) {
45
+ red = green = blue = lNorm;
49
46
  }
50
- return p;
51
- };
52
- if (lightness < 0.5) {
53
- q = lightness * (1 + saturation);
54
- } else {
55
- q = lightness + saturation - lightness * saturation;
56
- }
57
- p = 2 * lightness - q;
58
- red = hueToRgb(p, q, hue + 1 / 3);
59
- green = hueToRgb(p, q, hue);
60
- blue = hueToRgb(p, q, hue - 1 / 3);
47
+ else {
48
+ const hueToRgb = (p, q, t) => {
49
+ if (t < 0)
50
+ t += 1;
51
+ if (t > 1)
52
+ t -= 1;
53
+ if (t < 1 / 6)
54
+ return p + (q - p) * 6 * t;
55
+ if (t < 1 / 2)
56
+ return q;
57
+ if (t < 2 / 3)
58
+ return p + (q - p) * (2 / 3 - t) * 6;
59
+ return p;
60
+ };
61
+ const q = lNorm < 0.5 ? lNorm * (1 + sNorm) : lNorm + sNorm - lNorm * sNorm;
62
+ const p = 2 * lNorm - q;
63
+ red = hueToRgb(p, q, hNorm + 1 / 3);
64
+ green = hueToRgb(p, q, hNorm);
65
+ blue = hueToRgb(p, q, hNorm - 1 / 3);
66
+ }
67
+ const toHex = (c) => Math.round(c * 255)
68
+ .toString(16)
69
+ .padStart(2, "0");
70
+ return `#${toHex(red)}${toHex(green)}${toHex(blue)}`;
61
71
  }
62
- result = "#".concat(Math.round(red * 255).toString(16).padStart(2, '0')).concat(Math.round(green * 255).toString(16).padStart(2, '0')).concat(Math.round(blue * 255).toString(16).padStart(2, '0'));
63
- }
64
- return result;
72
+ return false;
65
73
  }
74
+ /**
75
+ * 16進数カラーコードをHSLオブジェクトに変換
76
+ */
66
77
  function rgb16ToHsl(strRgb16) {
67
- var rgb = createRGB(strRgb16);
68
- var red = rgb[0];
69
- var green = rgb[1];
70
- var blue = rgb[2];
71
- var result = false;
72
- if ((red || red === 0) && String(red).match(/^[0-9a-f]{2}$/i) && (green || green === 0) && String(green).match(/^[0-9a-f]{2}$/i) && (blue || blue === 0) && String(blue).match(/^[0-9a-f]{2}$/i)) {
73
- var hue = 0,
74
- saturation = 0,
75
- lightness = 0,
76
- max = 0,
77
- min = 0,
78
- diff = 0;
79
- red = parseInt(red, 16) / 255;
80
- green = parseInt(green, 16) / 255;
81
- blue = parseInt(blue, 16) / 255;
82
- max = Math.max(red, green, blue);
83
- min = Math.min(red, green, blue);
84
- lightness = (max + min) / 2;
85
- if (max !== min) {
86
- diff = max - min;
87
- if (lightness > 0.5) {
88
- saturation = diff / (2 - max - min);
89
- } else {
90
- saturation = diff / (max + min);
91
- }
92
- if (max === red) {
93
- hue = (green - blue) / diff;
94
- } else if (max === green) {
95
- hue = 2 + (blue - red) / diff;
96
- } else {
97
- hue = 4 + (red - green) / diff;
98
- }
99
- hue /= 6;
78
+ const rgb = createRGB(strRgb16); // 先ほど定義した [string, string, string] を返す関数
79
+ const [rHex, gHex, bHex] = rgb;
80
+ const hexPattern = /^[0-9a-f]{2}$/i;
81
+ if (hexPattern.test(rHex) && hexPattern.test(gHex) && hexPattern.test(bHex)) {
82
+ let h = 0, s = 0;
83
+ const r = parseInt(rHex, 16) / 255;
84
+ const g = parseInt(gHex, 16) / 255;
85
+ const b = parseInt(bHex, 16) / 255;
86
+ const max = Math.max(r, g, b);
87
+ const min = Math.min(r, g, b);
88
+ const l = (max + min) / 2;
89
+ if (max !== min) {
90
+ const d = max - min;
91
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
92
+ if (max === r)
93
+ h = (g - b) / d + (g < b ? 6 : 0);
94
+ else if (max === g)
95
+ h = (b - r) / d + 2;
96
+ else
97
+ h = (r - g) / d + 4;
98
+ h /= 6;
99
+ }
100
+ return {
101
+ hue: Math.round(h * 360),
102
+ saturation: Math.round(s * 100),
103
+ lightness: Math.round(l * 100),
104
+ };
100
105
  }
101
- result = {
102
- hue: Math.round(hue * 360),
103
- saturation: Math.round(saturation * 100),
104
- lightness: Math.round(lightness * 100)
105
- };
106
- }
107
- return result;
106
+ return false;
108
107
  }
108
+ /**
109
+ * 16進数カラーコードをRGBオブジェクトに変換
110
+ */
109
111
  function HexToRGB(strRgb16) {
110
- var rgb = createRGB(strRgb16);
111
- var red = rgb[0];
112
- var green = rgb[1];
113
- var blue = rgb[2];
114
- var result = false;
115
- if ((red || red === 0) && String(red).match(/^[0-9a-f]{2}$/i) && (green || green === 0) && String(green).match(/^[0-9a-f]{2}$/i) && (blue || blue === 0) && String(blue).match(/^[0-9a-f]{2}$/i)) {
116
- red = parseInt(red, 16);
117
- green = parseInt(green, 16);
118
- blue = parseInt(blue, 16);
119
- result = {
120
- red: Math.round(red),
121
- green: Math.round(green),
122
- blue: Math.round(blue)
123
- };
124
- }
125
- return result;
112
+ const [rHex, gHex, bHex] = createRGB(strRgb16);
113
+ const hexPattern = /^[0-9a-f]{2}$/i;
114
+ if (hexPattern.test(rHex) && hexPattern.test(gHex) && hexPattern.test(bHex)) {
115
+ return {
116
+ red: parseInt(rHex, 16),
117
+ green: parseInt(gHex, 16),
118
+ blue: parseInt(bHex, 16),
119
+ };
120
+ }
121
+ return false;
126
122
  }
127
123
 
128
124
  export { HexToRGB, hslToRgb16, rgb16ToHsl };