@eightshift/frontend-libs-tailwind 2.0.7 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.0",
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.4.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,8 +39,16 @@ 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
54
  buttonTooltip: {
@@ -160,7 +169,7 @@ export const ManageFileButton = (props) => {
160
169
  <Button
161
170
  onPress={open}
162
171
  icon={compact && buttonIcon}
163
- tooltip={buttonTooltip}
172
+ {...buttonProps}
164
173
  >
165
174
  {!compact && buttonLabel}
166
175
  </Button>
@@ -229,46 +238,34 @@ export const FileSelector = (props) => {
229
238
  };
230
239
 
231
240
  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
- >
241
+ <FilePickerShell
242
+ icon={fileIcons[kind]}
243
+ fileName={fileName}
244
+ url={fileName}
245
+ noUrlContent={
246
+ <>
241
247
  <ManageFileButton {...commonManageFileButtonProps} />
242
- {!noUpload && (
243
- <ManageFileButton
244
- {...commonManageFileButtonProps}
245
- type='upload'
246
- compact
247
- />
248
- )}
249
- </HStack>
250
- </FilePlaceholder>
251
248
 
252
- <AnimatedVisibility
253
- visible={(fileName ?? '').length > 0}
254
- noInitial
255
- >
256
- <HStack noWrap>
257
249
  <ManageFileButton
258
250
  {...commonManageFileButtonProps}
259
- currentId={fileId}
260
- type='replace'
251
+ type='upload'
252
+ hidden={noUpload}
261
253
  />
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>
254
+ </>
255
+ }
256
+ >
257
+ <ManageFileButton
258
+ {...commonManageFileButtonProps}
259
+ currentId={fileId}
260
+ type='replace'
261
+ />
262
+
263
+ <Button
264
+ onPress={() => onChange({ id: undefined, url: undefined })}
265
+ hidden={noDelete}
266
+ >
267
+ {__('Remove', 'eightshift-frontend-libs-tailwind')}
268
+ </Button>
269
+ </FilePickerShell>
273
270
  );
274
271
  };
@@ -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,50 @@ 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 && (
100
- <Button
101
- icon={icons.trash}
102
- tooltip={__('Remove image', 'infobip')}
103
- onPress={() => onChange({ id: undefined, url: undefined })}
104
- type='danger'
105
- />
106
- )}
107
63
  </>
108
- )}
109
- </HStack>
64
+ }
65
+ className={className}
66
+ >
67
+ <MediaButton
68
+ type='replace'
69
+ onChange={onChange}
70
+ currentId={imageId}
71
+ allowedTypes={allowedTypes}
72
+ buttonProps={{
73
+ type: 'glass',
74
+ }}
75
+ />
76
+
77
+ <Button
78
+ onPress={() => onChange({ id: undefined, url: undefined })}
79
+ type='glass'
80
+ hidden={noDelete}
81
+ >
82
+ {__('Remove', 'eightshift-frontend-libs-tailwind')}
83
+ </Button>
84
+ </FilePickerShell>
110
85
  );
111
86
  };