@tamagui/label 1.114.3 → 1.115.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,146 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf,
6
+ __hasOwnProp = Object.prototype.hasOwnProperty;
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, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ return to;
19
+ };
20
+ 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);
32
+ var Label_exports = {};
33
+ __export(Label_exports, {
34
+ Label: () => Label,
35
+ LabelFrame: () => LabelFrame,
36
+ useLabelContext: () => useLabelContext
37
+ });
38
+ 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")),
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
+ tag: "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
+ };
81
+ }
82
+ }
83
+ },
84
+ defaultVariants: {
85
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
86
+ }
87
+ }),
88
+ LabelComponent = React.forwardRef((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(() => {
100
+ if (htmlFor) {
101
+ 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, () => {
106
+ if (!id) return;
107
+ const ariaLabelledBy2 = getAriaLabel()?.replace(id, "");
108
+ ariaLabelledBy2 === "" ? element.removeAttribute("aria-labelledby") : ariaLabelledBy2 && element.setAttribute("aria-labelledby", ariaLabelledBy2);
109
+ };
110
+ }
111
+ }
112
+ }, [id, htmlFor]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(LabelProvider, {
113
+ 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);
130
+ }
131
+ })
132
+ });
133
+ });
134
+ LabelComponent.displayName = NAME;
135
+ const Label = LabelFrame.extractable((0, import_web.themeable)(LabelComponent), {
136
+ neverFlatten: !0
137
+ }),
138
+ useLabelContext = element => {
139
+ const context = useLabelContextImpl("LabelConsumer"),
140
+ {
141
+ controlRef
142
+ } = context;
143
+ return React.useEffect(() => {
144
+ element && (controlRef.current = element);
145
+ }, [element, controlRef]), context.id;
146
+ };
@@ -0,0 +1,18 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
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, {
7
+ get: () => from[key],
8
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ });
10
+ return to;
11
+ },
12
+ __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
13
+ var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
14
+ value: !0
15
+ }), mod);
16
+ var src_exports = {};
17
+ module.exports = __toCommonJS(src_exports);
18
+ __reExport(src_exports, require("./Label.cjs"), module.exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/label",
3
- "version": "1.114.3",
3
+ "version": "1.115.0",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -29,25 +29,26 @@
29
29
  "react-native": "./dist/cjs/index.native.js",
30
30
  "types": "./types/index.d.ts",
31
31
  "import": "./dist/esm/index.mjs",
32
- "require": "./dist/cjs/index.js"
32
+ "require": "./dist/cjs/index.cjs",
33
+ "default": "./dist/cjs/index.native.js"
33
34
  }
34
35
  },
35
36
  "dependencies": {
36
- "@tamagui/compose-refs": "1.114.3",
37
- "@tamagui/constants": "1.114.3",
38
- "@tamagui/create-context": "1.114.3",
39
- "@tamagui/focusable": "1.114.3",
40
- "@tamagui/get-button-sized": "1.114.3",
41
- "@tamagui/get-font-sized": "1.114.3",
42
- "@tamagui/text": "1.114.3",
43
- "@tamagui/web": "1.114.3"
37
+ "@tamagui/compose-refs": "1.115.0",
38
+ "@tamagui/constants": "1.115.0",
39
+ "@tamagui/create-context": "1.115.0",
40
+ "@tamagui/focusable": "1.115.0",
41
+ "@tamagui/get-button-sized": "1.115.0",
42
+ "@tamagui/get-font-sized": "1.115.0",
43
+ "@tamagui/text": "1.115.0",
44
+ "@tamagui/web": "1.115.0"
44
45
  },
45
46
  "peerDependencies": {
46
47
  "react": "*",
47
48
  "react-native": "*"
48
49
  },
49
50
  "devDependencies": {
50
- "@tamagui/build": "1.114.3",
51
+ "@tamagui/build": "1.115.0",
51
52
  "react": "^18.2.0 || ^19.0.0",
52
53
  "react-native": "0.74.1"
53
54
  },
