@plesk/ui-library 3.40.10 → 3.40.12

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.
@@ -0,0 +1,61 @@
1
+ // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
2
+
3
+ import { useState } from 'react';
4
+ import classNames from 'classnames';
5
+ import Button from '../Button';
6
+ import Input from '../Input';
7
+ import Translate from '../Translate';
8
+ import locale from './locale/en-US';
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ const Editor = _ref => {
11
+ let {
12
+ value: initialValue = '',
13
+ onSave,
14
+ onCancel,
15
+ baseClassName
16
+ } = _ref;
17
+ const [value, setValue] = useState(initialValue);
18
+ const handleChange = event => {
19
+ setValue(event.target.value);
20
+ };
21
+ const handleSave = () => onSave(value);
22
+ const handleInputKeyDown = event => {
23
+ if (event.key === 'Escape') {
24
+ onCancel();
25
+ } else if (event.key === 'Enter') {
26
+ handleSave();
27
+ }
28
+ };
29
+ return /*#__PURE__*/_jsxs("div", {
30
+ className: `${baseClassName}__edit`,
31
+ children: [/*#__PURE__*/_jsx(Input, {
32
+ className: `${baseClassName}__edit-input`,
33
+ value: value,
34
+ onChange: handleChange,
35
+ onKeyDown: handleInputKeyDown,
36
+ autoFocus: true
37
+ }), /*#__PURE__*/_jsxs("div", {
38
+ className: `${baseClassName}__edit-actions`,
39
+ children: [/*#__PURE__*/_jsx(Button, {
40
+ ghost: true,
41
+ className: classNames(`${baseClassName}__control-button`, `${baseClassName}__control-button--ok`),
42
+ icon: "check-mark",
43
+ onClick: handleSave,
44
+ tooltip: /*#__PURE__*/_jsx(Translate, {
45
+ content: "InPlaceEdit.okButtonHint",
46
+ fallback: locale.okButtonHint
47
+ })
48
+ }), /*#__PURE__*/_jsx(Button, {
49
+ ghost: true,
50
+ className: classNames(`${baseClassName}__control-button`, `${baseClassName}__control-button--cancel`),
51
+ icon: "cross-mark",
52
+ onClick: onCancel,
53
+ tooltip: /*#__PURE__*/_jsx(Translate, {
54
+ content: "InPlaceEdit.cancelButtonHint",
55
+ fallback: locale.cancelButtonHint
56
+ })
57
+ })]
58
+ })]
59
+ });
60
+ };
61
+ export default Editor;
@@ -1,13 +1,11 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
3
2
 
4
- import { Component } from 'react';
3
+ import { useState } from 'react';
5
4
  import classNames from 'classnames';
6
5
  import { CLS_PREFIX } from '../../constants';
7
6
  import Button from '../Button';
8
- import Input from '../Input';
9
- import Tooltip from '../Tooltip';
10
7
  import Translate from '../Translate';
8
+ import Editor from './Editor';
11
9
  import locale from './locale/en-US';
12
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
11
  /**
@@ -16,114 +14,41 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
14
  * give users a different way of editing the text.
17
15
  * @since 1.8.3
18
16
  */
