@entur/chip 0.6.18 → 0.6.20

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.
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import './BaseChip.scss';
3
3
  import './ActionChip.scss';
4
- export declare type ActionChipProps = {
4
+ export type ActionChipProps = {
5
5
  /** Teksten som vises i ActionChip */
6
6
  children: React.ReactNode;
7
7
  /** Ekstra klassenavn */
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import './BaseChip.scss';
3
3
  import './ChoiceChip.scss';
4
- export declare type ChoiceChipProps = {
4
+ export type ChoiceChipProps = {
5
5
  /** Ekstra klassenavn */
6
6
  className?: string;
7
7
  /** Om Choicechip er deaktivert eller ikke
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- export declare type ChoiceChipGroupProps = {
2
+ export type ChoiceChipGroupProps = {
3
3
  /** Navnet til ChoiceChipsGroup */
4
4
  name: string;
5
5
  /** Verdien til den valgte ChoiceChipen */
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- declare type ChoiceChipGroupContextProps = {
2
+ type ChoiceChipGroupContextProps = {
3
3
  name: string;
4
4
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
5
5
  value: string | null;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import './BaseChip.scss';
3
3
  import './FilterChip.scss';
4
- export declare type FilterChipProps = {
4
+ export type FilterChipProps = {
5
5
  /** Ekstra klassenavn */
6
6
  className?: string;
7
7
  /** Label til FilterChip */
package/dist/TagChip.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import './BaseChip.scss';
3
3
  import './TagChip.scss';
4
- export declare type TagChipProps = {
4
+ export type TagChipProps = {
5
5
  /** Teksten som vises i TagChip */
6
6
  children: React.ReactNode;
7
7
  /** Ekstra klassenavn */
@@ -15,35 +15,29 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
15
15
  var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
16
16
 
17
17
  function _extends() {
18
- _extends = Object.assign || function (target) {
18
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
19
19
  for (var i = 1; i < arguments.length; i++) {
20
20
  var source = arguments[i];
21
-
22
21
  for (var key in source) {
23
22
  if (Object.prototype.hasOwnProperty.call(source, key)) {
24
23
  target[key] = source[key];
25
24
  }
26
25
  }
27
26
  }
28
-
29
27
  return target;
30
28
  };
31
-
32
29
  return _extends.apply(this, arguments);
33
30
  }
34
-
35
31
  function _objectWithoutPropertiesLoose(source, excluded) {
36
32
  if (source == null) return {};
37
33
  var target = {};
38
34
  var sourceKeys = Object.keys(source);
39
35
  var key, i;
40
-
41
36
  for (i = 0; i < sourceKeys.length; i++) {
42
37
  key = sourceKeys[i];
43
38
  if (excluded.indexOf(key) >= 0) continue;
44
39
  target[key] = source[key];
45
40
  }
46
-
47
41
  return target;
48
42
  }
49
43
 
@@ -51,24 +45,21 @@ var ChoiceChipGroupContext = /*#__PURE__*/React__default["default"].createContex
51
45
  var ChoiceChipGroupContextProvider = ChoiceChipGroupContext.Provider;
52
46
  var useChoiceChipGroupContext = function useChoiceChipGroupContext() {
53
47
  var context = React__default["default"].useContext(ChoiceChipGroupContext);
54
-
55
48
  if (!context) {
56
49
  throw new Error('You need to wrap your ChoiceChips in a ChoiceChipGroup-component');
57
50
  }
58
-
59
51
  return context;
60
52
  };
61
53
 
62
54
  var _excluded$4 = ["className", "children", "value", "disabled", "style"];
63
55
  var ChoiceChip = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
64
56
  var className = _ref.className,
65
- children = _ref.children,
66
- value = _ref.value,
67
- _ref$disabled = _ref.disabled,
68
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
69
- style = _ref.style,
70
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
71
-
57
+ children = _ref.children,
58
+ value = _ref.value,
59
+ _ref$disabled = _ref.disabled,
60
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
61
+ style = _ref.style,
62
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
72
63
  var childrenArray = React__default["default"].Children.toArray(children);
73
64
  var hasLeadingIcon = childrenArray.length > 1 && typeof childrenArray[0] !== 'string';
74
65
  var hasTrailingIcon = childrenArray.length > 1 && typeof childrenArray[childrenArray.length - 1] !== 'string';
@@ -77,12 +68,10 @@ var ChoiceChip = /*#__PURE__*/React__default["default"].forwardRef(function (_re
77
68
  'eds-chip--leading-icon': hasLeadingIcon,
78
69
  'eds-chip--trailing-icon': hasTrailingIcon
79
70
  });
80
-
81
71
  var _useChoiceChipGroupCo = useChoiceChipGroupContext(),
82
- name = _useChoiceChipGroupCo.name,
83
- selectedValue = _useChoiceChipGroupCo.value,
84
- onChange = _useChoiceChipGroupCo.onChange;
85
-
72
+ name = _useChoiceChipGroupCo.name,
73
+ selectedValue = _useChoiceChipGroupCo.value,
74
+ onChange = _useChoiceChipGroupCo.onChange;
86
75
  return React__default["default"].createElement("label", {
87
76
  className: "eds-choice-chip",
88
77
  style: style
@@ -103,21 +92,18 @@ var ChoiceChip = /*#__PURE__*/React__default["default"].forwardRef(function (_re
103
92
  var _excluded$3 = ["children", "className", "loading"];
104
93
  var ActionChip = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
105
94
  var children = _ref.children,
106
- className = _ref.className,
107
- _ref$loading = _ref.loading,
108
- loading = _ref$loading === void 0 ? false : _ref$loading,
109
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
110
-
95
+ className = _ref.className,
96
+ _ref$loading = _ref.loading,
97
+ loading = _ref$loading === void 0 ? false : _ref$loading,
98
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
111
99
  var childrenArray = React__default["default"].Children.toArray(children);
112
100
  var hasLeadingIcon = childrenArray.length > 1 && typeof childrenArray[0] !== 'string';
113
101
  var hasTrailingIcon = childrenArray.length > 1 && typeof childrenArray[childrenArray.length - 1] !== 'string';
114
-
115
102
  var ariaLabelValue = function ariaLabelValue() {
116
103
  if (rest['aria-label']) return rest['aria-label'];
117
104
  if (loading) return ariaLabelWhenLoading;
118
105
  return undefined;
119
106
  };
120
-
121
107
  var ariaLabelWhenLoading = childrenArray.filter(function (child) {
122
108
  return typeof child === 'string';
123
109
  }).join(' ');
@@ -134,24 +120,21 @@ var ActionChip = /*#__PURE__*/React__default["default"].forwardRef(function (_re
134
120
  }, rest), loading ? React__default["default"].createElement(loader.LoadingDots, {
135
121
  className: "eds-action-chip__loading-dots"
136
122
  }) : children);
137
-
138
123
  if (rest.disabled) {
139
124
  return React__default["default"].createElement("div", {
140
125
  className: "eds-action-chip--disabled__wrapper"
141
126
  }, actionChip);
142
127
  }
143
-
144
128
  return React__default["default"].createElement(React__default["default"].Fragment, null, actionChip);
145
129
  });
146
130
 
147
131
  var _excluded$2 = ["children", "className", "onClose", "closeButtonAriaLabel"];
148
132
  var TagChip = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
149
133
  var children = _ref.children,
150
- className = _ref.className,
151
- onClose = _ref.onClose,
152
- closeButtonAriaLabel = _ref.closeButtonAriaLabel,
153
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
154
-
134
+ className = _ref.className,
135
+ onClose = _ref.onClose,
136
+ closeButtonAriaLabel = _ref.closeButtonAriaLabel,
137
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
155
138
  var selectedCloseLabel = closeButtonAriaLabel != null ? closeButtonAriaLabel : 'Fjern ' + (children == null ? void 0 : children.toString());
156
139
  return React__default["default"].createElement("div", _extends({
157
140
  className: classNames__default["default"]('eds-chip', 'eds-tag-chip', className)
@@ -167,14 +150,13 @@ var TagChip = /*#__PURE__*/React__default["default"].forwardRef(function (_ref,
167
150
  var _excluded$1 = ["className", "children", "value", "disabled", "name", "style"];
168
151
  var FilterChip = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
169
152
  var className = _ref.className,
170
- children = _ref.children,
171
- value = _ref.value,
172
- _ref$disabled = _ref.disabled,
173
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
174
- name = _ref.name,
175
- style = _ref.style,
176
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
177
-
153
+ children = _ref.children,
154
+ value = _ref.value,
155
+ _ref$disabled = _ref.disabled,
156
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
157
+ name = _ref.name,
158
+ style = _ref.style,
159
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
178
160
  var classList = classNames__default["default"](className, 'eds-chip', 'eds-filter-chip');
179
161
  return React__default["default"].createElement("label", {
180
162
  className: classList,
@@ -190,7 +172,6 @@ var FilterChip = /*#__PURE__*/React__default["default"].forwardRef(function (_re
190
172
  className: "eds-filter-chip__icon"
191
173
  }, React__default["default"].createElement(CheckboxIcon, null)), children);
192
174
  });
193
-
194
175
  var CheckboxIcon = function CheckboxIcon() {
195
176
  return React__default["default"].createElement("svg", {
196
177
  className: "eds-filter-chip-icon",
@@ -207,12 +188,11 @@ var CheckboxIcon = function CheckboxIcon() {
207
188
  var _excluded = ["name", "value", "children", "onChange", "label"];
208
189
  var ChoiceChipGroup = function ChoiceChipGroup(_ref) {
209
190
  var name = _ref.name,
210
- value = _ref.value,
211
- children = _ref.children,
212
- onChange = _ref.onChange,
213
- label = _ref.label,
214
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
215
-
191
+ value = _ref.value,
192
+ children = _ref.children,
193
+ onChange = _ref.onChange,
194
+ label = _ref.label,
195
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
216
196
  var contextValue = React__default["default"].useMemo(function () {
217
197
  return {
218
198
  name: name,
@@ -1 +1 @@
1
- {"version":3,"file":"chip.cjs.development.js","sources":["../src/ChoiceChipGroupContext.tsx","../src/ChoiceChip.tsx","../src/ActionChip.tsx","../src/TagChip.tsx","../src/FilterChip.tsx","../src/ChoiceChipGroup.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\n\ntype ChoiceChipGroupContextProps = {\n name: string;\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n value: string | null;\n};\n\nconst ChoiceChipGroupContext =\n React.createContext<ChoiceChipGroupContextProps | null>(null);\n\nexport const ChoiceChipGroupContextProvider = ChoiceChipGroupContext.Provider;\n\nexport const useChoiceChipGroupContext: () => ChoiceChipGroupContextProps =\n () => {\n const context = React.useContext(ChoiceChipGroupContext);\n if (!context) {\n throw new Error(\n 'You need to wrap your ChoiceChips in a ChoiceChipGroup-component',\n );\n }\n return context;\n };\n","import React from 'react';\nimport cx from 'classnames';\nimport { useChoiceChipGroupContext } from './ChoiceChipGroupContext';\nimport './BaseChip.scss';\nimport './ChoiceChip.scss';\n\nexport type ChoiceChipProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Om Choicechip er deaktivert eller ikke\n * @default false\n */\n disabled?: boolean;\n /** Label til ChoiceChip */\n children?: React.ReactNode;\n /** Verdien til ChoiceChip */\n value: string;\n} & Omit<\n React.DetailedHTMLProps<\n React.InputHTMLAttributes<HTMLInputElement>,\n HTMLInputElement\n >,\n 'value'\n>;\n\nexport const ChoiceChip = React.forwardRef<HTMLInputElement, ChoiceChipProps>(\n (\n { className, children, value, disabled = false, style, ...rest },\n ref: React.Ref<HTMLInputElement>,\n ) => {\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n const classList = cx(className, 'eds-chip', {\n 'eds-chip--disabled': disabled,\n 'eds-chip--leading-icon': hasLeadingIcon,\n 'eds-chip--trailing-icon': hasTrailingIcon,\n });\n const {\n name,\n value: selectedValue,\n onChange,\n } = useChoiceChipGroupContext();\n return (\n <label className=\"eds-choice-chip\" style={style}>\n <input\n className=\"eds-choice-chip__input\"\n type=\"radio\"\n name={name}\n ref={ref}\n value={value}\n disabled={disabled}\n checked={selectedValue === value}\n onChange={onChange}\n {...rest}\n />\n <div className={classList}>{children}</div>\n </label>\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { LoadingDots } from '@entur/loader';\nimport './BaseChip.scss';\nimport './ActionChip.scss';\n\nexport type ActionChipProps = {\n /** Teksten som vises i ActionChip */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Om chip-en er opptatt, f.eks med å oppdatere informasjon\n * @default false\n */\n loading?: boolean;\n} & React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>;\n\nexport const ActionChip = React.forwardRef<HTMLButtonElement, ActionChipProps>(\n (\n { children, className, loading = false, ...rest },\n ref: React.Ref<HTMLButtonElement>,\n ) => {\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n const ariaLabelValue = () => {\n if (rest['aria-label']) return rest['aria-label'];\n if (loading) return ariaLabelWhenLoading;\n return undefined;\n };\n\n const ariaLabelWhenLoading = childrenArray\n .filter(child => typeof child === 'string')\n .join(' ');\n\n const actionChip = (\n <button\n className={classNames(\n 'eds-chip',\n 'eds-action-chip',\n {\n 'eds-chip--leading-icon': hasLeadingIcon,\n 'eds-chip--trailing-icon': hasTrailingIcon,\n 'eds-action-chip--disabled': rest.disabled,\n },\n className,\n )}\n ref={ref}\n aria-busy={loading}\n aria-label={ariaLabelValue()}\n type=\"button\"\n {...rest}\n >\n {loading ? (\n <LoadingDots className=\"eds-action-chip__loading-dots\" />\n ) : (\n children\n )}\n </button>\n );\n\n if (rest.disabled) {\n return (\n <div className=\"eds-action-chip--disabled__wrapper\">{actionChip}</div>\n );\n }\n return <>{actionChip}</>;\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { CloseIcon } from '@entur/icons';\nimport './BaseChip.scss';\nimport './TagChip.scss';\n\nexport type TagChipProps = {\n /** Teksten som vises i TagChip */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Callback for når man klikker på krysset */\n onClose: () => void;\n /** Skjermlesertekst for X-knappen */\n closeButtonAriaLabel?: string;\n};\n\nexport const TagChip = React.forwardRef<HTMLButtonElement, TagChipProps>(\n (\n { children, className, onClose, closeButtonAriaLabel, ...rest },\n ref: React.Ref<HTMLButtonElement>,\n ) => {\n const selectedCloseLabel =\n closeButtonAriaLabel ?? 'Fjern ' + children?.toString();\n\n return (\n <div\n className={classNames('eds-chip', 'eds-tag-chip', className)}\n {...rest}\n >\n {children}\n <button\n className=\"eds-tag-chip__close-button\"\n type=\"button\"\n onClick={onClose}\n aria-label={selectedCloseLabel}\n ref={ref}\n >\n <CloseIcon />\n </button>\n </div>\n );\n },\n);\n","import React from 'react';\nimport cx from 'classnames';\nimport './BaseChip.scss';\nimport './FilterChip.scss';\n\nexport type FilterChipProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Label til FilterChip */\n children?: React.ReactNode;\n /** Verdien til FilterChip */\n value: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\nexport const FilterChip = React.forwardRef<HTMLInputElement, FilterChipProps>(\n (\n { className, children, value, disabled = false, name, style, ...rest },\n ref: React.Ref<HTMLInputElement>,\n ) => {\n const classList = cx(className, 'eds-chip', 'eds-filter-chip');\n\n return (\n <label className={classList} style={style}>\n <input\n className=\"eds-filter-chip__input\"\n type=\"checkbox\"\n name={name}\n ref={ref}\n value={value}\n disabled={disabled}\n {...rest}\n />\n <span className=\"eds-filter-chip__icon\">\n <CheckboxIcon />\n </span>\n {children}\n </label>\n );\n },\n);\n\nconst CheckboxIcon: React.FC = () => {\n return (\n <svg\n className=\"eds-filter-chip-icon\"\n width=\"11px\"\n height=\"9px\"\n viewBox=\"6 11 37 33\"\n >\n <path\n className=\"eds-filter-chip-icon__path\"\n d=\"M14.1 27.2l7.1 7.2 14.6-14.8\"\n fill=\"none\"\n />\n </svg>\n );\n};\n","import React from 'react';\nimport { ChoiceChipGroupContextProvider } from './ChoiceChipGroupContext';\nimport { Fieldset } from '@entur/form';\nexport type ChoiceChipGroupProps = {\n /** Navnet til ChoiceChipsGroup */\n name: string;\n /** Verdien til den valgte ChoiceChipen */\n value: string | null;\n /** ChoiceChip-komponentene sendes inn som children */\n children: React.ReactNode;\n /** En callback som blir kalles hver gang en ChoiceChip klikkes på */\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n /** Labelen til ChoiceChip-gruppen. */\n label?: React.ReactNode;\n [key: string]: any;\n};\n\nexport const ChoiceChipGroup: React.FC<ChoiceChipGroupProps> = ({\n name,\n value,\n children,\n onChange,\n label,\n ...rest\n}) => {\n const contextValue = React.useMemo(\n () => ({ name, value, onChange }),\n [name, value, onChange],\n );\n return (\n <ChoiceChipGroupContextProvider value={contextValue}>\n <Fieldset className=\"eds-choice-chips-group\" label={label} {...rest}>\n {children}\n </Fieldset>\n </ChoiceChipGroupContextProvider>\n );\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('chip', 'form');\n\nexport * from './ChoiceChip';\nexport * from './ActionChip';\nexport * from './TagChip';\nexport * from './FilterChip';\nexport * from './ChoiceChipGroup';\n"],"names":["ChoiceChipGroupContext","React","createContext","ChoiceChipGroupContextProvider","Provider","useChoiceChipGroupContext","context","useContext","Error","ChoiceChip","forwardRef","ref","className","children","value","disabled","style","rest","childrenArray","Children","toArray","hasLeadingIcon","length","hasTrailingIcon","classList","cx","name","selectedValue","onChange","type","checked","ActionChip","loading","ariaLabelValue","ariaLabelWhenLoading","undefined","filter","child","join","actionChip","classNames","LoadingDots","TagChip","onClose","closeButtonAriaLabel","selectedCloseLabel","toString","onClick","CloseIcon","FilterChip","CheckboxIcon","width","height","viewBox","d","fill","ChoiceChipGroup","label","contextValue","useMemo","Fieldset","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;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IAAF;AAAQZ,MAAAA,KAAK,EAALA,KAAR;AAAec,MAAAA,QAAQ,EAARA;AAAf,KAAP;AAAA,GADmB,EAEnB,CAACF,IAAD,EAAOZ,KAAP,EAAcc,QAAd,CAFmB,CAArB;AAIA,SACE3B,uCAAA,CAACE,8BAAD;AAAgCW,IAAAA,KAAK,EAAE4C;GAAvC,EACEzD,uCAAA,CAAC2D,aAAD;AAAUhD,IAAAA,SAAS,EAAC,wBAApB;AAA6C6C,IAAAA,KAAK,EAAEA;AAApD,KAA+DxC,IAA/D,GACGJ,QADH,CADF,CADF;AAOD;;ACjCDgD,4BAAsB,CAAC,MAAD,EAAS,MAAT,CAAtB;;;;;;;;"}
1
+ {"version":3,"file":"chip.cjs.development.js","sources":["../src/ChoiceChipGroupContext.tsx","../src/ChoiceChip.tsx","../src/ActionChip.tsx","../src/TagChip.tsx","../src/FilterChip.tsx","../src/ChoiceChipGroup.tsx","../src/index.tsx"],"sourcesContent":["import React from 'react';\n\ntype ChoiceChipGroupContextProps = {\n name: string;\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n value: string | null;\n};\n\nconst ChoiceChipGroupContext =\n React.createContext<ChoiceChipGroupContextProps | null>(null);\n\nexport const ChoiceChipGroupContextProvider = ChoiceChipGroupContext.Provider;\n\nexport const useChoiceChipGroupContext: () => ChoiceChipGroupContextProps =\n () => {\n const context = React.useContext(ChoiceChipGroupContext);\n if (!context) {\n throw new Error(\n 'You need to wrap your ChoiceChips in a ChoiceChipGroup-component',\n );\n }\n return context;\n };\n","import React from 'react';\nimport cx from 'classnames';\nimport { useChoiceChipGroupContext } from './ChoiceChipGroupContext';\nimport './BaseChip.scss';\nimport './ChoiceChip.scss';\n\nexport type ChoiceChipProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Om Choicechip er deaktivert eller ikke\n * @default false\n */\n disabled?: boolean;\n /** Label til ChoiceChip */\n children?: React.ReactNode;\n /** Verdien til ChoiceChip */\n value: string;\n} & Omit<\n React.DetailedHTMLProps<\n React.InputHTMLAttributes<HTMLInputElement>,\n HTMLInputElement\n >,\n 'value'\n>;\n\nexport const ChoiceChip = React.forwardRef<HTMLInputElement, ChoiceChipProps>(\n (\n { className, children, value, disabled = false, style, ...rest },\n ref: React.Ref<HTMLInputElement>,\n ) => {\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n const classList = cx(className, 'eds-chip', {\n 'eds-chip--disabled': disabled,\n 'eds-chip--leading-icon': hasLeadingIcon,\n 'eds-chip--trailing-icon': hasTrailingIcon,\n });\n const {\n name,\n value: selectedValue,\n onChange,\n } = useChoiceChipGroupContext();\n return (\n <label className=\"eds-choice-chip\" style={style}>\n <input\n className=\"eds-choice-chip__input\"\n type=\"radio\"\n name={name}\n ref={ref}\n value={value}\n disabled={disabled}\n checked={selectedValue === value}\n onChange={onChange}\n {...rest}\n />\n <div className={classList}>{children}</div>\n </label>\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { LoadingDots } from '@entur/loader';\nimport './BaseChip.scss';\nimport './ActionChip.scss';\n\nexport type ActionChipProps = {\n /** Teksten som vises i ActionChip */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Om chip-en er opptatt, f.eks med å oppdatere informasjon\n * @default false\n */\n loading?: boolean;\n} & React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>;\n\nexport const ActionChip = React.forwardRef<HTMLButtonElement, ActionChipProps>(\n (\n { children, className, loading = false, ...rest },\n ref: React.Ref<HTMLButtonElement>,\n ) => {\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n const ariaLabelValue = () => {\n if (rest['aria-label']) return rest['aria-label'];\n if (loading) return ariaLabelWhenLoading;\n return undefined;\n };\n\n const ariaLabelWhenLoading = childrenArray\n .filter(child => typeof child === 'string')\n .join(' ');\n\n const actionChip = (\n <button\n className={classNames(\n 'eds-chip',\n 'eds-action-chip',\n {\n 'eds-chip--leading-icon': hasLeadingIcon,\n 'eds-chip--trailing-icon': hasTrailingIcon,\n 'eds-action-chip--disabled': rest.disabled,\n },\n className,\n )}\n ref={ref}\n aria-busy={loading}\n aria-label={ariaLabelValue()}\n type=\"button\"\n {...rest}\n >\n {loading ? (\n <LoadingDots className=\"eds-action-chip__loading-dots\" />\n ) : (\n children\n )}\n </button>\n );\n\n if (rest.disabled) {\n return (\n <div className=\"eds-action-chip--disabled__wrapper\">{actionChip}</div>\n );\n }\n return <>{actionChip}</>;\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { CloseIcon } from '@entur/icons';\nimport './BaseChip.scss';\nimport './TagChip.scss';\n\nexport type TagChipProps = {\n /** Teksten som vises i TagChip */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Callback for når man klikker på krysset */\n onClose: () => void;\n /** Skjermlesertekst for X-knappen */\n closeButtonAriaLabel?: string;\n};\n\nexport const TagChip = React.forwardRef<HTMLButtonElement, TagChipProps>(\n (\n { children, className, onClose, closeButtonAriaLabel, ...rest },\n ref: React.Ref<HTMLButtonElement>,\n ) => {\n const selectedCloseLabel =\n closeButtonAriaLabel ?? 'Fjern ' + children?.toString();\n\n return (\n <div\n className={classNames('eds-chip', 'eds-tag-chip', className)}\n {...rest}\n >\n {children}\n <button\n className=\"eds-tag-chip__close-button\"\n type=\"button\"\n onClick={onClose}\n aria-label={selectedCloseLabel}\n ref={ref}\n >\n <CloseIcon />\n </button>\n </div>\n );\n },\n);\n","import React from 'react';\nimport cx from 'classnames';\nimport './BaseChip.scss';\nimport './FilterChip.scss';\n\nexport type FilterChipProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Label til FilterChip */\n children?: React.ReactNode;\n /** Verdien til FilterChip */\n value: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\nexport const FilterChip = React.forwardRef<HTMLInputElement, FilterChipProps>(\n (\n { className, children, value, disabled = false, name, style, ...rest },\n ref: React.Ref<HTMLInputElement>,\n ) => {\n const classList = cx(className, 'eds-chip', 'eds-filter-chip');\n\n return (\n <label className={classList} style={style}>\n <input\n className=\"eds-filter-chip__input\"\n type=\"checkbox\"\n name={name}\n ref={ref}\n value={value}\n disabled={disabled}\n {...rest}\n />\n <span className=\"eds-filter-chip__icon\">\n <CheckboxIcon />\n </span>\n {children}\n </label>\n );\n },\n);\n\nconst CheckboxIcon: React.FC = () => {\n return (\n <svg\n className=\"eds-filter-chip-icon\"\n width=\"11px\"\n height=\"9px\"\n viewBox=\"6 11 37 33\"\n >\n <path\n className=\"eds-filter-chip-icon__path\"\n d=\"M14.1 27.2l7.1 7.2 14.6-14.8\"\n fill=\"none\"\n />\n </svg>\n );\n};\n","import React from 'react';\nimport { ChoiceChipGroupContextProvider } from './ChoiceChipGroupContext';\nimport { Fieldset } from '@entur/form';\nexport type ChoiceChipGroupProps = {\n /** Navnet til ChoiceChipsGroup */\n name: string;\n /** Verdien til den valgte ChoiceChipen */\n value: string | null;\n /** ChoiceChip-komponentene sendes inn som children */\n children: React.ReactNode;\n /** En callback som blir kalles hver gang en ChoiceChip klikkes på */\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n /** Labelen til ChoiceChip-gruppen. */\n label?: React.ReactNode;\n [key: string]: any;\n};\n\nexport const ChoiceChipGroup: React.FC<ChoiceChipGroupProps> = ({\n name,\n value,\n children,\n onChange,\n label,\n ...rest\n}) => {\n const contextValue = React.useMemo(\n () => ({ name, value, onChange }),\n [name, value, onChange],\n );\n return (\n <ChoiceChipGroupContextProvider value={contextValue}>\n <Fieldset className=\"eds-choice-chips-group\" label={label} {...rest}>\n {children}\n </Fieldset>\n </ChoiceChipGroupContextProvider>\n );\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('chip', 'form');\n\nexport * from './ChoiceChip';\nexport * from './ActionChip';\nexport * from './TagChip';\nexport * from './FilterChip';\nexport * from './ChoiceChipGroup';\n"],"names":["ChoiceChipGroupContext","React","createContext","ChoiceChipGroupContextProvider","Provider","useChoiceChipGroupContext","context","useContext","Error","ChoiceChip","forwardRef","ref","className","children","value","disabled","style","rest","_excluded","childrenArray","Children","toArray","hasLeadingIcon","length","hasTrailingIcon","classList","cx","name","selectedValue","onChange","createElement","type","checked","ActionChip","loading","ariaLabelValue","ariaLabelWhenLoading","undefined","filter","child","join","actionChip","classNames","LoadingDots","Fragment","TagChip","onClose","closeButtonAriaLabel","selectedCloseLabel","toString","onClick","CloseIcon","FilterChip","CheckboxIcon","width","height","viewBox","d","fill","ChoiceChipGroup","label","contextValue","useMemo","Fieldset","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAMA,sBAAsB,gBAC1BC,yBAAK,CAACC,aAAa,CAAqC,IAAI,CAAC,CAAA;AAExD,IAAMC,8BAA8B,GAAGH,sBAAsB,CAACI,QAAQ,CAAA;AAEtE,IAAMC,yBAAyB,GACpC,SADWA,yBAAyB,GAC/B;AACH,EAAA,IAAMC,OAAO,GAAGL,yBAAK,CAACM,UAAU,CAACP,sBAAsB,CAAC,CAAA;EACxD,IAAI,CAACM,OAAO,EAAE;AACZ,IAAA,MAAM,IAAIE,KAAK,CACb,kEAAkE,CACnE,CAAA;AACF,GAAA;AACD,EAAA,OAAOF,OAAO,CAAA;AAChB,CAAC;;;ACGI,IAAMG,UAAU,gBAAGR,yBAAK,CAACS,UAAU,CACxC,UAEEC,IAAAA,EAAAA,GAAgC,EAC9B;EAAA,IAFAC,SAAS,QAATA,SAAS;AAAEC,IAAAA,QAAQ,QAARA,QAAQ;AAAEC,IAAAA,KAAK,QA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AAA,IAAA,EAAA,SAAA,CAAA,CAAA;AAEP,EAAA,IAAM4C,YAAY,GAAG5D,yBAAK,CAAC6D,OAAO,CAChC,YAAA;IAAA,OAAO;AAAEnC,MAAAA,IAAI,EAAJA,IAAI;AAAEb,MAAAA,KAAK,EAALA,KAAK;AAAEe,MAAAA,QAAQ,EAARA,QAAAA;KAAU,CAAA;GAAC,EACjC,CAACF,IAAI,EAAEb,KAAK,EAAEe,QAAQ,CAAC,CACxB,CAAA;AACD,EAAA,OACE5B,yBAAC,CAAA6B,aAAA,CAAA3B,8BAA8B,EAAC;AAAAW,IAAAA,KAAK,EAAE+C,YAAAA;AAAY,GAAA,EACjD5D,yBAAA,CAAA6B,aAAA,CAACiC,aAAQ,EAAA,QAAA,CAAA;AAACnD,IAAAA,SAAS,EAAC,wBAAwB;AAACgD,IAAAA,KAAK,EAAEA,KAAAA;AAAK,GAAA,EAAM3C,IAAI,CAAA,EAChEJ,QAAQ,CACA,CACoB,CAAA;AAErC;;ACjCAmD,4BAAsB,CAAC,MAAM,EAAE,MAAM,CAAC;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),a=require("react"),t=require("classnames"),l=require("@entur/loader"),n=require("@entur/icons"),r=require("@entur/form");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=i(a),s=i(t);function d(){return d=Object.assign||function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},d.apply(this,arguments)}function o(e,a){if(null==e)return{};var t,l,n={},r=Object.keys(e);for(l=0;l<r.length;l++)a.indexOf(t=r[l])>=0||(n[t]=e[t]);return n}var u=c.default.createContext(null),f=u.Provider,h=["className","children","value","disabled","style"],p=c.default.forwardRef((function(e,a){var t=e.className,l=e.children,n=e.value,r=e.disabled,i=void 0!==r&&r,f=e.style,p=o(e,h),m=c.default.Children.toArray(l),g=s.default(t,"eds-chip",{"eds-chip--disabled":i,"eds-chip--leading-icon":m.length>1&&"string"!=typeof m[0],"eds-chip--trailing-icon":m.length>1&&"string"!=typeof m[m.length-1]}),v=function(){var e=c.default.useContext(u);if(!e)throw new Error("You need to wrap your ChoiceChips in a ChoiceChipGroup-component");return e}();return c.default.createElement("label",{className:"eds-choice-chip",style:f},c.default.createElement("input",d({className:"eds-choice-chip__input",type:"radio",name:v.name,ref:a,value:n,disabled:i,checked:v.value===n,onChange:v.onChange},p)),c.default.createElement("div",{className:g},l))})),m=["children","className","loading"],g=c.default.forwardRef((function(e,a){var t=e.children,n=e.className,r=e.loading,i=void 0!==r&&r,u=o(e,m),f=c.default.Children.toArray(t),h=f.length>1&&"string"!=typeof f[0],p=f.length>1&&"string"!=typeof f[f.length-1],g=f.filter((function(e){return"string"==typeof e})).join(" "),v=c.default.createElement("button",d({className:s.default("eds-chip","eds-action-chip",{"eds-chip--leading-icon":h,"eds-chip--trailing-icon":p,"eds-action-chip--disabled":u.disabled},n),ref:a,"aria-busy":i,"aria-label":u["aria-label"]?u["aria-label"]:i?g:void 0,type:"button"},u),i?c.default.createElement(l.LoadingDots,{className:"eds-action-chip__loading-dots"}):t);return u.disabled?c.default.createElement("div",{className:"eds-action-chip--disabled__wrapper"},v):c.default.createElement(c.default.Fragment,null,v)})),v=["children","className","onClose","closeButtonAriaLabel"],b=c.default.forwardRef((function(e,a){var t=e.children,l=e.className,r=e.onClose,i=e.closeButtonAriaLabel,u=o(e,v),f=null!=i?i:"Fjern "+(null==t?void 0:t.toString());return c.default.createElement("div",d({className:s.default("eds-chip","eds-tag-chip",l)},u),t,c.default.createElement("button",{className:"eds-tag-chip__close-button",type:"button",onClick:r,"aria-label":f,ref:a},c.default.createElement(n.CloseIcon,null)))})),y=["className","children","value","disabled","name","style"],C=c.default.forwardRef((function(e,a){var t=e.className,l=e.children,n=e.value,r=e.disabled,i=void 0!==r&&r,u=e.name,f=e.style,h=o(e,y),p=s.default(t,"eds-chip","eds-filter-chip");return c.default.createElement("label",{className:p,style:f},c.default.createElement("input",d({className:"eds-filter-chip__input",type:"checkbox",name:u,ref:a,value:n,disabled:i},h)),c.default.createElement("span",{className:"eds-filter-chip__icon"},c.default.createElement(N,null)),l)})),N=function(){return c.default.createElement("svg",{className:"eds-filter-chip-icon",width:"11px",height:"9px",viewBox:"6 11 37 33"},c.default.createElement("path",{className:"eds-filter-chip-icon__path",d:"M14.1 27.2l7.1 7.2 14.6-14.8",fill:"none"}))},E=["name","value","children","onChange","label"];e.warnAboutMissingStyles("chip","form"),exports.ActionChip=g,exports.ChoiceChip=p,exports.ChoiceChipGroup=function(e){var a=e.name,t=e.value,l=e.children,n=e.onChange,i=e.label,s=o(e,E),u=c.default.useMemo((function(){return{name:a,value:t,onChange:n}}),[a,t,n]);return c.default.createElement(f,{value:u},c.default.createElement(r.Fieldset,d({className:"eds-choice-chips-group",label:i},s),l))},exports.FilterChip=C,exports.TagChip=b;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@entur/utils"),a=require("react"),t=require("classnames"),l=require("@entur/loader"),n=require("@entur/icons"),r=require("@entur/form");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=i(a),s=i(t);function d(){return d=Object.assign?Object.assign.bind():function(e){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(e[l]=t[l])}return e},d.apply(this,arguments)}function o(e,a){if(null==e)return{};var t,l,n={},r=Object.keys(e);for(l=0;l<r.length;l++)a.indexOf(t=r[l])>=0||(n[t]=e[t]);return n}var u=c.default.createContext(null),f=u.Provider,h=["className","children","value","disabled","style"],p=c.default.forwardRef((function(e,a){var t=e.className,l=e.children,n=e.value,r=e.disabled,i=void 0!==r&&r,f=e.style,p=o(e,h),m=c.default.Children.toArray(l),b=s.default(t,"eds-chip",{"eds-chip--disabled":i,"eds-chip--leading-icon":m.length>1&&"string"!=typeof m[0],"eds-chip--trailing-icon":m.length>1&&"string"!=typeof m[m.length-1]}),g=function(){var e=c.default.useContext(u);if(!e)throw new Error("You need to wrap your ChoiceChips in a ChoiceChipGroup-component");return e}();return c.default.createElement("label",{className:"eds-choice-chip",style:f},c.default.createElement("input",d({className:"eds-choice-chip__input",type:"radio",name:g.name,ref:a,value:n,disabled:i,checked:g.value===n,onChange:g.onChange},p)),c.default.createElement("div",{className:b},l))})),m=["children","className","loading"],b=c.default.forwardRef((function(e,a){var t=e.children,n=e.className,r=e.loading,i=void 0!==r&&r,u=o(e,m),f=c.default.Children.toArray(t),h=f.length>1&&"string"!=typeof f[0],p=f.length>1&&"string"!=typeof f[f.length-1],b=f.filter((function(e){return"string"==typeof e})).join(" "),g=c.default.createElement("button",d({className:s.default("eds-chip","eds-action-chip",{"eds-chip--leading-icon":h,"eds-chip--trailing-icon":p,"eds-action-chip--disabled":u.disabled},n),ref:a,"aria-busy":i,"aria-label":u["aria-label"]?u["aria-label"]:i?b:void 0,type:"button"},u),i?c.default.createElement(l.LoadingDots,{className:"eds-action-chip__loading-dots"}):t);return u.disabled?c.default.createElement("div",{className:"eds-action-chip--disabled__wrapper"},g):c.default.createElement(c.default.Fragment,null,g)})),g=["children","className","onClose","closeButtonAriaLabel"],v=c.default.forwardRef((function(e,a){var t=e.children,l=e.className,r=e.onClose,i=e.closeButtonAriaLabel,u=o(e,g),f=null!=i?i:"Fjern "+(null==t?void 0:t.toString());return c.default.createElement("div",d({className:s.default("eds-chip","eds-tag-chip",l)},u),t,c.default.createElement("button",{className:"eds-tag-chip__close-button",type:"button",onClick:r,"aria-label":f,ref:a},c.default.createElement(n.CloseIcon,null)))})),y=["className","children","value","disabled","name","style"],C=c.default.forwardRef((function(e,a){var t=e.className,l=e.children,n=e.value,r=e.disabled,i=void 0!==r&&r,u=e.name,f=e.style,h=o(e,y),p=s.default(t,"eds-chip","eds-filter-chip");return c.default.createElement("label",{className:p,style:f},c.default.createElement("input",d({className:"eds-filter-chip__input",type:"checkbox",name:u,ref:a,value:n,disabled:i},h)),c.default.createElement("span",{className:"eds-filter-chip__icon"},c.default.createElement(N,null)),l)})),N=function(){return c.default.createElement("svg",{className:"eds-filter-chip-icon",width:"11px",height:"9px",viewBox:"6 11 37 33"},c.default.createElement("path",{className:"eds-filter-chip-icon__path",d:"M14.1 27.2l7.1 7.2 14.6-14.8",fill:"none"}))},E=["name","value","children","onChange","label"];e.warnAboutMissingStyles("chip","form"),exports.ActionChip=b,exports.ChoiceChip=p,exports.ChoiceChipGroup=function(e){var a=e.name,t=e.value,l=e.children,n=e.onChange,i=e.label,s=o(e,E),u=c.default.useMemo((function(){return{name:a,value:t,onChange:n}}),[a,t,n]);return c.default.createElement(f,{value:u},c.default.createElement(r.Fieldset,d({className:"eds-choice-chips-group",label:i},s),l))},exports.FilterChip=C,exports.TagChip=v;
2
2
  //# sourceMappingURL=chip.cjs.production.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chip.cjs.production.min.js","sources":["../src/ChoiceChipGroupContext.tsx","../src/ChoiceChip.tsx","../src/ActionChip.tsx","../src/TagChip.tsx","../src/FilterChip.tsx","../src/index.tsx","../src/ChoiceChipGroup.tsx"],"sourcesContent":["import React from 'react';\n\ntype ChoiceChipGroupContextProps = {\n name: string;\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n value: string | null;\n};\n\nconst ChoiceChipGroupContext =\n React.createContext<ChoiceChipGroupContextProps | null>(null);\n\nexport const ChoiceChipGroupContextProvider = ChoiceChipGroupContext.Provider;\n\nexport const useChoiceChipGroupContext: () => ChoiceChipGroupContextProps =\n () => {\n const context = React.useContext(ChoiceChipGroupContext);\n if (!context) {\n throw new Error(\n 'You need to wrap your ChoiceChips in a ChoiceChipGroup-component',\n );\n }\n return context;\n };\n","import React from 'react';\nimport cx from 'classnames';\nimport { useChoiceChipGroupContext } from './ChoiceChipGroupContext';\nimport './BaseChip.scss';\nimport './ChoiceChip.scss';\n\nexport type ChoiceChipProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Om Choicechip er deaktivert eller ikke\n * @default false\n */\n disabled?: boolean;\n /** Label til ChoiceChip */\n children?: React.ReactNode;\n /** Verdien til ChoiceChip */\n value: string;\n} & Omit<\n React.DetailedHTMLProps<\n React.InputHTMLAttributes<HTMLInputElement>,\n HTMLInputElement\n >,\n 'value'\n>;\n\nexport const ChoiceChip = React.forwardRef<HTMLInputElement, ChoiceChipProps>(\n (\n { className, children, value, disabled = false, style, ...rest },\n ref: React.Ref<HTMLInputElement>,\n ) => {\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n const classList = cx(className, 'eds-chip', {\n 'eds-chip--disabled': disabled,\n 'eds-chip--leading-icon': hasLeadingIcon,\n 'eds-chip--trailing-icon': hasTrailingIcon,\n });\n const {\n name,\n value: selectedValue,\n onChange,\n } = useChoiceChipGroupContext();\n return (\n <label className=\"eds-choice-chip\" style={style}>\n <input\n className=\"eds-choice-chip__input\"\n type=\"radio\"\n name={name}\n ref={ref}\n value={value}\n disabled={disabled}\n checked={selectedValue === value}\n onChange={onChange}\n {...rest}\n />\n <div className={classList}>{children}</div>\n </label>\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { LoadingDots } from '@entur/loader';\nimport './BaseChip.scss';\nimport './ActionChip.scss';\n\nexport type ActionChipProps = {\n /** Teksten som vises i ActionChip */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Om chip-en er opptatt, f.eks med å oppdatere informasjon\n * @default false\n */\n loading?: boolean;\n} & React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>;\n\nexport const ActionChip = React.forwardRef<HTMLButtonElement, ActionChipProps>(\n (\n { children, className, loading = false, ...rest },\n ref: React.Ref<HTMLButtonElement>,\n ) => {\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n const ariaLabelValue = () => {\n if (rest['aria-label']) return rest['aria-label'];\n if (loading) return ariaLabelWhenLoading;\n return undefined;\n };\n\n const ariaLabelWhenLoading = childrenArray\n .filter(child => typeof child === 'string')\n .join(' ');\n\n const actionChip = (\n <button\n className={classNames(\n 'eds-chip',\n 'eds-action-chip',\n {\n 'eds-chip--leading-icon': hasLeadingIcon,\n 'eds-chip--trailing-icon': hasTrailingIcon,\n 'eds-action-chip--disabled': rest.disabled,\n },\n className,\n )}\n ref={ref}\n aria-busy={loading}\n aria-label={ariaLabelValue()}\n type=\"button\"\n {...rest}\n >\n {loading ? (\n <LoadingDots className=\"eds-action-chip__loading-dots\" />\n ) : (\n children\n )}\n </button>\n );\n\n if (rest.disabled) {\n return (\n <div className=\"eds-action-chip--disabled__wrapper\">{actionChip}</div>\n );\n }\n return <>{actionChip}</>;\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { CloseIcon } from '@entur/icons';\nimport './BaseChip.scss';\nimport './TagChip.scss';\n\nexport type TagChipProps = {\n /** Teksten som vises i TagChip */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Callback for når man klikker på krysset */\n onClose: () => void;\n /** Skjermlesertekst for X-knappen */\n closeButtonAriaLabel?: string;\n};\n\nexport const TagChip = React.forwardRef<HTMLButtonElement, TagChipProps>(\n (\n { children, className, onClose, closeButtonAriaLabel, ...rest },\n ref: React.Ref<HTMLButtonElement>,\n ) => {\n const selectedCloseLabel =\n closeButtonAriaLabel ?? 'Fjern ' + children?.toString();\n\n return (\n <div\n className={classNames('eds-chip', 'eds-tag-chip', className)}\n {...rest}\n >\n {children}\n <button\n className=\"eds-tag-chip__close-button\"\n type=\"button\"\n onClick={onClose}\n aria-label={selectedCloseLabel}\n ref={ref}\n >\n <CloseIcon />\n </button>\n </div>\n );\n },\n);\n","import React from 'react';\nimport cx from 'classnames';\nimport './BaseChip.scss';\nimport './FilterChip.scss';\n\nexport type FilterChipProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Label til FilterChip */\n children?: React.ReactNode;\n /** Verdien til FilterChip */\n value: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\nexport const FilterChip = React.forwardRef<HTMLInputElement, FilterChipProps>(\n (\n { className, children, value, disabled = false, name, style, ...rest },\n ref: React.Ref<HTMLInputElement>,\n ) => {\n const classList = cx(className, 'eds-chip', 'eds-filter-chip');\n\n return (\n <label className={classList} style={style}>\n <input\n className=\"eds-filter-chip__input\"\n type=\"checkbox\"\n name={name}\n ref={ref}\n value={value}\n disabled={disabled}\n {...rest}\n />\n <span className=\"eds-filter-chip__icon\">\n <CheckboxIcon />\n </span>\n {children}\n </label>\n );\n },\n);\n\nconst CheckboxIcon: React.FC = () => {\n return (\n <svg\n className=\"eds-filter-chip-icon\"\n width=\"11px\"\n height=\"9px\"\n viewBox=\"6 11 37 33\"\n >\n <path\n className=\"eds-filter-chip-icon__path\"\n d=\"M14.1 27.2l7.1 7.2 14.6-14.8\"\n fill=\"none\"\n />\n </svg>\n );\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('chip', 'form');\n\nexport * from './ChoiceChip';\nexport * from './ActionChip';\nexport * from './TagChip';\nexport * from './FilterChip';\nexport * from './ChoiceChipGroup';\n","import React from 'react';\nimport { ChoiceChipGroupContextProvider } from './ChoiceChipGroupContext';\nimport { Fieldset } from '@entur/form';\nexport type ChoiceChipGroupProps = {\n /** Navnet til ChoiceChipsGroup */\n name: string;\n /** Verdien til den valgte ChoiceChipen */\n value: string | null;\n /** ChoiceChip-komponentene sendes inn som children */\n children: React.ReactNode;\n /** En callback som blir kalles hver gang en ChoiceChip klikkes på */\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n /** Labelen til ChoiceChip-gruppen. */\n label?: React.ReactNode;\n [key: string]: any;\n};\n\nexport const ChoiceChipGroup: React.FC<ChoiceChipGroupProps> = ({\n name,\n value,\n children,\n onChange,\n label,\n ...rest\n}) => {\n const contextValue = React.useMemo(\n () => ({ name, value, onChange }),\n [name, value, onChange],\n );\n return (\n <ChoiceChipGroupContextProvider value={contextValue}>\n <Fieldset className=\"eds-choice-chips-group\" label={label} {...rest}>\n {children}\n </Fieldset>\n </ChoiceChipGroupContextProvider>\n );\n};\n"],"names":["ChoiceChipGroupContext","React","createContext","ChoiceChipGroupContextProvider","Provider","ChoiceChip","forwardRef","ref","className","children","value","disabled","style","rest","childrenArray","Children","toArray","classList","cx","length","context","useContext","Error","useChoiceChipGroupContext","type","name","checked","onChange","ActionChip","loading","hasLeadingIcon","hasTrailingIcon","ariaLabelWhenLoading","filter","child","join","actionChip","classNames","LoadingDots","TagChip","onClose","closeButtonAriaLabel","selectedCloseLabel","toString","onClick","CloseIcon","FilterChip","CheckboxIcon","width","height","viewBox","d","fill","warnAboutMissingStyles","label","contextValue","useMemo","Fieldset"],"mappings":"yoBAQA,IAAMA,EACJC,UAAMC,cAAkD,MAE7CC,EAAiCH,EAAuBI,+DCcxDC,EAAaJ,UAAMK,YAC9B,WAEEC,OADEC,IAAAA,UAAWC,IAAAA,SAAUC,IAAAA,UAAOC,SAAAA,gBAAkBC,IAAAA,MAAUC,SAGpDC,EAAgBb,UAAMc,SAASC,QAAQP,GAOvCQ,EAAYC,UAAGV,EAAW,WAAY,sBACpBG,2BANtBG,EAAcK,OAAS,GAAiC,iBAArBL,EAAc,6BAEjDA,EAAcK,OAAS,GAC4B,iBAA5CL,EAAcA,EAAcK,OAAS,ODrBhD,eACQC,EAAUnB,UAAMoB,WAAWrB,OAC5BoB,QACG,IAAIE,MACR,2EAGGF,ECyBHG,UAEFtB,iCAAOO,UAAU,kBAAkBI,MAAOA,GACxCX,mCACEO,UAAU,yBACVgB,KAAK,QACLC,OATJA,KAUIlB,IAAKA,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GAClCX,mCACEO,UAAU,yBACVgB,KAAK,WACLC,KAAMA,EACNlB,IAAKA,EACLG,MAAOA,EACPC,SAAUA,GACNE,IAENZ,gCAAMO,UAAU,yBACdP,wBAAC8C,SAEFtC,MAMHsC,EAAyB,kBAE3B9C,+BACEO,UAAU,uBACVwC,MAAM,OACNC,OAAO,MACPC,QAAQ,cAERjD,gCACEO,UAAU,6BACV2C,EAAE,+BACFC,KAAK,4DCjDbC,yBAAuB,OAAQ,0ECcgC,gBAC7D5B,IAAAA,KACAf,IAAAA,MACAD,IAAAA,SACAkB,IAAAA,SACA2B,IAAAA,MACGzC,SAEG0C,EAAetD,UAAMuD,SACzB,iBAAO,CAAE/B,KAAAA,EAAMf,MAAAA,EAAOiB,SAAAA,KACtB,CAACF,EAAMf,EAAOiB,WAGd1B,wBAACE,GAA+BO,MAAO6C,GACrCtD,wBAACwD,cAASjD,UAAU,yBAAyB8C,MAAOA,GAAWzC,GAC5DJ"}
1
+ {"version":3,"file":"chip.cjs.production.min.js","sources":["../src/ChoiceChipGroupContext.tsx","../src/ChoiceChip.tsx","../src/ActionChip.tsx","../src/TagChip.tsx","../src/FilterChip.tsx","../src/index.tsx","../src/ChoiceChipGroup.tsx"],"sourcesContent":["import React from 'react';\n\ntype ChoiceChipGroupContextProps = {\n name: string;\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n value: string | null;\n};\n\nconst ChoiceChipGroupContext =\n React.createContext<ChoiceChipGroupContextProps | null>(null);\n\nexport const ChoiceChipGroupContextProvider = ChoiceChipGroupContext.Provider;\n\nexport const useChoiceChipGroupContext: () => ChoiceChipGroupContextProps =\n () => {\n const context = React.useContext(ChoiceChipGroupContext);\n if (!context) {\n throw new Error(\n 'You need to wrap your ChoiceChips in a ChoiceChipGroup-component',\n );\n }\n return context;\n };\n","import React from 'react';\nimport cx from 'classnames';\nimport { useChoiceChipGroupContext } from './ChoiceChipGroupContext';\nimport './BaseChip.scss';\nimport './ChoiceChip.scss';\n\nexport type ChoiceChipProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Om Choicechip er deaktivert eller ikke\n * @default false\n */\n disabled?: boolean;\n /** Label til ChoiceChip */\n children?: React.ReactNode;\n /** Verdien til ChoiceChip */\n value: string;\n} & Omit<\n React.DetailedHTMLProps<\n React.InputHTMLAttributes<HTMLInputElement>,\n HTMLInputElement\n >,\n 'value'\n>;\n\nexport const ChoiceChip = React.forwardRef<HTMLInputElement, ChoiceChipProps>(\n (\n { className, children, value, disabled = false, style, ...rest },\n ref: React.Ref<HTMLInputElement>,\n ) => {\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n const classList = cx(className, 'eds-chip', {\n 'eds-chip--disabled': disabled,\n 'eds-chip--leading-icon': hasLeadingIcon,\n 'eds-chip--trailing-icon': hasTrailingIcon,\n });\n const {\n name,\n value: selectedValue,\n onChange,\n } = useChoiceChipGroupContext();\n return (\n <label className=\"eds-choice-chip\" style={style}>\n <input\n className=\"eds-choice-chip__input\"\n type=\"radio\"\n name={name}\n ref={ref}\n value={value}\n disabled={disabled}\n checked={selectedValue === value}\n onChange={onChange}\n {...rest}\n />\n <div className={classList}>{children}</div>\n </label>\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { LoadingDots } from '@entur/loader';\nimport './BaseChip.scss';\nimport './ActionChip.scss';\n\nexport type ActionChipProps = {\n /** Teksten som vises i ActionChip */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Om chip-en er opptatt, f.eks med å oppdatere informasjon\n * @default false\n */\n loading?: boolean;\n} & React.DetailedHTMLProps<\n React.ButtonHTMLAttributes<HTMLButtonElement>,\n HTMLButtonElement\n>;\n\nexport const ActionChip = React.forwardRef<HTMLButtonElement, ActionChipProps>(\n (\n { children, className, loading = false, ...rest },\n ref: React.Ref<HTMLButtonElement>,\n ) => {\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n const ariaLabelValue = () => {\n if (rest['aria-label']) return rest['aria-label'];\n if (loading) return ariaLabelWhenLoading;\n return undefined;\n };\n\n const ariaLabelWhenLoading = childrenArray\n .filter(child => typeof child === 'string')\n .join(' ');\n\n const actionChip = (\n <button\n className={classNames(\n 'eds-chip',\n 'eds-action-chip',\n {\n 'eds-chip--leading-icon': hasLeadingIcon,\n 'eds-chip--trailing-icon': hasTrailingIcon,\n 'eds-action-chip--disabled': rest.disabled,\n },\n className,\n )}\n ref={ref}\n aria-busy={loading}\n aria-label={ariaLabelValue()}\n type=\"button\"\n {...rest}\n >\n {loading ? (\n <LoadingDots className=\"eds-action-chip__loading-dots\" />\n ) : (\n children\n )}\n </button>\n );\n\n if (rest.disabled) {\n return (\n <div className=\"eds-action-chip--disabled__wrapper\">{actionChip}</div>\n );\n }\n return <>{actionChip}</>;\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport { CloseIcon } from '@entur/icons';\nimport './BaseChip.scss';\nimport './TagChip.scss';\n\nexport type TagChipProps = {\n /** Teksten som vises i TagChip */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Callback for når man klikker på krysset */\n onClose: () => void;\n /** Skjermlesertekst for X-knappen */\n closeButtonAriaLabel?: string;\n};\n\nexport const TagChip = React.forwardRef<HTMLButtonElement, TagChipProps>(\n (\n { children, className, onClose, closeButtonAriaLabel, ...rest },\n ref: React.Ref<HTMLButtonElement>,\n ) => {\n const selectedCloseLabel =\n closeButtonAriaLabel ?? 'Fjern ' + children?.toString();\n\n return (\n <div\n className={classNames('eds-chip', 'eds-tag-chip', className)}\n {...rest}\n >\n {children}\n <button\n className=\"eds-tag-chip__close-button\"\n type=\"button\"\n onClick={onClose}\n aria-label={selectedCloseLabel}\n ref={ref}\n >\n <CloseIcon />\n </button>\n </div>\n );\n },\n);\n","import React from 'react';\nimport cx from 'classnames';\nimport './BaseChip.scss';\nimport './FilterChip.scss';\n\nexport type FilterChipProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Label til FilterChip */\n children?: React.ReactNode;\n /** Verdien til FilterChip */\n value: string;\n} & React.InputHTMLAttributes<HTMLInputElement>;\n\nexport const FilterChip = React.forwardRef<HTMLInputElement, FilterChipProps>(\n (\n { className, children, value, disabled = false, name, style, ...rest },\n ref: React.Ref<HTMLInputElement>,\n ) => {\n const classList = cx(className, 'eds-chip', 'eds-filter-chip');\n\n return (\n <label className={classList} style={style}>\n <input\n className=\"eds-filter-chip__input\"\n type=\"checkbox\"\n name={name}\n ref={ref}\n value={value}\n disabled={disabled}\n {...rest}\n />\n <span className=\"eds-filter-chip__icon\">\n <CheckboxIcon />\n </span>\n {children}\n </label>\n );\n },\n);\n\nconst CheckboxIcon: React.FC = () => {\n return (\n <svg\n className=\"eds-filter-chip-icon\"\n width=\"11px\"\n height=\"9px\"\n viewBox=\"6 11 37 33\"\n >\n <path\n className=\"eds-filter-chip-icon__path\"\n d=\"M14.1 27.2l7.1 7.2 14.6-14.8\"\n fill=\"none\"\n />\n </svg>\n );\n};\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('chip', 'form');\n\nexport * from './ChoiceChip';\nexport * from './ActionChip';\nexport * from './TagChip';\nexport * from './FilterChip';\nexport * from './ChoiceChipGroup';\n","import React from 'react';\nimport { ChoiceChipGroupContextProvider } from './ChoiceChipGroupContext';\nimport { Fieldset } from '@entur/form';\nexport type ChoiceChipGroupProps = {\n /** Navnet til ChoiceChipsGroup */\n name: string;\n /** Verdien til den valgte ChoiceChipen */\n value: string | null;\n /** ChoiceChip-komponentene sendes inn som children */\n children: React.ReactNode;\n /** En callback som blir kalles hver gang en ChoiceChip klikkes på */\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n /** Labelen til ChoiceChip-gruppen. */\n label?: React.ReactNode;\n [key: string]: any;\n};\n\nexport const ChoiceChipGroup: React.FC<ChoiceChipGroupProps> = ({\n name,\n value,\n children,\n onChange,\n label,\n ...rest\n}) => {\n const contextValue = React.useMemo(\n () => ({ name, value, onChange }),\n [name, value, onChange],\n );\n return (\n <ChoiceChipGroupContextProvider value={contextValue}>\n <Fieldset className=\"eds-choice-chips-group\" label={label} {...rest}>\n {children}\n </Fieldset>\n </ChoiceChipGroupContextProvider>\n );\n};\n"],"names":["ChoiceChipGroupContext","React","createContext","ChoiceChipGroupContextProvider","Provider","ChoiceChip","forwardRef","ref","className","children","value","_ref$disabled","_ref","disabled","style","rest","_objectWithoutPropertiesLoose","_excluded","childrenArray","Children","toArray","classList","cx","length","_useChoiceChipGroupCo","context","useContext","Error","useChoiceChipGroupContext","createElement","_extends","type","name","checked","onChange","ActionChip","_ref$loading","loading","hasLeadingIcon","hasTrailingIcon","ariaLabelWhenLoading","filter","child","join","actionChip","classNames","LoadingDots","Fragment","TagChip","onClose","closeButtonAriaLabel","selectedCloseLabel","toString","onClick","CloseIcon","FilterChip","CheckboxIcon","width","height","viewBox","d","fill","warnAboutMissingStyles","label","contextValue","useMemo","Fieldset"],"mappings":"6pBAQA,IAAMA,EACJC,EAAK,QAACC,cAAkD,MAE7CC,EAAiCH,EAAuBI,+DCcxDC,EAAaJ,EAAAA,QAAMK,YAC9B,SAEEC,EAAAA,GACE,IAFAC,IAAAA,UAAWC,IAAAA,SAAUC,IAAAA,MAAKC,EAAAC,EAAEC,SAAAA,cAAgBF,EAAEG,IAAAA,MAAUC,EAAIC,EAAAJ,EAAAK,GAGxDC,EAAgBjB,EAAK,QAACkB,SAASC,QAAQX,GAOvCY,EAAYC,EAAAA,QAAGd,EAAW,WAAY,CAC1C,qBAAsBK,EACtB,yBAPAK,EAAcK,OAAS,GAAiC,iBAArBL,EAAc,GAQjD,0BANAA,EAAcK,OAAS,GA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AA,KACAtB,IAAAA,MACAD,IAAAA,SACAyB,IAAAA,SACA6B,IAAAA,MACGhD,EAAIC,EAAAJ,EAAAK,GAED+C,EAAe/D,UAAMgE,SACzB,WAAA,MAAO,CAAEjC,KAAAA,EAAMtB,MAAAA,EAAOwB,SAAAA,KACtB,CAACF,EAAMtB,EAAOwB,IAEhB,OACEjC,EAAC,QAAA4B,cAAA1B,EAA+B,CAAAO,MAAOsD,GACrC/D,UAAA4B,cAACqC,EAAQA,SAAApC,EAAA,CAACtB,UAAU,yBAAyBuD,MAAOA,GAAWhD,GAC5DN"}
package/dist/chip.esm.js CHANGED
@@ -6,35 +6,29 @@ import { CloseIcon } from '@entur/icons';
6
6
  import { Fieldset } from '@entur/form';
7
7
 
8
8
  function _extends() {
9
- _extends = Object.assign || function (target) {
9
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
10
10
  for (var i = 1; i < arguments.length; i++) {
11
11
  var source = arguments[i];
12
-
13
12
  for (var key in source) {
14
13
  if (Object.prototype.hasOwnProperty.call(source, key)) {
15
14
  target[key] = source[key];
16
15
  }
17
16
  }
18
17
  }
19
-
20
18
  return target;
21
19
  };
22
-
23
20
  return _extends.apply(this, arguments);
24
21
  }
25
-
26
22
  function _objectWithoutPropertiesLoose(source, excluded) {
27
23
  if (source == null) return {};
28
24
  var target = {};
29
25
  var sourceKeys = Object.keys(source);
30
26
  var key, i;
31
-
32
27
  for (i = 0; i < sourceKeys.length; i++) {
33
28
  key = sourceKeys[i];
34
29
  if (excluded.indexOf(key) >= 0) continue;
35
30
  target[key] = source[key];
36
31
  }
37
-
38
32
  return target;
39
33
  }
40
34
 
@@ -42,24 +36,21 @@ var ChoiceChipGroupContext = /*#__PURE__*/React.createContext(null);
42
36
  var ChoiceChipGroupContextProvider = ChoiceChipGroupContext.Provider;
43
37
  var useChoiceChipGroupContext = function useChoiceChipGroupContext() {
44
38
  var context = React.useContext(ChoiceChipGroupContext);
45
-
46
39
  if (!context) {
47
40
  throw new Error('You need to wrap your ChoiceChips in a ChoiceChipGroup-component');
48
41
  }
49
-
50
42
  return context;
51
43
  };
52
44
 
53
45
  var _excluded$4 = ["className", "children", "value", "disabled", "style"];
54
46
  var ChoiceChip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
55
47
  var className = _ref.className,
56
- children = _ref.children,
57
- value = _ref.value,
58
- _ref$disabled = _ref.disabled,
59
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
60
- style = _ref.style,
61
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
62
-
48
+ children = _ref.children,
49
+ value = _ref.value,
50
+ _ref$disabled = _ref.disabled,
51
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
52
+ style = _ref.style,
53
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
63
54
  var childrenArray = React.Children.toArray(children);
64
55
  var hasLeadingIcon = childrenArray.length > 1 && typeof childrenArray[0] !== 'string';
65
56
  var hasTrailingIcon = childrenArray.length > 1 && typeof childrenArray[childrenArray.length - 1] !== 'string';
@@ -68,12 +59,10 @@ var ChoiceChip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
68
59
  'eds-chip--leading-icon': hasLeadingIcon,
69
60
  'eds-chip--trailing-icon': hasTrailingIcon
70
61
  });
71
-
72
62
  var _useChoiceChipGroupCo = useChoiceChipGroupContext(),
73
- name = _useChoiceChipGroupCo.name,
74
- selectedValue = _useChoiceChipGroupCo.value,
75
- onChange = _useChoiceChipGroupCo.onChange;
76
-
63
+ name = _useChoiceChipGroupCo.name,
64
+ selectedValue = _useChoiceChipGroupCo.value,
65
+ onChange = _useChoiceChipGroupCo.onChange;
77
66
  return React.createElement("label", {
78
67
  className: "eds-choice-chip",
79
68
  style: style
@@ -94,21 +83,18 @@ var ChoiceChip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
94
83
  var _excluded$3 = ["children", "className", "loading"];
95
84
  var ActionChip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
96
85
  var children = _ref.children,
97
- className = _ref.className,
98
- _ref$loading = _ref.loading,
99
- loading = _ref$loading === void 0 ? false : _ref$loading,
100
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
101
-
86
+ className = _ref.className,
87
+ _ref$loading = _ref.loading,
88
+ loading = _ref$loading === void 0 ? false : _ref$loading,
89
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
102
90
  var childrenArray = React.Children.toArray(children);
103
91
  var hasLeadingIcon = childrenArray.length > 1 && typeof childrenArray[0] !== 'string';
104
92
  var hasTrailingIcon = childrenArray.length > 1 && typeof childrenArray[childrenArray.length - 1] !== 'string';
105
-
106
93
  var ariaLabelValue = function ariaLabelValue() {
107
94
  if (rest['aria-label']) return rest['aria-label'];
108
95
  if (loading) return ariaLabelWhenLoading;
109
96
  return undefined;
110
97
  };
111
-
112
98
  var ariaLabelWhenLoading = childrenArray.filter(function (child) {
113
99
  return typeof child === 'string';
114
100
  }).join(' ');
@@ -125,24 +111,21 @@ var ActionChip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
125
111
  }, rest), loading ? React.createElement(LoadingDots, {
126
112
  className: "eds-action-chip__loading-dots"
127
113
  }) : children);
128
-
129
114
  if (rest.disabled) {
130
115
  return React.createElement("div", {
131
116
  className: "eds-action-chip--disabled__wrapper"
132
117
  }, actionChip);
133
118
  }
134
-
135
119
  return React.createElement(React.Fragment, null, actionChip);
136
120
  });
137
121
 
138
122
  var _excluded$2 = ["children", "className", "onClose", "closeButtonAriaLabel"];
139
123
  var TagChip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
140
124
  var children = _ref.children,
141
- className = _ref.className,
142
- onClose = _ref.onClose,
143
- closeButtonAriaLabel = _ref.closeButtonAriaLabel,
144
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
145
-
125
+ className = _ref.className,
126
+ onClose = _ref.onClose,
127
+ closeButtonAriaLabel = _ref.closeButtonAriaLabel,
128
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
146
129
  var selectedCloseLabel = closeButtonAriaLabel != null ? closeButtonAriaLabel : 'Fjern ' + (children == null ? void 0 : children.toString());
147
130
  return React.createElement("div", _extends({
148
131
  className: classNames('eds-chip', 'eds-tag-chip', className)
@@ -158,14 +141,13 @@ var TagChip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
158
141
  var _excluded$1 = ["className", "children", "value", "disabled", "name", "style"];
159
142
  var FilterChip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
160
143
  var className = _ref.className,
161
- children = _ref.children,
162
- value = _ref.value,
163
- _ref$disabled = _ref.disabled,
164
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
165
- name = _ref.name,
166
- style = _ref.style,
167
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
168
-
144
+ children = _ref.children,
145
+ value = _ref.value,
146
+ _ref$disabled = _ref.disabled,
147
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled,
148
+ name = _ref.name,
149
+ style = _ref.style,
150
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
169
151
  var classList = classNames(className, 'eds-chip', 'eds-filter-chip');
170
152
  return React.createElement("label", {
171
153
  className: classList,
@@ -181,7 +163,6 @@ var FilterChip = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
181
163
  className: "eds-filter-chip__icon"
182
164
  }, React.createElement(CheckboxIcon, null)), children);
183
165
  });
184
-
185
166
  var CheckboxIcon = function CheckboxIcon() {
186
167
  return React.createElement("svg", {
187
168
  className: "eds-filter-chip-icon",
@@ -198,12 +179,11 @@ var CheckboxIcon = function CheckboxIcon() {
198
179
  var _excluded = ["name", "value", "children", "onChange", "label"];
199
180
  var ChoiceChipGroup = function ChoiceChipGroup(_ref) {
200
181
  var name = _ref.name,
201
- value = _ref.value,
202
- children = _ref.children,
203
- onChange = _ref.onChange,
204
- label = _ref.label,
205
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
206
-
182
+ value = _ref.value,
183
+ children = _ref.children,
184
+ onChange = _ref.onChange,
185
+ label = _ref.label,
186
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
207
187
  var contextValue = React.useMemo(function () {
208
188
  return {
209
189
  name: name,