@tamagui/label 1.46.1 → 1.47.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/package.json +9 -9
- package/dist/jsx/Label.mjs +0 -136
- package/dist/jsx/Label.mjs.map +0 -6
- package/dist/jsx/index.mjs +0 -2
- package/dist/jsx/index.mjs.map +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/label",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.0",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -31,20 +31,20 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@tamagui/compose-refs": "1.
|
|
35
|
-
"@tamagui/create-context": "1.
|
|
36
|
-
"@tamagui/focusable": "1.
|
|
37
|
-
"@tamagui/get-button-sized": "1.
|
|
38
|
-
"@tamagui/get-font-sized": "1.
|
|
39
|
-
"@tamagui/text": "1.
|
|
40
|
-
"@tamagui/web": "1.
|
|
34
|
+
"@tamagui/compose-refs": "1.47.0",
|
|
35
|
+
"@tamagui/create-context": "1.47.0",
|
|
36
|
+
"@tamagui/focusable": "1.47.0",
|
|
37
|
+
"@tamagui/get-button-sized": "1.47.0",
|
|
38
|
+
"@tamagui/get-font-sized": "1.47.0",
|
|
39
|
+
"@tamagui/text": "1.47.0",
|
|
40
|
+
"@tamagui/web": "1.47.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": "*",
|
|
44
44
|
"react-native": "*"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@tamagui/build": "1.
|
|
47
|
+
"@tamagui/build": "1.47.0",
|
|
48
48
|
"react": "^18.2.0",
|
|
49
49
|
"react-native": "^0.72.1"
|
|
50
50
|
},
|
package/dist/jsx/Label.mjs
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { useComposedRefs } from "@tamagui/compose-refs";
|
|
2
|
-
import { createContext } from "@tamagui/create-context";
|
|
3
|
-
import { focusFocusable } from "@tamagui/focusable";
|
|
4
|
-
import { getButtonSized } from "@tamagui/get-button-sized";
|
|
5
|
-
import { getFontSized } from "@tamagui/get-font-sized";
|
|
6
|
-
import { SizableText } from "@tamagui/text";
|
|
7
|
-
import {
|
|
8
|
-
isWeb,
|
|
9
|
-
styled,
|
|
10
|
-
themeable
|
|
11
|
-
} from "@tamagui/web";
|
|
12
|
-
import * as React from "react";
|
|
13
|
-
const NAME = "Label";
|
|
14
|
-
const [LabelProvider, useLabelContextImpl] = createContext(NAME, {
|
|
15
|
-
id: void 0,
|
|
16
|
-
controlRef: { current: null }
|
|
17
|
-
});
|
|
18
|
-
const LabelFrame = styled(SizableText, {
|
|
19
|
-
name: "Label",
|
|
20
|
-
tag: "label",
|
|
21
|
-
variants: {
|
|
22
|
-
unstyled: {
|
|
23
|
-
false: {
|
|
24
|
-
size: "$true",
|
|
25
|
-
color: "$color",
|
|
26
|
-
backgroundColor: "transparent",
|
|
27
|
-
display: "flex",
|
|
28
|
-
alignItems: "center",
|
|
29
|
-
userSelect: "none",
|
|
30
|
-
cursor: "default",
|
|
31
|
-
pressStyle: {
|
|
32
|
-
color: "$colorPress"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
size: {
|
|
37
|
-
"...size": (val, extras) => {
|
|
38
|
-
const buttonStyle = getButtonSized(val, extras);
|
|
39
|
-
const fontStyle = getFontSized(val, extras);
|
|
40
|
-
return {
|
|
41
|
-
...fontStyle,
|
|
42
|
-
lineHeight: extras.tokens.size[buttonStyle.height]
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
defaultVariants: {
|
|
48
|
-
unstyled: false
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
const LabelComponent = React.forwardRef(
|
|
52
|
-
(props, forwardedRef) => {
|
|
53
|
-
const { htmlFor, id: idProp, ...labelProps } = props;
|
|
54
|
-
const controlRef = React.useRef(null);
|
|
55
|
-
const ref = React.useRef(null);
|
|
56
|
-
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
57
|
-
const backupId = React.useId();
|
|
58
|
-
const id = idProp ?? backupId;
|
|
59
|
-
if (isWeb) {
|
|
60
|
-
React.useEffect(() => {
|
|
61
|
-
if (htmlFor) {
|
|
62
|
-
const element = document.getElementById(htmlFor);
|
|
63
|
-
const label = ref.current;
|
|
64
|
-
if (label && element) {
|
|
65
|
-
const getAriaLabel = () => element.getAttribute("aria-labelledby");
|
|
66
|
-
const ariaLabelledBy = [id, getAriaLabel()].filter(Boolean).join(" ");
|
|
67
|
-
element.setAttribute("aria-labelledby", ariaLabelledBy);
|
|
68
|
-
controlRef.current = element;
|
|
69
|
-
return () => {
|
|
70
|
-
if (!id)
|
|
71
|
-
return;
|
|
72
|
-
const ariaLabelledBy2 = getAriaLabel()?.replace(id, "");
|
|
73
|
-
if (ariaLabelledBy2 === "") {
|
|
74
|
-
element.removeAttribute("aria-labelledby");
|
|
75
|
-
} else if (ariaLabelledBy2) {
|
|
76
|
-
element.setAttribute("aria-labelledby", ariaLabelledBy2);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}, [id, htmlFor]);
|
|
82
|
-
}
|
|
83
|
-
return <LabelProvider id={id} controlRef={controlRef}><LabelFrame
|
|
84
|
-
role="heading"
|
|
85
|
-
id={id}
|
|
86
|
-
htmlFor={htmlFor}
|
|
87
|
-
{...labelProps}
|
|
88
|
-
ref={composedRefs}
|
|
89
|
-
onMouseDown={(event) => {
|
|
90
|
-
props.onMouseDown?.(event);
|
|
91
|
-
if (!event.defaultPrevented && event.detail > 1) {
|
|
92
|
-
event.preventDefault();
|
|
93
|
-
}
|
|
94
|
-
}}
|
|
95
|
-
onPress={(event) => {
|
|
96
|
-
props.onPress?.(event);
|
|
97
|
-
if (isWeb) {
|
|
98
|
-
if (htmlFor || !controlRef.current || event.defaultPrevented)
|
|
99
|
-
return;
|
|
100
|
-
const isClickingControl = controlRef.current.contains(
|
|
101
|
-
event.target
|
|
102
|
-
);
|
|
103
|
-
const isUserClick = event.isTrusted === true;
|
|
104
|
-
if (!isClickingControl && isUserClick) {
|
|
105
|
-
controlRef.current.click();
|
|
106
|
-
controlRef.current.focus();
|
|
107
|
-
}
|
|
108
|
-
} else {
|
|
109
|
-
if (props.htmlFor) {
|
|
110
|
-
focusFocusable(props.htmlFor);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}}
|
|
114
|
-
/></LabelProvider>;
|
|
115
|
-
}
|
|
116
|
-
);
|
|
117
|
-
LabelComponent.displayName = NAME;
|
|
118
|
-
const Label = LabelFrame.extractable(themeable(LabelComponent), {
|
|
119
|
-
neverFlatten: true
|
|
120
|
-
});
|
|
121
|
-
const useLabelContext = (element) => {
|
|
122
|
-
const context = useLabelContextImpl("LabelConsumer");
|
|
123
|
-
const { controlRef } = context;
|
|
124
|
-
React.useEffect(() => {
|
|
125
|
-
if (element)
|
|
126
|
-
controlRef.current = element;
|
|
127
|
-
}, [element, controlRef]);
|
|
128
|
-
return context.id;
|
|
129
|
-
};
|
|
130
|
-
const Root = Label;
|
|
131
|
-
export {
|
|
132
|
-
Label,
|
|
133
|
-
LabelFrame,
|
|
134
|
-
useLabelContext
|
|
135
|
-
};
|
|
136
|
-
//# sourceMappingURL=Label.mjs.map
|
package/dist/jsx/Label.mjs.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/Label.tsx"],
|
|
4
|
-
"mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB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