@fluentui/react-tags 0.0.0-nightly-20231004-0414.1
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/CHANGELOG.json +958 -0
- package/CHANGELOG.md +302 -0
- package/LICENSE +15 -0
- package/README.md +72 -0
- package/dist/index.d.ts +405 -0
- package/lib/InteractionTag.js +1 -0
- package/lib/InteractionTag.js.map +1 -0
- package/lib/InteractionTagPrimary.js +1 -0
- package/lib/InteractionTagPrimary.js.map +1 -0
- package/lib/InteractionTagSecondary.js +1 -0
- package/lib/InteractionTagSecondary.js.map +1 -0
- package/lib/Tag.js +1 -0
- package/lib/Tag.js.map +1 -0
- package/lib/TagGroup.js +1 -0
- package/lib/TagGroup.js.map +1 -0
- package/lib/components/InteractionTag/InteractionTag.js +16 -0
- package/lib/components/InteractionTag/InteractionTag.js.map +1 -0
- package/lib/components/InteractionTag/InteractionTag.types.js +1 -0
- package/lib/components/InteractionTag/InteractionTag.types.js.map +1 -0
- package/lib/components/InteractionTag/index.js +6 -0
- package/lib/components/InteractionTag/index.js.map +1 -0
- package/lib/components/InteractionTag/renderInteractionTag.js +12 -0
- package/lib/components/InteractionTag/renderInteractionTag.js.map +1 -0
- package/lib/components/InteractionTag/useInteractionTag.js +36 -0
- package/lib/components/InteractionTag/useInteractionTag.js.map +1 -0
- package/lib/components/InteractionTag/useInteractionTagContextValues.js +23 -0
- package/lib/components/InteractionTag/useInteractionTagContextValues.js.map +1 -0
- package/lib/components/InteractionTag/useInteractionTagStyles.styles.js +45 -0
- package/lib/components/InteractionTag/useInteractionTagStyles.styles.js.map +1 -0
- package/lib/components/InteractionTagPrimary/InteractionTagPrimary.js +16 -0
- package/lib/components/InteractionTagPrimary/InteractionTagPrimary.js.map +1 -0
- package/lib/components/InteractionTagPrimary/InteractionTagPrimary.types.js +1 -0
- package/lib/components/InteractionTagPrimary/InteractionTagPrimary.types.js.map +1 -0
- package/lib/components/InteractionTagPrimary/index.js +5 -0
- package/lib/components/InteractionTagPrimary/index.js.map +1 -0
- package/lib/components/InteractionTagPrimary/renderInteractionTagPrimary.js +19 -0
- package/lib/components/InteractionTagPrimary/renderInteractionTagPrimary.js.map +1 -0
- package/lib/components/InteractionTagPrimary/useInteractionTagPrimary.js +64 -0
- package/lib/components/InteractionTagPrimary/useInteractionTagPrimary.js.map +1 -0
- package/lib/components/InteractionTagPrimary/useInteractionTagPrimaryStyles.styles.js +232 -0
- package/lib/components/InteractionTagPrimary/useInteractionTagPrimaryStyles.styles.js.map +1 -0
- package/lib/components/InteractionTagSecondary/InteractionTagSecondary.js +14 -0
- package/lib/components/InteractionTagSecondary/InteractionTagSecondary.js.map +1 -0
- package/lib/components/InteractionTagSecondary/InteractionTagSecondary.types.js +1 -0
- package/lib/components/InteractionTagSecondary/InteractionTagSecondary.types.js.map +1 -0
- package/lib/components/InteractionTagSecondary/index.js +5 -0
- package/lib/components/InteractionTagSecondary/index.js.map +1 -0
- package/lib/components/InteractionTagSecondary/renderInteractionTagSecondary.js +8 -0
- package/lib/components/InteractionTagSecondary/renderInteractionTagSecondary.js.map +1 -0
- package/lib/components/InteractionTagSecondary/useInteractionTagSecondary.js +57 -0
- package/lib/components/InteractionTagSecondary/useInteractionTagSecondary.js.map +1 -0
- package/lib/components/InteractionTagSecondary/useInteractionTagSecondaryStyles.styles.js +126 -0
- package/lib/components/InteractionTagSecondary/useInteractionTagSecondaryStyles.styles.js.map +1 -0
- package/lib/components/Tag/Tag.js +16 -0
- package/lib/components/Tag/Tag.js.map +1 -0
- package/lib/components/Tag/Tag.types.js +1 -0
- package/lib/components/Tag/Tag.types.js.map +1 -0
- package/lib/components/Tag/index.js +5 -0
- package/lib/components/Tag/index.js.map +1 -0
- package/lib/components/Tag/renderTag.js +20 -0
- package/lib/components/Tag/renderTag.js.map +1 -0
- package/lib/components/Tag/useTag.js +98 -0
- package/lib/components/Tag/useTag.js.map +1 -0
- package/lib/components/Tag/useTagStyles.styles.js +320 -0
- package/lib/components/Tag/useTagStyles.styles.js.map +1 -0
- package/lib/components/TagGroup/TagGroup.js +16 -0
- package/lib/components/TagGroup/TagGroup.js.map +1 -0
- package/lib/components/TagGroup/TagGroup.types.js +1 -0
- package/lib/components/TagGroup/TagGroup.types.js.map +1 -0
- package/lib/components/TagGroup/index.js +6 -0
- package/lib/components/TagGroup/index.js.map +1 -0
- package/lib/components/TagGroup/renderTagGroup.js +12 -0
- package/lib/components/TagGroup/renderTagGroup.js.map +1 -0
- package/lib/components/TagGroup/useTagGroup.js +67 -0
- package/lib/components/TagGroup/useTagGroup.js.map +1 -0
- package/lib/components/TagGroup/useTagGroupContextValues.js +13 -0
- package/lib/components/TagGroup/useTagGroupContextValues.js.map +1 -0
- package/lib/components/TagGroup/useTagGroupStyles.styles.js +36 -0
- package/lib/components/TagGroup/useTagGroupStyles.styles.js.map +1 -0
- package/lib/contexts/interactionTagContext.js +16 -0
- package/lib/contexts/interactionTagContext.js.map +1 -0
- package/lib/contexts/tagGroupContext.js +11 -0
- package/lib/contexts/tagGroupContext.js.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/types.js +1 -0
- package/lib/utils/types.js.map +1 -0
- package/lib/utils/useTagAvatarContextValues.js +14 -0
- package/lib/utils/useTagAvatarContextValues.js.map +1 -0
- package/lib-commonjs/InteractionTag.js +6 -0
- package/lib-commonjs/InteractionTag.js.map +1 -0
- package/lib-commonjs/InteractionTagPrimary.js +6 -0
- package/lib-commonjs/InteractionTagPrimary.js.map +1 -0
- package/lib-commonjs/InteractionTagSecondary.js +6 -0
- package/lib-commonjs/InteractionTagSecondary.js.map +1 -0
- package/lib-commonjs/Tag.js +6 -0
- package/lib-commonjs/Tag.js.map +1 -0
- package/lib-commonjs/TagGroup.js +6 -0
- package/lib-commonjs/TagGroup.js.map +1 -0
- package/lib-commonjs/components/InteractionTag/InteractionTag.js +24 -0
- package/lib-commonjs/components/InteractionTag/InteractionTag.js.map +1 -0
- package/lib-commonjs/components/InteractionTag/InteractionTag.types.js +4 -0
- package/lib-commonjs/components/InteractionTag/InteractionTag.types.js.map +1 -0
- package/lib-commonjs/components/InteractionTag/index.js +11 -0
- package/lib-commonjs/components/InteractionTag/index.js.map +1 -0
- package/lib-commonjs/components/InteractionTag/renderInteractionTag.js +20 -0
- package/lib-commonjs/components/InteractionTag/renderInteractionTag.js.map +1 -0
- package/lib-commonjs/components/InteractionTag/useInteractionTag.js +39 -0
- package/lib-commonjs/components/InteractionTag/useInteractionTag.js.map +1 -0
- package/lib-commonjs/components/InteractionTag/useInteractionTagContextValues.js +34 -0
- package/lib-commonjs/components/InteractionTag/useInteractionTagContextValues.js.map +1 -0
- package/lib-commonjs/components/InteractionTag/useInteractionTagStyles.styles.js +93 -0
- package/lib-commonjs/components/InteractionTag/useInteractionTagStyles.styles.js.map +1 -0
- package/lib-commonjs/components/InteractionTagPrimary/InteractionTagPrimary.js +24 -0
- package/lib-commonjs/components/InteractionTagPrimary/InteractionTagPrimary.js.map +1 -0
- package/lib-commonjs/components/InteractionTagPrimary/InteractionTagPrimary.types.js +4 -0
- package/lib-commonjs/components/InteractionTagPrimary/InteractionTagPrimary.types.js.map +1 -0
- package/lib-commonjs/components/InteractionTagPrimary/index.js +10 -0
- package/lib-commonjs/components/InteractionTagPrimary/index.js.map +1 -0
- package/lib-commonjs/components/InteractionTagPrimary/renderInteractionTagPrimary.js +27 -0
- package/lib-commonjs/components/InteractionTagPrimary/renderInteractionTagPrimary.js.map +1 -0
- package/lib-commonjs/components/InteractionTagPrimary/useInteractionTagPrimary.js +67 -0
- package/lib-commonjs/components/InteractionTagPrimary/useInteractionTagPrimary.js.map +1 -0
- package/lib-commonjs/components/InteractionTagPrimary/useInteractionTagPrimaryStyles.styles.js +431 -0
- package/lib-commonjs/components/InteractionTagPrimary/useInteractionTagPrimaryStyles.styles.js.map +1 -0
- package/lib-commonjs/components/InteractionTagSecondary/InteractionTagSecondary.js +23 -0
- package/lib-commonjs/components/InteractionTagSecondary/InteractionTagSecondary.js.map +1 -0
- package/lib-commonjs/components/InteractionTagSecondary/InteractionTagSecondary.types.js +4 -0
- package/lib-commonjs/components/InteractionTagSecondary/InteractionTagSecondary.types.js.map +1 -0
- package/lib-commonjs/components/InteractionTagSecondary/index.js +10 -0
- package/lib-commonjs/components/InteractionTagSecondary/index.js.map +1 -0
- package/lib-commonjs/components/InteractionTagSecondary/renderInteractionTagSecondary.js +16 -0
- package/lib-commonjs/components/InteractionTagSecondary/renderInteractionTagSecondary.js.map +1 -0
- package/lib-commonjs/components/InteractionTagSecondary/useInteractionTagSecondary.js +60 -0
- package/lib-commonjs/components/InteractionTagSecondary/useInteractionTagSecondary.js.map +1 -0
- package/lib-commonjs/components/InteractionTagSecondary/useInteractionTagSecondaryStyles.styles.js +261 -0
- package/lib-commonjs/components/InteractionTagSecondary/useInteractionTagSecondaryStyles.styles.js.map +1 -0
- package/lib-commonjs/components/Tag/Tag.js +24 -0
- package/lib-commonjs/components/Tag/Tag.js.map +1 -0
- package/lib-commonjs/components/Tag/Tag.types.js +4 -0
- package/lib-commonjs/components/Tag/Tag.types.js.map +1 -0
- package/lib-commonjs/components/Tag/index.js +10 -0
- package/lib-commonjs/components/Tag/index.js.map +1 -0
- package/lib-commonjs/components/Tag/renderTag.js +28 -0
- package/lib-commonjs/components/Tag/renderTag.js.map +1 -0
- package/lib-commonjs/components/Tag/useTag.js +101 -0
- package/lib-commonjs/components/Tag/useTag.js.map +1 -0
- package/lib-commonjs/components/Tag/useTagStyles.styles.js +569 -0
- package/lib-commonjs/components/Tag/useTagStyles.styles.js.map +1 -0
- package/lib-commonjs/components/TagGroup/TagGroup.js +24 -0
- package/lib-commonjs/components/TagGroup/TagGroup.js.map +1 -0
- package/lib-commonjs/components/TagGroup/TagGroup.types.js +4 -0
- package/lib-commonjs/components/TagGroup/TagGroup.types.js.map +1 -0
- package/lib-commonjs/components/TagGroup/index.js +11 -0
- package/lib-commonjs/components/TagGroup/index.js.map +1 -0
- package/lib-commonjs/components/TagGroup/renderTagGroup.js +20 -0
- package/lib-commonjs/components/TagGroup/renderTagGroup.js.map +1 -0
- package/lib-commonjs/components/TagGroup/useTagGroup.js +70 -0
- package/lib-commonjs/components/TagGroup/useTagGroup.js.map +1 -0
- package/lib-commonjs/components/TagGroup/useTagGroupContextValues.js +24 -0
- package/lib-commonjs/components/TagGroup/useTagGroupContextValues.js.map +1 -0
- package/lib-commonjs/components/TagGroup/useTagGroupStyles.styles.js +51 -0
- package/lib-commonjs/components/TagGroup/useTagGroupStyles.styles.js.map +1 -0
- package/lib-commonjs/contexts/interactionTagContext.js +38 -0
- package/lib-commonjs/contexts/interactionTagContext.js.map +1 -0
- package/lib-commonjs/contexts/tagGroupContext.js +33 -0
- package/lib-commonjs/contexts/tagGroupContext.js.map +1 -0
- package/lib-commonjs/index.js +102 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/utils/index.js +7 -0
- package/lib-commonjs/utils/index.js.map +1 -0
- package/lib-commonjs/utils/types.js +6 -0
- package/lib-commonjs/utils/types.js.map +1 -0
- package/lib-commonjs/utils/useTagAvatarContextValues.js +25 -0
- package/lib-commonjs/utils/useTagAvatarContextValues.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { __resetStyles, __styles, mergeClasses, shorthands } from '@griffel/react';
|
|
2
|
+
import { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';
|
|
3
|
+
import { tokens } from '@fluentui/react-theme';
|
|
4
|
+
export const interactionTagSecondaryClassNames = {
|
|
5
|
+
root: 'fui-InteractionTagSecondary'
|
|
6
|
+
};
|
|
7
|
+
const mediumIconSize = '20px';
|
|
8
|
+
const smallIconSize = '16px';
|
|
9
|
+
const extraSmallIconSize = '12px';
|
|
10
|
+
const useRootBaseClassName = /*#__PURE__*/__resetStyles("r7ezzwf", "rv64w1", [".r7ezzwf{color:inherit;font-family:inherit;padding:0px;border-style:none;-webkit-appearance:button;-moz-appearance:button;-ms-appearance:button;appearance:button;text-align:unset;background-color:transparent;display:flex;height:100%;align-items:center;border:var(--strokeWidthThin) solid var(--colorTransparentStroke);border-left-color:var(--colorNeutralStroke1);border-top-left-radius:var(--borderRadiusNone);border-bottom-left-radius:var(--borderRadiusNone);}", ".r7ezzwf[data-fui-focus-visible]{outline-width:var(--strokeWidthThick);outline-style:solid;outline-color:var(--colorStrokeFocus2);}", ".rv64w1{color:inherit;font-family:inherit;padding:0px;border-style:none;-webkit-appearance:button;-moz-appearance:button;-ms-appearance:button;appearance:button;text-align:unset;background-color:transparent;display:flex;height:100%;align-items:center;border:var(--strokeWidthThin) solid var(--colorTransparentStroke);border-right-color:var(--colorNeutralStroke1);border-top-right-radius:var(--borderRadiusNone);border-bottom-right-radius:var(--borderRadiusNone);}", ".rv64w1[data-fui-focus-visible]{outline-width:var(--strokeWidthThick);outline-style:solid;outline-color:var(--colorStrokeFocus2);}"]);
|
|
11
|
+
const useRootStyles = /*#__PURE__*/__styles({
|
|
12
|
+
filled: {
|
|
13
|
+
De3pzq: "f16xq7d1",
|
|
14
|
+
sj55zd: "fkfq4zb",
|
|
15
|
+
eoavqd: "f8491dx",
|
|
16
|
+
Jwef8y: "f1h648pw",
|
|
17
|
+
Bi91k9c: "f139oj5f",
|
|
18
|
+
ecr2s2: "fwdzr64",
|
|
19
|
+
lj723h: "f19au66r",
|
|
20
|
+
Bqrx1nm: "fq7113v",
|
|
21
|
+
kx9iu6: "fp3oj7s"
|
|
22
|
+
},
|
|
23
|
+
outline: {
|
|
24
|
+
De3pzq: "fhovq9v",
|
|
25
|
+
sj55zd: "fkfq4zb",
|
|
26
|
+
g2u3we: "fj3muxo",
|
|
27
|
+
h3c5rm: ["f1akhkt", "f1lxtadh"],
|
|
28
|
+
B9xav0g: "f1aperda",
|
|
29
|
+
zhjwy3: ["f1lxtadh", "f1akhkt"],
|
|
30
|
+
eoavqd: "f8491dx",
|
|
31
|
+
Jwef8y: "f1t94bn6",
|
|
32
|
+
Bi91k9c: "f139oj5f",
|
|
33
|
+
ecr2s2: "f1wfn5kd",
|
|
34
|
+
lj723h: "f19au66r",
|
|
35
|
+
Bqrx1nm: "fq7113v",
|
|
36
|
+
kx9iu6: "fp3oj7s"
|
|
37
|
+
},
|
|
38
|
+
brand: {
|
|
39
|
+
De3pzq: "f16xkysk",
|
|
40
|
+
sj55zd: "f16muhyy",
|
|
41
|
+
zhjwy3: ["f1sl6hi9", "f1c8dzaj"],
|
|
42
|
+
eoavqd: "f8491dx",
|
|
43
|
+
Jwef8y: "f1yj72w4",
|
|
44
|
+
Bi91k9c: "f3ymbdj",
|
|
45
|
+
ecr2s2: "fy3sl2y",
|
|
46
|
+
lj723h: "fryz5bw",
|
|
47
|
+
Bqrx1nm: "fq7113v",
|
|
48
|
+
kx9iu6: "fp3oj7s"
|
|
49
|
+
},
|
|
50
|
+
rounded: {
|
|
51
|
+
B7oj6ja: ["f1jar5jt", "fyu767a"],
|
|
52
|
+
Bbmb7ep: ["f1aa9q02", "f16jpd5f"]
|
|
53
|
+
},
|
|
54
|
+
circular: {
|
|
55
|
+
B7oj6ja: ["f1djnp8u", "f1s8kh49"],
|
|
56
|
+
Bbmb7ep: ["f8fbkgy", "f1nfllo7"]
|
|
57
|
+
},
|
|
58
|
+
medium: {
|
|
59
|
+
Be2twd7: "fe5j1ua",
|
|
60
|
+
uwmqm3: ["f15vdbe4", "fwiuce9"],
|
|
61
|
+
z189sj: ["fwiuce9", "f15vdbe4"]
|
|
62
|
+
},
|
|
63
|
+
small: {
|
|
64
|
+
Be2twd7: "f4ybsrx",
|
|
65
|
+
uwmqm3: ["f2lugmd", "f6zblan"],
|
|
66
|
+
z189sj: ["f6zblan", "f2lugmd"]
|
|
67
|
+
},
|
|
68
|
+
"extra-small": {
|
|
69
|
+
Be2twd7: "f1ugzwwg",
|
|
70
|
+
uwmqm3: ["f15vdbe4", "fwiuce9"],
|
|
71
|
+
z189sj: ["fwiuce9", "f15vdbe4"]
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
d: [".f16xq7d1{background-color:var(--colorNeutralBackground3);}", ".fkfq4zb{color:var(--colorNeutralForeground2);}", ".fhovq9v{background-color:var(--colorSubtleBackground);}", ".fj3muxo{border-top-color:var(--colorNeutralStroke1);}", ".f1akhkt{border-right-color:var(--colorNeutralStroke1);}", ".f1lxtadh{border-left-color:var(--colorNeutralStroke1);}", ".f1aperda{border-bottom-color:var(--colorNeutralStroke1);}", ".f16xkysk{background-color:var(--colorBrandBackground2);}", ".f16muhyy{color:var(--colorBrandForeground1);}", ".f1sl6hi9{border-left-color:var(--colorBrandStroke2);}", ".f1c8dzaj{border-right-color:var(--colorBrandStroke2);}", ".f1jar5jt{border-top-right-radius:var(--borderRadiusMedium);}", ".fyu767a{border-top-left-radius:var(--borderRadiusMedium);}", ".f1aa9q02{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f16jpd5f{border-bottom-left-radius:var(--borderRadiusMedium);}", ".f1djnp8u{border-top-right-radius:var(--borderRadiusCircular);}", ".f1s8kh49{border-top-left-radius:var(--borderRadiusCircular);}", ".f8fbkgy{border-bottom-right-radius:var(--borderRadiusCircular);}", ".f1nfllo7{border-bottom-left-radius:var(--borderRadiusCircular);}", ".fe5j1ua{font-size:20px;}", ".f15vdbe4{padding-left:5px;}", ".fwiuce9{padding-right:5px;}", ".f4ybsrx{font-size:16px;}", ".f2lugmd{padding-left:3px;}", ".f6zblan{padding-right:3px;}", ".f1ugzwwg{font-size:12px;}"],
|
|
75
|
+
h: [".f8491dx:hover{cursor:pointer;}", ".f1h648pw:hover{background-color:var(--colorNeutralBackground3Hover);}", ".f139oj5f:hover{color:var(--colorNeutralForeground2BrandHover);}", ".f1t94bn6:hover{background-color:var(--colorSubtleBackgroundHover);}", ".f1yj72w4:hover{background-color:var(--colorBrandBackground2Hover);}", ".f3ymbdj:hover{color:var(--colorCompoundBrandForeground1Hover);}"],
|
|
76
|
+
a: [".fwdzr64:active{background-color:var(--colorNeutralBackground3Pressed);}", ".f19au66r:active{color:var(--colorNeutralForeground2BrandPressed);}", ".f1wfn5kd:active{background-color:var(--colorSubtleBackgroundPressed);}", ".fy3sl2y:active{background-color:var(--colorBrandBackground2Pressed);}", ".fryz5bw:active{color:var(--colorCompoundBrandForeground1Pressed);}"],
|
|
77
|
+
m: [["@media (forced-colors: active){.fq7113v:hover{background-color:HighlightText;}}", {
|
|
78
|
+
m: "(forced-colors: active)"
|
|
79
|
+
}], ["@media (forced-colors: active){.fp3oj7s:active{background-color:HighlightText;}}", {
|
|
80
|
+
m: "(forced-colors: active)"
|
|
81
|
+
}]]
|
|
82
|
+
});
|
|
83
|
+
const useRootDisabledStyles = /*#__PURE__*/__styles({
|
|
84
|
+
filled: {
|
|
85
|
+
Bceei9c: "fdrzuqr",
|
|
86
|
+
De3pzq: "f1bg9a2p",
|
|
87
|
+
sj55zd: "f1s2aq7o",
|
|
88
|
+
g2u3we: "fgig46g",
|
|
89
|
+
h3c5rm: ["f1mxt3zg", "fziff3p"],
|
|
90
|
+
B9xav0g: "f250w3l",
|
|
91
|
+
zhjwy3: ["fy0fskl", "f15xbau"]
|
|
92
|
+
},
|
|
93
|
+
outline: {
|
|
94
|
+
Bceei9c: "fdrzuqr",
|
|
95
|
+
De3pzq: "fhovq9v",
|
|
96
|
+
sj55zd: "f1s2aq7o",
|
|
97
|
+
g2u3we: "f1jj8ep1",
|
|
98
|
+
h3c5rm: ["f15xbau", "fy0fskl"],
|
|
99
|
+
B9xav0g: "f4ikngz",
|
|
100
|
+
zhjwy3: ["fy0fskl", "f15xbau"]
|
|
101
|
+
},
|
|
102
|
+
brand: {
|
|
103
|
+
Bceei9c: "fdrzuqr",
|
|
104
|
+
De3pzq: "f1bg9a2p",
|
|
105
|
+
sj55zd: "f1s2aq7o",
|
|
106
|
+
g2u3we: "fgig46g",
|
|
107
|
+
h3c5rm: ["f1mxt3zg", "fziff3p"],
|
|
108
|
+
B9xav0g: "f250w3l",
|
|
109
|
+
zhjwy3: ["fy0fskl", "f15xbau"]
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
d: [".fdrzuqr{cursor:not-allowed;}", ".f1bg9a2p{background-color:var(--colorNeutralBackgroundDisabled);}", ".f1s2aq7o{color:var(--colorNeutralForegroundDisabled);}", ".fgig46g{border-top-color:var(--colorTransparentStrokeDisabled);}", ".f1mxt3zg{border-right-color:var(--colorTransparentStrokeDisabled);}", ".fziff3p{border-left-color:var(--colorTransparentStrokeDisabled);}", ".f250w3l{border-bottom-color:var(--colorTransparentStrokeDisabled);}", ".fy0fskl{border-left-color:var(--colorNeutralStrokeDisabled);}", ".f15xbau{border-right-color:var(--colorNeutralStrokeDisabled);}", ".fhovq9v{background-color:var(--colorSubtleBackground);}", ".f1jj8ep1{border-top-color:var(--colorNeutralStrokeDisabled);}", ".f4ikngz{border-bottom-color:var(--colorNeutralStrokeDisabled);}"]
|
|
113
|
+
});
|
|
114
|
+
export const useInteractionTagSecondaryStyles_unstable = state => {
|
|
115
|
+
const rootBaseClassName = useRootBaseClassName();
|
|
116
|
+
const rootStyles = useRootStyles();
|
|
117
|
+
const rootDisabledStyles = useRootDisabledStyles();
|
|
118
|
+
const {
|
|
119
|
+
shape,
|
|
120
|
+
size,
|
|
121
|
+
appearance
|
|
122
|
+
} = state;
|
|
123
|
+
state.root.className = mergeClasses(interactionTagSecondaryClassNames.root, rootBaseClassName, state.disabled ? rootDisabledStyles[appearance] : rootStyles[appearance], rootStyles[shape], rootStyles[size], state.root.className);
|
|
124
|
+
return state;
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=useInteractionTagSecondaryStyles.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__resetStyles","__styles","mergeClasses","shorthands","createCustomFocusIndicatorStyle","tokens","interactionTagSecondaryClassNames","root","mediumIconSize","smallIconSize","extraSmallIconSize","useRootBaseClassName","useRootStyles","filled","De3pzq","sj55zd","eoavqd","Jwef8y","Bi91k9c","ecr2s2","lj723h","Bqrx1nm","kx9iu6","outline","g2u3we","h3c5rm","B9xav0g","zhjwy3","brand","rounded","B7oj6ja","Bbmb7ep","circular","medium","Be2twd7","uwmqm3","z189sj","small","d","h","a","m","useRootDisabledStyles","Bceei9c","useInteractionTagSecondaryStyles_unstable","state","rootBaseClassName","rootStyles","rootDisabledStyles","shape","size","appearance","className","disabled"],"sources":["useInteractionTagSecondaryStyles.styles.js"],"sourcesContent":["import { makeResetStyles, makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nexport const interactionTagSecondaryClassNames = {\n root: 'fui-InteractionTagSecondary'\n};\nconst mediumIconSize = '20px';\nconst smallIconSize = '16px';\nconst extraSmallIconSize = '12px';\nconst useRootBaseClassName = makeResetStyles({\n // reset default button style:\n color: 'inherit',\n fontFamily: 'inherit',\n padding: '0px',\n borderStyle: 'none',\n appearance: 'button',\n textAlign: 'unset',\n backgroundColor: 'transparent',\n display: 'flex',\n height: '100%',\n alignItems: 'center',\n ...createCustomFocusIndicatorStyle(shorthands.outline(tokens.strokeWidthThick, 'solid', tokens.colorStrokeFocus2)),\n border: `${tokens.strokeWidthThin} solid ${tokens.colorTransparentStroke}`,\n // divider:\n borderLeftColor: tokens.colorNeutralStroke1,\n borderTopLeftRadius: tokens.borderRadiusNone,\n borderBottomLeftRadius: tokens.borderRadiusNone\n});\nconst useRootStyles = makeStyles({\n filled: {\n backgroundColor: tokens.colorNeutralBackground3,\n color: tokens.colorNeutralForeground2,\n ':hover': {\n cursor: 'pointer',\n backgroundColor: tokens.colorNeutralBackground3Hover,\n color: tokens.colorNeutralForeground2BrandHover\n },\n ':active': {\n backgroundColor: tokens.colorNeutralBackground3Pressed,\n color: tokens.colorNeutralForeground2BrandPressed\n },\n '@media (forced-colors: active)': {\n ':hover': {\n backgroundColor: 'HighlightText'\n },\n ':active': {\n backgroundColor: 'HighlightText'\n }\n }\n },\n outline: {\n backgroundColor: tokens.colorSubtleBackground,\n color: tokens.colorNeutralForeground2,\n ...shorthands.borderColor(tokens.colorNeutralStroke1),\n ':hover': {\n cursor: 'pointer',\n backgroundColor: tokens.colorSubtleBackgroundHover,\n color: tokens.colorNeutralForeground2BrandHover\n },\n ':active': {\n backgroundColor: tokens.colorSubtleBackgroundPressed,\n color: tokens.colorNeutralForeground2BrandPressed\n },\n '@media (forced-colors: active)': {\n ':hover': {\n backgroundColor: 'HighlightText'\n },\n ':active': {\n backgroundColor: 'HighlightText'\n }\n }\n },\n brand: {\n backgroundColor: tokens.colorBrandBackground2,\n color: tokens.colorBrandForeground1,\n borderLeftColor: tokens.colorBrandStroke2,\n ':hover': {\n cursor: 'pointer',\n backgroundColor: tokens.colorBrandBackground2Hover,\n color: tokens.colorCompoundBrandForeground1Hover\n },\n ':active': {\n backgroundColor: tokens.colorBrandBackground2Pressed,\n color: tokens.colorCompoundBrandForeground1Pressed\n },\n '@media (forced-colors: active)': {\n ':hover': {\n backgroundColor: 'HighlightText'\n },\n ':active': {\n backgroundColor: 'HighlightText'\n }\n }\n },\n rounded: {\n borderTopRightRadius: tokens.borderRadiusMedium,\n borderBottomRightRadius: tokens.borderRadiusMedium\n },\n circular: {\n borderTopRightRadius: tokens.borderRadiusCircular,\n borderBottomRightRadius: tokens.borderRadiusCircular\n },\n medium: {\n fontSize: mediumIconSize,\n paddingLeft: '5px',\n paddingRight: '5px'\n },\n small: {\n fontSize: smallIconSize,\n paddingLeft: '3px',\n paddingRight: '3px'\n },\n 'extra-small': {\n fontSize: extraSmallIconSize,\n paddingLeft: '5px',\n paddingRight: '5px'\n }\n});\nconst useRootDisabledStyles = makeStyles({\n filled: {\n cursor: 'not-allowed',\n backgroundColor: tokens.colorNeutralBackgroundDisabled,\n color: tokens.colorNeutralForegroundDisabled,\n ...shorthands.borderColor(tokens.colorTransparentStrokeDisabled),\n borderLeftColor: tokens.colorNeutralStrokeDisabled\n },\n outline: {\n cursor: 'not-allowed',\n backgroundColor: tokens.colorSubtleBackground,\n color: tokens.colorNeutralForegroundDisabled,\n ...shorthands.borderColor(tokens.colorNeutralStrokeDisabled)\n },\n brand: {\n cursor: 'not-allowed',\n backgroundColor: tokens.colorNeutralBackgroundDisabled,\n color: tokens.colorNeutralForegroundDisabled,\n ...shorthands.borderColor(tokens.colorTransparentStrokeDisabled),\n borderLeftColor: tokens.colorNeutralStrokeDisabled\n }\n});\nexport const useInteractionTagSecondaryStyles_unstable = (state)=>{\n const rootBaseClassName = useRootBaseClassName();\n const rootStyles = useRootStyles();\n const rootDisabledStyles = useRootDisabledStyles();\n const { shape, size, appearance } = state;\n state.root.className = mergeClasses(interactionTagSecondaryClassNames.root, rootBaseClassName, state.disabled ? rootDisabledStyles[appearance] : rootStyles[appearance], rootStyles[shape], rootStyles[size], state.root.className);\n return state;\n};\n"],"mappings":"AAAA,SAAAA,aAAA,EAAAC,QAAA,EAAsCC,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AACtF,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,OAAO,MAAMC,iCAAiC,GAAG;EAC7CC,IAAI,EAAE;AACV,CAAC;AACD,MAAMC,cAAc,GAAG,MAAM;AAC7B,MAAMC,aAAa,GAAG,MAAM;AAC5B,MAAMC,kBAAkB,GAAG,MAAM;AACjC,MAAMC,oBAAoB,gBAAGX,aAAA,usCAkB5B,CAAC;AACF,MAAMY,aAAa,gBAAGX,QAAA;EAAAY,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,OAAA;IAAAT,MAAA;IAAAC,MAAA;IAAAS,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAX,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAM,KAAA;IAAAd,MAAA;IAAAC,MAAA;IAAAY,MAAA;IAAAX,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAO,OAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;EAAAC,QAAA;IAAAF,OAAA;IAAAC,OAAA;EAAA;EAAAE,MAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;EAAA;EAAAC,KAAA;IAAAH,OAAA;IAAAC,MAAA;IAAAC,MAAA;EAAA;EAAA;IAAAF,OAAA;IAAAC,MAAA;IAAAC,MAAA;EAAA;AAAA;EAAAE,CAAA;EAAAC,CAAA;EAAAC,CAAA;EAAAC,CAAA;IAAAA,CAAA;EAAA;IAAAA,CAAA;EAAA;AAAA,CAyFrB,CAAC;AACF,MAAMC,qBAAqB,gBAAGzC,QAAA;EAAAY,MAAA;IAAA8B,OAAA;IAAA7B,MAAA;IAAAC,MAAA;IAAAS,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAJ,OAAA;IAAAoB,OAAA;IAAA7B,MAAA;IAAAC,MAAA;IAAAS,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;EAAAC,KAAA;IAAAe,OAAA;IAAA7B,MAAA;IAAAC,MAAA;IAAAS,MAAA;IAAAC,MAAA;IAAAC,OAAA;IAAAC,MAAA;EAAA;AAAA;EAAAW,CAAA;AAAA,CAqB7B,CAAC;AACF,OAAO,MAAMM,yCAAyC,GAAIC,KAAK,IAAG;EAC9D,MAAMC,iBAAiB,GAAGnC,oBAAoB,CAAC,CAAC;EAChD,MAAMoC,UAAU,GAAGnC,aAAa,CAAC,CAAC;EAClC,MAAMoC,kBAAkB,GAAGN,qBAAqB,CAAC,CAAC;EAClD,MAAM;IAAEO,KAAK;IAAEC,IAAI;IAAEC;EAAW,CAAC,GAAGN,KAAK;EACzCA,KAAK,CAACtC,IAAI,CAAC6C,SAAS,GAAGlD,YAAY,CAACI,iCAAiC,CAACC,IAAI,EAAEuC,iBAAiB,EAAED,KAAK,CAACQ,QAAQ,GAAGL,kBAAkB,CAACG,UAAU,CAAC,GAAGJ,UAAU,CAACI,UAAU,CAAC,EAAEJ,UAAU,CAACE,KAAK,CAAC,EAAEF,UAAU,CAACG,IAAI,CAAC,EAAEL,KAAK,CAACtC,IAAI,CAAC6C,SAAS,CAAC;EACnO,OAAOP,KAAK;AAChB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useTag_unstable } from './useTag';
|
|
3
|
+
import { renderTag_unstable } from './renderTag';
|
|
4
|
+
import { useTagStyles_unstable } from './useTagStyles.styles';
|
|
5
|
+
import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';
|
|
6
|
+
import { useTagAvatarContextValues_unstable } from '../../utils';
|
|
7
|
+
/**
|
|
8
|
+
* Tag component - a visual representation of an attribute.
|
|
9
|
+
* Provides visual attributes such as media, icon, primary and secondary text, as well as the ability to attach an action (by default it is dismiss)
|
|
10
|
+
*/ export const Tag = /*#__PURE__*/ React.forwardRef((props, ref)=>{
|
|
11
|
+
const state = useTag_unstable(props, ref);
|
|
12
|
+
useTagStyles_unstable(state);
|
|
13
|
+
useCustomStyleHook_unstable('useTagStyles_unstable')(state);
|
|
14
|
+
return renderTag_unstable(state, useTagAvatarContextValues_unstable(state));
|
|
15
|
+
});
|
|
16
|
+
Tag.displayName = 'Tag';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Tag.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useTag_unstable } from './useTag';\nimport { renderTag_unstable } from './renderTag';\nimport { useTagStyles_unstable } from './useTagStyles.styles';\nimport type { TagProps } from './Tag.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\nimport { useTagAvatarContextValues_unstable } from '../../utils';\n\n/**\n * Tag component - a visual representation of an attribute.\n * Provides visual attributes such as media, icon, primary and secondary text, as well as the ability to attach an action (by default it is dismiss)\n */\nexport const Tag: ForwardRefComponent<TagProps> = React.forwardRef((props, ref) => {\n const state = useTag_unstable(props, ref);\n\n useTagStyles_unstable(state);\n\n useCustomStyleHook_unstable('useTagStyles_unstable')(state);\n\n return renderTag_unstable(state, useTagAvatarContextValues_unstable(state));\n});\n\nTag.displayName = 'Tag';\n"],"names":["React","useTag_unstable","renderTag_unstable","useTagStyles_unstable","useCustomStyleHook_unstable","useTagAvatarContextValues_unstable","Tag","forwardRef","props","ref","state","displayName"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,eAAe,QAAQ,WAAW;AAC3C,SAASC,kBAAkB,QAAQ,cAAc;AACjD,SAASC,qBAAqB,QAAQ,wBAAwB;AAG9D,SAASC,2BAA2B,QAAQ,kCAAkC;AAC9E,SAASC,kCAAkC,QAAQ,cAAc;AAEjE;;;CAGC,GACD,OAAO,MAAMC,oBAAqCN,MAAMO,UAAU,CAAC,CAACC,OAAOC;IACzE,MAAMC,QAAQT,gBAAgBO,OAAOC;IAErCN,sBAAsBO;IAEtBN,4BAA4B,yBAAyBM;IAErD,OAAOR,mBAAmBQ,OAAOL,mCAAmCK;AACtE,GAAG;AAEHJ,IAAIK,WAAW,GAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Tag.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { TagAppearance, TagShape, TagSize } from '../../utils/types';\nimport { TagAvatarContextValues, UseTagAvatarContextValuesOptions } from '../../utils/useTagAvatarContextValues';\n\nexport type TagContextValues = TagAvatarContextValues;\n\nexport type TagSlots = {\n root: NonNullable<Slot<'button', 'span'>>;\n\n /**\n * Slot for a visual element, usually an avatar\n */\n media?: Slot<'span'>;\n\n /**\n * Slot for an icon\n */\n icon?: Slot<'span'>;\n\n /**\n * Main text for the Tag. Children of the root slot are automatically rendered here\n */\n primaryText: Slot<'span'>;\n\n /**\n * Secondary text that describes or complements the main text\n */\n secondaryText?: Slot<'span'>;\n\n /**\n * Slot for the dismiss icon\n */\n dismissIcon?: Slot<'span'>;\n};\n\n/**\n * Tag Props\n */\nexport type TagProps<Value = string> = ComponentProps<Partial<TagSlots>> & {\n /**\n * A Tag can have filled, outlined or brand experience.\n *\n * @default 'filled'\n */\n appearance?: TagAppearance;\n\n /**\n * A Tag can show that it cannot be interacted with.\n *\n * @default false\n */\n disabled?: boolean;\n\n /**\n * A Tag can be dismissible\n *\n * @default false\n */\n dismissible?: boolean;\n\n /**\n * A Tag can have rounded or circular shape.\n *\n * @default 'round'\n */\n shape?: TagShape;\n\n /**\n * A Tag has three sizes.\n *\n * @default 'medium'\n */\n size?: TagSize;\n\n /**\n * Unique value identifying the tag within a TagGroup\n */\n value?: Value;\n};\n\n/**\n * State used in rendering Tag\n */\nexport type TagState = ComponentState<TagSlots> &\n Required<Pick<TagProps, 'appearance' | 'disabled' | 'dismissible' | 'shape' | 'size'>> &\n UseTagAvatarContextValuesOptions;\n"],"names":[],"mappings":"AAAA,WAqFmC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './Tag';\nexport * from './Tag.types';\nexport * from './renderTag';\nexport * from './useTag';\nexport * from './useTagStyles.styles';\n"],"names":[],"mappings":"AAAA,cAAc,QAAQ;AACtB,cAAc,cAAc;AAC5B,cAAc,cAAc;AAC5B,cAAc,WAAW;AACzB,cAAc,wBAAwB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
|
|
2
|
+
import { assertSlots } from '@fluentui/react-utilities';
|
|
3
|
+
import { AvatarContextProvider } from '@fluentui/react-avatar';
|
|
4
|
+
/**
|
|
5
|
+
* Render the final JSX of Tag
|
|
6
|
+
*/ export const renderTag_unstable = (state, contextValues)=>{
|
|
7
|
+
assertSlots(state);
|
|
8
|
+
return /*#__PURE__*/ _jsxs(state.root, {
|
|
9
|
+
children: [
|
|
10
|
+
state.media && /*#__PURE__*/ _jsx(AvatarContextProvider, {
|
|
11
|
+
value: contextValues.avatar,
|
|
12
|
+
children: /*#__PURE__*/ _jsx(state.media, {})
|
|
13
|
+
}),
|
|
14
|
+
state.icon && /*#__PURE__*/ _jsx(state.icon, {}),
|
|
15
|
+
state.primaryText && /*#__PURE__*/ _jsx(state.primaryText, {}),
|
|
16
|
+
state.secondaryText && /*#__PURE__*/ _jsx(state.secondaryText, {}),
|
|
17
|
+
state.dismissIcon && state.dismissible && /*#__PURE__*/ _jsx(state.dismissIcon, {})
|
|
18
|
+
]
|
|
19
|
+
});
|
|
20
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["renderTag.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { TagState, TagSlots, TagContextValues } from './Tag.types';\nimport { AvatarContextProvider } from '@fluentui/react-avatar';\n\n/**\n * Render the final JSX of Tag\n */\nexport const renderTag_unstable = (state: TagState, contextValues: TagContextValues) => {\n assertSlots<TagSlots>(state);\n\n return (\n <state.root>\n {state.media && (\n <AvatarContextProvider value={contextValues.avatar}>\n <state.media />\n </AvatarContextProvider>\n )}\n\n {state.icon && <state.icon />}\n {state.primaryText && <state.primaryText />}\n {state.secondaryText && <state.secondaryText />}\n {state.dismissIcon && state.dismissible && <state.dismissIcon />}\n </state.root>\n );\n};\n"],"names":["assertSlots","AvatarContextProvider","renderTag_unstable","state","contextValues","root","media","value","avatar","icon","primaryText","secondaryText","dismissIcon","dismissible"],"mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAExD,SAASC,qBAAqB,QAAQ,yBAAyB;AAE/D;;CAEC,GACD,OAAO,MAAMC,qBAAqB,CAACC,OAAiBC;IAClDJ,YAAsBG;IAEtB,qBACE,MAACA,MAAME,IAAI;;YACRF,MAAMG,KAAK,kBACV,KAACL;gBAAsBM,OAAOH,cAAcI,MAAM;0BAChD,cAAA,KAACL,MAAMG,KAAK;;YAIfH,MAAMM,IAAI,kBAAI,KAACN,MAAMM,IAAI;YACzBN,MAAMO,WAAW,kBAAI,KAACP,MAAMO,WAAW;YACvCP,MAAMQ,aAAa,kBAAI,KAACR,MAAMQ,aAAa;YAC3CR,MAAMS,WAAW,IAAIT,MAAMU,WAAW,kBAAI,KAACV,MAAMS,WAAW;;;AAGnE,EAAE"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getNativeElementProps, useEventCallback, useId, slot } from '@fluentui/react-utilities';
|
|
3
|
+
import { DismissRegular } from '@fluentui/react-icons';
|
|
4
|
+
import { Delete, Backspace } from '@fluentui/keyboard-keys';
|
|
5
|
+
import { useTagGroupContext_unstable } from '../../contexts/tagGroupContext';
|
|
6
|
+
const tagAvatarSizeMap = {
|
|
7
|
+
medium: 28,
|
|
8
|
+
small: 20,
|
|
9
|
+
'extra-small': 16
|
|
10
|
+
};
|
|
11
|
+
const tagAvatarShapeMap = {
|
|
12
|
+
rounded: 'square',
|
|
13
|
+
circular: 'circular'
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Create the state required to render Tag.
|
|
17
|
+
*
|
|
18
|
+
* The returned state can be modified with hooks such as useTagStyles_unstable,
|
|
19
|
+
* before being passed to renderTag_unstable.
|
|
20
|
+
*
|
|
21
|
+
* @param props - props from this instance of Tag
|
|
22
|
+
* @param ref - reference to root HTMLSpanElement or HTMLButtonElement of Tag
|
|
23
|
+
*/ export const useTag_unstable = (props, ref)=>{
|
|
24
|
+
const { handleTagDismiss, size: contextSize } = useTagGroupContext_unstable();
|
|
25
|
+
const id = useId('fui-Tag', props.id);
|
|
26
|
+
const { appearance = 'filled', disabled = false, dismissible = false, shape = 'rounded', size = contextSize, value = id } = props;
|
|
27
|
+
const dismissOnClick = useEventCallback((ev)=>{
|
|
28
|
+
var _props_onClick;
|
|
29
|
+
(_props_onClick = props.onClick) === null || _props_onClick === void 0 ? void 0 : _props_onClick.call(props, ev);
|
|
30
|
+
if (!ev.defaultPrevented) {
|
|
31
|
+
handleTagDismiss === null || handleTagDismiss === void 0 ? void 0 : handleTagDismiss(ev, {
|
|
32
|
+
value
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const dismissOnKeyDown = useEventCallback((ev)=>{
|
|
37
|
+
var _props_onKeyDown;
|
|
38
|
+
props === null || props === void 0 ? void 0 : (_props_onKeyDown = props.onKeyDown) === null || _props_onKeyDown === void 0 ? void 0 : _props_onKeyDown.call(props, ev);
|
|
39
|
+
if (!ev.defaultPrevented && (ev.key === Delete || ev.key === Backspace)) {
|
|
40
|
+
handleTagDismiss === null || handleTagDismiss === void 0 ? void 0 : handleTagDismiss(ev, {
|
|
41
|
+
value
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
const elementType = dismissible ? 'button' : 'span';
|
|
46
|
+
return {
|
|
47
|
+
appearance,
|
|
48
|
+
avatarShape: tagAvatarShapeMap[shape],
|
|
49
|
+
avatarSize: tagAvatarSizeMap[size],
|
|
50
|
+
disabled,
|
|
51
|
+
dismissible,
|
|
52
|
+
shape,
|
|
53
|
+
size,
|
|
54
|
+
components: {
|
|
55
|
+
root: elementType,
|
|
56
|
+
media: 'span',
|
|
57
|
+
icon: 'span',
|
|
58
|
+
primaryText: 'span',
|
|
59
|
+
secondaryText: 'span',
|
|
60
|
+
dismissIcon: 'span'
|
|
61
|
+
},
|
|
62
|
+
root: slot.always(getNativeElementProps(elementType, {
|
|
63
|
+
ref,
|
|
64
|
+
...props,
|
|
65
|
+
id,
|
|
66
|
+
...dismissible && {
|
|
67
|
+
onClick: dismissOnClick,
|
|
68
|
+
onKeyDown: dismissOnKeyDown
|
|
69
|
+
}
|
|
70
|
+
}), {
|
|
71
|
+
elementType
|
|
72
|
+
}),
|
|
73
|
+
media: slot.optional(props.media, {
|
|
74
|
+
elementType: 'span'
|
|
75
|
+
}),
|
|
76
|
+
icon: slot.optional(props.icon, {
|
|
77
|
+
elementType: 'span'
|
|
78
|
+
}),
|
|
79
|
+
primaryText: slot.optional(props.primaryText, {
|
|
80
|
+
renderByDefault: true,
|
|
81
|
+
defaultProps: {
|
|
82
|
+
children: props.children
|
|
83
|
+
},
|
|
84
|
+
elementType: 'span'
|
|
85
|
+
}),
|
|
86
|
+
secondaryText: slot.optional(props.secondaryText, {
|
|
87
|
+
elementType: 'span'
|
|
88
|
+
}),
|
|
89
|
+
dismissIcon: slot.optional(props.dismissIcon, {
|
|
90
|
+
renderByDefault: dismissible,
|
|
91
|
+
defaultProps: {
|
|
92
|
+
children: /*#__PURE__*/ React.createElement(DismissRegular, null),
|
|
93
|
+
role: 'img'
|
|
94
|
+
},
|
|
95
|
+
elementType: 'span'
|
|
96
|
+
})
|
|
97
|
+
};
|
|
98
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["useTag.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, useEventCallback, useId, slot } from '@fluentui/react-utilities';\nimport { DismissRegular } from '@fluentui/react-icons';\nimport type { TagProps, TagState } from './Tag.types';\nimport { Delete, Backspace } from '@fluentui/keyboard-keys';\nimport { useTagGroupContext_unstable } from '../../contexts/tagGroupContext';\n\nconst tagAvatarSizeMap = {\n medium: 28,\n small: 20,\n 'extra-small': 16,\n} as const;\n\nconst tagAvatarShapeMap = {\n rounded: 'square',\n circular: 'circular',\n} as const;\n\n/**\n * Create the state required to render Tag.\n *\n * The returned state can be modified with hooks such as useTagStyles_unstable,\n * before being passed to renderTag_unstable.\n *\n * @param props - props from this instance of Tag\n * @param ref - reference to root HTMLSpanElement or HTMLButtonElement of Tag\n */\nexport const useTag_unstable = (props: TagProps, ref: React.Ref<HTMLSpanElement | HTMLButtonElement>): TagState => {\n const { handleTagDismiss, size: contextSize } = useTagGroupContext_unstable();\n\n const id = useId('fui-Tag', props.id);\n\n const {\n appearance = 'filled',\n disabled = false,\n dismissible = false,\n shape = 'rounded',\n size = contextSize,\n value = id,\n } = props;\n\n const dismissOnClick = useEventCallback((ev: React.MouseEvent<HTMLButtonElement>) => {\n props.onClick?.(ev);\n if (!ev.defaultPrevented) {\n handleTagDismiss?.(ev, { value });\n }\n });\n\n const dismissOnKeyDown = useEventCallback((ev: React.KeyboardEvent<HTMLButtonElement>) => {\n props?.onKeyDown?.(ev);\n if (!ev.defaultPrevented && (ev.key === Delete || ev.key === Backspace)) {\n handleTagDismiss?.(ev, { value });\n }\n });\n\n const elementType = dismissible ? 'button' : 'span';\n\n return {\n appearance,\n avatarShape: tagAvatarShapeMap[shape],\n avatarSize: tagAvatarSizeMap[size],\n disabled,\n dismissible,\n shape,\n size,\n\n components: {\n root: elementType,\n media: 'span',\n icon: 'span',\n primaryText: 'span',\n secondaryText: 'span',\n dismissIcon: 'span',\n },\n\n root: slot.always(\n getNativeElementProps(elementType, {\n ref,\n ...props,\n id,\n ...(dismissible && { onClick: dismissOnClick, onKeyDown: dismissOnKeyDown }),\n }),\n { elementType },\n ),\n\n media: slot.optional(props.media, { elementType: 'span' }),\n icon: slot.optional(props.icon, { elementType: 'span' }),\n primaryText: slot.optional(props.primaryText, {\n renderByDefault: true,\n defaultProps: {\n children: props.children,\n },\n elementType: 'span',\n }),\n secondaryText: slot.optional(props.secondaryText, { elementType: 'span' }),\n dismissIcon: slot.optional(props.dismissIcon, {\n renderByDefault: dismissible,\n defaultProps: {\n children: <DismissRegular />,\n role: 'img',\n },\n elementType: 'span',\n }),\n };\n};\n"],"names":["React","getNativeElementProps","useEventCallback","useId","slot","DismissRegular","Delete","Backspace","useTagGroupContext_unstable","tagAvatarSizeMap","medium","small","tagAvatarShapeMap","rounded","circular","useTag_unstable","props","ref","handleTagDismiss","size","contextSize","id","appearance","disabled","dismissible","shape","value","dismissOnClick","ev","onClick","defaultPrevented","dismissOnKeyDown","onKeyDown","key","elementType","avatarShape","avatarSize","components","root","media","icon","primaryText","secondaryText","dismissIcon","always","optional","renderByDefault","defaultProps","children","role"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,qBAAqB,EAAEC,gBAAgB,EAAEC,KAAK,EAAEC,IAAI,QAAQ,4BAA4B;AACjG,SAASC,cAAc,QAAQ,wBAAwB;AAEvD,SAASC,MAAM,EAAEC,SAAS,QAAQ,0BAA0B;AAC5D,SAASC,2BAA2B,QAAQ,iCAAiC;AAE7E,MAAMC,mBAAmB;IACvBC,QAAQ;IACRC,OAAO;IACP,eAAe;AACjB;AAEA,MAAMC,oBAAoB;IACxBC,SAAS;IACTC,UAAU;AACZ;AAEA;;;;;;;;CAQC,GACD,OAAO,MAAMC,kBAAkB,CAACC,OAAiBC;IAC/C,MAAM,EAAEC,gBAAgB,EAAEC,MAAMC,WAAW,EAAE,GAAGZ;IAEhD,MAAMa,KAAKlB,MAAM,WAAWa,MAAMK,EAAE;IAEpC,MAAM,EACJC,aAAa,QAAQ,EACrBC,WAAW,KAAK,EAChBC,cAAc,KAAK,EACnBC,QAAQ,SAAS,EACjBN,OAAOC,WAAW,EAClBM,QAAQL,EAAE,EACX,GAAGL;IAEJ,MAAMW,iBAAiBzB,iBAAiB,CAAC0B;YACvCZ;SAAAA,iBAAAA,MAAMa,OAAO,cAAbb,qCAAAA,oBAAAA,OAAgBY;QAChB,IAAI,CAACA,GAAGE,gBAAgB,EAAE;YACxBZ,6BAAAA,uCAAAA,iBAAmBU,IAAI;gBAAEF;YAAM;QACjC;IACF;IAEA,MAAMK,mBAAmB7B,iBAAiB,CAAC0B;YACzCZ;QAAAA,kBAAAA,6BAAAA,mBAAAA,MAAOgB,SAAS,cAAhBhB,uCAAAA,sBAAAA,OAAmBY;QACnB,IAAI,CAACA,GAAGE,gBAAgB,IAAKF,CAAAA,GAAGK,GAAG,KAAK3B,UAAUsB,GAAGK,GAAG,KAAK1B,SAAQ,GAAI;YACvEW,6BAAAA,uCAAAA,iBAAmBU,IAAI;gBAAEF;YAAM;QACjC;IACF;IAEA,MAAMQ,cAAcV,cAAc,WAAW;IAE7C,OAAO;QACLF;QACAa,aAAavB,iBAAiB,CAACa,MAAM;QACrCW,YAAY3B,gBAAgB,CAACU,KAAK;QAClCI;QACAC;QACAC;QACAN;QAEAkB,YAAY;YACVC,MAAMJ;YACNK,OAAO;YACPC,MAAM;YACNC,aAAa;YACbC,eAAe;YACfC,aAAa;QACf;QAEAL,MAAMlC,KAAKwC,MAAM,CACf3C,sBAAsBiC,aAAa;YACjCjB;YACA,GAAGD,KAAK;YACRK;YACA,GAAIG,eAAe;gBAAEK,SAASF;gBAAgBK,WAAWD;YAAiB,CAAC;QAC7E,IACA;YAAEG;QAAY;QAGhBK,OAAOnC,KAAKyC,QAAQ,CAAC7B,MAAMuB,KAAK,EAAE;YAAEL,aAAa;QAAO;QACxDM,MAAMpC,KAAKyC,QAAQ,CAAC7B,MAAMwB,IAAI,EAAE;YAAEN,aAAa;QAAO;QACtDO,aAAarC,KAAKyC,QAAQ,CAAC7B,MAAMyB,WAAW,EAAE;YAC5CK,iBAAiB;YACjBC,cAAc;gBACZC,UAAUhC,MAAMgC,QAAQ;YAC1B;YACAd,aAAa;QACf;QACAQ,eAAetC,KAAKyC,QAAQ,CAAC7B,MAAM0B,aAAa,EAAE;YAAER,aAAa;QAAO;QACxES,aAAavC,KAAKyC,QAAQ,CAAC7B,MAAM2B,WAAW,EAAE;YAC5CG,iBAAiBtB;YACjBuB,cAAc;gBACZC,wBAAU,oBAAC3C;gBACX4C,MAAM;YACR;YACAf,aAAa;QACf;IACF;AACF,EAAE"}
|