@danske/sapphire-react-lab 0.84.2 → 0.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/index.js +1078 -907
- package/build/cjs/index.js.map +1 -1
- package/build/esm/Tag/src/Tag.js +109 -0
- package/build/esm/Tag/src/Tag.js.map +1 -0
- package/build/esm/Tag/src/TagGroup.js +75 -0
- package/build/esm/Tag/src/TagGroup.js.map +1 -0
- package/build/esm/Tag/src/TagItem.js +6 -0
- package/build/esm/Tag/src/TagItem.js.map +1 -0
- package/build/esm/index.js +2 -0
- package/build/esm/index.js.map +1 -1
- package/build/index.d.ts +44 -2
- package/package.json +5 -3
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { useButton } from '@react-aria/button';
|
|
4
|
+
import { useHover } from '@react-aria/interactions';
|
|
5
|
+
import { useTag } from '@react-aria/tag';
|
|
6
|
+
import { mergeProps } from '@react-aria/utils';
|
|
7
|
+
import { useThemeCheck } from '@danske/sapphire-react';
|
|
8
|
+
import { Close, AlertCircle } from '@danske/sapphire-icons/react';
|
|
9
|
+
import styles from '@danske/sapphire-css/components/tag/tag.module.css';
|
|
10
|
+
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __defProps = Object.defineProperties;
|
|
13
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
14
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
17
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
18
|
+
var __spreadValues = (a, b) => {
|
|
19
|
+
for (var prop in b || (b = {}))
|
|
20
|
+
if (__hasOwnProp.call(b, prop))
|
|
21
|
+
__defNormalProp(a, prop, b[prop]);
|
|
22
|
+
if (__getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
24
|
+
if (__propIsEnum.call(b, prop))
|
|
25
|
+
__defNormalProp(a, prop, b[prop]);
|
|
26
|
+
}
|
|
27
|
+
return a;
|
|
28
|
+
};
|
|
29
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
30
|
+
var __objRest = (source, exclude) => {
|
|
31
|
+
var target = {};
|
|
32
|
+
for (var prop in source)
|
|
33
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
34
|
+
target[prop] = source[prop];
|
|
35
|
+
if (source != null && __getOwnPropSymbols)
|
|
36
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
37
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
38
|
+
target[prop] = source[prop];
|
|
39
|
+
}
|
|
40
|
+
return target;
|
|
41
|
+
};
|
|
42
|
+
function Tag(props) {
|
|
43
|
+
useThemeCheck();
|
|
44
|
+
const { hasError = false, item, state } = props;
|
|
45
|
+
const ref = useRef(null);
|
|
46
|
+
const _a = useTag(props, state, ref), {
|
|
47
|
+
allowsRemoving,
|
|
48
|
+
allowsSelection,
|
|
49
|
+
gridCellProps,
|
|
50
|
+
isDisabled,
|
|
51
|
+
isFocused,
|
|
52
|
+
isPressed,
|
|
53
|
+
isSelected,
|
|
54
|
+
removeButtonProps,
|
|
55
|
+
rowProps: _b
|
|
56
|
+
} = _a, _c = _b, { onKeyDown } = _c, rowProps = __objRest(_c, ["onKeyDown"]), otherProps = __objRest(_a, [
|
|
57
|
+
"allowsRemoving",
|
|
58
|
+
"allowsSelection",
|
|
59
|
+
"gridCellProps",
|
|
60
|
+
"isDisabled",
|
|
61
|
+
"isFocused",
|
|
62
|
+
"isPressed",
|
|
63
|
+
"isSelected",
|
|
64
|
+
"removeButtonProps",
|
|
65
|
+
"rowProps"
|
|
66
|
+
]);
|
|
67
|
+
const { hoverProps, isHovered } = useHover({ isDisabled });
|
|
68
|
+
const hasAction = otherProps.hasAction;
|
|
69
|
+
return /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({
|
|
70
|
+
ref
|
|
71
|
+
}, mergeProps({
|
|
72
|
+
onKeyDown: (e) => {
|
|
73
|
+
if (e.key !== " ") {
|
|
74
|
+
onKeyDown == null ? void 0 : onKeyDown(e);
|
|
75
|
+
} else {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, rowProps, hoverProps)), {
|
|
80
|
+
className: clsx(styles["sapphire-tag"], styles["js-focus"], styles["js-hover"], {
|
|
81
|
+
[styles["sapphire-tag--error"]]: hasError,
|
|
82
|
+
[styles["is-active"]]: allowsSelection && isSelected,
|
|
83
|
+
[styles["is-active"]]: hasAction && isPressed,
|
|
84
|
+
[styles["is-focus"]]: isFocused,
|
|
85
|
+
[styles["is-hover"]]: hasAction && isHovered,
|
|
86
|
+
[styles["is-disabled"]]: isDisabled
|
|
87
|
+
}),
|
|
88
|
+
"aria-invalid": hasError
|
|
89
|
+
}), /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, gridCellProps), {
|
|
90
|
+
className: styles["sapphire-tag__gridcell"]
|
|
91
|
+
}), hasError && /* @__PURE__ */ React.createElement(IconError, null), item.rendered, allowsRemoving && /* @__PURE__ */ React.createElement(RemoveButton, __spreadValues({}, removeButtonProps))));
|
|
92
|
+
}
|
|
93
|
+
function RemoveButton(removeButtonProps) {
|
|
94
|
+
const buttonRef = useRef(null);
|
|
95
|
+
const { buttonProps } = useButton(removeButtonProps, buttonRef);
|
|
96
|
+
return /* @__PURE__ */ React.createElement("button", __spreadProps(__spreadValues({}, buttonProps), {
|
|
97
|
+
className: clsx(styles["sapphire-tag__button"], styles["js-focus"])
|
|
98
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
99
|
+
className: styles["sapphire-tag__icon"]
|
|
100
|
+
}, /* @__PURE__ */ React.createElement(Close, null)));
|
|
101
|
+
}
|
|
102
|
+
const IconError = () => {
|
|
103
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
104
|
+
className: clsx(styles["sapphire-tag__icon"], styles["sapphire-tag__icon--error"])
|
|
105
|
+
}, /* @__PURE__ */ React.createElement(AlertCircle, null));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export { Tag };
|
|
109
|
+
//# sourceMappingURL=Tag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tag.js","sources":["../../../../src/Tag/src/Tag.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport clsx from 'clsx';\nimport { AriaButtonProps, useButton } from '@react-aria/button';\nimport { useHover } from '@react-aria/interactions';\nimport { useTag } from '@react-aria/tag';\nimport { mergeProps } from '@react-aria/utils';\nimport type { ListState } from '@react-stately/list';\nimport type { FocusableElement, Node } from '@react-types/shared';\n\nimport { useThemeCheck } from '@danske/sapphire-react';\nimport { AlertCircle, Close } from '@danske/sapphire-icons/react';\nimport styles from '@danske/sapphire-css/components/tag/tag.module.css';\n\nexport interface TagProps<T> {\n /**\n * Object representing the tag. Contains relevant information about the tag.\n */\n item: Node<T>;\n /**\n * State for TagGroup, returned by `useListState`\n */\n state: ListState<T>;\n /**\n * Shows error icon.\n * @default 'false'\n */\n hasError?: boolean;\n}\n\nexport function Tag<T>(props: TagProps<T>) {\n useThemeCheck();\n const { hasError = false, item, state } = props;\n const ref = useRef(null);\n const {\n allowsRemoving,\n allowsSelection,\n gridCellProps,\n isDisabled,\n isFocused,\n isPressed,\n isSelected,\n removeButtonProps,\n rowProps: { onKeyDown, ...rowProps },\n ...otherProps\n } = useTag(props, state, ref);\n const { hoverProps, isHovered } = useHover({ isDisabled });\n /* hasAction prop is passed when onAction is present, we are using it to set the hover and action classes.\n The workaround below is made because AriaTagProps Omit's hasAction to avoid typecheck error */\n const hasAction = (otherProps as any).hasAction;\n\n return (\n <div\n ref={ref}\n {...mergeProps(\n {\n onKeyDown: (e: React.KeyboardEvent<FocusableElement>) => {\n /* We are removing Space key interaction and prevent default behavior to avoid isPressed prop being set\n as we do not want to apply is-active class on \"Space\" interaction when having actionable tags with onAction or link */\n if (e.key !== ' ') {\n onKeyDown?.(e);\n } else {\n e.preventDefault();\n }\n },\n },\n rowProps,\n hoverProps\n )}\n className={clsx(\n styles['sapphire-tag'],\n styles['js-focus'],\n styles['js-hover'],\n {\n [styles['sapphire-tag--error']]: hasError,\n [styles['is-active']]: allowsSelection && isSelected,\n [styles['is-active']]: hasAction && isPressed,\n [styles['is-focus']]: isFocused,\n [styles['is-hover']]: hasAction && isHovered,\n [styles['is-disabled']]: isDisabled,\n }\n )}\n aria-invalid={hasError}\n >\n <div {...gridCellProps} className={styles['sapphire-tag__gridcell']}>\n {hasError && <IconError />}\n {item.rendered}\n {allowsRemoving && (\n <RemoveButton {...(removeButtonProps as AriaButtonProps)} />\n )}\n </div>\n </div>\n );\n}\n\nfunction RemoveButton(removeButtonProps: AriaButtonProps) {\n const buttonRef = useRef(null);\n const { buttonProps } = useButton(removeButtonProps, buttonRef);\n return (\n <button\n {...buttonProps}\n className={clsx(styles['sapphire-tag__button'], styles['js-focus'])}\n >\n <span className={styles['sapphire-tag__icon']}>\n <Close />\n </span>\n </button>\n );\n}\n\nconst IconError = () => {\n return (\n <span\n className={clsx(\n styles['sapphire-tag__icon'],\n styles['sapphire-tag__icon--error']\n )}\n >\n <AlertCircle />\n </span>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,SAAA,GAAA,CAAgB,KAAoB,EAAA;AACzC,EAAA,aAAA,EAAA,CAAA;AACA,EAAA,MAAM,EAAE,QAAA,GAAW,KAAO,EAAA,IAAA,EAAM,KAAU,EAAA,GAAA,KAAA,CAAA;AAC1C,EAAA,MAAM,MAAM,MAAO,CAAA,IAAA,CAAA,CAA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AAA,IAAA,CAAA,CAAA,CAAA,CAAA;AAAA,CAAA;AAMR,MAAM,YAAY,MAAM;AACtB,EAAA,2CACG,MAAD,EAAA;AAAA,IACE,SAAW,EAAA,IAAA,CACT,MAAO,CAAA,oBAAA,CAAA,EACP,MAAO,CAAA,2BAAA,CAAA,CAAA;AAAA,GAAA,sCAGR,WAAD,EAAA,IAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { useTagGroup } from '@react-aria/tag';
|
|
3
|
+
import { useListState } from '@react-stately/list';
|
|
4
|
+
import { useThemeCheck, Field, Label } from '@danske/sapphire-react';
|
|
5
|
+
import styles from '@danske/sapphire-css/components/tag/tag.module.css';
|
|
6
|
+
import { Tag } from './Tag.js';
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __defProps = Object.defineProperties;
|
|
10
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
11
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
14
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __spreadValues = (a, b) => {
|
|
16
|
+
for (var prop in b || (b = {}))
|
|
17
|
+
if (__hasOwnProp.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
if (__getOwnPropSymbols)
|
|
20
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
21
|
+
if (__propIsEnum.call(b, prop))
|
|
22
|
+
__defNormalProp(a, prop, b[prop]);
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
25
|
+
};
|
|
26
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
27
|
+
var __objRest = (source, exclude) => {
|
|
28
|
+
var target = {};
|
|
29
|
+
for (var prop in source)
|
|
30
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
31
|
+
target[prop] = source[prop];
|
|
32
|
+
if (source != null && __getOwnPropSymbols)
|
|
33
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
34
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
35
|
+
target[prop] = source[prop];
|
|
36
|
+
}
|
|
37
|
+
return target;
|
|
38
|
+
};
|
|
39
|
+
function TagGroup(props) {
|
|
40
|
+
useThemeCheck();
|
|
41
|
+
const _a = props, {
|
|
42
|
+
contextualHelp,
|
|
43
|
+
errorMessage,
|
|
44
|
+
label: labelText,
|
|
45
|
+
labelPlacement = "above",
|
|
46
|
+
note
|
|
47
|
+
} = _a, otherProps = __objRest(_a, [
|
|
48
|
+
"contextualHelp",
|
|
49
|
+
"errorMessage",
|
|
50
|
+
"label",
|
|
51
|
+
"labelPlacement",
|
|
52
|
+
"note"
|
|
53
|
+
]);
|
|
54
|
+
const ref = useRef(null);
|
|
55
|
+
const state = useListState(props);
|
|
56
|
+
const { descriptionProps, gridProps, labelProps, errorMessageProps } = useTagGroup(props, state, ref);
|
|
57
|
+
return /* @__PURE__ */ React.createElement(Field, __spreadProps(__spreadValues({}, otherProps), {
|
|
58
|
+
error: !!errorMessage,
|
|
59
|
+
labelPlacement,
|
|
60
|
+
labelVerticalAlignment: "top"
|
|
61
|
+
}), (labelText || contextualHelp) && /* @__PURE__ */ React.createElement(Field.Label, null, /* @__PURE__ */ React.createElement(Label, __spreadProps(__spreadValues({}, labelProps), {
|
|
62
|
+
contextualHelp
|
|
63
|
+
}), labelText)), /* @__PURE__ */ React.createElement(Field.Control, null, /* @__PURE__ */ React.createElement("div", __spreadProps(__spreadValues({}, gridProps), {
|
|
64
|
+
ref,
|
|
65
|
+
className: styles["sapphire-tag-group"]
|
|
66
|
+
}), [...state.collection].map((item) => /* @__PURE__ */ React.createElement(Tag, {
|
|
67
|
+
key: item.key,
|
|
68
|
+
item,
|
|
69
|
+
state,
|
|
70
|
+
hasError: item.props.hasError
|
|
71
|
+
})))), (note || errorMessage) && (errorMessage ? /* @__PURE__ */ React.createElement(Field.Footer, null, /* @__PURE__ */ React.createElement(Field.Note, __spreadValues({}, errorMessageProps), errorMessage)) : /* @__PURE__ */ React.createElement(Field.Footer, null, /* @__PURE__ */ React.createElement(Field.Note, __spreadValues({}, descriptionProps), note))));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { TagGroup };
|
|
75
|
+
//# sourceMappingURL=TagGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagGroup.js","sources":["../../../../src/Tag/src/TagGroup.tsx"],"sourcesContent":["import React, { Key, ReactNode, useRef } from 'react';\nimport { useTagGroup } from '@react-aria/tag';\nimport { useListState } from '@react-stately/list';\nimport {\n AriaLabelingProps,\n CollectionBase,\n DOMProps,\n} from '@react-types/shared';\nimport {\n Field,\n Label,\n SapphireStyleProps,\n useThemeCheck,\n} from '@danske/sapphire-react';\nimport styles from '@danske/sapphire-css/components/tag/tag.module.css';\n\nimport { Tag } from './Tag';\n\nexport interface TagGroupProps<T>\n extends CollectionBase<T>,\n DOMProps,\n AriaLabelingProps,\n SapphireStyleProps {\n /**\n * A ContextualHelp element to place next to the label.\n */\n contextualHelp?: ReactNode;\n /**\n * Custom error message help text.\n */\n errorMessage?: string;\n /**\n * The label of the tag group.\n */\n label?: string;\n /**\n * Places the label either above (default) or on the left side of tags.\n * @default 'above'\n */\n labelPlacement?: 'above' | 'side';\n /**\n * Help text description displayed below tags.\n */\n note?: string;\n /**\n * onAction handler passed down for actionable Tags, called onPress of tags.\n */\n onAction?: (key: Key) => void;\n /**\n * Handler that is called when a user deletes a tag.\n */\n onRemove?: (keys: Set<Key>) => void;\n}\n\nexport function TagGroup<T extends object>(props: TagGroupProps<T>) {\n useThemeCheck();\n const {\n contextualHelp,\n errorMessage,\n label: labelText,\n labelPlacement = 'above',\n note,\n ...otherProps\n } = props;\n const ref = useRef(null);\n const state = useListState(props);\n const { descriptionProps, gridProps, labelProps, errorMessageProps } =\n useTagGroup(props, state, ref);\n\n return (\n <Field\n {...otherProps}\n error={!!errorMessage}\n labelPlacement={labelPlacement}\n labelVerticalAlignment=\"top\"\n >\n {(labelText || contextualHelp) && (\n <Field.Label>\n <Label {...labelProps} contextualHelp={contextualHelp}>\n {labelText}\n </Label>\n </Field.Label>\n )}\n <Field.Control>\n <div {...gridProps} ref={ref} className={styles['sapphire-tag-group']}>\n {[...state.collection].map((item) => (\n <Tag\n key={item.key}\n item={item}\n state={state}\n hasError={item.props.hasError}\n />\n ))}\n </div>\n </Field.Control>\n {(note || errorMessage) &&\n (errorMessage ? (\n <Field.Footer>\n <Field.Note {...errorMessageProps}>{errorMessage}</Field.Note>\n </Field.Footer>\n ) : (\n <Field.Footer>\n <Field.Note {...descriptionProps}>{note}</Field.Note>\n </Field.Footer>\n ))}\n </Field>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDO,SAAA,QAAA,CAAoC,KAAyB,EAAA;AAClE,EAAA,aAAA,EAAA,CAAA;AACA,EAAA,MAOI,EANF,GAAA,KAAA,EAAA;AAAA,IAAA,cAAA;AAAA,IACA,YAAA;AAAA,IACA,KAAO,EAAA,SAAA;AAAA,IACP,cAAiB,GAAA,OAAA;AAAA,IACjB,IAAA;AAAA,GAEE,GAAA,EAAA,EADC,uBACD,EADC,EAAA;AAAA,IALH,gBAAA;AAAA,IACA,cAAA;AAAA,IACA,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,MAAA;AAAA,GAAA,CAAA,CAAA;AAGF,EAAA,MAAM,MAAM,MAAO,CAAA,IAAA,CAAA,CAAA;AACnB,EAAA,MAAM,QAAQ,YAAa,CAAA,KAAA,CAAA,CAAA;AAC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,CAAM,IAAP,EAAA,cAAA,CAAA,EAAA,EAAgB,gBAAmB,CAAA,EAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TagItem.js","sources":["../../../../src/Tag/src/TagItem.tsx"],"sourcesContent":["import { Item } from '@react-stately/collections';\nimport { ItemProps } from '@react-types/shared';\n\nexport interface TagItemProps<T> extends ItemProps<T> {\n /**\n * Shows error icon.\n * @default 'false'\n */\n hasError?: boolean;\n}\n\nconst TagItem = Item as <T>(props: TagItemProps<T>) => JSX.Element;\n\nexport { TagItem };\n"],"names":[],"mappings":";;AAWA,MAAM,OAAU,GAAA;;;;"}
|
package/build/esm/index.js
CHANGED
|
@@ -21,5 +21,7 @@ export { FileDropzone } from './FileDropzone/src/FileDropzone.js';
|
|
|
21
21
|
export { FileTrigger } from './FileDropzone/src/FileTrigger.js';
|
|
22
22
|
export { AlertDialog } from './AlertDialog/src/AlertDialog.js';
|
|
23
23
|
export { NumberField } from './NumberField/src/NumberField.js';
|
|
24
|
+
export { TagGroup } from './Tag/src/TagGroup.js';
|
|
25
|
+
export { TagItem } from './Tag/src/TagItem.js';
|
|
24
26
|
export { useLocale } from '@react-aria/i18n';
|
|
25
27
|
//# sourceMappingURL=index.js.map
|
package/build/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _react_types_shared from '@react-types/shared';
|
|
2
2
|
import { PressEvents, Validation, RangeValue, HelpTextProps, LabelableProps, CollectionBase, DOMProps, Expandable, ItemProps, AriaLabelingProps, FocusableRefValue } from '@react-types/shared';
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import React__default, { ReactNode, ComponentType, RefObject } from 'react';
|
|
4
|
+
import React__default, { ReactNode, ComponentType, RefObject, Key } from 'react';
|
|
5
5
|
import { AriaToggleButtonProps } from '@react-aria/button';
|
|
6
6
|
import { SapphireStyleProps, PopoverTriggerProps, HeadingProps, TextStyleProps, DialogProps } from '@danske/sapphire-react';
|
|
7
7
|
import { DateValue } from '@internationalized/date';
|
|
@@ -926,4 +926,46 @@ interface NumberFieldProps extends SapphireNumberFieldProps, PressEvents, Sapphi
|
|
|
926
926
|
}
|
|
927
927
|
declare const NumberField: React__default.ForwardRefExoticComponent<NumberFieldProps & React__default.RefAttributes<NumberFieldRef>>;
|
|
928
928
|
|
|
929
|
-
|
|
929
|
+
interface TagGroupProps<T> extends CollectionBase<T>, DOMProps, AriaLabelingProps, SapphireStyleProps {
|
|
930
|
+
/**
|
|
931
|
+
* A ContextualHelp element to place next to the label.
|
|
932
|
+
*/
|
|
933
|
+
contextualHelp?: ReactNode;
|
|
934
|
+
/**
|
|
935
|
+
* Custom error message help text.
|
|
936
|
+
*/
|
|
937
|
+
errorMessage?: string;
|
|
938
|
+
/**
|
|
939
|
+
* The label of the tag group.
|
|
940
|
+
*/
|
|
941
|
+
label?: string;
|
|
942
|
+
/**
|
|
943
|
+
* Places the label either above (default) or on the left side of tags.
|
|
944
|
+
* @default 'above'
|
|
945
|
+
*/
|
|
946
|
+
labelPlacement?: 'above' | 'side';
|
|
947
|
+
/**
|
|
948
|
+
* Help text description displayed below tags.
|
|
949
|
+
*/
|
|
950
|
+
note?: string;
|
|
951
|
+
/**
|
|
952
|
+
* onAction handler passed down for actionable Tags, called onPress of tags.
|
|
953
|
+
*/
|
|
954
|
+
onAction?: (key: Key) => void;
|
|
955
|
+
/**
|
|
956
|
+
* Handler that is called when a user deletes a tag.
|
|
957
|
+
*/
|
|
958
|
+
onRemove?: (keys: Set<Key>) => void;
|
|
959
|
+
}
|
|
960
|
+
declare function TagGroup<T extends object>(props: TagGroupProps<T>): React__default.JSX.Element;
|
|
961
|
+
|
|
962
|
+
interface TagItemProps<T> extends ItemProps<T> {
|
|
963
|
+
/**
|
|
964
|
+
* Shows error icon.
|
|
965
|
+
* @default 'false'
|
|
966
|
+
*/
|
|
967
|
+
hasError?: boolean;
|
|
968
|
+
}
|
|
969
|
+
declare const TagItem: <T>(props: TagItemProps<T>) => JSX.Element;
|
|
970
|
+
|
|
971
|
+
export { _Accordion as Accordion, AlertDialog, Avatar, Calendar, CalendarView, DateField, DateFieldProps, DateRangeField, DateRangeFieldProps, FeedbackMessage, Fieldset, FieldsetProps, FileDropzone, FileDropzoneProps, FileTrigger, FileTriggerProps, FilterDropdown, NotificationBadge, NotificationBadgeProps, NumberField, NumberFieldProps, NumberFieldRef, PredefinedDateRange, RangeCalendar, SapphireAccordionHeadingProps, SapphireAccordionItemProps, SapphireAccordionProps, SapphireAlertDialogProps, SapphireAvatarProps, SapphireCalendarProps, SapphireFeedbackMessageProps, SapphireFilterDropdownProps, SapphireRangeCalendarProps, SapphireSearchFieldProps, SapphireToggleButtonProps, SearchField, ShowToastFn, ShowToastOptions, Spinner, SpinnerProps, TagGroup, TagGroupProps, TagItem, ToastProvider, ToastProviderProps, ToggleButton, Typography, TypographyBodyProps, TypographyCaptionProps, TypographyHeadingProps, TypographySubheadingProps, isDateOutsideValidRange, isEndDateBeforeStartDate, useShowToast };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danske/sapphire-react-lab",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.85.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "Experimental React components of the Sapphire Design System from Danske Bank A/S",
|
|
6
6
|
"exports": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"cross-env": "^7.0.3"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@danske/sapphire-css": "^28.
|
|
39
|
+
"@danske/sapphire-css": "^28.3.0",
|
|
40
40
|
"@internationalized/date": "^3.5.2",
|
|
41
41
|
"@internationalized/string": "^3.2.1",
|
|
42
42
|
"@react-aria/accordion": "^3.0.0-alpha.29",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"@react-aria/numberfield": "^3.11.3",
|
|
54
54
|
"@react-aria/overlays": "^3.21.1",
|
|
55
55
|
"@react-aria/searchfield": "^3.7.3",
|
|
56
|
+
"@react-aria/tag": "^3.4.2",
|
|
56
57
|
"@react-aria/toast": "^3.0.0-beta.10",
|
|
57
58
|
"@react-aria/utils": "^3.23.2",
|
|
58
59
|
"@react-aria/visually-hidden": "^3.8.10",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"@react-stately/collections": "^3.10.5",
|
|
62
63
|
"@react-stately/combobox": "^3.8.2",
|
|
63
64
|
"@react-stately/datepicker": "^3.9.2",
|
|
65
|
+
"@react-stately/list": "^3.10.6",
|
|
64
66
|
"@react-stately/numberfield": "^3.9.3",
|
|
65
67
|
"@react-stately/searchfield": "^3.5.1",
|
|
66
68
|
"@react-stately/toast": "^3.0.0-beta.2",
|
|
@@ -72,5 +74,5 @@
|
|
|
72
74
|
"clsx": "^1.1.1",
|
|
73
75
|
"react-transition-group": "^4.4.5"
|
|
74
76
|
},
|
|
75
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "898067929452d335a664e4d5fb5287775d1dbbd0"
|
|
76
78
|
}
|