@tamagui/label 2.0.0-rc.4 → 2.0.0-rc.40
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/dist/cjs/Label.cjs +139 -113
- package/dist/cjs/Label.native.js +144 -122
- package/dist/cjs/Label.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Label.mjs +105 -81
- package/dist/esm/Label.mjs.map +1 -1
- package/dist/esm/Label.native.js +110 -90
- package/dist/esm/Label.native.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -6
- package/dist/jsx/Label.mjs +105 -81
- package/dist/jsx/Label.mjs.map +1 -1
- package/dist/jsx/Label.native.js +144 -122
- package/dist/jsx/Label.native.js.map +1 -1
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -6
- package/dist/jsx/index.native.js +7 -5
- package/package.json +14 -17
- package/dist/cjs/Label.js +0 -107
- package/dist/cjs/Label.js.map +0 -6
- package/dist/cjs/index.js +0 -15
- package/dist/cjs/index.js.map +0 -6
- package/dist/esm/Label.js +0 -92
- package/dist/esm/Label.js.map +0 -6
- package/dist/jsx/Label.js +0 -92
- package/dist/jsx/Label.js.map +0 -6
package/dist/cjs/Label.cjs
CHANGED
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var Label_exports = {};
|
|
33
35
|
__export(Label_exports, {
|
|
34
36
|
Label: () => Label,
|
|
@@ -36,107 +38,131 @@ __export(Label_exports, {
|
|
|
36
38
|
useLabelContext: () => useLabelContext
|
|
37
39
|
});
|
|
38
40
|
module.exports = __toCommonJS(Label_exports);
|
|
39
|
-
var import_compose_refs = require("@tamagui/compose-refs")
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const NAME = "Label"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
size: {
|
|
75
|
-
"...size": (val, extras) => {
|
|
76
|
-
const buttonHeight = (0, import_get_button_sized.getButtonSized)(val, extras)?.height;
|
|
77
|
-
return {
|
|
78
|
-
...(0, import_get_font_sized.getFontSized)(val, extras),
|
|
79
|
-
lineHeight: buttonHeight ? extras.tokens.size[buttonHeight] : void 0
|
|
80
|
-
};
|
|
41
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
42
|
+
var import_constants = require("@tamagui/constants");
|
|
43
|
+
var import_create_context = require("@tamagui/create-context");
|
|
44
|
+
var import_focusable = require("@tamagui/focusable");
|
|
45
|
+
var import_get_button_sized = require("@tamagui/get-button-sized");
|
|
46
|
+
var import_get_font_sized = require("@tamagui/get-font-sized");
|
|
47
|
+
var import_text = require("@tamagui/text");
|
|
48
|
+
var import_web = require("@tamagui/web");
|
|
49
|
+
var React = __toESM(require("react"), 1);
|
|
50
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
+
const NAME = "Label";
|
|
52
|
+
const [LabelProvider, useLabelContextImpl] = (0, import_create_context.createContext)(NAME, {
|
|
53
|
+
id: void 0,
|
|
54
|
+
controlRef: {
|
|
55
|
+
current: null
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const LabelFrame = (0, import_web.styled)(import_text.SizableText, {
|
|
59
|
+
name: "Label",
|
|
60
|
+
render: "label",
|
|
61
|
+
variants: {
|
|
62
|
+
unstyled: {
|
|
63
|
+
false: {
|
|
64
|
+
size: "$true",
|
|
65
|
+
color: "$color",
|
|
66
|
+
backgroundColor: "transparent",
|
|
67
|
+
display: "flex",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
userSelect: "none",
|
|
70
|
+
cursor: "default",
|
|
71
|
+
pressStyle: {
|
|
72
|
+
color: "$colorPress"
|
|
81
73
|
}
|
|
82
74
|
}
|
|
83
75
|
},
|
|
84
|
-
|
|
85
|
-
|
|
76
|
+
size: {
|
|
77
|
+
"...size": (val, extras) => {
|
|
78
|
+
const buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras);
|
|
79
|
+
const buttonHeight = buttonStyle?.height;
|
|
80
|
+
const fontStyle = (0, import_get_font_sized.getFontSized)(val, extras);
|
|
81
|
+
return {
|
|
82
|
+
...fontStyle,
|
|
83
|
+
lineHeight: buttonHeight ? extras.tokens.size[buttonHeight] : void 0
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
86
|
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
87
|
+
},
|
|
88
|
+
defaultVariants: {
|
|
89
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
const Label = LabelFrame.styleable(function Label2(props, forwardedRef) {
|
|
93
|
+
const {
|
|
94
|
+
htmlFor,
|
|
95
|
+
id: idProp,
|
|
96
|
+
...labelProps
|
|
97
|
+
} = props;
|
|
98
|
+
const controlRef = React.useRef(null);
|
|
99
|
+
const ref = React.useRef(null);
|
|
100
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
101
|
+
const backupId = React.useId();
|
|
102
|
+
const id = idProp ?? backupId;
|
|
103
|
+
if (import_constants.isWeb) {
|
|
104
|
+
React.useEffect(() => {
|
|
100
105
|
if (htmlFor) {
|
|
101
106
|
const element = document.getElementById(htmlFor);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
const label = ref.current;
|
|
108
|
+
if (label && element) {
|
|
109
|
+
const getAriaLabel = () => element.getAttribute("aria-labelledby");
|
|
110
|
+
const ariaLabelledBy = [id, getAriaLabel()].filter(Boolean).join(" ");
|
|
111
|
+
element.setAttribute("aria-labelledby", ariaLabelledBy);
|
|
112
|
+
controlRef.current = element;
|
|
113
|
+
return () => {
|
|
106
114
|
if (!id) return;
|
|
107
115
|
const ariaLabelledBy2 = getAriaLabel()?.replace(id, "");
|
|
108
|
-
ariaLabelledBy2 === ""
|
|
116
|
+
if (ariaLabelledBy2 === "") {
|
|
117
|
+
element.removeAttribute("aria-labelledby");
|
|
118
|
+
} else if (ariaLabelledBy2) {
|
|
119
|
+
element.setAttribute("aria-labelledby", ariaLabelledBy2);
|
|
120
|
+
}
|
|
109
121
|
};
|
|
110
122
|
}
|
|
111
123
|
}
|
|
112
|
-
}, [id, htmlFor])
|
|
124
|
+
}, [id, htmlFor]);
|
|
125
|
+
}
|
|
126
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(LabelProvider, {
|
|
127
|
+
id,
|
|
128
|
+
controlRef,
|
|
129
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(LabelFrame, {
|
|
113
130
|
id,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
props.onMouseDown?.(event), !event.defaultPrevented && event.detail > 1 && event.preventDefault();
|
|
122
|
-
},
|
|
123
|
-
onPress: event => {
|
|
124
|
-
if (props.onPress?.(event), import_constants.isWeb) {
|
|
125
|
-
if (htmlFor || !controlRef.current || event.defaultPrevented) return;
|
|
126
|
-
const isClickingControl = controlRef.current.contains(event.target),
|
|
127
|
-
isUserClick = event.isTrusted === !0;
|
|
128
|
-
!isClickingControl && isUserClick && (controlRef.current.click(), controlRef.current.focus());
|
|
129
|
-
} else props.htmlFor && (0, import_focusable.focusFocusable)(props.htmlFor);
|
|
131
|
+
htmlFor,
|
|
132
|
+
...labelProps,
|
|
133
|
+
ref: composedRefs,
|
|
134
|
+
onMouseDown: event => {
|
|
135
|
+
props.onMouseDown?.(event);
|
|
136
|
+
if (!event.defaultPrevented && event.detail > 1) {
|
|
137
|
+
event.preventDefault();
|
|
130
138
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
},
|
|
140
|
+
onPress: event => {
|
|
141
|
+
props.onPress?.(event);
|
|
142
|
+
if (import_constants.isWeb) {
|
|
143
|
+
if (htmlFor || !controlRef.current || event.defaultPrevented) return;
|
|
144
|
+
const isClickingControl = controlRef.current.contains(event.target);
|
|
145
|
+
const isUserClick = event.isTrusted === true;
|
|
146
|
+
if (!isClickingControl && isUserClick) {
|
|
147
|
+
controlRef.current.click();
|
|
148
|
+
controlRef.current.focus();
|
|
149
|
+
}
|
|
150
|
+
} else {
|
|
151
|
+
if (props.htmlFor) {
|
|
152
|
+
(0, import_focusable.focusFocusable)(props.htmlFor);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
const useLabelContext = element => {
|
|
160
|
+
const context = useLabelContextImpl("LabelConsumer");
|
|
161
|
+
const {
|
|
162
|
+
controlRef
|
|
163
|
+
} = context;
|
|
164
|
+
React.useEffect(() => {
|
|
165
|
+
if (element) controlRef.current = element;
|
|
166
|
+
}, [element, controlRef]);
|
|
167
|
+
return context.id;
|
|
168
|
+
};
|
package/dist/cjs/Label.native.js
CHANGED
|
@@ -4,33 +4,35 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var Label_exports = {};
|
|
35
37
|
__export(Label_exports, {
|
|
36
38
|
Label: () => Label,
|
|
@@ -38,118 +40,138 @@ __export(Label_exports, {
|
|
|
38
40
|
useLabelContext: () => useLabelContext
|
|
39
41
|
});
|
|
40
42
|
module.exports = __toCommonJS(Label_exports);
|
|
41
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
size: {
|
|
77
|
-
"...size": function (val, extras) {
|
|
78
|
-
var buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras),
|
|
79
|
-
buttonHeight = buttonStyle?.height,
|
|
80
|
-
fontStyle = (0, import_get_font_sized.getFontSized)(val, extras);
|
|
81
|
-
return {
|
|
82
|
-
...fontStyle,
|
|
83
|
-
lineHeight: buttonHeight ? extras.tokens.size[buttonHeight] : void 0
|
|
84
|
-
};
|
|
43
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
44
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
45
|
+
var import_constants = require("@tamagui/constants");
|
|
46
|
+
var import_create_context = require("@tamagui/create-context");
|
|
47
|
+
var import_focusable = require("@tamagui/focusable");
|
|
48
|
+
var import_get_button_sized = require("@tamagui/get-button-sized");
|
|
49
|
+
var import_get_font_sized = require("@tamagui/get-font-sized");
|
|
50
|
+
var import_text = require("@tamagui/text");
|
|
51
|
+
var import_web = require("@tamagui/web");
|
|
52
|
+
var React = __toESM(require("react"), 1);
|
|
53
|
+
var NAME = "Label";
|
|
54
|
+
var [LabelProvider, useLabelContextImpl] = (0, import_create_context.createContext)(NAME, {
|
|
55
|
+
id: void 0,
|
|
56
|
+
controlRef: {
|
|
57
|
+
current: null
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
var LabelFrame = (0, import_web.styled)(import_text.SizableText, {
|
|
61
|
+
name: "Label",
|
|
62
|
+
render: "label",
|
|
63
|
+
variants: {
|
|
64
|
+
unstyled: {
|
|
65
|
+
false: {
|
|
66
|
+
size: "$true",
|
|
67
|
+
color: "$color",
|
|
68
|
+
backgroundColor: "transparent",
|
|
69
|
+
display: "flex",
|
|
70
|
+
alignItems: "center",
|
|
71
|
+
userSelect: "none",
|
|
72
|
+
cursor: "default",
|
|
73
|
+
pressStyle: {
|
|
74
|
+
color: "$colorPress"
|
|
85
75
|
}
|
|
86
76
|
}
|
|
87
77
|
},
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
size: {
|
|
79
|
+
"...size": function (val, extras) {
|
|
80
|
+
var buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras);
|
|
81
|
+
var buttonHeight = buttonStyle === null || buttonStyle === void 0 ? void 0 : buttonStyle.height;
|
|
82
|
+
var fontStyle = (0, import_get_font_sized.getFontSized)(val, extras);
|
|
83
|
+
return {
|
|
84
|
+
...fontStyle,
|
|
85
|
+
lineHeight: buttonHeight ? extras.tokens.size[buttonHeight] : void 0
|
|
86
|
+
};
|
|
87
|
+
}
|
|
90
88
|
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
},
|
|
90
|
+
defaultVariants: {
|
|
91
|
+
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
var Label = LabelFrame.styleable(function Label2(props, forwardedRef) {
|
|
95
|
+
var {
|
|
96
|
+
htmlFor,
|
|
97
|
+
id: idProp,
|
|
98
|
+
...labelProps
|
|
99
|
+
} = props;
|
|
100
|
+
var controlRef = React.useRef(null);
|
|
101
|
+
var ref = React.useRef(null);
|
|
102
|
+
var composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
103
|
+
var backupId = React.useId();
|
|
104
|
+
var id = idProp !== null && idProp !== void 0 ? idProp : backupId;
|
|
105
|
+
if (import_constants.isWeb) {
|
|
106
|
+
React.useEffect(function () {
|
|
104
107
|
if (htmlFor) {
|
|
105
|
-
var element = document.getElementById(htmlFor)
|
|
106
|
-
|
|
108
|
+
var element = document.getElementById(htmlFor);
|
|
109
|
+
var label = ref.current;
|
|
107
110
|
if (label && element) {
|
|
108
111
|
var getAriaLabel = function () {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
return element.getAttribute("aria-labelledby");
|
|
113
|
+
};
|
|
114
|
+
var ariaLabelledBy = [id, getAriaLabel()].filter(Boolean).join(" ");
|
|
115
|
+
element.setAttribute("aria-labelledby", ariaLabelledBy);
|
|
116
|
+
controlRef.current = element;
|
|
117
|
+
return function () {
|
|
113
118
|
var _getAriaLabel;
|
|
114
|
-
if (id)
|
|
115
|
-
|
|
116
|
-
|
|
119
|
+
if (!id) return;
|
|
120
|
+
var ariaLabelledBy2 = (_getAriaLabel = getAriaLabel()) === null || _getAriaLabel === void 0 ? void 0 : _getAriaLabel.replace(id, "");
|
|
121
|
+
if (ariaLabelledBy2 === "") {
|
|
122
|
+
element.removeAttribute("aria-labelledby");
|
|
123
|
+
} else if (ariaLabelledBy2) {
|
|
124
|
+
element.setAttribute("aria-labelledby", ariaLabelledBy2);
|
|
117
125
|
}
|
|
118
126
|
};
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
|
-
}, [id, htmlFor])
|
|
129
|
+
}, [id, htmlFor]);
|
|
130
|
+
}
|
|
131
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(LabelProvider, {
|
|
132
|
+
id,
|
|
133
|
+
controlRef,
|
|
134
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(LabelFrame, {
|
|
122
135
|
id,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
(_props_onMouseDown = props.onMouseDown) === null || _props_onMouseDown === void 0 || _props_onMouseDown.call(props, event), !event.defaultPrevented && event.detail > 1 && event.preventDefault();
|
|
133
|
-
},
|
|
134
|
-
onPress: function (event) {
|
|
135
|
-
var _props_onPress;
|
|
136
|
-
if ((_props_onPress = props.onPress) === null || _props_onPress === void 0 || _props_onPress.call(props, event), import_constants.isWeb) {
|
|
137
|
-
if (htmlFor || !controlRef.current || event.defaultPrevented) return;
|
|
138
|
-
var isClickingControl = controlRef.current.contains(event.target),
|
|
139
|
-
isUserClick = event.isTrusted === !0;
|
|
140
|
-
!isClickingControl && isUserClick && (controlRef.current.click(), controlRef.current.focus());
|
|
141
|
-
} else props.htmlFor && (0, import_focusable.focusFocusable)(props.htmlFor);
|
|
136
|
+
// @ts-ignore
|
|
137
|
+
htmlFor,
|
|
138
|
+
...labelProps,
|
|
139
|
+
ref: composedRefs,
|
|
140
|
+
onMouseDown: function (event) {
|
|
141
|
+
var _props_onMouseDown;
|
|
142
|
+
(_props_onMouseDown = props.onMouseDown) === null || _props_onMouseDown === void 0 ? void 0 : _props_onMouseDown.call(props, event);
|
|
143
|
+
if (!event.defaultPrevented && event.detail > 1) {
|
|
144
|
+
event.preventDefault();
|
|
142
145
|
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
146
|
+
},
|
|
147
|
+
onPress: function (event) {
|
|
148
|
+
var _props_onPress;
|
|
149
|
+
(_props_onPress = props.onPress) === null || _props_onPress === void 0 ? void 0 : _props_onPress.call(props, event);
|
|
150
|
+
if (import_constants.isWeb) {
|
|
151
|
+
if (htmlFor || !controlRef.current || event.defaultPrevented) return;
|
|
152
|
+
var isClickingControl = controlRef.current.contains(event.target);
|
|
153
|
+
var isUserClick = event.isTrusted === true;
|
|
154
|
+
if (!isClickingControl && isUserClick) {
|
|
155
|
+
controlRef.current.click();
|
|
156
|
+
controlRef.current.focus();
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
if (props.htmlFor) {
|
|
160
|
+
(0, import_focusable.focusFocusable)(props.htmlFor);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
var useLabelContext = function (element) {
|
|
168
|
+
var context = useLabelContextImpl("LabelConsumer");
|
|
169
|
+
var {
|
|
170
|
+
controlRef
|
|
171
|
+
} = context;
|
|
172
|
+
React.useEffect(function () {
|
|
173
|
+
if (element) controlRef.current = element;
|
|
174
|
+
}, [element, controlRef]);
|
|
175
|
+
return context.id;
|
|
176
|
+
};
|
|
155
177
|
//# sourceMappingURL=Label.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Label_exports","__export","Label","LabelFrame","useLabelContext","module","exports","import_jsx_runtime","require","import_compose_refs","import_constants","import_create_context","import_focusable","import_get_button_sized","import_get_font_sized","import_text","import_web","React","__toESM","NAME","LabelProvider","useLabelContextImpl","createContext","id","controlRef","current","styled","SizableText","name","render","variants","unstyled","false","size","color","backgroundColor","display","alignItems","userSelect","cursor","pressStyle","...size","val","extras","buttonStyle","getButtonSized","buttonHeight","height","fontStyle","getFontSized","lineHeight","tokens","defaultVariants","process","env","TAMAGUI_HEADLESS","styleable","props","forwardedRef","htmlFor","idProp","labelProps","useRef","ref","composedRefs","useComposedRefs","backupId","useId","isWeb","useEffect","element","document","getElementById","label","getAriaLabel","getAttribute","ariaLabelledBy","filter","Boolean","join","setAttribute","_getAriaLabel","ariaLabelledBy2","replace","removeAttribute","jsx","children","onMouseDown","event","_props_onMouseDown","call","defaultPrevented","detail","preventDefault","onPress","_props_onPress"],"sources":["../../src/Label.tsx"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","Label_exports","__export","Label","LabelFrame","useLabelContext","module","exports","import_jsx_runtime","require","import_compose_refs","import_constants","import_create_context","import_focusable","import_get_button_sized","import_get_font_sized","import_text","import_web","React","__toESM","NAME","LabelProvider","useLabelContextImpl","createContext","id","controlRef","current","styled","SizableText","name","render","variants","unstyled","false","size","color","backgroundColor","display","alignItems","userSelect","cursor","pressStyle","...size","val","extras","buttonStyle","getButtonSized","buttonHeight","height","fontStyle","getFontSized","lineHeight","tokens","defaultVariants","process","env","TAMAGUI_HEADLESS","styleable","Label2","props","forwardedRef","htmlFor","idProp","labelProps","useRef","ref","composedRefs","useComposedRefs","backupId","useId","isWeb","useEffect","element","document","getElementById","label","getAriaLabel","getAttribute","ariaLabelledBy","filter","Boolean","join","setAttribute","_getAriaLabel","ariaLabelledBy2","replace","removeAttribute","jsx","children","onMouseDown","event","_props_onMouseDown","call","defaultPrevented","detail","preventDefault","onPress","_props_onPress","isClickingControl","contains","target","isUserClick","isTrusted","click","focus","focusFocusable"],"s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IAAAT,OAAA,KAAApC,UAAA,CAAAC,OAAA,IAAAgE,KAAA,CAAAG,gBAAA;UAEH,IAAAK,iBAAA,GAAAzE,UAAA,CAAAC,OAAA,CAAAyE,QAAA,CAAAT,KAAA,CAAAU,MAAA;UAEY,IAAAC,WAAmB,GAAAX,KAAA,CAAAY,SAAiC;UACzD,KAAAJ,iBAAU,IAAAG,WAAoB;YAC5B5E,UAAW,CAAAC,OAAI,CAAA6E,KAAA;YAEjB9E,UAAU,CAAAC,OAAM,CAAA8E,KAAA;UAChB;QACF,OAAS;UAEN,IAAA7C,KAAQ,CAAAE,OAAA;YACjB,IAAAhD,gBAAA,CAAA4F,cAAA,EAAA9C,KAAA,CAAAE,OAAA","ignoreList":[]}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,15 +3,17 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
7
8
|
get: () => from[key],
|
|
8
9
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
10
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
15
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
-
value:
|
|
16
|
+
value: true
|
|
15
17
|
}), mod);
|
|
16
18
|
var index_exports = {};
|
|
17
19
|
module.exports = __toCommonJS(index_exports);
|