@equinor/cpl-compact-autocomplete 1.0.2 → 1.0.4

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 (3) hide show
  1. package/dist/index.js +14 -41
  2. package/dist/index.mjs +14 -44
  3. package/package.json +22 -15
package/dist/index.js CHANGED
@@ -3,34 +3,8 @@ var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
6
  var __getProtoOf = Object.getPrototypeOf;
8
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __objRest = (source, exclude) => {
23
- var target = {};
24
- for (var prop in source)
25
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
- target[prop] = source[prop];
27
- if (source != null && __getOwnPropSymbols)
28
- for (var prop of __getOwnPropSymbols(source)) {
29
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
- target[prop] = source[prop];
31
- }
32
- return target;
33
- };
34
8
  var __export = (target, all) => {
35
9
  for (var name in all)
36
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -104,38 +78,37 @@ var CompactAutocompleteWrapper = import_styled_components2.default.label`
104
78
 
105
79
  // src/CompactAutocomplete.tsx
106
80
  var import_jsx_runtime = require("react/jsx-runtime");
107
- function CompactAutocomplete(_a) {
108
- var _b = _a, {
109
- label,
110
- autocompleteRef
111
- } = _b, props = __objRest(_b, [
112
- "label",
113
- "autocompleteRef"
114
- ]);
81
+ function CompactAutocomplete({
82
+ label,
83
+ autocompleteRef,
84
+ ...props
85
+ }) {
115
86
  const { multiple, optionLabel, selectedOptions } = props;
116
87
  const placeholder = (0, import_react.useMemo)(() => {
117
88
  if (!multiple) {
118
89
  return void 0;
119
90
  }
120
- const selectedLabels = optionLabel ? selectedOptions == null ? void 0 : selectedOptions.map((option) => optionLabel(option)) : selectedOptions;
121
- return selectedLabels == null ? void 0 : selectedLabels.join(", ");
91
+ const selectedLabels = optionLabel ? selectedOptions?.map((option) => optionLabel(option)) : selectedOptions;
92
+ return selectedLabels?.join(", ");
122
93
  }, [multiple, optionLabel, selectedOptions]);
123
94
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CompactAutocompleteWrapper, { onClick: handleClick, children: [
124
95
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CompactAutocompleteLabel, { className: LABEL_CLASS_NAME, children: label }),
125
96
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CPLAutocompleteWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
126
97
  import_eds_core_react.Autocomplete,
127
- __spreadValues({
98
+ {
128
99
  label: null,
129
100
  placeholder,
130
- ref: autocompleteRef
131
- }, props)
101
+ ref: autocompleteRef,
102
+ // Disable linting for spreading generic props that depends on T
103
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Props are spread to Autocomplete component which is typed with T, so type should be correct
104
+ ...props
105
+ }
132
106
  ) })
133
107
  ] });
134
108
  }
135
109
  var LABEL_CLASS_NAME = "cpl-compact-autocomplete-label";
136
110
  function handleClick(event) {
137
- var _a;
138
- const clickedLabel = (_a = event.target) == null ? void 0 : _a.classList.contains(LABEL_CLASS_NAME);
111
+ const clickedLabel = event.target?.classList.contains(LABEL_CLASS_NAME);
139
112
  if (!clickedLabel) {
140
113
  event.stopPropagation();
141
114
  event.preventDefault();
package/dist/index.mjs CHANGED
@@ -1,32 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- var __objRest = (source, exclude) => {
18
- var target = {};
19
- for (var prop in source)
20
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
- target[prop] = source[prop];
22
- if (source != null && __getOwnPropSymbols)
23
- for (var prop of __getOwnPropSymbols(source)) {
24
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
- target[prop] = source[prop];
26
- }
27
- return target;
28
- };
29
-
30
1
  // src/CompactAutocomplete.tsx
31
2
  import { Autocomplete } from "@equinor/eds-core-react";
32
3
  import { tokens as tokens2 } from "@equinor/eds-tokens";
@@ -69,38 +40,37 @@ var CompactAutocompleteWrapper = styled2.label`
69
40
 
70
41
  // src/CompactAutocomplete.tsx
71
42
  import { jsx, jsxs } from "react/jsx-runtime";
72
- function CompactAutocomplete(_a) {
73
- var _b = _a, {
74
- label,
75
- autocompleteRef
76
- } = _b, props = __objRest(_b, [
77
- "label",
78
- "autocompleteRef"
79
- ]);
43
+ function CompactAutocomplete({
44
+ label,
45
+ autocompleteRef,
46
+ ...props
47
+ }) {
80
48
  const { multiple, optionLabel, selectedOptions } = props;
81
49
  const placeholder = useMemo(() => {
82
50
  if (!multiple) {
83
51
  return void 0;
84
52
  }
85
- const selectedLabels = optionLabel ? selectedOptions == null ? void 0 : selectedOptions.map((option) => optionLabel(option)) : selectedOptions;
86
- return selectedLabels == null ? void 0 : selectedLabels.join(", ");
53
+ const selectedLabels = optionLabel ? selectedOptions?.map((option) => optionLabel(option)) : selectedOptions;
54
+ return selectedLabels?.join(", ");
87
55
  }, [multiple, optionLabel, selectedOptions]);
88
56
  return /* @__PURE__ */ jsxs(CompactAutocompleteWrapper, { onClick: handleClick, children: [
89
57
  /* @__PURE__ */ jsx(CompactAutocompleteLabel, { className: LABEL_CLASS_NAME, children: label }),
90
58
  /* @__PURE__ */ jsx(CPLAutocompleteWrapper, { children: /* @__PURE__ */ jsx(
91
59
  Autocomplete,
92
- __spreadValues({
60
+ {
93
61
  label: null,
94
62
  placeholder,
95
- ref: autocompleteRef
96
- }, props)
63
+ ref: autocompleteRef,
64
+ // Disable linting for spreading generic props that depends on T
65
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Props are spread to Autocomplete component which is typed with T, so type should be correct
66
+ ...props
67
+ }
97
68
  ) })
98
69
  ] });
99
70
  }
100
71
  var LABEL_CLASS_NAME = "cpl-compact-autocomplete-label";
101
72
  function handleClick(event) {
102
- var _a;
103
- const clickedLabel = (_a = event.target) == null ? void 0 : _a.classList.contains(LABEL_CLASS_NAME);
73
+ const clickedLabel = event.target?.classList.contains(LABEL_CLASS_NAME);
104
74
  if (!clickedLabel) {
105
75
  event.stopPropagation();
106
76
  event.preventDefault();
package/package.json CHANGED
@@ -1,30 +1,37 @@
1
1
  {
2
2
  "name": "@equinor/cpl-compact-autocomplete",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
8
15
  "files": [
9
16
  "dist/**"
10
17
  ],
11
18
  "dependencies": {
12
- "@equinor/eds-icons": "^0.21.0",
13
- "@equinor/eds-tokens": "^0.9.2"
19
+ "@equinor/eds-icons": "1.2.1",
20
+ "@equinor/eds-tokens": "2.1.1"
14
21
  },
15
22
  "devDependencies": {
16
- "@equinor/eds-core-react": "^2.2.0",
17
- "@storybook/react": "^9.1.1",
18
- "@types/react": "^18.3.18",
19
- "@types/react-dom": "^18.3.5",
20
- "@types/styled-components": "^5.1.34",
21
- "eslint": "^9.21.0",
22
- "react": "^18.2.0",
23
- "react-dom": "^18.2.0",
24
- "styled-components": "^6.1.14",
25
- "tsup": "^8.5.1",
26
- "@equinor/cpl-eslint-config": "1.0.0",
27
- "@equinor/cpl-typescript-config": "0.0.2"
23
+ "@equinor/eds-core-react": "2.3.4",
24
+ "@storybook/react-vite": "10.2.8",
25
+ "@types/react": "19.2.13",
26
+ "@types/react-dom": "19.2.3",
27
+ "@types/styled-components": "5.1.36",
28
+ "eslint": "10.0.0",
29
+ "react": "19.2.4",
30
+ "react-dom": "19.2.4",
31
+ "styled-components": "6.3.9",
32
+ "tsup": "8.5.1",
33
+ "@equinor/cpl-eslint-config": "1.0.4",
34
+ "@equinor/cpl-typescript-config": "0.0.5"
28
35
  },
29
36
  "peerDependencies": {
30
37
  "@equinor/eds-core-react": ">=2.2.0",