@eightshift/frontend-libs-tailwind 2.0.7 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eightshift/frontend-libs-tailwind",
3
- "version": "2.0.7",
3
+ "version": "2.1.1",
4
4
  "description": "A framework for creating modern Gutenberg themes with styling provided by Tailwind CSS.",
5
5
  "author": {
6
6
  "name": "Eightshift team",
@@ -35,39 +35,39 @@
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
37
  "@stylistic/eslint-plugin-js": "^4.4.1",
38
- "@stylistic/stylelint-plugin": "^3.1.2",
39
- "@swc/core": "^1.12.1",
40
- "@wordpress/dependency-extraction-webpack-plugin": "^6.25.0",
41
- "browserslist": "^4.25.0",
38
+ "@stylistic/stylelint-plugin": "^4.0.0",
39
+ "@swc/core": "^1.13.5",
40
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.32.0",
41
+ "browserslist": "^4.26.3",
42
42
  "css-loader": "^7.1.2",
43
43
  "css-minimizer-webpack-plugin": "^7.0.2",
44
- "eslint": "^9.29.0",
45
- "eslint-config-prettier": "^10.1.5",
46
- "eslint-plugin-prettier": "^5.5.0",
47
- "globals": "^16.2.0",
44
+ "eslint": "^9.37.0",
45
+ "eslint-config-prettier": "^10.1.8",
46
+ "eslint-plugin-prettier": "^5.5.4",
47
+ "globals": "^16.4.0",
48
48
  "husky": "^9.1.7",
49
- "lightningcss": "^1.30.1",
50
- "mini-css-extract-plugin": "^2.9.2",
49
+ "lightningcss": "^1.30.2",
50
+ "mini-css-extract-plugin": "^2.9.4",
51
51
  "postcss": "^8.5.6",
52
- "postcss-loader": "^8.1.1",
53
- "prettier": "^3.5.3",
54
- "prettier-plugin-tailwindcss": "^0.6.12",
55
- "sonner": "^2.0.5",
56
- "stylelint": "^16.20.0",
57
- "stylelint-config-standard": "^38.0.0",
52
+ "postcss-loader": "^8.2.0",
53
+ "prettier": "^3.6.2",
54
+ "prettier-plugin-tailwindcss": "^0.6.14",
55
+ "sonner": "^2.0.7",
56
+ "stylelint": "^16.25.0",
57
+ "stylelint-config-standard": "^39.0.1",
58
58
  "swc-loader": "^0.2.6",
59
59
  "terser-webpack-plugin": "^5.3.14",
60
- "webpack": "^5.99.9",
60
+ "webpack": "^5.102.0",
61
61
  "webpack-cli": "^6.0.1",
62
62
  "webpack-manifest-plugin": "^5.0.1",
63
63
  "webpack-merge": "^6.0.1"
64
64
  },
65
65
  "devDependencies": {
66
- "lint-staged": "^15.5.2",
67
- "@wordpress/api-fetch": "^7.25.0"
66
+ "lint-staged": "^16.2.3",
67
+ "@wordpress/api-fetch": "^7.32.0"
68
68
  },
69
69
  "peerDependencies": {
70
- "@eightshift/ui-components": "^5.0.0"
70
+ "@eightshift/ui-components": "^5.5.0"
71
71
  },
72
72
  "sideEffects": false,
