@tamagui/label 1.2.9 → 1.2.10

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,135 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useComposedRefs } from "@tamagui/compose-refs";
3
+ import {
4
+ isWeb,
5
+ styled,
6
+ themeable,
7
+ useId
8
+ } from "@tamagui/core";
9
+ import { createContext } from "@tamagui/create-context";
10
+ import { focusFocusable } from "@tamagui/focusable";
11
+ import { getButtonSized } from "@tamagui/get-button-sized";
12
+ import { getFontSized } from "@tamagui/get-font-sized";
13
+ import { SizableText } from "@tamagui/text";
14
+ import * as React from "react";
15
+ const NAME = "Label";
16
+ const [LabelProvider, useLabelContextImpl] = createContext(NAME, {
17
+ id: void 0,
18
+ controlRef: { current: null }
19
+ });
20
+ const LabelFrame = styled(SizableText, {
21
+ name: "Label",
22
+ tag: "label",
23
+ size: "$true",
24
+ backgroundColor: "transparent",
25
+ display: "flex",
26
+ alignItems: "center",
27
+ userSelect: "none",
28
+ cursor: "default",
29
+ pressStyle: {
30
+ color: "$colorPress"
31
+ },
32
+ variants: {
33
+ size: {
34
+ "...size": (val, extras) => {
35
+ const buttonStyle = getButtonSized(val, extras);
36
+ return {
37
+ ...getFontSized(val, extras),
38
+ height: buttonStyle.height,
39
+ lineHeight: buttonStyle.height
40
+ };
41
+ }
42
+ }
43
+ }
44
+ });
45
+ const LabelComponent = React.forwardRef(
46
+ (props, forwardedRef) => {
47
+ const { htmlFor, id: idProp, ...labelProps } = props;
48
+ const controlRef = React.useRef(null);
49
+ const ref = React.useRef(null);
50
+ const composedRefs = useComposedRefs(forwardedRef, ref);
51
+ const backupId = useId();
52
+ const id = idProp ?? backupId;
53
+ if (isWeb) {
54
+ React.useEffect(() => {
55
+ if (htmlFor) {
56
+ const element = document.getElementById(htmlFor);
57
+ const label = ref.current;
58
+ if (label && element) {
59
+ const getAriaLabel = () => element.getAttribute("aria-labelledby");
60
+ const ariaLabelledBy = [id, getAriaLabel()].filter(Boolean).join(" ");
61
+ element.setAttribute("aria-labelledby", ariaLabelledBy);
62
+ controlRef.current = element;
63
+ return () => {
64
+ var _a;
65
+ if (!id)
66
+ return;
67
+ const ariaLabelledBy2 = (_a = getAriaLabel()) == null ? void 0 : _a.replace(id, "");
68
+ if (ariaLabelledBy2 === "") {
69
+ element.removeAttribute("aria-labelledby");
70
+ } else if (ariaLabelledBy2) {
71
+ element.setAttribute("aria-labelledby", ariaLabelledBy2);
72
+ }
73
+ };
74
+ }
75
+ }
76
+ }, [id, htmlFor]);
77
+ }
78
+ return /* @__PURE__ */ jsx(LabelProvider, { id, controlRef, children: /* @__PURE__ */ jsx(
79
+ LabelFrame,
80
+ {
81
+ role: "label",
82
+ id,
83
+ ...labelProps,
84
+ ref: composedRefs,
85
+ onMouseDown: (event) => {
86
+ var _a;
87
+ (_a = props.onMouseDown) == null ? void 0 : _a.call(props, event);
88
+ if (!event.defaultPrevented && event.detail > 1) {
89
+ event.preventDefault();
90
+ }
91
+ },
92
+ onPress: (event) => {
93
+ var _a;
94
+ (_a = props.onPress) == null ? void 0 : _a.call(props, event);
95
+ if (isWeb) {
96
+ if (!controlRef.current || event.defaultPrevented)
97
+ return;
98
+ const isClickingControl = controlRef.current.contains(
99
+ event.target
100
+ );
101
+ const isUserClick = event.isTrusted === true;
102
+ if (!isClickingControl && isUserClick) {
103
+ controlRef.current.click();
104
+ controlRef.current.focus();
105
+ }
106
+ } else {
107
+ if (props.htmlFor) {
108
+ focusFocusable(props.htmlFor);
109
+ }
110
+ }
111
+ }
112
+ }
113
+ ) });
114
+ }
115
+ );
116
+ LabelComponent.displayName = NAME;
117
+ const Label = LabelFrame.extractable(themeable(LabelComponent), {
118
+ neverFlatten: true
119
+ });
120
+ const useLabelContext = (element) => {
121
+ const context = useLabelContextImpl("LabelConsumer");
122
+ const { controlRef } = context;
123
+ React.useEffect(() => {
124
+ if (element)
125
+ controlRef.current = element;
126
+ }, [element, controlRef]);
127
+ return context.id;
128
+ };
129
+ const Root = Label;
130
+ export {
131
+ Label,
132
+ LabelFrame,
133
+ useLabelContext
134
+ };
135
+ //# sourceMappingURL=Label.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Label.tsx"],
4
+ "sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n GetProps,\n ReactComponentWithRef,\n isWeb,\n styled,\n themeable,\n useId,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport { createContext } from '@tamagui/create-context'\nimport { focusFocusable } from '@tamagui/focusable'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { getFontSized } from '@tamagui/get-font-sized'\nimport { SizableText } from '@tamagui/text'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nconst NAME = 'Label'\n\ntype LabelContextValue = {\n id?: string\n controlRef: React.MutableRefObject<HTMLElement | null>\n}\n\nconst [LabelProvider, useLabelContextImpl] = createContext<LabelContextValue>(NAME, {\n id: undefined,\n controlRef: { current: null },\n})\n\nexport const LabelFrame = styled(SizableText, {\n name: 'Label',\n tag: 'label',\n size: '$true',\n backgroundColor: 'transparent',\n display: 'flex',\n alignItems: 'center',\n userSelect: 'none',\n cursor: 'default',\n pressStyle: {\n color: '$colorPress',\n },\n variants: {\n size: {\n '...size': (val, extras) => {\n const buttonStyle = getButtonSized(val, extras)\n return {\n ...getFontSized(val, extras),\n height: buttonStyle.height,\n lineHeight: buttonStyle.height,\n }\n },\n },\n } as const,\n})\n\nexport type LabelProps = GetProps<typeof LabelFrame> & {\n htmlFor?: string\n}\n\nconst LabelComponent = React.forwardRef<typeof LabelFrame, LabelProps>(\n (props, forwardedRef) => {\n const { htmlFor, id: idProp, ...labelProps } = props\n const controlRef = React.useRef<HTMLElement | null>(null)\n const ref = React.useRef<any>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref)\n const backupId = useId()\n const id = idProp ?? backupId\n\n if (isWeb) {\n React.useEffect(() => {\n if (htmlFor) {\n const element = document.getElementById(htmlFor)\n const label = ref.current\n if (label && element) {\n const getAriaLabel = () => element.getAttribute('aria-labelledby')\n const ariaLabelledBy = [id, getAriaLabel()].filter(Boolean).join(' ')\n element.setAttribute('aria-labelledby', ariaLabelledBy)\n controlRef.current = element\n return () => {\n /**\n * We get the latest attribute value because at the time that this cleanup fires,\n * the values from the closure may have changed.\n */\n if (!id) return\n const ariaLabelledBy = getAriaLabel()?.replace(id, '')\n if (ariaLabelledBy === '') {\n element.removeAttribute('aria-labelledby')\n } else if (ariaLabelledBy) {\n element.setAttribute('aria-labelledby', ariaLabelledBy)\n }\n }\n }\n }\n }, [id, htmlFor])\n }\n\n return (\n <LabelProvider id={id} controlRef={controlRef}>\n <LabelFrame\n // @ts-ignore\n role=\"label\"\n id={id}\n {...labelProps}\n ref={composedRefs as any}\n onMouseDown={(event) => {\n props.onMouseDown?.(event)\n // prevent text selection when double clicking label\n if (!event.defaultPrevented && event.detail > 1) {\n event.preventDefault()\n }\n }}\n onPress={(event) => {\n props.onPress?.(event)\n\n if (isWeb) {\n if (!controlRef.current || event.defaultPrevented) return\n const isClickingControl = controlRef.current.contains(\n event.target as any as Node\n )\n // Ensure event was generated by a user action\n // https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted\n const isUserClick = event.isTrusted === true\n /**\n * When a label is wrapped around the control it labels, we trigger the appropriate events\n * on the control when the label is clicked. We do nothing if the user is already clicking the\n * control inside the label.\n */\n if (!isClickingControl && isUserClick) {\n controlRef.current.click()\n controlRef.current.focus()\n }\n } else {\n if (props.htmlFor) {\n focusFocusable(props.htmlFor)\n }\n }\n }}\n />\n </LabelProvider>\n )\n }\n)\n\nLabelComponent.displayName = NAME\n\nexport const Label: ReactComponentWithRef<LabelProps, HTMLButtonElement | View> =\n LabelFrame.extractable(themeable(LabelComponent as any) as any, {\n neverFlatten: true,\n })\n\nexport const useLabelContext = (element?: HTMLElement | null) => {\n const context = useLabelContextImpl('LabelConsumer')\n const { controlRef } = context\n\n React.useEffect(() => {\n if (element) controlRef.current = element\n }, [element, controlRef])\n\n return context.id\n}\n\nconst Root = Label\n"],
5
+ "mappings": "AAmGQ;AAnGR,SAAS,uBAAuB;AAChC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,YAAY,WAAW;AAGvB,MAAM,OAAO;AAOb,MAAM,CAAC,eAAe,mBAAmB,IAAI,cAAiC,MAAM;AAAA,EAClF,IAAI;AAAA,EACJ,YAAY,EAAE,SAAS,KAAK;AAC9B,CAAC;AAEM,MAAM,aAAa,OAAO,aAAa;AAAA,EAC5C,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,OAAO;AAAA,EACT;AAAA,EACA,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,KAAK,WAAW;AAC1B,cAAM,cAAc,eAAe,KAAK,MAAM;AAC9C,eAAO;AAAA,UACL,GAAG,aAAa,KAAK,MAAM;AAAA,UAC3B,QAAQ,YAAY;AAAA,UACpB,YAAY,YAAY;AAAA,QAC1B;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF,CAAC;AAMD,MAAM,iBAAiB,MAAM;AAAA,EAC3B,CAAC,OAAO,iBAAiB;AACvB,UAAM,EAAE,SAAS,IAAI,QAAQ,GAAG,WAAW,IAAI;AAC/C,UAAM,aAAa,MAAM,OAA2B,IAAI;AACxD,UAAM,MAAM,MAAM,OAAY,IAAI;AAClC,UAAM,eAAe,gBAAgB,cAAc,GAAG;AACtD,UAAM,WAAW,MAAM;AACvB,UAAM,KAAK,UAAU;AAErB,QAAI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W,QAAQ,MAAM;AAAA,YAC3B;AAAA,UACF,OAAO;AACL,gBAAI,MAAM,SAAS;AACjB,6BAAe,MAAM,OAAO;AAAA,YAC9B;AAAA,UACF;AAAA,QACF;AAAA;AAAA,IACF,GACF;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;AAEtB,MAAM,QACX,WAAW,YAAY,UAAU,cAAqB,GAAU;AAAA,EAC9D,cAAc;AAChB,CAAC;AAEI,MAAM,kBAAkB,CAAC,YAAiC;AAC/D,QAAM,UAAU,oBAAoB,eAAe;AACnD,QAAM,EAAE,WAAW,IAAI;AAEvB,QAAM,UAAU,MAAM;AACpB,QAAI;AAAS,iBAAW,UAAU;AAAA,EACpC,GAAG,CAAC,SAAS,UAAU,CAAC;AAExB,SAAO,QAAQ;AACjB;AAEA,MAAM,OAAO;",
6
+ "names": ["ariaLabelledBy"]
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Label";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Label'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
@@ -0,0 +1,128 @@
1
+ import { useComposedRefs } from "@tamagui/compose-refs";
2
+ import {
3
+ isWeb,
4
+ styled,
5
+ themeable,
6
+ useId
7
+ } from "@tamagui/core";
8
+ import { createContext } from "@tamagui/create-context";
9
+ import { focusFocusable } from "@tamagui/focusable";
10
+ import { getButtonSized } from "@tamagui/get-button-sized";
11
+ import { getFontSized } from "@tamagui/get-font-sized";
12
+ import { SizableText } from "@tamagui/text";
13
+ import * as React from "react";
14
+ const NAME = "Label";
15
+ const [LabelProvider, useLabelContextImpl] = createContext(NAME, {
16
+ id: void 0,
17
+ controlRef: { current: null }
18
+ });
19
+ const LabelFrame = styled(SizableText, {
20
+ name: "Label",
21
+ tag: "label",
22
+ size: "$true",
23
+ backgroundColor: "transparent",
24
+ display: "flex",
25
+ alignItems: "center",
26
+ userSelect: "none",
27
+ cursor: "default",
28
+ pressStyle: {
29
+ color: "$colorPress"
30
+ },
31
+ variants: {
32
+ size: {
33
+ "...size": (val, extras) => {
34
+ const buttonStyle = getButtonSized(val, extras);
35
+ return {
36
+ ...getFontSized(val, extras),
37
+ height: buttonStyle.height,
38
+ lineHeight: buttonStyle.height
39
+ };
40
+ }
41
+ }
42
+ }
43
+ });
44
+ const LabelComponent = React.forwardRef(
45
+ (props, forwardedRef) => {
46
+ const { htmlFor, id: idProp, ...labelProps } = props;
47
+ const controlRef = React.useRef(null);
48
+ const ref = React.useRef(null);
49
+ const composedRefs = useComposedRefs(forwardedRef, ref);
50
+ const backupId = useId();
51
+ const id = idProp ?? backupId;
52
+ if (isWeb) {
53
+ React.useEffect(() => {
54
+ if (htmlFor) {
55
+ const element = document.getElementById(htmlFor);
56
+ const label = ref.current;
57
+ if (label && element) {
58
+ const getAriaLabel = () => element.getAttribute("aria-labelledby");
59
+ const ariaLabelledBy = [id, getAriaLabel()].filter(Boolean).join(" ");
60
+ element.setAttribute("aria-labelledby", ariaLabelledBy);
61
+ controlRef.current = element;
62
+ return () => {
63
+ if (!id)
64
+ return;
65
+ const ariaLabelledBy2 = getAriaLabel()?.replace(id, "");
66
+ if (ariaLabelledBy2 === "") {
67
+ element.removeAttribute("aria-labelledby");
68
+ } else if (ariaLabelledBy2) {
69
+ element.setAttribute("aria-labelledby", ariaLabelledBy2);
70
+ }
71
+ };
72
+ }
73
+ }
74
+ }, [id, htmlFor]);
75
+ }
76
+ return <LabelProvider id={id} controlRef={controlRef}><LabelFrame
77
+ role="label"
78
+ id={id}
79
+ {...labelProps}
80
+ ref={composedRefs}
81
+ onMouseDown={(event) => {
82
+ props.onMouseDown?.(event);
83
+ if (!event.defaultPrevented && event.detail > 1) {
84
+ event.preventDefault();
85
+ }
86
+ }}
87
+ onPress={(event) => {
88
+ props.onPress?.(event);
89
+ if (isWeb) {
90
+ if (!controlRef.current || event.defaultPrevented)
91
+ return;
92
+ const isClickingControl = controlRef.current.contains(
93
+ event.target
94
+ );
95
+ const isUserClick = event.isTrusted === true;
96
+ if (!isClickingControl && isUserClick) {
97
+ controlRef.current.click();
98
+ controlRef.current.focus();
99
+ }
100
+ } else {
101
+ if (props.htmlFor) {
102
+ focusFocusable(props.htmlFor);
103
+ }
104
+ }
105
+ }}
106
+ /></LabelProvider>;
107
+ }
108
+ );
109
+ LabelComponent.displayName = NAME;
110
+ const Label = LabelFrame.extractable(themeable(LabelComponent), {
111
+ neverFlatten: true
112
+ });
113
+ const useLabelContext = (element) => {
114
+ const context = useLabelContextImpl("LabelConsumer");
115
+ const { controlRef } = context;
116
+ React.useEffect(() => {
117
+ if (element)
118
+ controlRef.current = element;
119
+ }, [element, controlRef]);
120
+ return context.id;
121
+ };
122
+ const Root = Label;
123
+ export {
124
+ Label,
125
+ LabelFrame,
126
+ useLabelContext
127
+ };
128
+ //# sourceMappingURL=Label.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/Label.tsx"],
4
+ "sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n GetProps,\n ReactComponentWithRef,\n isWeb,\n styled,\n themeable,\n useId,\n useIsomorphicLayoutEffect,\n} from '@tamagui/core'\nimport { createContext } from '@tamagui/create-context'\nimport { focusFocusable } from '@tamagui/focusable'\nimport { getButtonSized } from '@tamagui/get-button-sized'\nimport { getFontSized } from '@tamagui/get-font-sized'\nimport { SizableText } from '@tamagui/text'\nimport * as React from 'react'\nimport { View } from 'react-native'\n\nconst NAME = 'Label'\n\ntype LabelContextValue = {\n id?: string\n controlRef: React.MutableRefObject<HTMLElement | null>\n}\n\nconst [LabelProvider, useLabelContextImpl] = createContext<LabelContextValue>(NAME, {\n id: undefined,\n controlRef: { current: null },\n})\n\nexport const LabelFrame = styled(SizableText, {\n name: 'Label',\n tag: 'label',\n size: '$true',\n backgroundColor: 'transparent',\n display: 'flex',\n alignItems: 'center',\n userSelect: 'none',\n cursor: 'default',\n pressStyle: {\n color: '$colorPress',\n },\n variants: {\n size: {\n '...size': (val, extras) => {\n const buttonStyle = getButtonSized(val, extras)\n return {\n ...getFontSized(val, extras),\n height: buttonStyle.height,\n lineHeight: buttonStyle.height,\n }\n },\n },\n } as const,\n})\n\nexport type LabelProps = GetProps<typeof LabelFrame> & {\n htmlFor?: string\n}\n\nconst LabelComponent = React.forwardRef<typeof LabelFrame, LabelProps>(\n (props, forwardedRef) => {\n const { htmlFor, id: idProp, ...labelProps } = props\n const controlRef = React.useRef<HTMLElement | null>(null)\n const ref = React.useRef<any>(null)\n const composedRefs = useComposedRefs(forwardedRef, ref)\n const backupId = useId()\n const id = idProp ?? backupId\n\n if (isWeb) {\n React.useEffect(() => {\n if (htmlFor) {\n const element = document.getElementById(htmlFor)\n const label = ref.current\n if (label && element) {\n const getAriaLabel = () => element.getAttribute('aria-labelledby')\n const ariaLabelledBy = [id, getAriaLabel()].filter(Boolean).join(' ')\n element.setAttribute('aria-labelledby', ariaLabelledBy)\n controlRef.current = element\n return () => {\n /**\n * We get the latest attribute value because at the time that this cleanup fires,\n * the values from the closure may have changed.\n */\n if (!id) return\n const ariaLabelledBy = getAriaLabel()?.replace(id, '')\n if (ariaLabelledBy === '') {\n element.removeAttribute('aria-labelledby')\n } else if (ariaLabelledBy) {\n element.setAttribute('aria-labelledby', ariaLabelledBy)\n }\n }\n }\n }\n }, [id, htmlFor])\n }\n\n return (\n <LabelProvider id={id} controlRef={controlRef}>\n <LabelFrame\n // @ts-ignore\n role=\"label\"\n id={id}\n {...labelProps}\n ref={composedRefs as any}\n onMouseDown={(event) => {\n props.onMouseDown?.(event)\n // prevent text selection when double clicking label\n if (!event.defaultPrevented && event.detail > 1) {\n event.preventDefault()\n }\n }}\n onPress={(event) => {\n props.onPress?.(event)\n\n if (isWeb) {\n if (!controlRef.current || event.defaultPrevented) return\n const isClickingControl = controlRef.current.contains(\n event.target as any as Node\n )\n // Ensure event was generated by a user action\n // https://developer.mozilla.org/en-US/docs/Web/API/Event/isTrusted\n const isUserClick = event.isTrusted === true\n /**\n * When a label is wrapped around the control it labels, we trigger the appropriate events\n * on the control when the label is clicked. We do nothing if the user is already clicking the\n * control inside the label.\n */\n if (!isClickingControl && isUserClick) {\n controlRef.current.click()\n controlRef.current.focus()\n }\n } else {\n if (props.htmlFor) {\n focusFocusable(props.htmlFor)\n }\n }\n }}\n />\n </LabelProvider>\n )\n }\n)\n\nLabelComponent.displayName = NAME\n\nexport const Label: ReactComponentWithRef<LabelProps, HTMLButtonElement | View> =\n LabelFrame.extractable(themeable(LabelComponent as any) as any, {\n neverFlatten: true,\n })\n\nexport const useLabelContext = (element?: HTMLElement | null) => {\n const context = useLabelContextImpl('LabelConsumer')\n const { controlRef } = context\n\n React.useEffect(() => {\n if (element) controlRef.current = element\n }, [element, controlRef])\n\n return context.id\n}\n\nconst Root = Label\n"],
5
+ "mappings": "AAAA,SAAS,uBAAuB;AAChC;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,YAAY,WAAW;AAGvB,MAAM,OAAO;AAOb,MAAM,CAAC,eAAe,mBAAmB,IAAI,cAAiC,MAAM;AAAA,EAClF,IAAI;AAAA,EACJ,YAAY,EAAE,SAAS,KAAK;AAC9B,CAAC;AAEM,MAAM,aAAa,OAAO,aAAa;AAAA,EAC5C,MAAM;AAAA,EACN,KAAK;AAAA,EACL,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,YAAY;AAAA,IACV,OAAO;AAAA,EACT;AAAA,EACA,UAAU;AAAA,IACR,MAAM;AAAA,MACJ,WAAW,CAAC,KAAK,WAAW;AAC1B,cAAM,c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aAAa,CAAC,UAAU;AACtB,cAAM,cAAc,KAAK;AAEzB,YAAI,CAAC,MAAM,oBAAoB,MAAM,SAAS,GAAG;AAC/C,gBAAM,eAAe;AAAA,QACvB;AAAA,MACF;AAAA,MACA,SAAS,CAAC,UAAU;AAClB,cAAM,UAAU,KAAK;AAErB,YAAI,OAAO;AACT,cAAI,CAAC,WAAW,WAAW,MAAM;AAAkB;AACnD,gBAAM,oBAAoB,WAAW,QAAQ;AAAA,YAC3C,MAAM;AAAA,UACR;AAGA,gBAAM,cAAc,MAAM,cAAc;AAMxC,cAAI,CAAC,qBAAqB,aAAa;AACrC,uBAAW,QAAQ,MAAM;AACzB,uBAAW,QAAQ,MAAM;AAAA,UAC3B;AAAA,QACF,OAAO;AACL,cAAI,MAAM,SAAS;AACjB,2BAAe,MAAM,OAAO;AAAA,UAC9B;AAAA,QACF;AAAA,MACF;AAAA,IACF,EACF,EAzCC;AAAA,EA2CL;AACF;AAEA,eAAe,cAAc;AAEtB,MAAM,QACX,WAAW,YAAY,UAAU,cAAqB,GAAU;AAAA,EAC9D,cAAc;AAChB,CAAC;AAEI,MAAM,kBAAkB,CAAC,YAAiC;AAC/D,QAAM,UAAU,oBAAoB,eAAe;AACnD,QAAM,EAAE,WAAW,IAAI;AAEvB,QAAM,UAAU,MAAM;AACpB,QAAI;AAAS,iBAAW,UAAU;AAAA,EACpC,GAAG,CAAC,SAAS,UAAU,CAAC;AAExB,SAAO,QAAQ;AACjB;AAEA,MAAM,OAAO;",
6
+ "names": ["ariaLabelledBy"]
7
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./Label";
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './Label'\n"],
5
+ "mappings": "AAAA,cAAc;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/label",
3
- "version": "1.2.9",
3
+ "version": "1.2.10",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -26,18 +26,18 @@
26
26
  "./package.json": "./package.json",