package/dist/cjs/Label.js DELETED
@@ -1,113 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var Label_exports = {};
24
- __export(Label_exports, {
25
- Label: () => Label,
26
- LabelFrame: () => LabelFrame,
27
- useLabelContext: () => useLabelContext
28
- });
29
- module.exports = __toCommonJS(Label_exports);
30
- 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")), import_jsx_runtime = require("react/jsx-runtime");
31
- const NAME = "Label", [LabelProvider, useLabelContextImpl] = (0, import_create_context.createContext)(NAME, {
32
- id: void 0,
33
- controlRef: { current: null }
34
- }), LabelFrame = (0, import_web.styled)(import_text.SizableText, {
35
- name: "Label",
36
- tag: "label",
37
- variants: {
38
- unstyled: {
39
- false: {
40
- size: "$true",
41
- color: "$color",
42
- backgroundColor: "transparent",
43
- display: "flex",
44
- alignItems: "center",
45
- userSelect: "none",
46
- cursor: "default",
47
- pressStyle: {
48
- color: "$colorPress"
49
- }
50
- }
51
- },
52
- size: {
53
- "...size": (val, extras) => {
54
- const buttonHeight = (0, import_get_button_sized.getButtonSized)(val, extras)?.height;
55
- return {
56
- ...(0, import_get_font_sized.getFontSized)(val, extras),
57
- lineHeight: buttonHeight ? extras.tokens.size[buttonHeight] : void 0
58
- };
59
- }
60
- }
61
- },
62
- defaultVariants: {
63
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
64
- }
65
- }), LabelComponent = React.forwardRef(
66
- (props, forwardedRef) => {
67
- const { htmlFor, id: idProp, ...labelProps } = props, controlRef = React.useRef(null), ref = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref), backupId = React.useId(), id = idProp ?? backupId;
68
- return import_constants.isWeb && React.useEffect(() => {
69
- if (htmlFor) {
70
- const element = document.getElementById(htmlFor);
71
- if (ref.current && element) {
72
- const getAriaLabel = () => element.getAttribute("aria-labelledby"), ariaLabelledBy = [id, getAriaLabel()].filter(Boolean).join(" ");
73
- return element.setAttribute("aria-labelledby", ariaLabelledBy), controlRef.current = element, () => {
74
- if (!id) return;
75
- const ariaLabelledBy2 = getAriaLabel()?.replace(id, "");
76
- ariaLabelledBy2 === "" ? element.removeAttribute("aria-labelledby") : ariaLabelledBy2 && element.setAttribute("aria-labelledby", ariaLabelledBy2);
77
- };
78
- }
79
- }
80
- }, [id, htmlFor]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabelProvider, { id, controlRef, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
81
- LabelFrame,
82
- {
83
- id,
84
- htmlFor,
85
- ...labelProps,
86
- ref: composedRefs,
87
- onMouseDown: (event) => {
88
- props.onMouseDown?.(event), !event.defaultPrevented && event.detail > 1 && event.preventDefault();
89
- },
90
- onPress: (event) => {
91
- if (props.onPress?.(event), import_constants.isWeb) {
92
- if (htmlFor || !controlRef.current || event.defaultPrevented) return;
93
- const isClickingControl = controlRef.current.contains(
94
- event.target
95
- ), isUserClick = event.isTrusted === !0;
96
- !isClickingControl && isUserClick && (controlRef.current.click(), controlRef.current.focus());
97
- } else
98
- props.htmlFor && (0, import_focusable.focusFocusable)(props.htmlFor);
99
- }
100
- }
101
- ) });
102
- }
103
- );
104
- LabelComponent.displayName = NAME;
105
- const Label = LabelFrame.extractable((0, import_web.themeable)(LabelComponent), {
106
- neverFlatten: !0
107
- }), useLabelContext = (element) => {
108
- const context = useLabelContextImpl("LabelConsumer"), { controlRef } = context;
109
- return React.useEffect(() => {
110
- element && (controlRef.current = element);
111
- }, [element, controlRef]), context.id;
112
- };
113
- //# sourceMappingURL=Label.js.map
package/dist/cjs/index.js DELETED
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from == "object" || typeof from == "function")
7
- for (let key of __getOwnPropNames(from))
8
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
- return to;
10
- }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
- var src_exports = {};
13
- module.exports = __toCommonJS(src_exports);
14
- __reExport(src_exports, require("./Label"), module.exports);
15
- //# sourceMappingURL=index.js.map
File without changes
File without changes