19
- class InPlaceEdit extends Component {
20
- constructor() {
21
- super(...arguments);
22
- _defineProperty(this, "state", {
23
- editing: false,
24
- draft: ''
25
- });
26
- _defineProperty(this, "handleEdit", () => {
27
- this.setState(_ref => {
28
- let {
29
- editing
30
- } = _ref;
31
- return {
32
- editing: !editing,
33
- draft: editing ? '' : this.props.value
34
- };
35
- });
36
- });
37
- _defineProperty(this, "handleEditKey", event => {
38
- if (event.key === 'Escape') {
39
- this.handleEdit();
40
- } else if (event.key === 'Enter') {
41
- this.handleEditOk();
42
- }
43
- });
44
- _defineProperty(this, "handleChange", event => {
45
- this.setState({
46
- draft: event.target.value
47
- });
48
- });
49
- _defineProperty(this, "handleEditOk", () => {
50
- if (this.props.onChange) {
51
- this.props.onChange(this.state.draft);
52
- }
53
- this.handleEdit();
54
- });
55
- }
56
- render() {
57
- const {
58
- draft,
59
- editing
60
- } = this.state;
61
- const {
62
- baseClassName,
63
- className,
64
- onChange,
65
- value,
66
- ...props
67
- } = this.props;
68
- return /*#__PURE__*/_jsxs("div", {
69
- className: classNames(baseClassName, className),
70
- ...props,
71
- children: [editing ? /*#__PURE__*/_jsxs("div", {
72
- className: `${baseClassName}__edit`,
73
- children: [/*#__PURE__*/_jsx(Input, {
74
- className: `${baseClassName}__edit-input`,
75
- value: draft,
76
- onChange: this.handleChange,
77
- onKeyDown: this.handleEditKey,
78
- autoFocus: true
79
- }), /*#__PURE__*/_jsxs("div", {
80
- className: `${baseClassName}__edit-actions`,
81
- children: [/*#__PURE__*/_jsx(Tooltip, {
82
- title: /*#__PURE__*/_jsx(Translate, {
83
- content: "InPlaceEdit.okButtonHint",
84
- fallback: locale.okButtonHint
85
- }),
86
- children: /*#__PURE__*/_jsx(Button, {
87
- ghost: true,
88
- className: classNames(`${baseClassName}__control-button`, `${baseClassName}__control-button--ok`),
89
- icon: "check-mark",
90
- onClick: this.handleEditOk
91
- })
92
- }), /*#__PURE__*/_jsx(Tooltip, {
93
- title: /*#__PURE__*/_jsx(Translate, {
94
- content: "InPlaceEdit.cancelButtonHint",
95
- fallback: locale.cancelButtonHint
96
- }),
97
- children: /*#__PURE__*/_jsx(Button, {
98
- ghost: true,
99
- className: classNames(`${baseClassName}__control-button`, `${baseClassName}__control-button--cancel`),
100
- icon: "cross-mark",
101
- onClick: this.handleEdit
102
- })
103
- })]
104
- })]
105
- }) : value, onChange && !editing && /*#__PURE__*/_jsx(Tooltip, {
106
- title: /*#__PURE__*/_jsx(Translate, {
107
- content: "InPlaceEdit.editButtonHint",
108
- fallback: locale.editButtonHint
109
- }),
110
- children: /*#__PURE__*/_jsx(Button, {
111
- ghost: true,
112
- className: classNames(`${baseClassName}__control-button`, `${baseClassName}__control-button--edit`),
113
- onClick: this.handleEdit,
114
- icon: {
115
- name: 'pencil',
116
- className: `${baseClassName}__control-button-icon`
117
- }
118
- })
119
- })]
120
- });
121
- }
122
- }
123
- _defineProperty(InPlaceEdit, "defaultProps", {
124
- value: null,
125
- onChange: null,
126
- className: null,
127
- baseClassName: `${CLS_PREFIX}in-place-edit`
128
- });
17
+ const InPlaceEdit = _ref => {
18
+ let {
19
+ baseClassName = `${CLS_PREFIX}in-place-edit`,
20
+ className,
21
+ onChange,
22
+ value,
23
+ ...props
24
+ } = _ref;
25
+ const [isEditing, setIsEditing] = useState(false);
26
+ const toggleEditing = () => setIsEditing(current => !current);
27
+ const handleSave = newValue => {
28
+ onChange?.(newValue);
29
+ toggleEditing();
30
+ };
31
+ return /*#__PURE__*/_jsxs("div", {
32
+ className: classNames(baseClassName, className),
33
+ ...props,
34
+ children: [!isEditing && value, !isEditing && onChange && /*#__PURE__*/_jsx(Button, {
35
+ ghost: true,
36
+ className: classNames(`${baseClassName}__control-button`, `${baseClassName}__control-button--edit`),
37
+ onClick: toggleEditing,
38
+ icon: {
39
+ name: 'pencil',
40
+ className: `${baseClassName}__control-button-icon`
41
+ },
42
+ tooltip: /*#__PURE__*/_jsx(Translate, {
43
+ content: "InPlaceEdit.editButtonHint",
44
+ fallback: locale.editButtonHint
45
+ })
46
+ }), isEditing && /*#__PURE__*/_jsx(Editor, {
47
+ baseClassName: baseClassName,
48
+ value: `${value}`,
49
+ onSave: handleSave,
50
+ onCancel: toggleEditing
51
+ })]
52
+ });
53
+ };
129
54
  export default InPlaceEdit;
@@ -449,9 +449,12 @@ class Tabs extends Component {
449
449
  } = this.state;
450
450
  const clone = /*#__PURE__*/cloneElement(search, searchProps);
