@tamagui/label 1.89.26 → 1.89.27-1708113113238
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.native.js +168 -56
- package/dist/cjs/Label.native.js.map +3 -3
- package/dist/cjs/index.native.js.map +2 -2
- package/dist/esm/Label.native.js +167 -56
- package/dist/esm/Label.native.js.map +3 -3
- package/dist/esm/index.native.js.map +1 -1
- package/dist/jsx/Label.native.js +167 -56
- package/dist/jsx/Label.native.js.map +3 -3
- package/dist/jsx/index.native.js.map +1 -1
- package/package.json +11 -11
package/dist/cjs/Label.native.js
CHANGED
|
@@ -28,11 +28,113 @@ __export(Label_exports, {
|
|
|
28
28
|
useLabelContext: () => useLabelContext
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(Label_exports);
|
|
31
|
-
var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_create_context = require("@tamagui/create-context"), import_focusable = require("@tamagui/focusable"), import_get_button_sized = require("@tamagui/get-button-sized"), import_get_font_sized = require("@tamagui/get-font-sized"), import_text = require("@tamagui/text"), import_web = require("@tamagui/web"), React = __toESM(require("react"))
|
|
32
|
-
|
|
31
|
+
var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_create_context = require("@tamagui/create-context"), import_focusable = require("@tamagui/focusable"), import_get_button_sized = require("@tamagui/get-button-sized"), import_get_font_sized = require("@tamagui/get-font-sized"), import_text = require("@tamagui/text"), import_web = require("@tamagui/web"), React = __toESM(require("react"));
|
|
32
|
+
function _array_like_to_array(arr, len) {
|
|
33
|
+
(len == null || len > arr.length) && (len = arr.length);
|
|
34
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
35
|
+
arr2[i] = arr[i];
|
|
36
|
+
return arr2;
|
|
37
|
+
}
|
|
38
|
+
function _array_with_holes(arr) {
|
|
39
|
+
if (Array.isArray(arr))
|
|
40
|
+
return arr;
|
|
41
|
+
}
|
|
42
|
+
function _define_property(obj, key, value) {
|
|
43
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
44
|
+
value,
|
|
45
|
+
enumerable: !0,
|
|
46
|
+
configurable: !0,
|
|
47
|
+
writable: !0
|
|
48
|
+
}) : obj[key] = value, obj;
|
|
49
|
+
}
|
|
50
|
+
function _iterable_to_array_limit(arr, i) {
|
|
51
|
+
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
52
|
+
if (_i != null) {
|
|
53
|
+
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
54
|
+
try {
|
|
55
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
56
|
+
;
|
|
57
|
+
} catch (err) {
|
|
58
|
+
_d = !0, _e = err;
|
|
59
|
+
} finally {
|
|
60
|
+
try {
|
|
61
|
+
!_n && _i.return != null && _i.return();
|
|
62
|
+
} finally {
|
|
63
|
+
if (_d)
|
|
64
|
+
throw _e;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return _arr;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function _non_iterable_rest() {
|
|
71
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
72
|
+
}
|
|
73
|
+
function _object_spread(target) {
|
|
74
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
75
|
+
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
76
|
+
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
77
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
78
|
+
}))), ownKeys2.forEach(function(key) {
|
|
79
|
+
_define_property(target, key, source[key]);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return target;
|
|
83
|
+
}
|
|
84
|
+
function ownKeys(object, enumerableOnly) {
|
|
85
|
+
var keys = Object.keys(object);
|
|
86
|
+
if (Object.getOwnPropertySymbols) {
|
|
87
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
88
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
89
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
90
|
+
})), keys.push.apply(keys, symbols);
|
|
91
|
+
}
|
|
92
|
+
return keys;
|
|
93
|
+
}
|
|
94
|
+
function _object_spread_props(target, source) {
|
|
95
|
+
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
96
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
97
|
+
}), target;
|
|
98
|
+
}
|
|
99
|
+
function _object_without_properties(source, excluded) {
|
|
100
|
+
if (source == null)
|
|
101
|
+
return {};
|
|
102
|
+
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
103
|
+
if (Object.getOwnPropertySymbols) {
|
|
104
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
105
|
+
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
106
|
+
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
107
|
+
}
|
|
108
|
+
return target;
|
|
109
|
+
}
|
|
110
|
+
function _object_without_properties_loose(source, excluded) {
|
|
111
|
+
if (source == null)
|
|
112
|
+
return {};
|
|
113
|
+
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
114
|
+
for (i = 0; i < sourceKeys.length; i++)
|
|
115
|
+
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
116
|
+
return target;
|
|
117
|
+
}
|
|
118
|
+
function _sliced_to_array(arr, i) {
|
|
119
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
120
|
+
}
|
|
121
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
122
|
+
if (o) {
|
|
123
|
+
if (typeof o == "string")
|
|
124
|
+
return _array_like_to_array(o, minLen);
|
|
125
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
126
|
+
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
|
|
127
|
+
return Array.from(n);
|
|
128
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
129
|
+
return _array_like_to_array(o, minLen);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
var NAME = "Label", _createContext = _sliced_to_array((0, import_create_context.createContext)(NAME, {
|
|
33
133
|
id: void 0,
|
|
34
|
-
controlRef: {
|
|
35
|
-
|
|
134
|
+
controlRef: {
|
|
135
|
+
current: null
|
|
136
|
+
}
|
|
137
|
+
}), 2), LabelProvider = _createContext[0], useLabelContextImpl = _createContext[1], LabelFrame = (0, import_web.styled)(import_text.SizableText, {
|
|
36
138
|
name: "Label",
|
|
37
139
|
tag: "label",
|
|
38
140
|
variants: {
|
|
@@ -51,70 +153,80 @@ const NAME = "Label", [LabelProvider, useLabelContextImpl] = (0, import_create_c
|
|
|
51
153
|
}
|
|
52
154
|
},
|
|
53
155
|
size: {
|
|
54
|
-
"...size": (val, extras)
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
...(0, import_get_font_sized.getFontSized)(val, extras),
|
|
156
|
+
"...size": function(val, extras) {
|
|
157
|
+
var buttonStyle = (0, import_get_button_sized.getButtonSized)(val, extras), buttonHeight = buttonStyle == null ? void 0 : buttonStyle.height, fontStyle = (0, import_get_font_sized.getFontSized)(val, extras);
|
|
158
|
+
return _object_spread_props(_object_spread({}, fontStyle), {
|
|
58
159
|
lineHeight: buttonHeight ? extras.tokens.size[buttonHeight] : void 0
|
|
59
|
-
};
|
|
160
|
+
});
|
|
60
161
|
}
|
|
61
162
|
}
|
|
62
163
|
},
|
|
63
164
|
defaultVariants: {
|
|
64
165
|
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
65
166
|
}
|
|
66
|
-
}), LabelComponent = React.forwardRef(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
167
|
+
}), LabelComponent = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
168
|
+
var htmlFor = props.htmlFor, idProp = props.id, labelProps = _object_without_properties(props, [
|
|
169
|
+
"htmlFor",
|
|
170
|
+
"id"
|
|
171
|
+
]), controlRef = React.useRef(null), ref = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref), backupId = React.useId(), id = idProp ?? backupId;
|
|
172
|
+
return import_constants.isWeb && React.useEffect(function() {
|
|
173
|
+
if (htmlFor) {
|
|
174
|
+
var element = document.getElementById(htmlFor), label = ref.current;
|
|
175
|
+
if (label && element) {
|
|
176
|
+
var getAriaLabel = function() {
|
|
177
|
+
return element.getAttribute("aria-labelledby");
|
|
178
|
+
}, ariaLabelledBy = [
|
|
179
|
+
id,
|
|
180
|
+
getAriaLabel()
|
|
181
|
+
].filter(Boolean).join(" ");
|
|
182
|
+
return element.setAttribute("aria-labelledby", ariaLabelledBy), controlRef.current = element, function() {
|
|
183
|
+
var _getAriaLabel;
|
|
184
|
+
if (id) {
|
|
185
|
+
var ariaLabelledBy2 = (_getAriaLabel = getAriaLabel()) === null || _getAriaLabel === void 0 ? void 0 : _getAriaLabel.replace(id, "");
|
|
79
186
|
ariaLabelledBy2 === "" ? element.removeAttribute("aria-labelledby") : ariaLabelledBy2 && element.setAttribute("aria-labelledby", ariaLabelledBy2);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}, [id, htmlFor]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabelProvider, { id, controlRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
84
|
-
LabelFrame,
|
|
85
|
-
{
|
|
86
|
-
id,
|
|
87
|
-
htmlFor,
|
|
88
|
-
...labelProps,
|
|
89
|
-
ref: composedRefs,
|
|
90
|
-
onMouseDown: (event) => {
|
|
91
|
-
var _a;
|
|
92
|
-
(_a = props.onMouseDown) == null || _a.call(props, event), !event.defaultPrevented && event.detail > 1 && event.preventDefault();
|
|
93
|
-
},
|
|
94
|
-
onPress: (event) => {
|
|
95
|
-
var _a;
|
|
96
|
-
if ((_a = props.onPress) == null || _a.call(props, event), import_constants.isWeb) {
|
|
97
|
-
if (htmlFor || !controlRef.current || event.defaultPrevented)
|
|
98
|
-
return;
|
|
99
|
-
const isClickingControl = controlRef.current.contains(
|
|
100
|
-
event.target
|
|
101
|
-
), isUserClick = event.isTrusted === !0;
|
|
102
|
-
!isClickingControl && isUserClick && (controlRef.current.click(), controlRef.current.focus());
|
|
103
|
-
} else
|
|
104
|
-
props.htmlFor && (0, import_focusable.focusFocusable)(props.htmlFor);
|
|
105
|
-
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
106
189
|
}
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
190
|
+
}
|
|
191
|
+
}, [
|
|
192
|
+
id,
|
|
193
|
+
htmlFor
|
|
194
|
+
]), /* @__PURE__ */ React.createElement(LabelProvider, {
|
|
195
|
+
id,
|
|
196
|
+
controlRef
|
|
197
|
+
}, /* @__PURE__ */ React.createElement(LabelFrame, _object_spread_props(_object_spread({
|
|
198
|
+
id,
|
|
199
|
+
// @ts-ignore
|
|
200
|
+
htmlFor
|
|
201
|
+
}, labelProps), {
|
|
202
|
+
ref: composedRefs,
|
|
203
|
+
onMouseDown: function(event) {
|
|
204
|
+
var _props_onMouseDown;
|
|
205
|
+
(_props_onMouseDown = props.onMouseDown) === null || _props_onMouseDown === void 0 || _props_onMouseDown.call(props, event), !event.defaultPrevented && event.detail > 1 && event.preventDefault();
|
|
206
|
+
},
|
|
207
|
+
onPress: function(event) {
|
|
208
|
+
var _props_onPress;
|
|
209
|
+
if ((_props_onPress = props.onPress) === null || _props_onPress === void 0 || _props_onPress.call(props, event), import_constants.isWeb) {
|
|
210
|
+
if (htmlFor || !controlRef.current || event.defaultPrevented)
|
|
211
|
+
return;
|
|
212
|
+
var isClickingControl = controlRef.current.contains(event.target), isUserClick = event.isTrusted === !0;
|
|
213
|
+
!isClickingControl && isUserClick && (controlRef.current.click(), controlRef.current.focus());
|
|
214
|
+
} else
|
|
215
|
+
props.htmlFor && (0, import_focusable.focusFocusable)(props.htmlFor);
|
|
216
|
+
}
|
|
217
|
+
})));
|
|
218
|
+
});
|
|
110
219
|
LabelComponent.displayName = NAME;
|
|
111
|
-
|
|
220
|
+
var Label = LabelFrame.extractable((0, import_web.themeable)(LabelComponent), {
|
|
112
221
|
neverFlatten: !0
|
|
113
|
-
}), useLabelContext = (element)
|
|
114
|
-
|
|
115
|
-
return React.useEffect(()
|
|
222
|
+
}), useLabelContext = function(element) {
|
|
223
|
+
var context = useLabelContextImpl("LabelConsumer"), controlRef = context.controlRef;
|
|
224
|
+
return React.useEffect(function() {
|
|
116
225
|
element && (controlRef.current = element);
|
|
117
|
-
}, [
|
|
226
|
+
}, [
|
|
227
|
+
element,
|
|
228
|
+
controlRef
|
|
229
|
+
]), context.id;
|
|
118
230
|
};
|
|
119
231
|
// Annotate the CommonJS export names for ESM import in node:
|
|
120
232
|
0 && (module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/Label.tsx"],
|
|
4
|
-
"mappings": "
|
|
5
|
-
"names": ["ariaLabelledBy"]
|
|
3
|
+
"sources": ["../../src/Users/n8/tamagui/packages/label/src/Label.tsx"],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aAAO,QAAb/B,mBAAAA,UAAAA,eAAAA,KAAAA,OAAgB2B,KAAAA,GAEZhB,wBAAO;AACT,YAAIT,WAAW,CAACvC,WAAWC,WAAW+D,MAAMC;AAAkB;AAC9D,YAAMI,oBAAoBrE,WAAWC,QAAQqE,SAC3CN,MAAMO,MAAM,GAIRC,cAAcR,MAAMS,cAAc;AAMxC,QAAI,CAACJ,qBAAqBG,gBACxBxE,WAAWC,QAAQyE,MAAK,GACxB1E,WAAWC,QAAQ0E,MAAK;MAE5B;AACE,QAAItC,MAAME,eACRqC,iCAAevC,MAAME,OAAO;IAGlC;;AAIR,CAAA;AAGFL,eAAe2C,cAAcjF;AAEtB,IAAMkF,QACX1E,WAAW2E,gBAAYC,sBAAU9C,cAAAA,GAA+B;EAC9D+C,cAAc;AAChB,CAAA,GAEWC,kBAAkB,SAAChC,SAAAA;AAC9B,MAAMiC,UAAUhF,oBAAoB,eAAA,GAC5BH,aAAemF,QAAfnF;AAERmC,eAAMc,UAAU,WAAA;AACd,IAAIC,YAASlD,WAAWC,UAAUiD;EACpC,GAAG;IAACA;IAASlD;GAAW,GAEjBmF,QAAQrF;AACjB;",
|
|
5
|
+
"names": ["NAME", "createContext", "id", "undefined", "controlRef", "current", "LabelProvider", "useLabelContextImpl", "LabelFrame", "styled", "SizableText", "name", "tag", "variants", "unstyled", "false", "size", "color", "backgroundColor", "display", "alignItems", "userSelect", "cursor", "pressStyle", "val", "extras", "buttonStyle", "getButtonSized", "buttonHeight", "height", "fontStyle", "getFontSized", "lineHeight", "tokens", "defaultVariants", "process", "env", "TAMAGUI_HEADLESS", "LabelComponent", "React", "forwardRef", "props", "forwardedRef", "htmlFor", "idProp", "labelProps", "useRef", "ref", "composedRefs", "useComposedRefs", "backupId", "useId", "isWeb", "useEffect", "element", "document", "getElementById", "label", "getAriaLabel", "getAttribute", "ariaLabelledBy", "filter", "Boolean", "join", "setAttribute", "replace", "removeAttribute", "onMouseDown", "event", "defaultPrevented", "detail", "preventDefault", "onPress", "isClickingControl", "contains", "target", "isUserClick", "isTrusted", "click", "focus", "focusFocusable", "displayName", "Label", "extractable", "themeable", "neverFlatten", "useLabelContext", "context"]
|
|
6
6
|
}
|
package/dist/esm/Label.native.js
CHANGED
|
@@ -7,11 +7,112 @@ import { getFontSized } from "@tamagui/get-font-sized";
|
|
|
7
7
|
import { SizableText } from "@tamagui/text";
|
|
8
8
|
import { styled, themeable } from "@tamagui/web";
|
|
9
9
|
import * as React from "react";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
function _array_like_to_array(arr, len) {
|
|
11
|
+
(len == null || len > arr.length) && (len = arr.length);
|
|
12
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
13
|
+
arr2[i] = arr[i];
|
|
14
|
+
return arr2;
|
|
15
|
+
}
|
|
16
|
+
function _array_with_holes(arr) {
|
|
17
|
+
if (Array.isArray(arr))
|
|
18
|
+
return arr;
|
|
19
|
+
}
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
22
|
+
value,
|
|
23
|
+
enumerable: !0,
|
|
24
|
+
configurable: !0,
|
|
25
|
+
writable: !0
|
|
26
|
+
}) : obj[key] = value, obj;
|
|
27
|
+
}
|
|
28
|
+
function _iterable_to_array_limit(arr, i) {
|
|
29
|
+
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
30
|
+
if (_i != null) {
|
|
31
|
+
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
32
|
+
try {
|
|
33
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
34
|
+
;
|
|
35
|
+
} catch (err) {
|
|
36
|
+
_d = !0, _e = err;
|
|
37
|
+
} finally {
|
|
38
|
+
try {
|
|
39
|
+
!_n && _i.return != null && _i.return();
|
|
40
|
+
} finally {
|
|
41
|
+
if (_d)
|
|
42
|
+
throw _e;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return _arr;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function _non_iterable_rest() {
|
|
49
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50
|
+
}
|
|
51
|
+
function _object_spread(target) {
|
|
52
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
53
|
+
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
54
|
+
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
55
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
56
|
+
}))), ownKeys2.forEach(function(key) {
|
|
57
|
+
_define_property(target, key, source[key]);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return target;
|
|
61
|
+
}
|
|
62
|
+
function ownKeys(object, enumerableOnly) {
|
|
63
|
+
var keys = Object.keys(object);
|
|
64
|
+
if (Object.getOwnPropertySymbols) {
|
|
65
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
66
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
67
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
68
|
+
})), keys.push.apply(keys, symbols);
|
|
69
|
+
}
|
|
70
|
+
return keys;
|
|
71
|
+
}
|
|
72
|
+
function _object_spread_props(target, source) {
|
|
73
|
+
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
74
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
75
|
+
}), target;
|
|
76
|
+
}
|
|
77
|
+
function _object_without_properties(source, excluded) {
|
|
78
|
+
if (source == null)
|
|
79
|
+
return {};
|
|
80
|
+
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
81
|
+
if (Object.getOwnPropertySymbols) {
|
|
82
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
83
|
+
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
84
|
+
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
function _object_without_properties_loose(source, excluded) {
|
|
89
|
+
if (source == null)
|
|
90
|
+
return {};
|
|
91
|
+
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
92
|
+
for (i = 0; i < sourceKeys.length; i++)
|
|
93
|
+
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
94
|
+
return target;
|
|
95
|
+
}
|
|
96
|
+
function _sliced_to_array(arr, i) {
|
|
97
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
98
|
+
}
|
|
99
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
100
|
+
if (o) {
|
|
101
|
+
if (typeof o == "string")
|
|
102
|
+
return _array_like_to_array(o, minLen);
|
|
103
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
104
|
+
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
|
|
105
|
+
return Array.from(n);
|
|
106
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
107
|
+
return _array_like_to_array(o, minLen);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
var NAME = "Label", _createContext = _sliced_to_array(createContext(NAME, {
|
|
12
111
|
id: void 0,
|
|
13
|
-
controlRef: {
|
|
14
|
-
|
|
112
|
+
controlRef: {
|
|
113
|
+
current: null
|
|
114
|
+
}
|
|
115
|
+
}), 2), LabelProvider = _createContext[0], useLabelContextImpl = _createContext[1], LabelFrame = styled(SizableText, {
|
|
15
116
|
name: "Label",
|
|
16
117
|
tag: "label",
|
|
17
118
|
variants: {
|
|
@@ -30,70 +131,80 @@ const NAME = "Label", [LabelProvider, useLabelContextImpl] = createContext(NAME,
|
|
|
30
131
|
}
|
|
31
132
|
},
|
|
32
133
|
size: {
|
|
33
|
-
"...size": (val, extras)
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
...getFontSized(val, extras),
|
|
134
|
+
"...size": function(val, extras) {
|
|
135
|
+
var buttonStyle = getButtonSized(val, extras), buttonHeight = buttonStyle == null ? void 0 : buttonStyle.height, fontStyle = getFontSized(val, extras);
|
|
136
|
+
return _object_spread_props(_object_spread({}, fontStyle), {
|
|
37
137
|
lineHeight: buttonHeight ? extras.tokens.size[buttonHeight] : void 0
|
|
38
|
-
};
|
|
138
|
+
});
|
|
39
139
|
}
|
|
40
140
|
}
|
|
41
141
|
},
|
|
42
142
|
defaultVariants: {
|
|
43
143
|
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
44
144
|
}
|
|
45
|
-
}), LabelComponent = React.forwardRef(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
145
|
+
}), LabelComponent = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
146
|
+
var htmlFor = props.htmlFor, idProp = props.id, labelProps = _object_without_properties(props, [
|
|
147
|
+
"htmlFor",
|
|
148
|
+
"id"
|
|
149
|
+
]), controlRef = React.useRef(null), ref = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, ref), backupId = React.useId(), id = idProp ?? backupId;
|
|
150
|
+
return isWeb && React.useEffect(function() {
|
|
151
|
+
if (htmlFor) {
|
|
152
|
+
var element = document.getElementById(htmlFor), label = ref.current;
|
|
153
|
+
if (label && element) {
|
|
154
|
+
var getAriaLabel = function() {
|
|
155
|
+
return element.getAttribute("aria-labelledby");
|
|
156
|
+
}, ariaLabelledBy = [
|
|
157
|
+
id,
|
|
158
|
+
getAriaLabel()
|
|
159
|
+
].filter(Boolean).join(" ");
|
|
160
|
+
return element.setAttribute("aria-labelledby", ariaLabelledBy), controlRef.current = element, function() {
|
|
161
|
+
var _getAriaLabel;
|
|
162
|
+
if (id) {
|
|
163
|
+
var ariaLabelledBy2 = (_getAriaLabel = getAriaLabel()) === null || _getAriaLabel === void 0 ? void 0 : _getAriaLabel.replace(id, "");
|
|
58
164
|
ariaLabelledBy2 === "" ? element.removeAttribute("aria-labelledby") : ariaLabelledBy2 && element.setAttribute("aria-labelledby", ariaLabelledBy2);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}, [id, htmlFor]), /* @__PURE__ */ jsx(LabelProvider, { id, controlRef, children: /* @__PURE__ */ jsx(
|
|
63
|
-
LabelFrame,
|
|
64
|
-
{
|
|
65
|
-
id,
|
|
66
|
-
htmlFor,
|
|
67
|
-
...labelProps,
|
|
68
|
-
ref: composedRefs,
|
|
69
|
-
onMouseDown: (event) => {
|
|
70
|
-
var _a;
|
|
71
|
-
(_a = props.onMouseDown) == null || _a.call(props, event), !event.defaultPrevented && event.detail > 1 && event.preventDefault();
|
|
72
|
-
},
|
|
73
|
-
onPress: (event) => {
|
|
74
|
-
var _a;
|
|
75
|
-
if ((_a = props.onPress) == null || _a.call(props, event), isWeb) {
|
|
76
|
-
if (htmlFor || !controlRef.current || event.defaultPrevented)
|
|
77
|
-
return;
|
|
78
|
-
const isClickingControl = controlRef.current.contains(
|
|
79
|
-
event.target
|
|
80
|
-
), isUserClick = event.isTrusted === !0;
|
|
81
|
-
!isClickingControl && isUserClick && (controlRef.current.click(), controlRef.current.focus());
|
|
82
|
-
} else
|
|
83
|
-
props.htmlFor && focusFocusable(props.htmlFor);
|
|
84
|
-
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
85
167
|
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
168
|
+
}
|
|
169
|
+
}, [
|
|
170
|
+
id,
|
|
171
|
+
htmlFor
|
|
172
|
+
]), /* @__PURE__ */ React.createElement(LabelProvider, {
|
|
173
|
+
id,
|
|
174
|
+
controlRef
|
|
175
|
+
}, /* @__PURE__ */ React.createElement(LabelFrame, _object_spread_props(_object_spread({
|
|
176
|
+
id,
|
|
177
|
+
// @ts-ignore
|
|
178
|
+
htmlFor
|
|
179
|
+
}, labelProps), {
|
|
180
|
+
ref: composedRefs,
|
|
181
|
+
onMouseDown: function(event) {
|
|
182
|
+
var _props_onMouseDown;
|
|
183
|
+
(_props_onMouseDown = props.onMouseDown) === null || _props_onMouseDown === void 0 || _props_onMouseDown.call(props, event), !event.defaultPrevented && event.detail > 1 && event.preventDefault();
|
|
184
|
+
},
|
|
185
|
+
onPress: function(event) {
|
|
186
|
+
var _props_onPress;
|
|
187
|
+
if ((_props_onPress = props.onPress) === null || _props_onPress === void 0 || _props_onPress.call(props, event), isWeb) {
|
|
188
|
+
if (htmlFor || !controlRef.current || event.defaultPrevented)
|
|
189
|
+
return;
|
|
190
|
+
var isClickingControl = controlRef.current.contains(event.target), isUserClick = event.isTrusted === !0;
|
|
191
|
+
!isClickingControl && isUserClick && (controlRef.current.click(), controlRef.current.focus());
|
|
192
|
+
} else
|
|
193
|
+
props.htmlFor && focusFocusable(props.htmlFor);
|
|
194
|
+
}
|
|
195
|
+
})));
|
|
196
|
+
});
|
|
89
197
|
LabelComponent.displayName = NAME;
|
|
90
|
-
|
|
198
|
+
var Label = LabelFrame.extractable(themeable(LabelComponent), {
|
|
91
199
|
neverFlatten: !0
|
|
92
|
-
}), useLabelContext = (element)
|
|
93
|
-
|
|
94
|
-
return React.useEffect(()
|
|
200
|
+
}), useLabelContext = function(element) {
|
|
201
|
+
var context = useLabelContextImpl("LabelConsumer"), controlRef = context.controlRef;
|
|
202
|
+
return React.useEffect(function() {
|
|
95
203
|
element && (controlRef.current = element);
|
|
96
|
-
}, [
|
|
204
|
+
}, [
|
|
205
|
+
element,
|
|
206
|
+
controlRef
|
|
207
|
+
]), context.id;
|
|
97
208
|
};
|
|
98
209
|
export {
|
|
99
210
|
Label,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/Label.tsx"],
|
|
4
|
-
"mappings": "AAAA,
|
|
5
|
-
"names": ["ariaLabelledBy"]
|
|
3
|
+
"sources": ["../../src/Users/n8/tamagui/packages/label/src/Label.tsx"],
|
|
4
|
+
"mappings": "AAAA,SAASA,uBAAuB;AAChC,SAASC,aAAa;AACtB,SAASC,qBAAqB;AAC9B,SAASC,sBAAsB;AAC/B,SAASC,sBAAsB;AAC/B,SAASC,oBAAoB;AAC7B,SAASC,mBAAmB;AAE5B,SAASC,QAAQC,iBAAiB;AAClC,YAAYC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvB,IAAMC,OAAO,SAOgCR,iBAAAA,iBAAAA,cAAiCQ,MAAM;EAClFC,IAAIC;EACJC,YAAY;IAAEC,SAAS;EAAK;AAC9B,CAAA,GAAA,CAAA,GAHOC,gBAAsCb,eAAAA,CAAAA,GAAvBc,sBAAuBd,eAAAA,CAAAA,GAKhCe,aAAaV,OAAOD,aAAa;EAC5CY,MAAM;EACNC,KAAK;EAELC,UAAU;IACRC,UAAU;MACRC,OAAO;QACLC,MAAM;QACNC,OAAO;QACPC,iBAAiB;QACjBC,SAAS;QACTC,YAAY;QACZC,YAAY;QACZC,QAAQ;QACRC,YAAY;UACVN,OAAO;QACT;MACF;IACF;IAEAD,MAAM;MACJ,WAAW,SAACQ,KAAKC,QAAAA;AACf,YAAMC,cAAc7B,eAAe2B,KAAKC,MAAAA,GAClCE,eAAe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GAIhB,sBAAA,cAAChC,eAAAA;IAAcJ;IAAQE;KACrB,sBAAA,cAACI,YAAAA,qBAAAA,eAAAA;IACCN;;IAEAoC;KACIE,UAAAA,GAAAA;IACJE,KAAKC;IACLiB,aAAa,SAACC,OAAAA;UACZzB;OAAAA,qBAAAA,MAAMwB,iBAAW,QAAjBxB,uBAAAA,UAAAA,mBAAAA,KAAAA,OAAoByB,KAAAA,GAEhB,CAACA,MAAMC,oBAAoBD,MAAME,SAAS,KAC5CF,MAAMG,eAAc;IAExB;IACAC,SAAS,SAACJ,OAAAA;UACRzB;AAEA,WAFAA,iBAAAA,MAAM6B,aAAO,QAAb7B,mBAAAA,UAAAA,eAAAA,KAAAA,OAAgByB,KAAAA,GAEZrE,OAAO;AACT,YAAI8C,WAAW,CAAClC,WAAWC,WAAWwD,MAAMC;AAAkB;AAC9D,YAAMI,oBAAoB9D,WAAWC,QAAQ8D,SAC3CN,MAAMO,MAAM,GAIRC,cAAcR,MAAMS,cAAc;AAMxC,QAAI,CAACJ,qBAAqBG,gBACxBjE,WAAWC,QAAQkE,MAAK,GACxBnE,WAAWC,QAAQmE,MAAK;MAE5B;AACE,QAAIpC,MAAME,WACR5C,eAAe0C,MAAME,OAAO;IAGlC;;AAIR,CAAA;AAGFJ,eAAeuC,cAAcxE;AAEtB,IAAMyE,QACXlE,WAAWmE,YAAY5E,UAAUmC,cAAAA,GAA+B;EAC9D0C,cAAc;AAChB,CAAA,GAEWC,kBAAkB,SAAC9B,SAAAA;AAC9B,MAAM+B,UAAUvE,oBAAoB,eAAA,GAC5BH,aAAe0E,QAAf1E;AAERJ,eAAM8C,UAAU,WAAA;AACd,IAAIC,YAAS3C,WAAWC,UAAU0C;EACpC,GAAG;IAACA;IAAS3C;GAAW,GAEjB0E,QAAQ5E;AACjB;",
|
|
5
|
+
"names": ["useComposedRefs", "isWeb", "createContext", "focusFocusable", "getButtonSized", "getFontSized", "SizableText", "styled", "themeable", "React", "NAME", "id", "undefined", "controlRef", "current", "LabelProvider", "useLabelContextImpl", "LabelFrame", "name", "tag", "variants", "unstyled", "false", "size", "color", "backgroundColor", "display", "alignItems", "userSelect", "cursor", "pressStyle", "val", "extras", "buttonStyle", "buttonHeight", "height", "fontStyle", "lineHeight", "tokens", "defaultVariants", "process", "env", "TAMAGUI_HEADLESS", "LabelComponent", "forwardRef", "props", "forwardedRef", "htmlFor", "idProp", "labelProps", "useRef", "ref", "composedRefs", "backupId", "useId", "useEffect", "element", "document", "getElementById", "label", "getAriaLabel", "getAttribute", "ariaLabelledBy", "filter", "Boolean", "join", "setAttribute", "replace", "removeAttribute", "onMouseDown", "event", "defaultPrevented", "detail", "preventDefault", "onPress", "isClickingControl", "contains", "target", "isUserClick", "isTrusted", "click", "focus", "displayName", "Label", "extractable", "neverFlatten", "useLabelContext", "context"]
|
|
6
6
|
}
|
package/dist/jsx/Label.native.js
CHANGED
|
@@ -7,11 +7,112 @@ import { getFontSized } from "@tamagui/get-font-sized";
|
|
|
7
7
|
import { SizableText } from "@tamagui/text";
|
|
8
8
|
import { styled, themeable } from "@tamagui/web";
|
|
9
9
|
import * as React from "react";
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
function _array_like_to_array(arr, len) {
|
|
11
|
+
(len == null || len > arr.length) && (len = arr.length);
|
|
12
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
13
|
+
arr2[i] = arr[i];
|
|
14
|
+
return arr2;
|
|
15
|
+
}
|
|
16
|
+
function _array_with_holes(arr) {
|
|
17
|
+
if (Array.isArray(arr))
|
|
18
|
+
return arr;
|
|
19
|
+
}
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
22
|
+
value,
|
|
23
|
+
enumerable: !0,
|
|
24
|
+
configurable: !0,
|
|
25
|
+
writable: !0
|
|
26
|
+
}) : obj[key] = value, obj;
|
|
27
|
+
}
|
|
28
|
+
function _iterable_to_array_limit(arr, i) {
|
|
29
|
+
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
30
|
+
if (_i != null) {
|
|
31
|
+
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
32
|
+
try {
|
|
33
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
34
|
+
;
|
|
35
|
+
} catch (err) {
|
|
36
|
+
_d = !0, _e = err;
|
|
37
|
+
} finally {
|
|
38
|
+
try {
|
|
39
|
+
!_n && _i.return != null && _i.return();
|
|
40
|
+
} finally {
|
|
41
|
+
if (_d)
|
|
42
|
+
throw _e;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return _arr;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function _non_iterable_rest() {
|
|
49
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
50
|
+
}
|
|
51
|
+
function _object_spread(target) {
|
|
52
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
53
|
+
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
54
|
+
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
55
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
56
|
+
}))), ownKeys2.forEach(function(key) {
|
|
57
|
+
_define_property(target, key, source[key]);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return target;
|
|
61
|
+
}
|
|
62
|
+
function ownKeys(object, enumerableOnly) {
|
|
63
|
+
var keys = Object.keys(object);
|
|
64
|
+
if (Object.getOwnPropertySymbols) {
|
|
65
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
66
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
67
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
68
|
+
})), keys.push.apply(keys, symbols);
|
|
69
|
+
}
|
|
70
|
+
return keys;
|
|
71
|
+
}
|
|
72
|
+
function _object_spread_props(target, source) {
|
|
73
|
+
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
74
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
75
|
+
}), target;
|
|
76
|
+
}
|
|
77
|
+
function _object_without_properties(source, excluded) {
|
|
78
|
+
if (source == null)
|
|
79
|
+
return {};
|
|
80
|
+
var target = _object_without_properties_loose(source, excluded), key, i;
|
|
81
|
+
if (Object.getOwnPropertySymbols) {
|
|
82
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
83
|
+
for (i = 0; i < sourceSymbolKeys.length; i++)
|
|
84
|
+
key = sourceSymbolKeys[i], !(excluded.indexOf(key) >= 0) && Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
|
|
85
|
+
}
|
|
86
|
+
return target;
|
|
87
|
+
}
|
|
88
|
+
function _object_without_properties_loose(source, excluded) {
|
|
89
|
+
if (source == null)
|
|
90
|
+
return {};
|
|
91
|
+
var target = {}, sourceKeys = Object.keys(source), key, i;
|
|
92
|
+
for (i = 0; i < sourceKeys.length; i++)
|
|
93
|
+
key = sourceKeys[i], !(excluded.indexOf(key) >= 0) && (target[key] = source[key]);
|
|
94
|
+
return target;
|
|
95
|
+
}
|
|
96
|
+
function _sliced_to_array(arr, i) {
|
|
97
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
98
|
+
}
|
|
99
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
100
|
+
if (o) {
|
|
101
|
+
if (typeof o == "string")
|
|
102
|
+
return _array_like_to_array(o, minLen);
|
|
103
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
104
|
+
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
|
|
105
|
+
return Array.from(n);
|
|
106
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
107
|
+
return _array_like_to_array(o, minLen);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
var NAME = "Label", _createContext = _sliced_to_array(createContext(NAME, {
|
|
12
111
|
id: void 0,
|
|
13
|
-
controlRef: {
|
|
14
|
-
|
|
112
|
+
controlRef: {
|
|
113
|
+
current: null
|
|
114
|
+
}
|
|
115
|
+
}), 2), LabelProvider = _createContext[0], useLabelContextImpl = _createContext[1], LabelFrame = styled(SizableText, {
|
|
15
116
|
name: "Label",
|
|
16
117
|
tag: "label",
|
|
17
118
|
variants: {
|
|
@@ -30,70 +131,80 @@ const NAME = "Label", [LabelProvider, useLabelContextImpl] = createContext(NAME,
|
|
|
30
131
|
}
|
|
31
132
|
},
|
|
32
133
|
size: {
|
|
33
|
-
"...size": (val, extras)
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
...getFontSized(val, extras),
|
|
134
|
+
"...size": function(val, extras) {
|
|
135
|
+
var buttonStyle = getButtonSized(val, extras), buttonHeight = buttonStyle == null ? void 0 : buttonStyle.height, fontStyle = getFontSized(val, extras);
|
|
136
|
+
return _object_spread_props(_object_spread({}, fontStyle), {
|
|
37
137
|
lineHeight: buttonHeight ? extras.tokens.size[buttonHeight] : void 0
|
|
38
|
-
};
|
|
138
|
+
});
|
|
39
139
|
}
|
|
40
140
|
}
|
|
41
141
|
},
|
|
42
142
|
defaultVariants: {
|
|
43
143
|
unstyled: process.env.TAMAGUI_HEADLESS === "1"
|
|
44
144
|
}
|
|
45
|
-
}), LabelComponent = React.forwardRef(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
145
|
+
}), LabelComponent = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
|
|
146
|
+
var htmlFor = props.htmlFor, idProp = props.id, labelProps = _object_without_properties(props, [
|
|
147
|
+
"htmlFor",
|
|
148
|
+
"id"
|
|
149
|
+
]), controlRef = React.useRef(null), ref = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, ref), backupId = React.useId(), id = idProp ?? backupId;
|
|
150
|
+
return isWeb && React.useEffect(function() {
|
|
151
|
+
if (htmlFor) {
|
|
152
|
+
var element = document.getElementById(htmlFor), label = ref.current;
|
|
153
|
+
if (label && element) {
|
|
154
|
+
var getAriaLabel = function() {
|
|
155
|
+
return element.getAttribute("aria-labelledby");
|
|
156
|
+
}, ariaLabelledBy = [
|
|
157
|
+
id,
|
|
158
|
+
getAriaLabel()
|
|
159
|
+
].filter(Boolean).join(" ");
|
|
160
|
+
return element.setAttribute("aria-labelledby", ariaLabelledBy), controlRef.current = element, function() {
|
|
161
|
+
var _getAriaLabel;
|
|
162
|
+
if (id) {
|
|
163
|
+
var ariaLabelledBy2 = (_getAriaLabel = getAriaLabel()) === null || _getAriaLabel === void 0 ? void 0 : _getAriaLabel.replace(id, "");
|
|
58
164
|
ariaLabelledBy2 === "" ? element.removeAttribute("aria-labelledby") : ariaLabelledBy2 && element.setAttribute("aria-labelledby", ariaLabelledBy2);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}, [id, htmlFor]), /* @__PURE__ */ jsx(LabelProvider, { id, controlRef, children: /* @__PURE__ */ jsx(
|
|
63
|
-
LabelFrame,
|
|
64
|
-
{
|
|
65
|
-
id,
|
|
66
|
-
htmlFor,
|
|
67
|
-
...labelProps,
|
|
68
|
-
ref: composedRefs,
|
|
69
|
-
onMouseDown: (event) => {
|
|
70
|
-
var _a;
|
|
71
|
-
(_a = props.onMouseDown) == null || _a.call(props, event), !event.defaultPrevented && event.detail > 1 && event.preventDefault();
|
|
72
|
-
},
|
|
73
|
-
onPress: (event) => {
|
|
74
|
-
var _a;
|
|
75
|
-
if ((_a = props.onPress) == null || _a.call(props, event), isWeb) {
|
|
76
|
-
if (htmlFor || !controlRef.current || event.defaultPrevented)
|
|
77
|
-
return;
|
|
78
|
-
const isClickingControl = controlRef.current.contains(
|
|
79
|
-
event.target
|
|
80
|
-
), isUserClick = event.isTrusted === !0;
|
|
81
|
-
!isClickingControl && isUserClick && (controlRef.current.click(), controlRef.current.focus());
|
|
82
|
-
} else
|
|
83
|
-
props.htmlFor && focusFocusable(props.htmlFor);
|
|
84
|
-
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
85
167
|
}
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
168
|
+
}
|
|
169
|
+
}, [
|
|
170
|
+
id,
|
|
171
|
+
htmlFor
|
|
172
|
+
]), /* @__PURE__ */ React.createElement(LabelProvider, {
|
|
173
|
+
id,
|
|
174
|
+
controlRef
|
|
175
|
+
}, /* @__PURE__ */ React.createElement(LabelFrame, _object_spread_props(_object_spread({
|
|
176
|
+
id,
|
|
177
|
+
// @ts-ignore
|
|
178
|
+
htmlFor
|
|
179
|
+
}, labelProps), {
|
|
180
|
+
ref: composedRefs,
|
|
181
|
+
onMouseDown: function(event) {
|
|
182
|
+
var _props_onMouseDown;
|
|
183
|
+
(_props_onMouseDown = props.onMouseDown) === null || _props_onMouseDown === void 0 || _props_onMouseDown.call(props, event), !event.defaultPrevented && event.detail > 1 && event.preventDefault();
|
|
184
|
+
},
|
|
185
|
+
onPress: function(event) {
|
|
186
|
+
var _props_onPress;
|
|
187
|
+
if ((_props_onPress = props.onPress) === null || _props_onPress === void 0 || _props_onPress.call(props, event), isWeb) {
|
|
188
|
+
if (htmlFor || !controlRef.current || event.defaultPrevented)
|
|
189
|
+
return;
|
|
190
|
+
var isClickingControl = controlRef.current.contains(event.target), isUserClick = event.isTrusted === !0;
|
|
191
|
+
!isClickingControl && isUserClick && (controlRef.current.click(), controlRef.current.focus());
|
|
192
|
+
} else
|
|
193
|
+
props.htmlFor && focusFocusable(props.htmlFor);
|
|
194
|
+
}
|
|
195
|
+
})));
|
|
196
|
+
});
|
|
89
197
|
LabelComponent.displayName = NAME;
|
|
90
|
-
|
|
198
|
+
var Label = LabelFrame.extractable(themeable(LabelComponent), {
|
|
91
199
|
neverFlatten: !0
|
|
92
|
-
}), useLabelContext = (element)
|
|
93
|
-
|
|
94
|
-
return React.useEffect(()
|
|
200
|
+
}), useLabelContext = function(element) {
|
|
201
|
+
var context = useLabelContextImpl("LabelConsumer"), controlRef = context.controlRef;
|
|
202
|
+
return React.useEffect(function() {
|
|
95
203
|
element && (controlRef.current = element);
|
|
96
|
-
}, [
|
|
204
|
+
}, [
|
|
205
|
+
element,
|
|
206
|
+
controlRef
|
|
207
|
+
]), context.id;
|
|
97
208
|
};
|
|
98
209
|
export {
|
|
99
210
|
Label,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/Label.tsx"],
|
|
4
|
-
"mappings": "AAAA,
|
|
5
|
-
"names": ["ariaLabelledBy"]
|
|
3
|
+
"sources": ["../../src/Users/n8/tamagui/packages/label/src/Label.tsx"],
|
|
4
|
+
"mappings": "AAAA,SAASA,uBAAuB;AAChC,SAASC,aAAa;AACtB,SAASC,qBAAqB;AAC9B,SAASC,sBAAsB;AAC/B,SAASC,sBAAsB;AAC/B,SAASC,oBAAoB;AAC7B,SAASC,mBAAmB;AAE5B,SAASC,QAAQC,iBAAiB;AAClC,YAAYC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvB,IAAMC,OAAO,SAOgCR,iBAAAA,iBAAAA,cAAiCQ,MAAM;EAClFC,IAAIC;EACJC,YAAY;IAAEC,SAAS;EAAK;AAC9B,CAA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mE,YAAY5E,UAAUmC,cAAAA,GAA+B;EAC9D0C,cAAc;AAChB,CAAA,GAEWC,kBAAkB,SAAC9B,SAAAA;AAC9B,MAAM+B,UAAUvE,oBAAoB,eAAA,GAC5BH,aAAe0E,QAAf1E;AAERJ,eAAM8C,UAAU,WAAA;AACd,IAAIC,YAAS3C,WAAWC,UAAU0C;EACpC,GAAG;IAACA;IAAS3C;GAAW,GAEjB0E,QAAQ5E;AACjB;",
|
|
5
|
+
"names": ["useComposedRefs", "isWeb", "createContext", "focusFocusable", "getButtonSized", "getFontSized", "SizableText", "styled", "themeable", "React", "NAME", "id", "undefined", "controlRef", "current", "LabelProvider", "useLabelContextImpl", "LabelFrame", "name", "tag", "variants", "unstyled", "false", "size", "color", "backgroundColor", "display", "alignItems", "userSelect", "cursor", "pressStyle", "val", "extras", "buttonStyle", "buttonHeight", "height", "fontStyle", "lineHeight", "tokens", "defaultVariants", "process", "env", "TAMAGUI_HEADLESS", "LabelComponent", "forwardRef", "props", "forwardedRef", "htmlFor", "idProp", "labelProps", "useRef", "ref", "composedRefs", "backupId", "useId", "useEffect", "element", "document", "getElementById", "label", "getAriaLabel", "getAttribute", "ariaLabelledBy", "filter", "Boolean", "join", "setAttribute", "replace", "removeAttribute", "onMouseDown", "event", "defaultPrevented", "detail", "preventDefault", "onPress", "isClickingControl", "contains", "target", "isUserClick", "isTrusted", "click", "focus", "displayName", "Label", "extractable", "neverFlatten", "useLabelContext", "context"]
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/label",
|
|
3
|
-
"version": "1.89.
|
|
3
|
+
"version": "1.89.27-1708113113238",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -32,23 +32,23 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tamagui/compose-refs": "1.89.
|
|
36
|
-
"@tamagui/constants": "1.89.
|
|
37
|
-
"@tamagui/create-context": "1.89.
|
|
38
|
-
"@tamagui/focusable": "1.89.
|
|
39
|
-
"@tamagui/get-button-sized": "1.89.
|
|
40
|
-
"@tamagui/get-font-sized": "1.89.
|
|
41
|
-
"@tamagui/text": "1.89.
|
|
42
|
-
"@tamagui/web": "1.89.
|
|
35
|
+
"@tamagui/compose-refs": "1.89.27-1708113113238",
|
|
36
|
+
"@tamagui/constants": "1.89.27-1708113113238",
|
|
37
|
+
"@tamagui/create-context": "1.89.27-1708113113238",
|
|
38
|
+
"@tamagui/focusable": "1.89.27-1708113113238",
|
|
39
|
+
"@tamagui/get-button-sized": "1.89.27-1708113113238",
|
|
40
|
+
"@tamagui/get-font-sized": "1.89.27-1708113113238",
|
|
41
|
+
"@tamagui/text": "1.89.27-1708113113238",
|
|
42
|
+
"@tamagui/web": "1.89.27-1708113113238"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"react": "*",
|
|
46
46
|
"react-native": "*"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@tamagui/build": "1.89.
|
|
49
|
+
"@tamagui/build": "1.89.27-1708113113238",
|
|
50
50
|
"react": "^18.2.0",
|
|
51
|
-
"react-native": "^0.
|
|
51
|
+
"react-native": "^0.73.4"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|