27
27
  ".": {
28
28
  "types": "./types/index.d.ts",
29
- "import": "./dist/esm/index.js",
29
+ "import": "./dist/esm/index.mjs",
30
30
  "require": "./dist/cjs/index.js"
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@tamagui/compose-refs": "^1.2.9",
35
- "@tamagui/core": "^1.2.9",
36
- "@tamagui/create-context": "^1.2.9",
37
- "@tamagui/focusable": "^1.2.9",
38
- "@tamagui/get-button-sized": "^1.2.9",
39
- "@tamagui/get-font-sized": "^1.2.9",
40
- "@tamagui/text": "^1.2.9"
34
+ "@tamagui/compose-refs": "^1.2.10",
35
+ "@tamagui/core": "^1.2.10",
36
+ "@tamagui/create-context": "^1.2.10",
37
+ "@tamagui/focusable": "^1.2.10",
38
+ "@tamagui/get-button-sized": "^1.2.10",
39
+ "@tamagui/get-font-sized": "^1.2.10",
40
+ "@tamagui/text": "^1.2.10"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "react": "*",
@@ -45,7 +45,7 @@
45
45
  "react-native": "*"
46
46
  },
47
47
  "devDependencies": {
48
- "@tamagui/build": "^1.2.9",
48
+ "@tamagui/build": "^1.2.10",
49
49
  "react": "^18.2.0",
50
50
  "react-dom": "^18.2.0",
51
51
  "react-native": "*"