73
73
  "lint-staged": {
@@ -1,7 +1,6 @@
1
- import React from 'react';
2
1
  import { __ } from '@wordpress/i18n';
3
2
  import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
4
- import { Button, HStack, VStack, FilePlaceholder, AnimatedVisibility } from '@eightshift/ui-components';
3
+ import { Button, FilePickerShell } from '@eightshift/ui-components';
5
4
  import { icons } from '@eightshift/ui-components/icons';
6
5
 
7
6
  /**
@@ -16,6 +15,8 @@ import { icons } from '@eightshift/ui-components/icons';
16
15
  * @param {string[]} props.allowedTypes - Determines types of files which are allowed to be uploaded.
17
16
  * @param {ManageFileButtonKind} [props.kind] - The kind of file to manage. Controls labels and icons on the buttons.
18
17
  * @param {Object} [props.labels] - Custom UI labels for the buttons. Applies only if `kind` is set to `custom`.
18
+ * @param {Object} [props.buttonProps] - Props to pass to the trigger button.
19
+ * @param {boolean} [props.hidden] - If `true`, the component will not be rendered.
19
20
  *
20
21
  * @returns {JSX.Element} The ManageFileButton component.
21
22
  *
@@ -38,15 +39,18 @@ export const ManageFileButton = (props) => {
38
39
  kind = 'file',
39
40
 
40
41
  compact = false,
42
+
43
+ buttonProps,
44
+
45
+ hidden,
41
46
  } = props;
42
47
 
48
+ if (hidden) {
49
+ return null;
50
+ }
51
+
43
52
  const strings = {
44
53
  file: {
45
- buttonTooltip: {
46
- browse: __('Select a file from Media library', 'eightshift-frontend-libs-tailwind'),
47
- upload: __('Upload a file', 'eightshift-frontend-libs-tailwind'),
48
- replace: __('Replace file', 'eightshift-frontend-libs-tailwind'),
49
- },
50
54
  buttonLabel: {
51
55
  browse: __('Select', 'eightshift-frontend-libs-tailwind'),
52
56
  upload: __('Upload', 'eightshift-frontend-libs-tailwind'),
@@ -64,11 +68,6 @@ export const ManageFileButton = (props) => {
64
68
  },
65
69
  },
66
70
  video: {
67
- buttonTooltip: {
68
- browse: __('Select a video from Media library', 'eightshift-frontend-libs-tailwind'),
69
- upload: __('Upload a video', 'eightshift-frontend-libs-tailwind'),
70
- replace: __('Replace video', 'eightshift-frontend-libs-tailwind'),
71
- },
72
71
  modalTitle: {
73
72
  browse: __('Select a video', 'eightshift-frontend-libs-tailwind'),
74
73
  upload: __('Upload a video', 'eightshift-frontend-libs-tailwind'),
@@ -76,11 +75,6 @@ export const ManageFileButton = (props) => {
76
75
  },
77
76
  },
78
77
  image: {
79
- buttonTooltip: {
80
- browse: __('Select an image from Media library', 'eightshift-frontend-libs-tailwind'),
81
- upload: __('Upload an image', 'eightshift-frontend-libs-tailwind'),
82
- replace: __('Replace image', 'eightshift-frontend-libs-tailwind'),
83
- },
84
78
  modalTitle: {
85
79
  browse: __('Select an image', 'eightshift-frontend-libs-tailwind'),
86
80
  upload: __('Upload an image', 'eightshift-frontend-libs-tailwind'),
@@ -88,11 +82,6 @@ export const ManageFileButton = (props) => {
88
82
  },
89
83
  },
90
84
  subtitle: {
91
- buttonTooltip: {
92
- browse: __('Select a subtitle file', 'eightshift-frontend-libs-tailwind'),
93
- upload: __('Upload a subtitle file', 'eightshift-frontend-libs-tailwind'),
94
- replace: __('Replace subtitle file', 'eightshift-frontend-libs-tailwind'),
95
- },
96
85
  modalTitle: {
97
86
  browse: __('Select a subtitle file', 'eightshift-frontend-libs-tailwind'),
98
87
  upload: __('Upload a subtitle file', 'eightshift-frontend-libs-tailwind'),
@@ -100,11 +89,6 @@ export const ManageFileButton = (props) => {
100
89
  },
101
90
  },
102
91
  geoJson: {
103
- buttonTooltip: {
104
- browse: __('Select a GeoJSON file', 'eightshift-frontend-libs-tailwind'),
105
- upload: __('Upload a GeoJSON file', 'eightshift-frontend-libs-tailwind'),
106
- replace: __('Replace GeoJSON file', 'eightshift-frontend-libs-tailwind'),
107
- },
108
92
  modalTitle: {
109
93
  browse: __('Select a GeoJSON file', 'eightshift-frontend-libs-tailwind'),
110
94
  upload: __('Upload a GeoJSON file', 'eightshift-frontend-libs-tailwind'),
@@ -112,11 +96,6 @@ export const ManageFileButton = (props) => {
112
96
  },
113
97
  },
114
98
  lottie: {
115
- buttonTooltip: {
116
- browse: __('Select a Lottie animation', 'eightshift-frontend-libs-tailwind'),
117
- upload: __('Upload a Lottie animation', 'eightshift-frontend-libs-tailwind'),
118
- replace: __('Replace Lottie animation', 'eightshift-frontend-libs-tailwind'),
119
- },
120
99
  modalTitle: {
121
100
  browse: __('Select a Lottie animation', 'eightshift-frontend-libs-tailwind'),
122
101
  upload: __('Upload a Lottie animation', 'eightshift-frontend-libs-tailwind'),
@@ -124,11 +103,6 @@ export const ManageFileButton = (props) => {
124
103
  },
125
104
  },
126
105
  rive: {
127
- buttonTooltip: {
128
- browse: __('Select a Rive animation', 'eightshift-frontend-libs-tailwind'),
129
- upload: __('Upload a Rive animation', 'eightshift-frontend-libs-tailwind'),
130
- replace: __('Replace Rive animation', 'eightshift-frontend-libs-tailwind'),
131
- },
132
106
  modalTitle: {
133
107
  browse: __('Select a Rive animation', 'eightshift-frontend-libs-tailwind'),
134
108
  upload: __('Upload a Rive animation', 'eightshift-frontend-libs-tailwind'),
@@ -136,14 +110,12 @@ export const ManageFileButton = (props) => {
136
110
  },
137
111
  },
138
112
  custom: {
139
- buttonTooltip: labels?.buttonTooltip,
140
113
  buttonLabel: labels?.buttonLabel,
141
114
  modalTitle: labels?.modalTitle,
142
115
  buttonIcon: labels?.buttonIcon,
143
116
  },
144
117
  };
145
118
 
146
- const buttonTooltip = strings?.[kind]?.buttonTooltip?.[type] ?? strings.file.buttonTooltip?.[type];
147
119
  const buttonLabel = strings?.[kind]?.buttonLabel?.[type] ?? strings.file.buttonLabel?.[type];
148
120
  const buttonIcon = strings?.[kind]?.buttonIcon?.[type] ?? strings.file.buttonIcon?.[type];
149
121
  const modalTitle = strings?.[kind]?.modalTitle?.[type] ?? strings.file.modalTitle?.[type];
@@ -160,7 +132,7 @@ export const ManageFileButton = (props) => {
160
132
  <Button
161
133
  onPress={open}
162
134
  icon={compact && buttonIcon}
163
- tooltip={buttonTooltip}
135
+ {...buttonProps}
164
136
  >
165
137
  {!compact && buttonLabel}
166
138
  </Button>
@@ -207,17 +179,6 @@ export const FileSelector = (props) => {
207
179
  labels,
208
180
  };
209
181
 
210
- const removeTooltips = {
211
- file: __('Remove file', 'eightshift-frontend-libs-tailwind'),
212
- image: __('Remove image', 'eightshift-frontend-libs-tailwind'),
213
- video: __('Remove video', 'eightshift-frontend-libs-tailwind'),
214
- subtitle: __('Remove subtitle file', 'eightshift-frontend-libs-tailwind'),
215
- geoJson: __('Remove GeoJSON file', 'eightshift-frontend-libs-tailwind'),
216
- lottie: __('Remove Lottie animation', 'eightshift-frontend-libs-tailwind'),
217
- rive: __('Remove Rive animation', 'eightshift-frontend-libs-tailwind'),
218
- custom: labels?.removeTooltip,
219
- };
220
-
221
182
  const fileIcons = {
222
183
  image: icons.imageFile,
223
184
  video: icons.videoFile,
@@ -229,46 +190,36 @@ export const FileSelector = (props) => {
229
190
  };
230
191
 
231
192
  return (
232
- <VStack noWrap>
233
- <FilePlaceholder
234
- icon={fileIcons[kind] ?? icons.file}
235
- fileName={fileName}
236
- >
237
- <HStack
238
- noWrap
239
- className='es:pl-1'
240
- >
193
+ <FilePickerShell
194
+ icon={fileIcons[kind]}
195
+ fileName={fileName}
196
+ url={fileName}
197
+ noUrlContent={
198
+ <>
241
199
  <ManageFileButton {...commonManageFileButtonProps} />
242
- {!noUpload && (
243
- <ManageFileButton
244
- {...commonManageFileButtonProps}
245
- type='upload'
246
- compact
247
- />
248
- )}
249
- </HStack>
250
- </FilePlaceholder>
251
200
 
252
- <AnimatedVisibility
253
- visible={(fileName ?? '').length > 0}
254
- noInitial
255
- >
256
- <HStack noWrap>
257
201
  <ManageFileButton
258
202
  {...commonManageFileButtonProps}
259
- currentId={fileId}
260
- type='replace'
203
+ type='upload'
204
+ hidden={noUpload}
261
205
  />
262
- {!noDelete && (
263
- <Button
264
- icon={icons.trash}
265
- tooltip={removeTooltips[kind] ?? removeTooltips.file}
266
- onPress={() => onChange({ id: undefined, url: undefined })}
267
- type='danger'
268
- />
269
- )}
270
- </HStack>
271
- </AnimatedVisibility>
272
- </VStack>
206
+ </>
207
+ }
208
+ >
209
+ <ManageFileButton
210
+ {...commonManageFileButtonProps}
211
+ buttonProps={{ className: 'es:grow' }}
212
+ currentId={fileId}
213
+ type='replace'
214
+ />
215
+
216
+ <Button
217
+ onPress={() => onChange({ id: undefined, url: undefined })}
218
+ className='es:grow'
219
+ hidden={noDelete}
220
+ >
221
+ {__('Remove', 'eightshift-frontend-libs-tailwind')}
222
+ </Button>
223
+ </FilePickerShell>
273
224
  );
274
225
  };
@@ -1,7 +1,5 @@
1
- import React from 'react';
2
1
  import { __ } from '@wordpress/i18n';
3
- import { Button, HStack, ImagePlaceholder } from '@eightshift/ui-components';
4
- import { icons } from '@eightshift/ui-components/icons';
2
+ import { Button, FilePickerShell } from '@eightshift/ui-components';
5
3
  import { ManageFileButton } from './file-picker';
6
4
 
7
5
  const MediaButton = (props) => {
@@ -20,19 +18,15 @@ const MediaButton = (props) => {
20
18
  * @param {Object} props - Component props.
21
19
  * @param {Function} props.onChange - The function that handles the change event.
22
20
  * @param {string} props.imageId - ID of the currently selected image. Used to mark the currently selected item when replacing the image.
23
- * @param {string} props.imageAlt - Alt text of the currently selected image.
24
21
  * @param {string} props.imageUrl - URL of the currently selected image.
25
22
  * @param {boolean} [props.noDelete] - If `true`, the delete button will be hidden.
26
23
  * @param {boolean} [props.noUpload] - If `true`, the upload button will be hidden.
27
- * @param {ImagePlaceholderImageMode} [props.imageMode='cover'] - Determines inner image display mode.
28
24
  * @param {boolean} [props.hidden] - If `true`, the component will be hidden.
29
25
  * @param {string[]} [props.allowedTypes=['image']] - Determines types of files which are allowed to be uploaded.
30
26
  * @param {string} [props.className] - Classes to add to the button wrapper.
31
27
  *
32
28
  * @returns {JSX.Element} The MediaPicker component.
33
29
  *
34
- * @typedef {'cover'|'contain' | 'fill'} ImagePlaceholderImageMode
35
- *
36
30
  * @example
37
31
  * <MediaPicker
38
32
  * onChange={onChange}
@@ -43,69 +37,64 @@ const MediaButton = (props) => {
43
37
  *
44
38
  */
45
39
  export const MediaPicker = (props) => {
46
- const {
47
- onChange,
48
- imageId,
49
- imageAlt,
50
- imageUrl,
51
- noDelete,
52
- noUpload,
53
- imageMode,
54
- hidden,
55
- allowedTypes = ['image'],
56
- className,
57
- } = props;
40
+ const { onChange, imageId, imageUrl, noDelete, noUpload, hidden, allowedTypes = ['image'], className } = props;
58
41
 
59
42
  if (hidden) {
60
43
  return null;
61
44
  }
62
45
 
63
46
  return (
64
- <HStack
65
- className={className}
66
- noWrap
67
- >
68
- <ImagePlaceholder
69
- url={imageUrl}
70
- alt={imageAlt}
71
- imageMode={imageMode}
72
- />
73
-
74
- {!imageUrl && (
47
+ <FilePickerShell
48
+ url={imageUrl}
49
+ type='image'
50
+ noUrlContent={
75
51
  <>
76
52
  <MediaButton
77
53
  onChange={onChange}
78
54
  allowedTypes={allowedTypes}
79
55
  />
80
- {!noUpload && (
81
- <MediaButton
82
- onChange={onChange}
83
- type='upload'
84
- allowedTypes={allowedTypes}
85
- compact
86
- />
87
- )}
88
- </>
89
- )}
90
56
 
91
- {imageUrl && (
92
- <>
93
57
  <MediaButton
94
- type='replace'
95
58
  onChange={onChange}
96
- currentId={imageId}
59
+ type='upload'
97
60
  allowedTypes={allowedTypes}
61
+ hidden={noUpload}
98
62
  />
99
- {!noDelete && (
63
+ </>
64
+ }
65
+ className={className}
66
+ >
67
+ {({ isDark, isTransparent }) => {
68
+ let buttonType = 'default';
69
+
70
+ if (!isTransparent) {
71
+ buttonType = isDark ? 'glass' : 'glassDark';
72
+ }
73
+
74
+ return (
75
+ <>
76
+ <MediaButton
77
+ type='replace'
78
+ onChange={onChange}
79
+ currentId={imageId}
80
+ allowedTypes={allowedTypes}
81
+ buttonProps={{
82
+ type: buttonType,
83
+ className: 'es:grow',
84
+ }}
85
+ />
86
+
100
87
  <Button
101
- icon={icons.trash}
102
- tooltip={__('Remove image', 'infobip')}
103
88
  onPress={() => onChange({ id: undefined, url: undefined })}
104
- type='danger'
105
- />
106
- )}
107
- </>
108
- )}
109
- </HStack>
89
+ className='es:grow'
90
+ type={buttonType}
91
+ hidden={noDelete}
92
+ >
93
+ {__('Remove', 'eightshift-frontend-libs-tailwind')}
94
+ </Button>
95
+ </>
96
+ );
97
+ }}
98
+ </FilePickerShell>
110
99
  );
111
100
  };