451
451
  if (compact) {
452
- return /*#__PURE__*/_jsx("div", {
453
- className: `${baseClassName}__search`,
454
- children: clone
452
+ return /*#__PURE__*/_jsx(ResponsiveContext.Provider, {
453
+ value: true,
454
+ children: /*#__PURE__*/_jsx("div", {
455
+ className: `${baseClassName}__search`,
456
+ children: clone
457
+ })
455
458
  });
456
459
  }
457
460
  return clone;
@@ -511,55 +514,52 @@ class Tabs extends Component {
511
514
  addonBlock = this.renderSearchBar(searchProps);
512
515
  }
513
516
  }
514
- return /*#__PURE__*/_jsx(ResponsiveContext.Provider, {
515
- value: compact,
516
- children: /*#__PURE__*/_jsxs("div", {
517
- className: classNames(baseClassName, className),
518
- ...props,
519
- children: [/*#__PURE__*/_jsx(Measure, {
520
- onResize: this.handleResize,
521
- innerRef: ref => this.tabsnavRef = ref,
522
- children: _ref => {
523
- let {
524
- measureRef
525
- } = _ref;
526
- return /*#__PURE__*/_jsxs("div", {
527
- className: classNames(`${baseClassName}__nav`, compact && `${baseClassName}__nav--compact`, searching && `${baseClassName}__nav--searching`, search && `${baseClassName}__nav--search`),
528
- ref: measureRef,
529
- children: [this.renderTabList(), /*#__PURE__*/_jsx(Measure, {
530
- onResize: this.handleResize,
531
- children: _ref2 => {
532
- let {
533
- measureRef: ref
534
- } = _ref2;
535
- const fakeTabs = this.renderFakeTabs();
536
- return fakeTabs ? /*#__PURE__*/cloneElement(fakeTabs, {
537
- ref
538
- }) : null;
539
- }
540
- }), searchBlock, addonBlock && /*#__PURE__*/_jsx(Measure, {
541
- onResize: this.handleAddonResize,
542
- bounds: true,
543
- children: _ref3 => {
544
- let {
545
- measureRef: ref
546
- } = _ref3;
547
- return /*#__PURE__*/_jsx("div", {
548
- className: `${baseClassName}__addon`,
549
- ref: ref,
550
- ...addonProps,
551
- children: addonBlock
552
- });
553
- }
554
- })]
555
- });
556
- }
557
- }), /*#__PURE__*/_jsx("div", {
558
- className: `${baseClassName}__tab-panel`,
559
- role: "tabpanel",
560
- children: Children.map(children, (tab, index) => index + 1 === this.state.active ? tab : null)
561
- })]
562
- })
517
+ return /*#__PURE__*/_jsxs("div", {
518
+ className: classNames(baseClassName, className),
519
+ ...props,
520
+ children: [/*#__PURE__*/_jsx(Measure, {
521
+ onResize: this.handleResize,
522
+ innerRef: ref => this.tabsnavRef = ref,
523
+ children: _ref => {
524
+ let {
525
+ measureRef
526
+ } = _ref;
527
+ return /*#__PURE__*/_jsxs("div", {
528
+ className: classNames(`${baseClassName}__nav`, compact && `${baseClassName}__nav--compact`, searching && `${baseClassName}__nav--searching`, search && `${baseClassName}__nav--search`),
529
+ ref: measureRef,
530
+ children: [this.renderTabList(), /*#__PURE__*/_jsx(Measure, {
531
+ onResize: this.handleResize,
532
+ children: _ref2 => {
533
+ let {
534
+ measureRef: ref
535
+ } = _ref2;
536
+ const fakeTabs = this.renderFakeTabs();
537
+ return fakeTabs ? /*#__PURE__*/cloneElement(fakeTabs, {
538
+ ref
539
+ }) : null;
540
+ }
541
+ }), searchBlock, addonBlock && /*#__PURE__*/_jsx(Measure, {
542
+ onResize: this.handleAddonResize,
543
+ bounds: true,
544
+ children: _ref3 => {
545
+ let {
546
+ measureRef: ref
547
+ } = _ref3;
548
+ return /*#__PURE__*/_jsx("div", {
549
+ className: `${baseClassName}__addon`,
550
+ ref: ref,
551
+ ...addonProps,
552
+ children: addonBlock
553
+ });
554
+ }
555
+ })]
556
+ });
557
+ }
558
+ }), /*#__PURE__*/_jsx("div", {
559
+ className: `${baseClassName}__tab-panel`,
560
+ role: "tabpanel",
561
+ children: Children.map(children, (tab, index) => index + 1 === this.state.active ? tab : null)
562
+ })]
563
563
  });
564
564
  }
565
565
  }
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // Copyright 1999-2023. Plesk International GmbH. All rights reserved.
2
2
  import svg4everybody from 'svg4everybody';
3
- const version = "3.40.10";
3
+ const version = "3.40.12";
4
4
  export * from './publicPath';
5
5
  export { version };
6
6
  export * from './utils';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plesk/ui-library",
3
- "version": "3.40.10",
3
+ "version": "3.40.12",
4
4
  "description": "Plesk UI Library",
5
5
  "main": "index.js",
6
6
  "module": "esm/index.js",
@@ -25,8 +25,8 @@
25
25
  "lint:es": "eslint --ext js,md,tsx src configs scripts styleguidist",
26
26
  "lint:types": "tsc",
27
27
  "lint:style": "stylelint \"{src,styleguidist}/**/*.less\"",
28
- "format:check": "prettier --check src",
29
- "format": "prettier --write src",
28
+ "format:check": "prettier --check src styleguidist",
29
+ "format": "prettier --write src styleguidist",
30
30
  "styleguide": "styleguidist server --config ./configs/styleguide.config.js",
31
31
  "styleguide:build": "rimraf ./styleguide && styleguidist build --config ./configs/styleguide.config.js",
32
32
  "prepublishOnly": "yarn install && yarn test && yarn build && yarn styleguide:build",
@@ -48,13 +48,13 @@
48
48
  "classnames": "^2.5.1",
49
49
  "codemirror": "5.58.2",
50
50
  "marked": "4.2.12",
51
- "memoize-one": "^5.2.1",
51
+ "memoize-one": "^6.0.0",
52
52
  "popper.js": "1.16.1",
53
53
  "prop-types": "^15.8.1",
54
54
  "react-measure": "2.5.2",
55
55
  "react-sortable-hoc": "0.6.8",
56
56
  "react-transition-group": "^4.4.5",
57
- "scroll-into-view-if-needed": "^2.2.31",
57
+ "scroll-into-view-if-needed": "^3.1.0",
58
58
  "svg4everybody": "2.1.9",
59
59
  "use-focus-visible": "^1.0.2"
60
60
  },
