@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.
@@ -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
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: !0
11
- });
12
- },
13
- __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
- value: mod,
27
- enumerable: !0
28
- }) : target, mod)),
29
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
30
- value: !0
31
- }), mod);
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
- import_constants = require("@tamagui/constants"),
41
- import_create_context = require("@tamagui/create-context"),
42
- import_focusable = require("@tamagui/focusable"),
43
- import_get_button_sized = require("@tamagui/get-button-sized"),
44
- import_get_font_sized = require("@tamagui/get-font-sized"),
45
- import_text = require("@tamagui/text"),
46
- import_web = require("@tamagui/web"),
47
- React = __toESM(require("react"), 1),
48
- import_jsx_runtime = require("react/jsx-runtime");
49
- const NAME = "Label",
50
- [LabelProvider, useLabelContextImpl] = (0, import_create_context.createContext)(NAME, {
51
- id: void 0,
52
- controlRef: {
53
- current: null
54
- }
55
- }),
56
- LabelFrame = (0, import_web.styled)(import_text.SizableText, {
57
- name: "Label",
58
- render: "label",
59
- variants: {
60
- unstyled: {
61
- false: {
62
- size: "$true",
63
- color: "$color",
64
- backgroundColor: "transparent",
65
- display: "flex",
66
- alignItems: "center",
67
- userSelect: "none",
68
- cursor: "default",
69
- pressStyle: {
70
- color: "$colorPress"
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
- defaultVariants: {
85
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
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
- Label = LabelFrame.styleable(function (props, forwardedRef) {
89
- const {
90
- htmlFor,
91
- id: idProp,
92
- ...labelProps
93
- } = props,
94
- controlRef = React.useRef(null),
95
- ref = React.useRef(null),
96
- composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref),
97
- backupId = React.useId(),
98
- id = idProp ?? backupId;
99
- return import_constants.isWeb && React.useEffect(() => {
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
- if (ref.current && element) {
103
- const getAriaLabel = () => element.getAttribute("aria-labelledby"),
104
- ariaLabelledBy = [id, getAriaLabel()].filter(Boolean).join(" ");
105
- return element.setAttribute("aria-labelledby", ariaLabelledBy), controlRef.current = element, () => {
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 === "" ? element.removeAttribute("aria-labelledby") : ariaLabelledBy2 && element.setAttribute("aria-labelledby", 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]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(LabelProvider, {
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
- controlRef,
115
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(LabelFrame, {
116
- id,
117
- htmlFor,
118
- ...labelProps,
119
- ref: composedRefs,
120
- onMouseDown: event => {
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
- useLabelContext = element => {
135
- const context = useLabelContextImpl("LabelConsumer"),
136
- {
137
- controlRef
138
- } = context;
139
- return React.useEffect(() => {
140
- element && (controlRef.current = element);
141
- }, [element, controlRef]), context.id;
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
+ };
@@ -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
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
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
- import_compose_refs = require("@tamagui/compose-refs"),
43
- import_constants = require("@tamagui/constants"),
44
- import_create_context = require("@tamagui/create-context"),
45
- import_focusable = require("@tamagui/focusable"),
46
- import_get_button_sized = require("@tamagui/get-button-sized"),
47
- import_get_font_sized = require("@tamagui/get-font-sized"),
48
- import_text = require("@tamagui/text"),
49
- import_web = require("@tamagui/web"),
50
- React = __toESM(require("react"), 1),
51
- NAME = "Label",
52
- [LabelProvider, useLabelContextImpl] = (0, import_create_context.createContext)(NAME, {
53
- id: void 0,
54
- controlRef: {
55
- current: null
56
- }
57
- }),
58
- 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"
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
- defaultVariants: {
89
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
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
- Label = LabelFrame.styleable(function (props, forwardedRef) {
93
- var {
94
- htmlFor,
95
- id: idProp,
96
- ...labelProps
97
- } = props,
98
- controlRef = React.useRef(null),
99
- ref = React.useRef(null),
100
- composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref),
101
- backupId = React.useId(),
102
- id = idProp ?? backupId;
103
- return import_constants.isWeb && React.useEffect(function () {
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
- label = ref.current;
108
+ var element = document.getElementById(htmlFor);
109
+ var label = ref.current;
107
110
  if (label && element) {
108
111
  var getAriaLabel = function () {
109
- return element.getAttribute("aria-labelledby");
110
- },
111
- ariaLabelledBy = [id, getAriaLabel()].filter(Boolean).join(" ");
112
- return element.setAttribute("aria-labelledby", ariaLabelledBy), controlRef.current = element, function () {
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
- var ariaLabelledBy2 = (_getAriaLabel = getAriaLabel()) === null || _getAriaLabel === void 0 ? void 0 : _getAriaLabel.replace(id, "");
116
- ariaLabelledBy2 === "" ? element.removeAttribute("aria-labelledby") : ariaLabelledBy2 && element.setAttribute("aria-labelledby", ariaLabelledBy2);
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]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(LabelProvider, {
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
- controlRef,
124
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(LabelFrame, {
125
- id,
126
- // @ts-ignore
127
- htmlFor,
128
- ...labelProps,
129
- ref: composedRefs,
130
- onMouseDown: function (event) {
131
- var _props_onMouseDown;
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
- useLabelContext = function (element) {
147
- var context = useLabelContextImpl("LabelConsumer"),
148
- {
149
- controlRef
150
- } = context;
151
- return React.useEffect(function () {
152
- element && (controlRef.current = element);
153
- }, [element, controlRef]), context.id;
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":";;;;;;;;;;;;;;;;;;;;;;;;;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AA2D,eAAA,IAAAD,aAAA,GAAAP,YAAA,gBAAAO,aAAA,uBAAAA,aAAA,CAAAE,OAAA,CAAA5D,EAAA;cAEA2D,eAAA,UAAAZ,OAAA,CAAAc,eAAA,sBAAAF,eAAA,IAAAZ,OAAA,CAAAU,YAAA,oBAAAE,eAAA;YACI;UACJ;QACA;MACE;IAGuB,IAEzB3D,EACA,EAGEoC,OAAA,CACE,kBAAI,IAAYpD,kBAAW,CAAA8E,GAAW,EAAAjE,aAAM;MAC5CG,EAAA;MAA6CC,UAC3C;MAAM8D,QACR,EAGM,eAAc,IAAM/E,kBAAc,CAAA8E,GAAA,EAAAlF,UAAA;QAMxCoB,EAAA;QAE2B;QAG3BoC,OAAI;QAIR,GAAAE,UAAA;QAAAE,GAAA,EAAAC,YAAA;QAEJuB,WAAA,WAAAA,CAAAC,KAAA;UAIS,IAAAC,kBAAmB;UACxB,CAAAA,kBAAU,GAAAhC,KAAA,CAAA8B,WAAoB,MAAe,IAC7C,IAAEE,kBAAe,eAAAA,kBAAA,CAAAC,IAAA,CAAAjC,KAAA,EAAA+B,KAAA,IAAAA,KAAA,CAAAG,gBAAA,IAAAH,KAAA,CAAAI,MAAA,QAAAJ,KAAA,CAAAK,cAAA;QAEvB;QACMC,OAAA,WAAAA,CAASN,KAAW;UACtB,IAAAO,cAAoB;UAG1B,KAAAA,cAAA,GAAAtC,KAAA,CAAAqC,OAAA,cAAAC,cAAA,eAAAA,cAAA,CAAAL,IAAA,CAAAjC,KAAA,EAAA+B,KAAA,GAAA9E,gBAAA,CAAA0D,KAAA","ignoreList":[]}
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"],"sources":["../../src/Label.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,KAAA,EAAAA,CAAA,KAAAA,KAAA;EAAAC,UAAA,EAAAA,CAAA,KAAAA,UAAA;EAAAC,eAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAX,YAAgC,CAAAK,aAAA;AAChC,IAAAO,kBAAA,GAAsBC,OAAA;AACtB,IAAAC,mBAAA,GAAAD,OAA8B;AAC9B,IAAAE,gBAAA,GAA+BF,OAAA;AAC/B,IAAAG,qBAAA,GAAAH,OAA+B;AAC/B,IAAAI,gBAAA,GAAAJ,OAA6B;AAC7B,IAAAK,uBAA4B,GAAAL,OAAA;AAE5B,IAAAM,qBAAuB,GAAAN,OAAA;AACvB,IAAAO,WAAuB,GAAAP,OAAA;AA8FjB,IAAAQ,UAAA,GAAAR,OAAA;AA5FN,IAAAS,KAAM,GAAAC,OAAO,CAAAV,OAAA;AAOb,IAAAW,IAAO;AAA6E,IAClF,CAAAC,aAAI,EAAAC,mBAAA,QA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hC,KAAQ,CAAA8B,WAAM,cAAAE,kBAAA,uBAAAA,kBAAA,CAAAC,IAAA,CAAAjC,KAAA,EAAA+B,KAAA;QAAA,IAC3B,CAAAA,KAAA,CAAAG,gBAAA,IAAAH,KAAA,CAAAI,MAAA;UACFJ,KAAO,CAAAK,cAAA;QACL;MACE;MAA4BC,OAC9B,WAAAA,CAAAN,KAAA;QACF,IAAAO,cAAA;QACF,CAAAA,cAAA,GAAAtC,KAAA,CAAAqC,OAAA,cAAAC,cAAA,uBAAAA,cAAA,CAAAL,IAAA,CAAAjC,KAAA,EAAA+B,KAAA;QAAA,IAAA/E,gBAAA,CAAA2D,KAAA;UAEJ,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":[]}
@@ -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
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
11
- },
12
- __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
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: !0
16
+ value: true
15
17
  }), mod);
16
18
  var index_exports = {};
17
19
  module.exports = __toCommonJS(index_exports);