@eightshift/frontend-libs-tailwind 2.4.0 → 3.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/.gitattributes +0 -1
- package/CHANGELOG.md +26 -0
- package/bun.lock +144 -302
- package/linters/base.config.mjs +15 -0
- package/package.json +22 -28
- package/scripts/components/block-inserter.js +2 -3
- package/scripts/components/file-picker.js +32 -11
- package/scripts/components/link-section-editor.js +3 -3
- package/scripts/components/media-picker.js +1 -13
- package/scripts/components/picker-placeholder.js +10 -11
- package/scripts/components/settings/settings.js +3 -3
- package/scripts/editor/colors.js +3 -1
- package/scripts/editor/editor.js +0 -1
- package/scripts/editor/hooks.js +0 -1
- package/scripts/editor/registration.js +0 -1
- package/.stylelintrc +0 -4
package/linters/base.config.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import react from 'eslint-plugin-react';
|
|
2
2
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
3
3
|
import stylistic from '@stylistic/eslint-plugin';
|
|
4
|
+
import unusedImports from 'eslint-plugin-unused-imports';
|
|
4
5
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
5
6
|
import globals from 'globals';
|
|
6
7
|
|
|
@@ -26,6 +27,7 @@ export default [
|
|
|
26
27
|
react,
|
|
27
28
|
'react-hooks': reactHooks,
|
|
28
29
|
'@stylistic': stylistic,
|
|
30
|
+
'unused-imports': unusedImports,
|
|
29
31
|
},
|
|
30
32
|
rules: {
|
|
31
33
|
'newline-before-return': 'error',
|
|
@@ -34,6 +36,19 @@ export default [
|
|
|
34
36
|
'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
|
|
35
37
|
'no-nested-ternary': 'error',
|
|
36
38
|
'no-underscore-dangle': ['error', { allowAfterThis: true }],
|
|
39
|
+
'no-unused-vars': 'off',
|
|
40
|
+
'unused-imports/no-unused-imports': 'error',
|
|
41
|
+
'unused-imports/no-unused-vars': [
|
|
42
|
+
'error',
|
|
43
|
+
{
|
|
44
|
+
args: 'after-used',
|
|
45
|
+
argsIgnorePattern: '^_',
|
|
46
|
+
caughtErrors: 'all',
|
|
47
|
+
caughtErrorsIgnorePattern: '^_',
|
|
48
|
+
ignoreRestSiblings: true,
|
|
49
|
+
varsIgnorePattern: '^_',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
37
52
|
'no-void': 'error',
|
|
38
53
|
'@stylistic/semi': 'error',
|
|
39
54
|
'max-len': [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eightshift/frontend-libs-tailwind",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.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",
|
|
@@ -26,58 +26,52 @@
|
|
|
26
26
|
"url": "https://github.com/infinum/eightshift-frontend-libs-tailwind/issues"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
|
-
"lintStyle": "stylelint **/*.css",
|
|
30
29
|
"lintJs": "bunx eslint",
|
|
31
|
-
"lint": "
|
|
30
|
+
"lint": "bun run lintJs",
|
|
32
31
|
"prepare": "husky"
|
|
33
32
|
},
|
|
34
33
|
"homepage": "https://github.com/infinum/eightshift-frontend-libs-tailwind#readme",
|
|
35
34
|
"license": "MIT",
|
|
36
35
|
"dependencies": {
|
|
37
|
-
"@stylistic/eslint-plugin": "^5.
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
40
|
-
"
|
|
41
|
-
"browserslist": "^4.28.1",
|
|
36
|
+
"@stylistic/eslint-plugin": "^5.10.0",
|
|
37
|
+
"@swc/core": "^1.15.30",
|
|
38
|
+
"@wordpress/dependency-extraction-webpack-plugin": "^6.44.0",
|
|
39
|
+
"browserslist": "^4.28.2",
|
|
42
40
|
"css-loader": "^7.1.4",
|
|
43
|
-
"css-minimizer-webpack-plugin": "^
|
|
44
|
-
"eslint": "^
|
|
41
|
+
"css-minimizer-webpack-plugin": "^8.0.0",
|
|
42
|
+
"eslint": "^10.2.1",
|
|
45
43
|
"eslint-config-prettier": "^10.1.8",
|
|
46
44
|
"eslint-plugin-prettier": "^5.5.5",
|
|
47
|
-
"
|
|
45
|
+
"eslint-plugin-unused-imports": "^4.4.1",
|
|
46
|
+
"globals": "^17.5.0",
|
|
48
47
|
"husky": "^9.1.7",
|
|
49
|
-
"lightningcss": "^1.
|
|
50
|
-
"mini-css-extract-plugin": "^2.10.
|
|
51
|
-
"postcss": "^8.5.
|
|
48
|
+
"lightningcss": "^1.32.0",
|
|
49
|
+
"mini-css-extract-plugin": "^2.10.2",
|
|
50
|
+
"postcss": "^8.5.10",
|
|
52
51
|
"postcss-loader": "^8.2.1",
|
|
53
|
-
"prettier": "^3.8.
|
|
52
|
+
"prettier": "^3.8.3",
|
|
54
53
|
"prettier-plugin-tailwindcss": "^0.7.2",
|
|
55
54
|
"sonner": "^2.0.7",
|
|
56
|
-
"stylelint": "^16.26.1",
|
|
57
|
-
"stylelint-config-standard": "^39.0.1",
|
|
58
55
|
"swc-loader": "^0.2.7",
|
|
59
|
-
"terser-webpack-plugin": "^5.
|
|
60
|
-
"webpack": "^5.
|
|
61
|
-
"webpack-cli": "^
|
|
56
|
+
"terser-webpack-plugin": "^5.4.0",
|
|
57
|
+
"webpack": "^5.106.2",
|
|
58
|
+
"webpack-cli": "^7.0.2",
|
|
62
59
|
"webpack-manifest-plugin": "^6.0.1",
|
|
63
60
|
"webpack-merge": "^6.0.1",
|
|
64
61
|
"eslint-plugin-react": "^7.37.5",
|
|
65
|
-
"eslint-plugin-react-hooks": "^7.
|
|
62
|
+
"eslint-plugin-react-hooks": "^7.1.1"
|
|
66
63
|
},
|
|
67
64
|
"devDependencies": {
|
|
68
|
-
"
|
|
69
|
-
"
|
|
65
|
+
"@wordpress/api-fetch": "^7.44.0",
|
|
66
|
+
"lint-staged": "^16.4.0"
|
|
70
67
|
},
|
|
71
68
|
"peerDependencies": {
|
|
72
|
-
"@eightshift/ui-components": "^
|
|
69
|
+
"@eightshift/ui-components": "^7.3.0"
|
|
73
70
|
},
|
|
74
71
|
"sideEffects": false,
|
|
75
72
|
"lint-staged": {
|
|
76
|
-
"*.css": [
|
|
77
|
-
"npm run lintStyle"
|
|
78
|
-
],
|
|
79
73
|
"*.js": [
|
|
80
|
-
"
|
|
74
|
+
"bun run lintJs"
|
|
81
75
|
],
|
|
82
76
|
"*.php": [
|
|
83
77
|
"composer test"
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { __, sprintf } from '@wordpress/i18n';
|
|
3
2
|
import { Inserter } from '@wordpress/block-editor';
|
|
4
3
|
import { useSuspenseSelect } from '@wordpress/data';
|
|
5
4
|
import { Button } from '@eightshift/ui-components';
|
|
6
|
-
import {
|
|
5
|
+
import { add } from '@eightshift/ui-components/icons';
|
|
7
6
|
import { clsx } from '@eightshift/ui-components/utilities';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -70,7 +69,7 @@ export const BlockInserter = (props) => {
|
|
|
70
69
|
<Button
|
|
71
70
|
onPress={onToggle}
|
|
72
71
|
disabled={disabled}
|
|
73
|
-
icon={
|
|
72
|
+
icon={add}
|
|
74
73
|
size={small ? 'small' : 'default'}
|
|
75
74
|
className={clsx(className, 'es:font-sans')}
|
|
76
75
|
>
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
|
|
3
3
|
import { Button, FilePickerShell } from '@eightshift/ui-components';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
animationFile,
|
|
6
|
+
closedCaptions,
|
|
7
|
+
fileMetadata,
|
|
8
|
+
imageFile,
|
|
9
|
+
itemSelect,
|
|
10
|
+
swap,
|
|
11
|
+
upload,
|
|
12
|
+
videoFile,
|
|
13
|
+
} from '@eightshift/ui-components/icons';
|
|
5
14
|
|
|
6
15
|
/**
|
|
7
16
|
* A customizable button for managing files from the Media library.
|
|
@@ -62,9 +71,9 @@ export const ManageFileButton = (props) => {
|
|
|
62
71
|
replace: __('Select a new file', 'eightshift-frontend-libs-tailwind'),
|
|
63
72
|
},
|
|
64
73
|
buttonIcon: {
|
|
65
|
-
browse:
|
|
66
|
-
upload:
|
|
67
|
-
replace:
|
|
74
|
+
browse: itemSelect,
|
|
75
|
+
upload: upload,
|
|
76
|
+
replace: swap,
|
|
68
77
|
},
|
|
69
78
|
},
|
|
70
79
|
video: {
|
|
@@ -155,6 +164,7 @@ export const ManageFileButton = (props) => {
|
|
|
155
164
|
* @param {string[]} props.allowedTypes - Determines types of files which are allowed to be uploaded.
|
|
156
165
|
* @param {FileKind} [props.kind] - The kind of file to manage.
|
|
157
166
|
* @param {Object} [props.labels] - Custom UI labels for the buttons. Applies only if `kind` is set to `custom`.
|
|
167
|
+
* Additional props are passed to the `FilePickerShell` component.
|
|
158
168
|
*
|
|
159
169
|
* @returns {JSX.Element} The FileSelector component.
|
|
160
170
|
*
|
|
@@ -170,7 +180,17 @@ export const ManageFileButton = (props) => {
|
|
|
170
180
|
*
|
|
171
181
|
*/
|
|
172
182
|
export const FileSelector = (props) => {
|
|
173
|
-
const {
|
|
183
|
+
const {
|
|
184
|
+
onChange,
|
|
185
|
+
fileId,
|
|
186
|
+
fileName,
|
|
187
|
+
noDelete,
|
|
188
|
+
noUpload,
|
|
189
|
+
labels,
|
|
190
|
+
allowedTypes,
|
|
191
|
+
kind = 'file',
|
|
192
|
+
...filePickerShellProps
|
|
193
|
+
} = props;
|
|
174
194
|
|
|
175
195
|
const commonManageFileButtonProps = {
|
|
176
196
|
onChange,
|
|
@@ -180,12 +200,12 @@ export const FileSelector = (props) => {
|
|
|
180
200
|
};
|
|
181
201
|
|
|
182
202
|
const fileIcons = {
|
|
183
|
-
image:
|
|
184
|
-
video:
|
|
185
|
-
subtitle:
|
|
186
|
-
geoJson:
|
|
187
|
-
lottie:
|
|
188
|
-
rive:
|
|
203
|
+
image: imageFile,
|
|
204
|
+
video: videoFile,
|
|
205
|
+
subtitle: closedCaptions,
|
|
206
|
+
geoJson: fileMetadata,
|
|
207
|
+
lottie: animationFile,
|
|
208
|
+
rive: animationFile,
|
|
189
209
|
custom: labels?.removeIcon,
|
|
190
210
|
};
|
|
191
211
|
|
|
@@ -205,6 +225,7 @@ export const FileSelector = (props) => {
|
|
|
205
225
|
/>
|
|
206
226
|
</>
|
|
207
227
|
}
|
|
228
|
+
{...filePickerShellProps}
|
|
208
229
|
>
|
|
209
230
|
<ManageFileButton
|
|
210
231
|
{...commonManageFileButtonProps}
|
|
@@ -2,7 +2,7 @@ import { useCallback } from 'react';
|
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
3
|
import { RichText } from '@wordpress/block-editor';
|
|
4
4
|
import { Button } from '@eightshift/ui-components';
|
|
5
|
-
import {
|
|
5
|
+
import { add } from '@eightshift/ui-components/icons';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Link section editor.
|
|
@@ -292,7 +292,7 @@ export const LinkSectionEditor = (props) => {
|
|
|
292
292
|
|
|
293
293
|
<Button
|
|
294
294
|
size='small'
|
|
295
|
-
icon={
|
|
295
|
+
icon={add}
|
|
296
296
|
tooltip={__('Add link', 'eightshift-frontend-libs')}
|
|
297
297
|
onPress={({ target }) => {
|
|
298
298
|
updateItem(index, {
|
|
@@ -316,7 +316,7 @@ export const LinkSectionEditor = (props) => {
|
|
|
316
316
|
target?.previousElementSibling?.querySelector('[contenteditable="true"]')?.focus();
|
|
317
317
|
}, 20);
|
|
318
318
|
}}
|
|
319
|
-
icon={
|
|
319
|
+
icon={add}
|
|
320
320
|
tooltip={__('Add a section', 'eightshift-frontend-libs')}
|
|
321
321
|
className='justify-self-start'
|
|
322
322
|
>
|
|
@@ -24,7 +24,6 @@ const MediaButton = (props) => {
|
|
|
24
24
|
* @param {boolean} [props.hidden] - If `true`, the component will be hidden.
|
|
25
25
|
* @param {string[]} [props.allowedTypes=['image']] - Determines types of files which are allowed to be uploaded.
|
|
26
26
|
* @param {string} [props.className] - Classes to add to the button wrapper.
|
|
27
|
-
* @param {boolean} [props.__useSmartImageNext] - If `true`, the component will use the `__SmartImageNext` for image preview and processing.
|
|
28
27
|
*
|
|
29
28
|
* @returns {JSX.Element} The MediaPicker component.
|
|
30
29
|
*
|
|
@@ -38,17 +37,7 @@ const MediaButton = (props) => {
|
|
|
38
37
|
*
|
|
39
38
|
*/
|
|
40
39
|
export const MediaPicker = (props) => {
|
|
41
|
-
const {
|
|
42
|
-
onChange,
|
|
43
|
-
imageId,
|
|
44
|
-
imageUrl,
|
|
45
|
-
noDelete,
|
|
46
|
-
noUpload,
|
|
47
|
-
hidden,
|
|
48
|
-
allowedTypes = ['image'],
|
|
49
|
-
className,
|
|
50
|
-
__useSmartImageNext,
|
|
51
|
-
} = props;
|
|
40
|
+
const { onChange, imageId, imageUrl, noDelete, noUpload, hidden, allowedTypes = ['image'], className } = props;
|
|
52
41
|
|
|
53
42
|
if (hidden) {
|
|
54
43
|
return null;
|
|
@@ -74,7 +63,6 @@ export const MediaPicker = (props) => {
|
|
|
74
63
|
</>
|
|
75
64
|
}
|
|
76
65
|
className={className}
|
|
77
|
-
__useSmartImageNext={__useSmartImageNext}
|
|
78
66
|
>
|
|
79
67
|
{({ isDark, isTransparent }) => {
|
|
80
68
|
let buttonType = 'default';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { RichLabel, Button } from '@eightshift/ui-components';
|
|
3
|
-
import {
|
|
3
|
+
import { blockIcons, BlockIcon, componentGeneric, Icon } from '@eightshift/ui-components/icons';
|
|
4
4
|
import { dispatch } from '@wordpress/data';
|
|
5
5
|
import { createBlock } from '@wordpress/blocks';
|
|
6
6
|
import { BlockInserter } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
@@ -13,7 +13,7 @@ import { BlockInserter } from '@eightshift/frontend-libs-tailwind/scripts';
|
|
|
13
13
|
* @param {string|JSX.Element} [props.title] - Block name. Overrides manifest value (if provided).
|
|
14
14
|
* @param {Array} [props.presets] - Presets to show the user.
|
|
15
15
|
* @param {string} props.presets.name - Preset name.
|
|
16
|
-
* @param {string} props.presets.icon - Icon name. (
|
|
16
|
+
* @param {string} props.presets.icon - Icon name. (from `@eightshift/ui-components/icons`).
|
|
17
17
|
* @param {array} [props.presets.blocks] - Inner blocks to be added by the preset.
|
|
18
18
|
* @param {object} [props.presets.attributes] - Attributes to set to the current block.
|
|
19
19
|
* @param {string|JSX.Element} [props.blockIcon] - Block icon to show next to the title. Can either be a string (icon/block icon name - block icons have precedence), or a JSX element.
|
|
@@ -47,13 +47,12 @@ export const PickerPlaceholder = (props) => {
|
|
|
47
47
|
const blockIcon = rawBlockIcon ?? manifest?.icon?.src;
|
|
48
48
|
const presets = rawPresets ?? manifest?.layoutPresets;
|
|
49
49
|
|
|
50
|
-
let icon =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
50
|
+
let icon = (
|
|
51
|
+
<Icon
|
|
52
|
+
icon={blockIcon}
|
|
53
|
+
fallback={blockIcon in blockIcons ? <BlockIcon iconName={blockIcon} /> : componentGeneric}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
57
56
|
|
|
58
57
|
if (hidden) {
|
|
59
58
|
return null;
|
|
@@ -64,7 +63,7 @@ export const PickerPlaceholder = (props) => {
|
|
|
64
63
|
<RichLabel
|
|
65
64
|
icon={icon}
|
|
66
65
|
label={title}
|
|
67
|
-
className='col-span-2 mb-2
|
|
66
|
+
className='col-span-2 mb-2 font-medium !text-gray-400 select-none'
|
|
68
67
|
/>
|
|
69
68
|
|
|
70
69
|
<span className='es:col-span-2 es:select-none es:justify-self-center'>{presetsHeading}</span>
|
|
@@ -82,7 +81,7 @@ export const PickerPlaceholder = (props) => {
|
|
|
82
81
|
|
|
83
82
|
await dispatch('core/block-editor').insertBlocks(blocksToInsert, 0, clientId);
|
|
84
83
|
}}
|
|
85
|
-
icon={
|
|
84
|
+
icon={<Icon icon={icon} />}
|
|
86
85
|
size='large'
|
|
87
86
|
>
|
|
88
87
|
{name}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { Toaster } from 'sonner';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { Button, OptionsPanelHeader } from '@eightshift/ui-components';
|
|
6
|
-
import {
|
|
6
|
+
import { save } from '@eightshift/ui-components/icons';
|
|
7
7
|
import { createContext } from '@wordpress/element';
|
|
8
8
|
import { useThemeOptions } from './use-theme-options';
|
|
9
9
|
|
|
@@ -25,8 +25,8 @@ export const ThemeOptionsPage = ({
|
|
|
25
25
|
actions={
|
|
26
26
|
<Button
|
|
27
27
|
onPress={() => saveSettings()}
|
|
28
|
-
|
|
29
|
-
icon={
|
|
28
|
+
pending={isLoading}
|
|
29
|
+
icon={save}
|
|
30
30
|
>
|
|
31
31
|
{isLoading
|
|
32
32
|
? __('Saving...', 'eightshift-frontend-libs-tailwind')
|
package/scripts/editor/colors.js
CHANGED
|
@@ -14,7 +14,7 @@ import { upperFirst } from '@eightshift/ui-components/utilities';
|
|
|
14
14
|
* getPaletteColors()
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
export const
|
|
17
|
+
export const usePaletteColors = () =>
|
|
18
18
|
useSelect((select) => {
|
|
19
19
|
const colors = select(STORE_NAME).getSettings()?.globalVariables?.colors;
|
|
20
20
|
|
|
@@ -27,6 +27,8 @@ export const getPaletteColors = () =>
|
|
|
27
27
|
);
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
+
export const getPaletteColors = usePaletteColors;
|
|
31
|
+
|
|
30
32
|
export const getColorData = (themeColors) =>
|
|
31
33
|
Object.entries(themeColors ?? {})?.reduce((curr, [name, value]) => {
|
|
32
34
|
if (name === 'current') {
|
package/scripts/editor/editor.js
CHANGED
package/scripts/editor/hooks.js
CHANGED
package/.stylelintrc
DELETED