@@ -67,7 +67,7 @@
67
67
  "@babel/preset-react": "^7.24.7",
68
68
  "@babel/preset-typescript": "^7.24.7",
69
69
  "@babel/types": "^7.25.6",
70
- "@csstools/postcss-logical-float-and-clear": "^2.0.1",
70
+ "@csstools/postcss-logical-float-and-clear": "^3.0.0",
71
71
  "@plesk/eslint-config": "^3.0.0",
72
72
  "@plesk/stylelint-config": "^2.0.0",
73
73
  "@testing-library/dom": "^9.3.4",
@@ -77,7 +77,7 @@
77
77
  "@types/buble": "^0.20.5",
78
78
  "@types/classnames": "2.3.1",
79
79
  "@types/codemirror": "^5.60.15",
80
- "@types/doctrine": "^0.0.5",
80
+ "@types/doctrine": "^0.0.9",
81
81
  "@types/jest": "^29.5.13",
82
82
  "@types/jest-image-snapshot": "^6.4.0",
83
83
  "@types/marked": "^4.3.2",
@@ -86,12 +86,12 @@
86
86
  "@types/react-dom": "^18.3.0",
87
87
  "@types/react-measure": "2.0.9",
88
88
  "@types/react-transition-group": "^4.4.11",
89
- "@types/svg4everybody": "2.1.2",
89
+ "@types/svg4everybody": "2.1.5",
90
90
  "@types/webpack-env": "^1.18.5",
91
91
  "@typescript-eslint/eslint-plugin": "^6.21.0",
92
92
  "@typescript-eslint/parser": "^6.21.0",
93
93
  "autoprefixer": "^10.4.20",
94
- "babel-loader": "^8.4.1",
94
+ "babel-loader": "^9.2.1",
95
95
  "babel-plugin-transform-require-ignore": "^0.1.1",
96
96
  "cross-env": "^7.0.3",
97
97
  "css-loader": "^7.1.2",
@@ -110,8 +110,8 @@
110
110
  "postcss": "^8.4.47",
111
111
  "postcss-less": "^6.0.0",
112
112
  "postcss-loader": "^8.1.1",
113
- "postcss-logical": "^7.0.1",
114
- "prettier": "^2.8.8",
113
+ "postcss-logical": "^8.0.0",
114
+ "prettier": "^3.4.1",
115
115
  "puppeteer-core": "22.8.2",
116
116
  "react": "^18.3.1",
117
117
  "react-docgen-typescript": "^2.2.2",
@@ -123,7 +123,7 @@
123
123
  "stylelint": "^15.11.0",
124
124
  "stylelint-declaration-block-no-ignored-properties": "^2.8.0",
125
125
  "stylelint-no-unsupported-browser-features": "^6.1.0",
126
- "stylelint-prettier": "^3.0.0",
126
+ "stylelint-prettier": "^4.1.0",
127
127
  "stylelint-use-logical-spec": "^5.0.1",
128
128
  "svg-mixer": "^2.3.14",
129
129
  "terser-webpack-plugin": "^5.3.10",