@decisiv/ui-components 2.0.1-alpha.155 → 2.0.1-alpha.157
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/lib/components/Select/index.d.ts.map +1 -1
- package/lib/components/Select/index.js +3 -1
- package/lib/components/Select/index.test.js +43 -19
- package/lib/components/Select/schema.d.ts.map +1 -1
- package/lib/components/Select/schema.js +1 -0
- package/lib/components/Select/types.d.ts +1 -0
- package/lib/components/Select/types.d.ts.map +1 -1
- package/lib/components/Tag/Action.d.ts.map +1 -1
- package/lib/components/Tag/Action.js +2 -2
- package/lib/components/Tag/constants.d.ts +2 -2
- package/lib/components/Tag/constants.d.ts.map +1 -1
- package/lib/components/Tag/constants.js +2 -2
- package/lib/components/Tag/index.d.ts +1 -3
- package/lib/components/Tag/index.d.ts.map +1 -1
- package/lib/components/Tag/index.js +20 -154
- package/lib/components/Tag/index.test.js +86 -30
- package/lib/components/Tag/propTypes.d.ts +1 -0
- package/lib/components/Tag/propTypes.d.ts.map +1 -1
- package/lib/components/Tag/propTypes.js +2 -1
- package/lib/components/Tag/schema.d.ts.map +1 -1
- package/lib/components/Tag/schema.js +1 -0
- package/lib/components/Tag/styles.d.ts +13 -0
- package/lib/components/Tag/styles.d.ts.map +1 -0
- package/lib/components/Tag/styles.js +167 -0
- package/lib/components/Tag/types.d.ts +4 -3
- package/lib/components/Tag/types.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.tsx"],"names":[],"mappings":"AAGA,OAAc,EAEZ,sBAAsB,EAMvB,MAAM,OAAO,CAAC;AAoBf,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.tsx"],"names":[],"mappings":"AAGA,OAAc,EAEZ,sBAAsB,EAMvB,MAAM,OAAO,CAAC;AAoBf,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AA8PjD,QAAA,MAAM,aAAa,EAAE,sBAAsB,CACzC,SAAS,EACT,WAAW,CACS,CAAC;AAgCvB,eAAe,aAAa,CAAC"}
|
|
@@ -72,6 +72,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
72
72
|
function Select(props, ref) {
|
|
73
73
|
var actions = props.actions,
|
|
74
74
|
clearButtonLabel = props.clearButtonLabel,
|
|
75
|
+
_props$hideClearButto = props.hideClearButton,
|
|
76
|
+
hideClearButton = _props$hideClearButto === void 0 ? false : _props$hideClearButto,
|
|
75
77
|
defaultValue = props.defaultValue,
|
|
76
78
|
id = props.id,
|
|
77
79
|
inputContainerRef = props.inputContainerRef,
|
|
@@ -246,7 +248,7 @@ function Select(props, ref) {
|
|
|
246
248
|
"aria-owns": dropdownListId,
|
|
247
249
|
clearButtonLabel: clearButtonLabel,
|
|
248
250
|
disabled: disabled,
|
|
249
|
-
hasClearButton: Boolean(selectedValue),
|
|
251
|
+
hasClearButton: hideClearButton ? false : Boolean(selectedValue),
|
|
250
252
|
id: targetId,
|
|
251
253
|
inputFieldLabel: label,
|
|
252
254
|
isPopoverVisible: isPopoverVisible,
|
|
@@ -187,16 +187,40 @@ describe('Select', function () {
|
|
|
187
187
|
|
|
188
188
|
expect(getByText(cat0Opt0.label)).toBeTruthy();
|
|
189
189
|
});
|
|
190
|
+
describe('when "hideClearButton" is false', function () {
|
|
191
|
+
it('shows the clear button', function () {
|
|
192
|
+
var _render7 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
193
|
+
defaultValue: cat0Opt0.id,
|
|
194
|
+
hideClearButton: false,
|
|
195
|
+
clearButtonLabel: "clear selection"
|
|
196
|
+
}))),
|
|
197
|
+
getByLabelText = _render7.getByLabelText;
|
|
198
|
+
|
|
199
|
+
expect(getByLabelText(/clear selection/i)).toBeInTheDocument();
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
describe('when "hideClearButton" is true', function () {
|
|
203
|
+
it('does not show the clear button', function () {
|
|
204
|
+
var _render8 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
205
|
+
defaultValue: cat0Opt0.id,
|
|
206
|
+
hideClearButton: true,
|
|
207
|
+
clearButtonLabel: "clear selection"
|
|
208
|
+
}))),
|
|
209
|
+
queryByLabelText = _render8.queryByLabelText;
|
|
210
|
+
|
|
211
|
+
expect(queryByLabelText(/clear selection/i)).not.toBeInTheDocument();
|
|
212
|
+
});
|
|
213
|
+
});
|
|
190
214
|
describe('clicking an option', function () {
|
|
191
215
|
it('calls the onchange handler with the new value', function () {
|
|
192
216
|
var onChange = jest.fn();
|
|
193
217
|
|
|
194
|
-
var
|
|
218
|
+
var _render9 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
195
219
|
onChange: onChange,
|
|
196
220
|
defaultValue: opt1.id
|
|
197
221
|
}))),
|
|
198
|
-
baseElement =
|
|
199
|
-
getByText =
|
|
222
|
+
baseElement = _render9.baseElement,
|
|
223
|
+
getByText = _render9.getByText;
|
|
200
224
|
|
|
201
225
|
_react2.fireEvent.click(getByText(defaultProps.label));
|
|
202
226
|
|
|
@@ -205,11 +229,11 @@ describe('Select', function () {
|
|
|
205
229
|
expect(onChange).toHaveBeenCalledWith(cat0Opt0.id);
|
|
206
230
|
});
|
|
207
231
|
it('automatically updates the option label inside the input field', function () {
|
|
208
|
-
var
|
|
232
|
+
var _render10 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
209
233
|
defaultValue: opt1.id
|
|
210
234
|
}))),
|
|
211
|
-
baseElement =
|
|
212
|
-
getByText =
|
|
235
|
+
baseElement = _render10.baseElement,
|
|
236
|
+
getByText = _render10.getByText;
|
|
213
237
|
|
|
214
238
|
_react2.fireEvent.click(getByText(defaultProps.label));
|
|
215
239
|
|
|
@@ -222,32 +246,32 @@ describe('Select', function () {
|
|
|
222
246
|
});
|
|
223
247
|
describe('when label hidden', function () {
|
|
224
248
|
it('does not display the label element', function () {
|
|
225
|
-
var
|
|
249
|
+
var _render11 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
226
250
|
defaultvalue: opt1.id,
|
|
227
251
|
hideLabel: true
|
|
228
252
|
}))),
|
|
229
|
-
getByText =
|
|
253
|
+
getByText = _render11.getByText;
|
|
230
254
|
|
|
231
255
|
expect(getByText(defaultProps.label, {
|
|
232
256
|
selector: 'span'
|
|
233
257
|
})).not.toBeVisible();
|
|
234
258
|
});
|
|
235
259
|
it('does display the input related to the label', function () {
|
|
236
|
-
var
|
|
260
|
+
var _render12 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
237
261
|
defaultValue: opt1.id,
|
|
238
262
|
hideLabel: true
|
|
239
263
|
}))),
|
|
240
|
-
getByLabelText =
|
|
264
|
+
getByLabelText = _render12.getByLabelText;
|
|
241
265
|
|
|
242
266
|
expect(getByLabelText(defaultProps.label)).toBeVisible();
|
|
243
267
|
});
|
|
244
268
|
});
|
|
245
269
|
describe('when component is controlled', function () {
|
|
246
270
|
it('displays the option label matching the value inside the input field', function () {
|
|
247
|
-
var
|
|
271
|
+
var _render13 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
248
272
|
value: cat0Opt0.id
|
|
249
273
|
}))),
|
|
250
|
-
getByText =
|
|
274
|
+
getByText = _render13.getByText;
|
|
251
275
|
|
|
252
276
|
expect(getByText(cat0Opt0.label)).toBeTruthy();
|
|
253
277
|
});
|
|
@@ -255,12 +279,12 @@ describe('Select', function () {
|
|
|
255
279
|
it('calls the onchange handler with the new value', function () {
|
|
256
280
|
var onChange = jest.fn();
|
|
257
281
|
|
|
258
|
-
var
|
|
282
|
+
var _render14 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
259
283
|
onChange: onChange,
|
|
260
284
|
value: opt1.id
|
|
261
285
|
}))),
|
|
262
|
-
baseElement =
|
|
263
|
-
getByText =
|
|
286
|
+
baseElement = _render14.baseElement,
|
|
287
|
+
getByText = _render14.getByText;
|
|
264
288
|
|
|
265
289
|
_react2.fireEvent.click(getByText(defaultProps.label));
|
|
266
290
|
|
|
@@ -269,12 +293,12 @@ describe('Select', function () {
|
|
|
269
293
|
expect(onChange).toHaveBeenCalledWith(cat0Opt0.id);
|
|
270
294
|
});
|
|
271
295
|
it('does NOT automatically update the option label inside the input field', function () {
|
|
272
|
-
var
|
|
296
|
+
var _render15 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
273
297
|
value: opt1.id
|
|
274
298
|
}))),
|
|
275
|
-
baseElement =
|
|
276
|
-
getByText =
|
|
277
|
-
queryByText =
|
|
299
|
+
baseElement = _render15.baseElement,
|
|
300
|
+
getByText = _render15.getByText,
|
|
301
|
+
queryByText = _render15.queryByText;
|
|
278
302
|
|
|
279
303
|
_react2.fireEvent.click(getByText(defaultProps.label));
|
|
280
304
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Select/schema.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,MAAM,KAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Select/schema.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,MAAM,KAAsC,CAAC;AAwEnD,eAAe,MAAM,CAAC"}
|
|
@@ -23,6 +23,7 @@ var schema = (0, _reactDesc.describe)({
|
|
|
23
23
|
displayName: 'Select'
|
|
24
24
|
});
|
|
25
25
|
schema.propTypes = _objectSpread({}, (0, _omit.default)(_InputField.schema.makePropTypes(), ['children', 'maxLength', 'onChange', 'showCharacterCount']), {
|
|
26
|
+
hideClearButton: _reactDesc.PropTypes.bool.description('Whether or not to hide the clear button after selecting an item').defaultValue('false'),
|
|
26
27
|
clearButtonLabel: _reactDesc.PropTypes.string.description("A hidden label value for the clear button. The select component's label is available within the string for clarity.").defaultValue('Clear {label} value'),
|
|
27
28
|
containerSelector: _reactDesc.PropTypes.string.description("A CSS selector to the element where the Select should be rendered in, or \"parent\" to render the Select in-place.").defaultValue('body'),
|
|
28
29
|
defaultValue: _reactDesc.PropTypes.string.description('The ID of the option that should be selected by default.'),
|
|
@@ -11,6 +11,7 @@ interface BaseSelectProps extends ButtonHTMLAttributes<SelectRef>, Omit<BaseInpu
|
|
|
11
11
|
onKeyDown?: KeyboardEventHandler;
|
|
12
12
|
}
|
|
13
13
|
export declare type SelectProps = BaseSelectProps & {
|
|
14
|
+
hideClearButton?: boolean;
|
|
14
15
|
clearButtonLabel?: string;
|
|
15
16
|
defaultValue?: string;
|
|
16
17
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Select/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,oBAAY,SAAS,GAAG,iBAAiB,CAAC;AAE1C,UAAU,eACR,SAAQ,oBAAoB,CAAC,SAAS,CAAC,EACrC,IAAI,CACF,mBAAmB,EACnB,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,oBAAoB,GAAG,OAAO,CACvE,EACD,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,mBAAmB,CAAC;IACzD,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,SAAS,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED,oBAAY,WAAW,GAAG,eAAe,GAAG;IAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,WACf,SAAQ,oBAAoB,CAAC,SAAS,CAAC,EACrC,IAAI,CACF,mBAAmB,EACnB,UAAU,GAAG,IAAI,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,OAAO,CACxE;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC3C,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACzC"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Select/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,oBAAY,SAAS,GAAG,iBAAiB,CAAC;AAE1C,UAAU,eACR,SAAQ,oBAAoB,CAAC,SAAS,CAAC,EACrC,IAAI,CACF,mBAAmB,EACnB,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,oBAAoB,GAAG,OAAO,CACvE,EACD,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,mBAAmB,CAAC;IACzD,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,SAAS,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED,oBAAY,WAAW,GAAG,eAAe,GAAG;IAC1C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,WACf,SAAQ,oBAAoB,CAAC,SAAS,CAAC,EACrC,IAAI,CACF,mBAAmB,EACnB,UAAU,GAAG,IAAI,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,OAAO,CACxE;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC3C,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Action.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/Action.tsx"],"names":[],"mappings":"AAgBA,QAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"Action.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/Action.tsx"],"names":[],"mappings":"AAgBA,QAAA,MAAM,MAAM,oEAYX,CAAC;AAEF,eAAO,MAAM,eAAe,oEAK3B,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -27,12 +27,12 @@ var borderRadius = (0, _styledComponents.css)(["border-radius:0 ", " ", " 0;"],
|
|
|
27
27
|
var Action = _styledComponents.default.div.withConfig({
|
|
28
28
|
displayName: "Action",
|
|
29
29
|
componentId: "sc-53eucd-0"
|
|
30
|
-
})(["align-items:center;
|
|
30
|
+
})(["align-items:center;justify-content:center;border:0;color:", ";display:flex;height:100%;width:", ";padding-right:", ";outline:none;", ""], (0, _toColorString.default)(interactionColors.pacificOcean), (0, _rem.default)(_constants.ACTION_WIDTH), (0, _rem.default)(1), borderRadius);
|
|
31
31
|
|
|
32
32
|
var ActionContainer = _styledComponents.default.div.withConfig({
|
|
33
33
|
displayName: "Action__ActionContainer",
|
|
34
34
|
componentId: "sc-53eucd-1"
|
|
35
|
-
})(["height:
|
|
35
|
+
})(["height:100%;background-color:", ";", ";"], (0, _toColorString.default)(baseColors.snowWhite), borderRadius);
|
|
36
36
|
|
|
37
37
|
exports.ActionContainer = ActionContainer;
|
|
38
38
|
var _default = Action;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const ACTION_WIDTH =
|
|
2
|
-
export declare const CONTAINER_X_PADDING =
|
|
1
|
+
export declare const ACTION_WIDTH = 22;
|
|
2
|
+
export declare const CONTAINER_X_PADDING = 8;
|
|
3
3
|
export declare const ICON_CONTENT_MARGIN = 5;
|
|
4
4
|
export declare const MAX_CONTAINER_WIDTH = 300;
|
|
5
5
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,KAAK,CAAC;AAC/B,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,mBAAmB,MAAM,CAAC"}
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MAX_CONTAINER_WIDTH = exports.ICON_CONTENT_MARGIN = exports.CONTAINER_X_PADDING = exports.ACTION_WIDTH = void 0;
|
|
7
|
-
var ACTION_WIDTH =
|
|
7
|
+
var ACTION_WIDTH = 22;
|
|
8
8
|
exports.ACTION_WIDTH = ACTION_WIDTH;
|
|
9
|
-
var CONTAINER_X_PADDING =
|
|
9
|
+
var CONTAINER_X_PADDING = 8;
|
|
10
10
|
exports.CONTAINER_X_PADDING = CONTAINER_X_PADDING;
|
|
11
11
|
var ICON_CONTENT_MARGIN = 5;
|
|
12
12
|
exports.ICON_CONTENT_MARGIN = ICON_CONTENT_MARGIN;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { RefForwardingComponent } from 'react';
|
|
2
|
-
import { CommonUIColors } from '../../utils/commonUIColors';
|
|
3
2
|
import { TagProps, TagRef } from './types';
|
|
4
|
-
export { TagProps, TagRef, TagActionRef as TagActionButtonRef } from './types';
|
|
5
|
-
export declare type ColorKeys = keyof CommonUIColors;
|
|
6
3
|
declare const TagWithRef: RefForwardingComponent<TagRef, TagProps>;
|
|
4
|
+
export { TagProps, TagRef, TagActionRef as TagActionButtonRef, IconComponent, } from './types';
|
|
7
5
|
export default TagWithRef;
|
|
8
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/index.tsx"],"names":[],"mappings":"AAAA,OAAc,EAIZ,sBAAsB,EAIvB,MAAM,OAAO,CAAC;AAQf,OAAO,EAAiB,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAqG1D,QAAA,MAAM,UAAU,EAAE,sBAAsB,CAAC,MAAM,EAAE,QAAQ,CAAmB,CAAC;AAS7E,OAAO,EACL,QAAQ,EACR,MAAM,EACN,YAAY,IAAI,kBAAkB,EAClC,aAAa,GACd,MAAM,SAAS,CAAC;AAEjB,eAAe,UAAU,CAAC"}
|
|
@@ -21,42 +21,28 @@ Object.defineProperty(exports, "TagActionButtonRef", {
|
|
|
21
21
|
return _types.TagActionRef;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
+
Object.defineProperty(exports, "IconComponent", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _types.IconComponent;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
24
30
|
exports.default = void 0;
|
|
25
31
|
|
|
26
|
-
var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
|
|
27
|
-
|
|
28
|
-
var _rem = _interopRequireDefault(require("polished/lib/helpers/rem"));
|
|
29
|
-
|
|
30
32
|
var _react = _interopRequireWildcard(require("react"));
|
|
31
33
|
|
|
32
|
-
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
33
|
-
|
|
34
|
-
var _designTokens = _interopRequireWildcard(require("@decisiv/design-tokens"));
|
|
35
|
-
|
|
36
|
-
var _color = _interopRequireDefault(require("../../modifiers/color"));
|
|
37
|
-
|
|
38
|
-
var _focusRingWithColor = _interopRequireDefault(require("../../utils/focusRingWithColor"));
|
|
39
|
-
|
|
40
|
-
var _commonUIColors = require("../../utils/commonUIColors");
|
|
41
|
-
|
|
42
34
|
var _Typography = require("../Typography");
|
|
43
35
|
|
|
44
36
|
var _Action = _interopRequireWildcard(require("./Action"));
|
|
45
37
|
|
|
46
|
-
var _constants = require("./constants");
|
|
47
|
-
|
|
48
38
|
var _propTypes = require("./propTypes");
|
|
49
39
|
|
|
50
|
-
var
|
|
40
|
+
var _styles = require("./styles");
|
|
51
41
|
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
var _styleModifiers = require("../../utils/styleModifiers");
|
|
42
|
+
var _types = require("./types");
|
|
55
43
|
|
|
56
44
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
57
45
|
|
|
58
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
59
|
-
|
|
60
46
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
61
47
|
|
|
62
48
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
|
|
@@ -71,130 +57,6 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
71
57
|
|
|
72
58
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
73
59
|
|
|
74
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { keys.push.apply(keys, Object.getOwnPropertySymbols(object)); } if (enumerableOnly) keys = keys.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); return keys; }
|
|
75
|
-
|
|
76
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
77
|
-
|
|
78
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
79
|
-
|
|
80
|
-
var _designTokens$color = _designTokens.default.color,
|
|
81
|
-
interactionColors = _designTokens$color.interaction,
|
|
82
|
-
statusColors = _designTokens$color.status;
|
|
83
|
-
|
|
84
|
-
var getContentMaxWidth = function getContentMaxWidth(props) {
|
|
85
|
-
var isSingleChild = props.isSingleChild,
|
|
86
|
-
hasIcon = props.hasIcon;
|
|
87
|
-
var iconWidth = 12;
|
|
88
|
-
var actionBorder = 1;
|
|
89
|
-
var containerBorder = 2;
|
|
90
|
-
var baseWidth = _constants.MAX_CONTAINER_WIDTH - _constants.CONTAINER_X_PADDING - containerBorder;
|
|
91
|
-
var valuesToSubtract = [];
|
|
92
|
-
!isSingleChild && valuesToSubtract.push(_constants.ACTION_WIDTH, actionBorder);
|
|
93
|
-
hasIcon && valuesToSubtract.push(iconWidth, _constants.ICON_CONTENT_MARGIN);
|
|
94
|
-
return (0, _rem.default)(valuesToSubtract.reduce(function (r, v) {
|
|
95
|
-
return r - v;
|
|
96
|
-
}, baseWidth));
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
var PALETTE_MAPPER = {
|
|
100
|
-
pastel: 'light',
|
|
101
|
-
bright: 'medium',
|
|
102
|
-
dark: 'dark'
|
|
103
|
-
};
|
|
104
|
-
var FG_COLOR = {
|
|
105
|
-
pastel: _objectSpread({}, _designTokens.color.base.charcoal, {
|
|
106
|
-
alpha: 0.8
|
|
107
|
-
}),
|
|
108
|
-
bright: _designTokens.color.base.snowWhite,
|
|
109
|
-
dark: _designTokens.color.base.snowWhite
|
|
110
|
-
};
|
|
111
|
-
var BORDER_OPACITY = {
|
|
112
|
-
pastel: 0.1,
|
|
113
|
-
bright: 0.15,
|
|
114
|
-
dark: 0.3
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
var Content = _styledComponents.default.div.withConfig({
|
|
118
|
-
displayName: "Tag__Content",
|
|
119
|
-
componentId: "nifm8a-0"
|
|
120
|
-
})(["color:inherit;align-items:center;border:0;display:flex;padding:0 ", ";border-right:1px solid ", ";", ";> svg{flex:1 0 auto;}* + *{margin-left:", ";}span{max-width:", ";}"], (0, _rem.default)(_constants.CONTAINER_X_PADDING / 2), function (_ref) {
|
|
121
|
-
var _ref$palette = _ref.palette,
|
|
122
|
-
palette = _ref$palette === void 0 ? 'bright' : _ref$palette;
|
|
123
|
-
return (0, _toColorString.default)(_objectSpread({}, _designTokens.color.base.charcoal, {
|
|
124
|
-
alpha: BORDER_OPACITY[palette]
|
|
125
|
-
}));
|
|
126
|
-
}, function (_ref2) {
|
|
127
|
-
var isSingleChild = _ref2.isSingleChild;
|
|
128
|
-
return (0, _styledComponents.css)(["max-width:", ";border-width:", ";"], isSingleChild ? '100%' : "calc(100% - ".concat(_constants.ACTION_WIDTH, "px)"), isSingleChild ? '0' : '1px');
|
|
129
|
-
}, (0, _rem.default)(_constants.ICON_CONTENT_MARGIN), getContentMaxWidth);
|
|
130
|
-
|
|
131
|
-
var contentSVGColor = function contentSVGColor(_ref3) {
|
|
132
|
-
var variant = _ref3.variant,
|
|
133
|
-
colorProp = _ref3.color;
|
|
134
|
-
|
|
135
|
-
if (variant === 'outline' && colorProp && colorProp in _commonUIColors.commonUIColors) {
|
|
136
|
-
return (0, _styledComponents.css)(["", " svg{color:", ";}"], Content, (0, _toColorString.default)(_commonUIColors.commonUIColors[colorProp]));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return null;
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
var getColorByProps = function getColorByProps(_ref4) {
|
|
143
|
-
var variant = _ref4.variant,
|
|
144
|
-
colorProp = _ref4.color,
|
|
145
|
-
_ref4$palette = _ref4.palette,
|
|
146
|
-
palette = _ref4$palette === void 0 ? 'bright' : _ref4$palette;
|
|
147
|
-
if (variant === 'outline') return _objectSpread({}, _designTokens.color.base.snowWhite, {
|
|
148
|
-
fg: _designTokens.color.base.alaskanHusky
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
if (colorProp && colorProp in _commonUIColors.commonUIThreeShadeColors) {
|
|
152
|
-
var baseColor = _commonUIColors.commonUIThreeShadeColors[colorProp];
|
|
153
|
-
var fgColor = FG_COLOR[palette];
|
|
154
|
-
var bgColor = baseColor[PALETTE_MAPPER[palette]];
|
|
155
|
-
return palette === 'bright' ? bgColor : _objectSpread({}, bgColor, {
|
|
156
|
-
fg: fgColor
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return _commonUIColors.commonUIColors.licoriceMousse;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
var colorModifiers = function colorModifiers(props) {
|
|
164
|
-
var _props$palette = props.palette,
|
|
165
|
-
palette = _props$palette === void 0 ? 'bright' : _props$palette;
|
|
166
|
-
|
|
167
|
-
var borderColor = _objectSpread({}, _designTokens.color.base.charcoal, {
|
|
168
|
-
alpha: BORDER_OPACITY[palette]
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
return (0, _styledComponents.css)(["", ";border:1px solid ", ";", ""], (0, _color.default)(getColorByProps(props)), (0, _toColorString.default)(borderColor), (0, _styleModifiers.when)('isSingleChild', false, (0, _styledComponents.css)(["&:hover{box-shadow:inset 0 0 0 ", " ", ";", "{border-color:transparent;}}"], (0, _rem.default)(100), (0, _toColorString.default)(borderColor), Content)));
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
var variantModifiers = function variantModifiers(props) {
|
|
175
|
-
var _props$variant = props.variant,
|
|
176
|
-
variant = _props$variant === void 0 ? 'normal' : _props$variant;
|
|
177
|
-
if (variant === 'normal') return undefined;
|
|
178
|
-
return (0, _styledComponents.css)(["border:1px solid ", ";", " &:focus{border:1px solid ", ";", ";}"], (0, _toColorString.default)(_designTokens.color.opacity.charcoal15), (0, _styleModifiers.when)('isSingleChild', false, (0, _styledComponents.css)(["&:hover{box-shadow:none;background-color:", ";}"], (0, _toColorString.default)(_objectSpread({}, _designTokens.color.base.charcoal, {
|
|
179
|
-
alpha: 0.07
|
|
180
|
-
})))), (0, _toColorString.default)(_designTokens.color.interaction.pacificOcean), (0, _focusRingWithColor.default)(_designTokens.color.interaction.pacificOcean40));
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
var actionColors = {
|
|
184
|
-
normal: (0, _toColorString.default)(interactionColors.indianOcean),
|
|
185
|
-
danger: (0, _toColorString.default)(statusColors.danger.medium)
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
var actionColor = function actionColor(_ref5) {
|
|
189
|
-
var actionIntent = _ref5.actionIntent;
|
|
190
|
-
return actionColors[actionIntent !== 'danger' ? 'normal' : 'danger'];
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
var Container = (0, _styledComponents.default)(_BaseButton.default).withConfig({
|
|
194
|
-
displayName: "Tag__Container",
|
|
195
|
-
componentId: "nifm8a-1"
|
|
196
|
-
})(["font-family:", ";font-size:", ";font-weight:", ";align-items:center;border-radius:", ";display:inline-flex;height:", ";max-width:100%;min-width:", ";padding:0;background-color:transparent;&:focus{border:1px solid ", ";", ";", "{height:", ";box-shadow:none;}}&:focus-visible{outline:none;}&:hover{", "{color:", ";}}", ";", ";", ";"], _designTokens.typography.typeface.default, (0, _rem.default)(_designTokens.typography.size.alias.default), _designTokens.typography.weight.alias.default, (0, _rem.default)(10), (0, _rem.default)(20), (0, _rem.default)(26), (0, _toColorString.default)(_designTokens.color.base.blackSheep), (0, _focusRingWithColor.default)(_designTokens.color.opacity.charcoal40), _Action.ActionContainer, (0, _rem.default)(14), _Action.default, actionColor, colorModifiers, variantModifiers, contentSVGColor);
|
|
197
|
-
|
|
198
60
|
function Tag(props, containerRef) {
|
|
199
61
|
var action = props.action,
|
|
200
62
|
actionAttributes = props.actionAttributes,
|
|
@@ -204,7 +66,9 @@ function Tag(props, containerRef) {
|
|
|
204
66
|
Icon = props.icon,
|
|
205
67
|
text = props.text,
|
|
206
68
|
palette = props.palette,
|
|
207
|
-
|
|
69
|
+
_props$size = props.size,
|
|
70
|
+
size = _props$size === void 0 ? 'small' : _props$size,
|
|
71
|
+
rest = _objectWithoutProperties(props, ["action", "actionAttributes", "actionIcon", "actionIntent", "actionRef", "icon", "text", "palette", "size"]);
|
|
208
72
|
|
|
209
73
|
var _useState = (0, _react.useState)(false),
|
|
210
74
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -212,19 +76,19 @@ function Tag(props, containerRef) {
|
|
|
212
76
|
setIsFocused = _useState2[1];
|
|
213
77
|
|
|
214
78
|
var onTagFocus = (0, _react.useCallback)(function (e) {
|
|
215
|
-
var
|
|
79
|
+
var _ref = actionAttributes || {
|
|
216
80
|
onFocus: undefined
|
|
217
81
|
},
|
|
218
|
-
onFocus =
|
|
82
|
+
onFocus = _ref.onFocus;
|
|
219
83
|
|
|
220
84
|
setIsFocused(true);
|
|
221
85
|
onFocus && onFocus(e);
|
|
222
86
|
}, [actionAttributes]);
|
|
223
87
|
var onTagBlur = (0, _react.useCallback)(function (e) {
|
|
224
|
-
var
|
|
88
|
+
var _ref2 = actionAttributes || {
|
|
225
89
|
onBlur: undefined
|
|
226
90
|
},
|
|
227
|
-
onBlur =
|
|
91
|
+
onBlur = _ref2.onBlur;
|
|
228
92
|
|
|
229
93
|
setIsFocused(false);
|
|
230
94
|
onBlur && onBlur(e);
|
|
@@ -251,7 +115,9 @@ function Tag(props, containerRef) {
|
|
|
251
115
|
* seconds content component, and calculate the max width of the container.
|
|
252
116
|
*/
|
|
253
117
|
|
|
254
|
-
return _react.default.createElement(Container, _extends({}, rest, actionAttributes, {
|
|
118
|
+
return _react.default.createElement(_styles.Container, _extends({}, rest, actionAttributes, {
|
|
119
|
+
tabIndex: 0,
|
|
120
|
+
size: size,
|
|
255
121
|
isSingleChild: contentIsSingleChild,
|
|
256
122
|
palette: palette,
|
|
257
123
|
ref: containerRef,
|
|
@@ -260,7 +126,7 @@ function Tag(props, containerRef) {
|
|
|
260
126
|
onFocus: onTagFocus,
|
|
261
127
|
isFocused: isFocused,
|
|
262
128
|
actionIntent: actionIntent
|
|
263
|
-
}), _react.default.createElement(Content, {
|
|
129
|
+
}), _react.default.createElement(_styles.Content, {
|
|
264
130
|
palette: palette,
|
|
265
131
|
hasIcon: !!Icon,
|
|
266
132
|
isSingleChild: contentIsSingleChild
|
|
@@ -269,7 +135,7 @@ function Tag(props, containerRef) {
|
|
|
269
135
|
}), text && _react.default.createElement(_Typography.P, {
|
|
270
136
|
as: "span",
|
|
271
137
|
color: "inherit",
|
|
272
|
-
size:
|
|
138
|
+
size: size === 'small' ? 'small' : undefined,
|
|
273
139
|
truncate: true
|
|
274
140
|
}, text)), ActionElement);
|
|
275
141
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var _react = _interopRequireDefault(require("react"));
|
|
4
4
|
|
|
5
|
+
require("jest-styled-components");
|
|
6
|
+
|
|
5
7
|
var _react2 = require("@testing-library/react");
|
|
6
8
|
|
|
7
9
|
var _Home = _interopRequireDefault(require("@decisiv/iconix/lib/components/Home"));
|
|
@@ -17,6 +19,7 @@ describe('Tag', function () {
|
|
|
17
19
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
18
20
|
var variant = arguments.length > 1 ? arguments[1] : undefined;
|
|
19
21
|
return (0, _react2.render)(_react.default.createElement(_.default, _extends({
|
|
22
|
+
"data-testid": "tag",
|
|
20
23
|
text: "text"
|
|
21
24
|
}, props, {
|
|
22
25
|
variant: variant
|
|
@@ -83,39 +86,90 @@ describe('Tag', function () {
|
|
|
83
86
|
describe('Outline variant', function () {
|
|
84
87
|
TestVariant('outline');
|
|
85
88
|
});
|
|
89
|
+
describe('Size Props', function () {
|
|
90
|
+
describe('when the size is "small"', function () {
|
|
91
|
+
it('renders with a height of 1.25rem', function () {
|
|
92
|
+
var _render = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
93
|
+
"data-testid": "small-tag",
|
|
94
|
+
text: "text",
|
|
95
|
+
size: "small"
|
|
96
|
+
})),
|
|
97
|
+
getByTestId = _render.getByTestId;
|
|
98
|
+
|
|
99
|
+
expect(getByTestId('small-tag')).toHaveStyleRule('height', '1.25rem');
|
|
100
|
+
});
|
|
101
|
+
it('renders with a font-size of 0.75rem', function () {
|
|
102
|
+
var _render2 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
103
|
+
"data-testid": "small-tag",
|
|
104
|
+
text: "text",
|
|
105
|
+
size: "small"
|
|
106
|
+
})),
|
|
107
|
+
getByText = _render2.getByText;
|
|
108
|
+
|
|
109
|
+
expect(getByText(/text/i, {
|
|
110
|
+
selector: 'span'
|
|
111
|
+
})).toHaveStyleRule('font-size', '0.75rem');
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
describe('when the size is "medium"', function () {
|
|
115
|
+
it('renders with a height of 1.5625rem', function () {
|
|
116
|
+
var _render3 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
117
|
+
"data-testid": "medium-tag",
|
|
118
|
+
text: "text",
|
|
119
|
+
size: "medium"
|
|
120
|
+
})),
|
|
121
|
+
getByTestId = _render3.getByTestId;
|
|
122
|
+
|
|
123
|
+
expect(getByTestId('medium-tag')).toHaveStyleRule('height', '1.5625rem');
|
|
124
|
+
});
|
|
125
|
+
it('renders with a font-size of 0.875rem', function () {
|
|
126
|
+
var _render4 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
127
|
+
"data-testid": "small-tag",
|
|
128
|
+
text: "text",
|
|
129
|
+
size: "medium"
|
|
130
|
+
})),
|
|
131
|
+
getByText = _render4.getByText;
|
|
132
|
+
|
|
133
|
+
expect(getByText(/text/i, {
|
|
134
|
+
selector: 'span'
|
|
135
|
+
})).toHaveStyleRule('font-size', '0.875rem');
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
86
139
|
describe('Palette variants', function () {
|
|
87
140
|
describe('bright', function () {
|
|
88
141
|
it('renders correctly', function () {
|
|
89
|
-
var
|
|
142
|
+
var _render5 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
90
143
|
text: "text",
|
|
91
144
|
palette: "bright"
|
|
92
145
|
})),
|
|
93
|
-
container =
|
|
146
|
+
container = _render5.container;
|
|
94
147
|
|
|
95
148
|
expect(container).toMatchSnapshot();
|
|
96
149
|
});
|
|
97
150
|
it('renders correctly with an Icon', function () {
|
|
98
|
-
var
|
|
151
|
+
var _render6 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
99
152
|
text: "text",
|
|
100
153
|
palette: "bright",
|
|
101
154
|
icon: _Home.default
|
|
102
155
|
})),
|
|
103
|
-
container =
|
|
156
|
+
container = _render6.container;
|
|
104
157
|
|
|
105
158
|
expect(container).toMatchSnapshot();
|
|
106
159
|
});
|
|
107
160
|
it('renders correctly with different colors', function () {
|
|
108
|
-
var
|
|
161
|
+
var _render7 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
109
162
|
text: "text",
|
|
110
163
|
palette: "bright",
|
|
111
164
|
color: "information"
|
|
112
165
|
})),
|
|
113
|
-
container =
|
|
166
|
+
container = _render7.container;
|
|
114
167
|
|
|
115
168
|
expect(container).toMatchSnapshot();
|
|
116
169
|
});
|
|
117
170
|
it('renders correctly with an action', function () {
|
|
118
|
-
var
|
|
171
|
+
var _render8 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
172
|
+
"data-testid": "action-tag",
|
|
119
173
|
text: "text",
|
|
120
174
|
palette: "bright",
|
|
121
175
|
action: jest.fn(),
|
|
@@ -124,12 +178,14 @@ describe('Tag', function () {
|
|
|
124
178
|
},
|
|
125
179
|
actionIcon: _Home.default
|
|
126
180
|
})),
|
|
127
|
-
container =
|
|
181
|
+
container = _render8.container,
|
|
182
|
+
getByTestId = _render8.getByTestId;
|
|
128
183
|
|
|
184
|
+
expect(getByTestId('action-tag')).toHaveStyleRule('cursor', 'pointer');
|
|
129
185
|
expect(container).toMatchSnapshot();
|
|
130
186
|
});
|
|
131
187
|
it('renders the action correctly with the danger intent', function () {
|
|
132
|
-
var
|
|
188
|
+
var _render9 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
133
189
|
text: "text",
|
|
134
190
|
palette: "bright",
|
|
135
191
|
action: jest.fn(),
|
|
@@ -139,43 +195,43 @@ describe('Tag', function () {
|
|
|
139
195
|
actionIcon: _Home.default,
|
|
140
196
|
actionIntent: "danger"
|
|
141
197
|
})),
|
|
142
|
-
container =
|
|
198
|
+
container = _render9.container;
|
|
143
199
|
|
|
144
200
|
expect(container).toMatchSnapshot();
|
|
145
201
|
});
|
|
146
202
|
});
|
|
147
203
|
describe('pastel', function () {
|
|
148
204
|
it('renders correctly', function () {
|
|
149
|
-
var
|
|
205
|
+
var _render10 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
150
206
|
text: "text",
|
|
151
207
|
palette: "pastel"
|
|
152
208
|
})),
|
|
153
|
-
container =
|
|
209
|
+
container = _render10.container;
|
|
154
210
|
|
|
155
211
|
expect(container).toMatchSnapshot();
|
|
156
212
|
});
|
|
157
213
|
it('renders correctly with an Icon', function () {
|
|
158
|
-
var
|
|
214
|
+
var _render11 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
159
215
|
text: "text",
|
|
160
216
|
palette: "pastel",
|
|
161
217
|
icon: _Home.default
|
|
162
218
|
})),
|
|
163
|
-
container =
|
|
219
|
+
container = _render11.container;
|
|
164
220
|
|
|
165
221
|
expect(container).toMatchSnapshot();
|
|
166
222
|
});
|
|
167
223
|
it('renders correctly with different colors', function () {
|
|
168
|
-
var
|
|
224
|
+
var _render12 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
169
225
|
text: "text",
|
|
170
226
|
palette: "pastel",
|
|
171
227
|
color: "information"
|
|
172
228
|
})),
|
|
173
|
-
container =
|
|
229
|
+
container = _render12.container;
|
|
174
230
|
|
|
175
231
|
expect(container).toMatchSnapshot();
|
|
176
232
|
});
|
|
177
233
|
it('renders correctly with an action', function () {
|
|
178
|
-
var
|
|
234
|
+
var _render13 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
179
235
|
text: "text",
|
|
180
236
|
palette: "pastel",
|
|
181
237
|
action: jest.fn(),
|
|
@@ -184,12 +240,12 @@ describe('Tag', function () {
|
|
|
184
240
|
},
|
|
185
241
|
actionIcon: _Home.default
|
|
186
242
|
})),
|
|
187
|
-
container =
|
|
243
|
+
container = _render13.container;
|
|
188
244
|
|
|
189
245
|
expect(container).toMatchSnapshot();
|
|
190
246
|
});
|
|
191
247
|
it('renders the action correctly with the danger intent', function () {
|
|
192
|
-
var
|
|
248
|
+
var _render14 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
193
249
|
text: "text",
|
|
194
250
|
palette: "pastel",
|
|
195
251
|
action: jest.fn(),
|
|
@@ -199,43 +255,43 @@ describe('Tag', function () {
|
|
|
199
255
|
actionIcon: _Home.default,
|
|
200
256
|
actionIntent: "danger"
|
|
201
257
|
})),
|
|
202
|
-
container =
|
|
258
|
+
container = _render14.container;
|
|
203
259
|
|
|
204
260
|
expect(container).toMatchSnapshot();
|
|
205
261
|
});
|
|
206
262
|
});
|
|
207
263
|
describe('dark', function () {
|
|
208
264
|
it('renders correctly', function () {
|
|
209
|
-
var
|
|
265
|
+
var _render15 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
210
266
|
text: "text",
|
|
211
267
|
palette: "dark"
|
|
212
268
|
})),
|
|
213
|
-
container =
|
|
269
|
+
container = _render15.container;
|
|
214
270
|
|
|
215
271
|
expect(container).toMatchSnapshot();
|
|
216
272
|
});
|
|
217
273
|
it('renders correctly with an Icon', function () {
|
|
218
|
-
var
|
|
274
|
+
var _render16 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
219
275
|
text: "text",
|
|
220
276
|
palette: "dark",
|
|
221
277
|
icon: _Home.default
|
|
222
278
|
})),
|
|
223
|
-
container =
|
|
279
|
+
container = _render16.container;
|
|
224
280
|
|
|
225
281
|
expect(container).toMatchSnapshot();
|
|
226
282
|
});
|
|
227
283
|
it('renders correctly with different colors', function () {
|
|
228
|
-
var
|
|
284
|
+
var _render17 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
229
285
|
text: "text",
|
|
230
286
|
palette: "dark",
|
|
231
287
|
color: "information"
|
|
232
288
|
})),
|
|
233
|
-
container =
|
|
289
|
+
container = _render17.container;
|
|
234
290
|
|
|
235
291
|
expect(container).toMatchSnapshot();
|
|
236
292
|
});
|
|
237
293
|
it('renders correctly with an action', function () {
|
|
238
|
-
var
|
|
294
|
+
var _render18 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
239
295
|
text: "text",
|
|
240
296
|
palette: "dark",
|
|
241
297
|
action: jest.fn(),
|
|
@@ -244,12 +300,12 @@ describe('Tag', function () {
|
|
|
244
300
|
},
|
|
245
301
|
actionIcon: _Home.default
|
|
246
302
|
})),
|
|
247
|
-
container =
|
|
303
|
+
container = _render18.container;
|
|
248
304
|
|
|
249
305
|
expect(container).toMatchSnapshot();
|
|
250
306
|
});
|
|
251
307
|
it('renders the action correctly with the danger intent', function () {
|
|
252
|
-
var
|
|
308
|
+
var _render19 = (0, _react2.render)(_react.default.createElement(_.default, {
|
|
253
309
|
text: "text",
|
|
254
310
|
palette: "dark",
|
|
255
311
|
action: jest.fn(),
|
|
@@ -259,7 +315,7 @@ describe('Tag', function () {
|
|
|
259
315
|
actionIcon: _Home.default,
|
|
260
316
|
actionIntent: "danger"
|
|
261
317
|
})),
|
|
262
|
-
container =
|
|
318
|
+
container = _render19.container;
|
|
263
319
|
|
|
264
320
|
expect(container).toMatchSnapshot();
|
|
265
321
|
});
|
|
@@ -10,6 +10,7 @@ export declare const propTypes: {
|
|
|
10
10
|
color: PropTypes.Requireable<import("../../utils/commonUIColors").CommonUIColorKeys>;
|
|
11
11
|
variant: PropTypes.Requireable<string>;
|
|
12
12
|
palette: PropTypes.Requireable<string>;
|
|
13
|
+
size: PropTypes.Requireable<string>;
|
|
13
14
|
};
|
|
14
15
|
export declare const defaultProps: {
|
|
15
16
|
action: undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"propTypes.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/propTypes.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,YAAY,CAAC;AAYnC,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"propTypes.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/propTypes.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,YAAY,CAAC;AAYnC,eAAO,MAAM,SAAS;;;;;;;;;;;;CA4BrB,CAAC;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;CAWxB,CAAC"}
|
|
@@ -41,7 +41,8 @@ var propTypes = {
|
|
|
41
41
|
actionRef: _propTypes.default.any,
|
|
42
42
|
color: _propTypes.default.oneOf(_commonUIColors.commonUIColorKeys),
|
|
43
43
|
variant: _propTypes.default.oneOf(['normal', 'outline']),
|
|
44
|
-
palette: _propTypes.default.oneOf(['pastel', 'bright', 'dark'])
|
|
44
|
+
palette: _propTypes.default.oneOf(['pastel', 'bright', 'dark']),
|
|
45
|
+
size: _propTypes.default.oneOf(['small', 'medium'])
|
|
45
46
|
};
|
|
46
47
|
exports.propTypes = propTypes;
|
|
47
48
|
var defaultProps = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/schema.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,MAAM,KAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/schema.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,MAAM,KAAmC,CAAC;AAkDhD,eAAe,MAAM,CAAC"}
|
|
@@ -16,6 +16,7 @@ var schema = (0, _reactDesc.describe)({
|
|
|
16
16
|
schema.propTypes = {
|
|
17
17
|
text: _reactDesc.PropTypes.string.description("The tag's text"),
|
|
18
18
|
icon: _reactDesc.PropTypes.element.description('Which `iconix` icon to render as the main icon'),
|
|
19
|
+
size: _reactDesc.PropTypes.oneOf(['small', 'medium']).description('The size to use for the Tag').defaultValue('small'),
|
|
19
20
|
color: _reactDesc.PropTypes.oneOf(_commonUIColors.commonUIColorKeys).description('The color to use as the tag background or SVG color when outlined').format('string (see notes below)').defaultValue('licoriceMousse'),
|
|
20
21
|
palette: _reactDesc.PropTypes.oneOf(['bright', 'pastel', 'dark']).description('What color variant to render').defaultValue('bright'),
|
|
21
22
|
variant: _reactDesc.PropTypes.oneOf(['normal', 'outline']).description('What tag variant to render').defaultValue('normal'),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TagProps } from './types';
|
|
2
|
+
interface ContentProps extends Pick<TagProps, 'palette'> {
|
|
3
|
+
hasIcon: boolean;
|
|
4
|
+
isSingleChild: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare type ContainerProps = TagProps & {
|
|
7
|
+
isFocused: boolean;
|
|
8
|
+
isSingleChild: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const Content: import("styled-components").StyledComponent<"div", any, ContentProps, never>;
|
|
11
|
+
export declare const Container: import("styled-components").StyledComponent<"div", any, ContainerProps, never>;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/styles.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAa,QAAQ,EAAoB,MAAM,SAAS,CAAC;AAahE,UAAU,YAAa,SAAQ,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;IACtD,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,aAAK,cAAc,GAAG,QAAQ,GAAG;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,CAAC;AAoChF,eAAO,MAAM,OAAO,8EAkCnB,CAAC;AAmIF,eAAO,MAAM,SAAS,gFAqDrB,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Container = exports.Content = void 0;
|
|
7
|
+
|
|
8
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
9
|
+
|
|
10
|
+
var _toColorString = _interopRequireDefault(require("polished/lib/color/toColorString"));
|
|
11
|
+
|
|
12
|
+
var _rem = _interopRequireDefault(require("polished/lib/helpers/rem"));
|
|
13
|
+
|
|
14
|
+
var _designTokens = _interopRequireWildcard(require("@decisiv/design-tokens"));
|
|
15
|
+
|
|
16
|
+
var _commonUIColors = require("../../utils/commonUIColors");
|
|
17
|
+
|
|
18
|
+
var _color = _interopRequireDefault(require("../../modifiers/color"));
|
|
19
|
+
|
|
20
|
+
var _focusRingWithColor = _interopRequireDefault(require("../../utils/focusRingWithColor"));
|
|
21
|
+
|
|
22
|
+
var _styleModifiers = require("../../utils/styleModifiers");
|
|
23
|
+
|
|
24
|
+
var _Action = _interopRequireWildcard(require("./Action"));
|
|
25
|
+
|
|
26
|
+
var _constants = require("./constants");
|
|
27
|
+
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
|
|
30
|
+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
|
31
|
+
|
|
32
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { keys.push.apply(keys, Object.getOwnPropertySymbols(object)); } if (enumerableOnly) keys = keys.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); return keys; }
|
|
33
|
+
|
|
34
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
35
|
+
|
|
36
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
37
|
+
|
|
38
|
+
var _designTokens$color = _designTokens.default.color,
|
|
39
|
+
interactionColors = _designTokens$color.interaction,
|
|
40
|
+
statusColors = _designTokens$color.status;
|
|
41
|
+
var PALETTE_MAPPER = {
|
|
42
|
+
pastel: 'light',
|
|
43
|
+
bright: 'medium',
|
|
44
|
+
dark: 'dark'
|
|
45
|
+
};
|
|
46
|
+
var FG_COLOR = {
|
|
47
|
+
pastel: _objectSpread({}, _designTokens.color.base.charcoal, {
|
|
48
|
+
alpha: 0.8
|
|
49
|
+
}),
|
|
50
|
+
bright: _designTokens.color.base.snowWhite,
|
|
51
|
+
dark: _designTokens.color.base.snowWhite
|
|
52
|
+
};
|
|
53
|
+
var BORDER_OPACITY = {
|
|
54
|
+
pastel: 0.1,
|
|
55
|
+
bright: 0.15,
|
|
56
|
+
dark: 0.3
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
var getContentMaxWidth = function getContentMaxWidth(props) {
|
|
60
|
+
var isSingleChild = props.isSingleChild,
|
|
61
|
+
hasIcon = props.hasIcon;
|
|
62
|
+
var iconWidth = 12;
|
|
63
|
+
var actionBorder = 1;
|
|
64
|
+
var containerBorder = 2;
|
|
65
|
+
var baseWidth = _constants.MAX_CONTAINER_WIDTH - _constants.CONTAINER_X_PADDING - containerBorder;
|
|
66
|
+
var valuesToSubtract = [];
|
|
67
|
+
!isSingleChild && valuesToSubtract.push(_constants.ACTION_WIDTH, actionBorder);
|
|
68
|
+
hasIcon && valuesToSubtract.push(iconWidth, _constants.ICON_CONTENT_MARGIN);
|
|
69
|
+
return (0, _rem.default)(valuesToSubtract.reduce(function (r, v) {
|
|
70
|
+
return r - v;
|
|
71
|
+
}, baseWidth));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
var Content = _styledComponents.default.div.withConfig({
|
|
75
|
+
displayName: "styles__Content",
|
|
76
|
+
componentId: "sc-1sm93ik-0"
|
|
77
|
+
})(["height:100%;color:inherit;align-items:center;border:0;display:flex;padding:0 ", ";border-right:1px solid ", ";", ";> svg{flex:1 0 auto;}* + *{margin-left:", ";}span{max-width:", ";}"], (0, _rem.default)(_constants.CONTAINER_X_PADDING), function (_ref) {
|
|
78
|
+
var _ref$palette = _ref.palette,
|
|
79
|
+
palette = _ref$palette === void 0 ? 'bright' : _ref$palette;
|
|
80
|
+
return (0, _toColorString.default)(_objectSpread({}, _designTokens.color.base.charcoal, {
|
|
81
|
+
alpha: BORDER_OPACITY[palette]
|
|
82
|
+
}));
|
|
83
|
+
}, function (_ref2) {
|
|
84
|
+
var isSingleChild = _ref2.isSingleChild;
|
|
85
|
+
return (0, _styledComponents.css)(["max-width:", ";border-width:", ";"], isSingleChild ? '100%' : "calc(100% - ".concat(_constants.ACTION_WIDTH, "px)"), isSingleChild ? '0' : '1px');
|
|
86
|
+
}, (0, _rem.default)(_constants.ICON_CONTENT_MARGIN), getContentMaxWidth);
|
|
87
|
+
|
|
88
|
+
exports.Content = Content;
|
|
89
|
+
|
|
90
|
+
var contentSVGColor = function contentSVGColor(_ref3) {
|
|
91
|
+
var variant = _ref3.variant,
|
|
92
|
+
colorProp = _ref3.color;
|
|
93
|
+
|
|
94
|
+
if (variant === 'outline' && colorProp && colorProp in _commonUIColors.commonUIColors) {
|
|
95
|
+
return (0, _styledComponents.css)(["", " svg{color:", ";}"], Content, (0, _toColorString.default)(_commonUIColors.commonUIColors[colorProp]));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return null;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
var getColorByProps = function getColorByProps(_ref4) {
|
|
102
|
+
var variant = _ref4.variant,
|
|
103
|
+
colorProp = _ref4.color,
|
|
104
|
+
_ref4$palette = _ref4.palette,
|
|
105
|
+
palette = _ref4$palette === void 0 ? 'bright' : _ref4$palette;
|
|
106
|
+
if (variant === 'outline') return _objectSpread({}, _designTokens.color.base.snowWhite, {
|
|
107
|
+
fg: _designTokens.color.base.alaskanHusky
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
if (colorProp && colorProp in _commonUIColors.commonUIThreeShadeColors) {
|
|
111
|
+
var baseColor = _commonUIColors.commonUIThreeShadeColors[colorProp];
|
|
112
|
+
var fgColor = FG_COLOR[palette];
|
|
113
|
+
var bgColor = baseColor[PALETTE_MAPPER[palette]];
|
|
114
|
+
return palette === 'bright' ? bgColor : _objectSpread({}, bgColor, {
|
|
115
|
+
fg: fgColor
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return _commonUIColors.commonUIColors.licoriceMousse;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
var actionColors = {
|
|
123
|
+
normal: (0, _toColorString.default)(interactionColors.indianOcean),
|
|
124
|
+
danger: (0, _toColorString.default)(statusColors.danger.medium)
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var actionColor = function actionColor(_ref5) {
|
|
128
|
+
var actionIntent = _ref5.actionIntent;
|
|
129
|
+
return actionColors[actionIntent !== 'danger' ? 'normal' : 'danger'];
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
var colorModifiers = function colorModifiers(props) {
|
|
133
|
+
var _props$palette = props.palette,
|
|
134
|
+
palette = _props$palette === void 0 ? 'bright' : _props$palette;
|
|
135
|
+
|
|
136
|
+
var borderColor = _objectSpread({}, _designTokens.color.base.charcoal, {
|
|
137
|
+
alpha: BORDER_OPACITY[palette]
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return (0, _styledComponents.css)(["", ";border:1px solid ", ";", ""], (0, _color.default)(getColorByProps(props)), (0, _toColorString.default)(borderColor), (0, _styleModifiers.when)('isSingleChild', false, (0, _styledComponents.css)(["&:hover{box-shadow:inset 0 0 0 ", " ", ";", "{border-color:transparent;}}"], (0, _rem.default)(100), (0, _toColorString.default)(borderColor), Content)));
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
var variantModifiers = function variantModifiers(props) {
|
|
144
|
+
var _props$variant = props.variant,
|
|
145
|
+
variant = _props$variant === void 0 ? 'normal' : _props$variant;
|
|
146
|
+
if (variant === 'normal') return undefined;
|
|
147
|
+
return (0, _styledComponents.css)(["border:1px solid ", ";", " &:focus{border:1px solid ", ";::before{", ";}}"], (0, _toColorString.default)(_designTokens.color.opacity.charcoal15), (0, _styleModifiers.when)('isSingleChild', false, (0, _styledComponents.css)(["&:hover{background-color:", ";}"], (0, _toColorString.default)(_objectSpread({}, _designTokens.color.base.charcoal, {
|
|
148
|
+
alpha: 0.07
|
|
149
|
+
})))), (0, _toColorString.default)(_designTokens.color.interaction.pacificOcean), (0, _focusRingWithColor.default)(_designTokens.color.interaction.pacificOcean40));
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
var sizeModifiers = function sizeModifiers(props) {
|
|
153
|
+
var _props$size = props.size,
|
|
154
|
+
size = _props$size === void 0 ? 'small' : _props$size;
|
|
155
|
+
if (size === 'small') return undefined;
|
|
156
|
+
var mediumHeight = (0, _rem.default)(25);
|
|
157
|
+
var mediumRadius = (0, _rem.default)(15);
|
|
158
|
+
var mediumBorderRadius = "0 ".concat(mediumRadius, " ").concat(mediumRadius, " 0");
|
|
159
|
+
return (0, _styledComponents.css)(["height:", ";border-radius:", ";&:focus{::before{border-radius:", ";}}", "{padding-right:", ";}", ",", "{border-radius:", ";}"], mediumHeight, mediumRadius, mediumRadius, _Action.default, (0, _rem.default)(2), _Action.default, _Action.ActionContainer, mediumBorderRadius);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
var Container = _styledComponents.default.div.withConfig({
|
|
163
|
+
displayName: "styles__Container",
|
|
164
|
+
componentId: "sc-1sm93ik-1"
|
|
165
|
+
})(["position:relative;font-family:", ";font-size:", ";font-weight:", ";align-items:center;justify-content:center;border-radius:", ";display:inline-flex;height:", ";max-width:100%;min-width:", ";background-color:transparent;padding:0;", " &:focus{border:1px solid ", ";&::before{position:absolute;top:0;left:0;width:100%;height:100%;content:'';border-radius:", ";", ";}}&:focus-visible{outline:none;}&:hover{", "{color:", ";}}", ";", ";", ";", ";"], _designTokens.typography.typeface.default, (0, _rem.default)(_designTokens.typography.size.alias.default), _designTokens.typography.weight.alias.default, (0, _rem.default)(10), (0, _rem.default)(20), (0, _rem.default)(26), (0, _styleModifiers.when)('isSingleChild', false, (0, _styledComponents.css)(["cursor:pointer;"])), (0, _toColorString.default)(_designTokens.color.base.blackSheep), (0, _rem.default)(10), (0, _focusRingWithColor.default)(_designTokens.color.opacity.charcoal40), _Action.default, actionColor, sizeModifiers, colorModifiers, variantModifiers, contentSVGColor);
|
|
166
|
+
|
|
167
|
+
exports.Container = Container;
|
|
@@ -2,12 +2,13 @@ import React, { Ref, RefAttributes, AriaAttributes, DOMAttributes } from 'react'
|
|
|
2
2
|
import { CSSObject } from 'styled-components';
|
|
3
3
|
import { IconProps } from '@decisiv/iconix';
|
|
4
4
|
import { CommonUIColorKeys } from '../../utils/commonUIColors';
|
|
5
|
-
export declare type TagRef =
|
|
5
|
+
export declare type TagRef = HTMLDivElement;
|
|
6
6
|
export declare type TagActionRef = HTMLDivElement;
|
|
7
7
|
export declare type IconComponent = (props: IconProps) => JSX.Element;
|
|
8
|
-
export declare type ActionHandler = (event: React.MouseEvent<
|
|
8
|
+
export declare type ActionHandler = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => unknown;
|
|
9
9
|
export declare type BaseProps = {
|
|
10
10
|
color?: CommonUIColorKeys;
|
|
11
|
+
size?: 'medium' | 'small';
|
|
11
12
|
palette?: 'pastel' | 'bright' | 'dark';
|
|
12
13
|
variant?: 'normal' | 'outline';
|
|
13
14
|
style?: CSSObject;
|
|
@@ -38,7 +39,7 @@ declare type ConditionalProps = Text & {
|
|
|
38
39
|
export declare type ActionExtraProps = {
|
|
39
40
|
actionRef?: Ref<TagActionRef>;
|
|
40
41
|
actionIntent?: 'normal' | 'danger';
|
|
41
|
-
actionAttributes?: AriaAttributes & DOMAttributes<
|
|
42
|
+
actionAttributes?: AriaAttributes & DOMAttributes<HTMLDivElement>;
|
|
42
43
|
};
|
|
43
44
|
export declare type TagProps = RefAttributes<TagRef> & BaseProps & ContentProps & ConditionalProps & ActionExtraProps;
|
|
44
45
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EACZ,GAAG,EACH,aAAa,EACb,cAAc,EACd,aAAa,EACd,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,oBAAY,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Tag/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EACZ,GAAG,EACH,aAAa,EACb,cAAc,EACd,aAAa,EACd,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,oBAAY,MAAM,GAAG,cAAc,CAAC;AACpC,oBAAY,YAAY,GAAG,cAAc,CAAC;AAC1C,oBAAY,aAAa,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAE9D,oBAAY,aAAa,GAAG,CAC1B,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,EAAE,UAAU,CAAC,KAChD,OAAO,CAAC;AAEb,oBAAY,SAAS,GAAG;IACtB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC1B,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IACvC,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,aAAK,YAAY,GAAG;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B,CAAC;AAEF,aAAK,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7B,aAAK,IAAI,GAAG;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AACpC,aAAK,MAAM,GAAG;IAAE,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC;AACxC,aAAK,UAAU,GAAG;IAAE,UAAU,EAAE,aAAa,CAAA;CAAE,CAAC;AAEhD,aAAK,gBAAgB,GACjB,IAAI,GAAG;IAAE,MAAM,CAAC,EAAE,aAAa,CAAA;CAAE,GACjC,IAAI,GAAG;IAAE,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,GACzB,IAAI,GAAG,IAAI,GACX,IAAI,GAAG,MAAM,GAAG,UAAU,GAC1B,IAAI,GAAG,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC;AAEtC,oBAAY,gBAAgB,GAAG;IAC7B,SAAS,CAAC,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9B,YAAY,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACnC,gBAAgB,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;CACnE,CAAC;AAEF,oBAAY,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,GAC1C,SAAS,GACT,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decisiv/ui-components",
|
|
3
|
-
"version": "2.0.1-alpha.
|
|
3
|
+
"version": "2.0.1-alpha.157+be9b5ed",
|
|
4
4
|
"description": "Decisiv's design system React components",
|
|
5
5
|
"author": "Decisiv UI Development Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@decisiv/breakpoint-observer": "^1.8.8",
|
|
19
|
-
"@decisiv/design-tokens": "^1.8.
|
|
20
|
-
"@decisiv/iconix": "^2.0.
|
|
19
|
+
"@decisiv/design-tokens": "^1.8.8",
|
|
20
|
+
"@decisiv/iconix": "^2.0.0",
|
|
21
21
|
"@decisiv/prop-types": "^1.6.9",
|
|
22
22
|
"@seznam/compose-react-refs": "^1.0.2",
|
|
23
23
|
"csstype": "^2.6.5",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
73
|
"private": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "be9b5edd78ae3dbcd629363868f410d13e7eafe8"
|
|
75
75
|
}
|