@tamagui/group 2.7.7 → 3.0.0-beta.643.1

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.
Files changed (49) hide show
  1. package/dist/cjs/Group.cjs +104 -132
  2. package/dist/cjs/Group.native.cjs +147 -0
  3. package/dist/cjs/Group.native.js +109 -136
  4. package/dist/cjs/Group.native.js.map +1 -1
  5. package/dist/cjs/index.cjs +10 -11
  6. package/dist/cjs/index.native.cjs +21 -0
  7. package/dist/cjs/index.native.js +10 -10
  8. package/dist/cjs/index.native.js.map +1 -1
  9. package/dist/cjs/useIndexedChildren.cjs +52 -58
  10. package/dist/cjs/useIndexedChildren.native.cjs +84 -0
  11. package/dist/cjs/useIndexedChildren.native.js +60 -65
  12. package/dist/cjs/useIndexedChildren.native.js.map +1 -1
  13. package/dist/esm/Group.mjs +84 -104
  14. package/dist/esm/Group.mjs.map +1 -1
  15. package/dist/esm/Group.native.js +90 -110
  16. package/dist/esm/Group.native.js.map +1 -1
  17. package/dist/esm/index.js +1 -2
  18. package/dist/esm/index.mjs +1 -2
  19. package/dist/esm/index.native.js +1 -2
  20. package/dist/esm/useIndexedChildren.mjs +35 -33
  21. package/dist/esm/useIndexedChildren.mjs.map +1 -1
  22. package/dist/esm/useIndexedChildren.native.js +44 -42
  23. package/dist/esm/useIndexedChildren.native.js.map +1 -1
  24. package/dist/jsx/Group.mjs +84 -104
  25. package/dist/jsx/Group.mjs.map +1 -1
  26. package/dist/jsx/Group.native.cjs +147 -0
  27. package/dist/jsx/Group.native.js +109 -136
  28. package/dist/jsx/Group.native.js.map +1 -1
  29. package/dist/jsx/index.js +1 -2
  30. package/dist/jsx/index.mjs +1 -2
  31. package/dist/jsx/index.native.cjs +21 -0
  32. package/dist/jsx/index.native.js +10 -10
  33. package/dist/jsx/index.native.js.map +1 -1
  34. package/dist/jsx/useIndexedChildren.mjs +35 -33
  35. package/dist/jsx/useIndexedChildren.mjs.map +1 -1
  36. package/dist/jsx/useIndexedChildren.native.cjs +84 -0
  37. package/dist/jsx/useIndexedChildren.native.js +60 -65
  38. package/dist/jsx/useIndexedChildren.native.js.map +1 -1
  39. package/package.json +9 -9
  40. package/src/Group.tsx +20 -19
  41. package/types/Group.d.ts +107 -78
  42. package/types/Group.d.ts.map +1 -1
  43. package/types/useIndexedChildren.d.ts +1 -1
  44. package/types/useIndexedChildren.d.ts.map +1 -1
  45. package/dist/esm/index.js.map +0 -1
  46. package/dist/esm/index.mjs.map +0 -1
  47. package/dist/esm/index.native.js.map +0 -1
  48. package/dist/jsx/index.js.map +0 -1
  49. package/dist/jsx/index.mjs.map +0 -1
@@ -1,3 +1,4 @@
1
+
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -5,40 +6,33 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
6
  var __getProtoOf = Object.getPrototypeOf;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
12
13
  };
13
14
  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, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
21
22
  };
22
- 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: true
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
30
26
  }) : target, mod));
31
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: true
33
- }), mod);
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
28
  var Group_exports = {};
35
29
  __export(Group_exports, {
36
- Group: () => Group,
37
- GroupFrame: () => GroupFrame,
38
- XGroup: () => XGroup,
39
- YGroup: () => YGroup,
40
- createGroupScope: () => createGroupScope,
41
- useGroupItem: () => useGroupItem
30
+ Group: () => Group,
31
+ GroupFrame: () => GroupFrame,
32
+ XGroup: () => XGroup,
33
+ YGroup: () => YGroup,
34
+ createGroupScope: () => createGroupScope,
35
+ useGroupItem: () => useGroupItem
42
36
  });
43
37
  module.exports = __toCommonJS(Group_exports);
44
38
  var import_core = require("@tamagui/core");
@@ -51,119 +45,97 @@ var import_jsx_runtime = require("react/jsx-runtime");
51
45
  const GROUP_NAME = "Group";
52
46
  const [createGroupContext, createGroupScope] = (0, import_create_context.createContextScope)(GROUP_NAME);
53
47
  const [GroupProvider, useGroupContext] = createGroupContext(GROUP_NAME);
48
+ const groupSizeVariant = (val, { tokens }) => {
49
+ const radiusToken = (0, import_core.resolveSizeToken)(val, "radius");
50
+ return { borderRadius: tokens.radius[radiusToken] ?? radiusToken };
51
+ };
54
52
  const GroupFrame = (0, import_core.styled)(import_stacks.YStack, {
55
- name: "GroupFrame",
56
- variants: {
57
- unstyled: {
58
- false: {
59
- size: "$true"
60
- }
61
- },
62
- size: (val, {
63
- tokens
64
- }) => {
65
- const borderRadius = tokens.radius[val] ?? val ?? tokens.radius["$true"];
66
- return {
67
- borderRadius
68
- };
69
- }
70
- },
71
- defaultVariants: {
72
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
73
- }
53
+ displayName: "GroupFrame",
54
+ size: true,
55
+ variants: { size: {
56
+ true: groupSizeVariant,
57
+ any: groupSizeVariant
58
+ } }
74
59
  });
75
60
  function createGroup(verticalDefault) {
76
- return (0, import_helpers.withStaticProperties)(GroupFrame.styleable((props, ref) => {
77
- const {
78
- __scopeGroup,
79
- children: childrenProp,
80
- orientation = verticalDefault ? "vertical" : "horizontal",
81
- disabled,
82
- ...restProps
83
- } = props;
84
- const vertical = orientation === "vertical";
85
- const indexedChildren = (0, import_useIndexedChildren.useIndexedChildren)(import_react.default.Children.toArray(childrenProp));
86
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(GroupProvider, {
87
- vertical,
88
- disabled,
89
- scope: __scopeGroup,
90
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(GroupFrame, {
91
- ref,
92
- flexDirection: vertical ? "column" : "row",
93
- ...restProps,
94
- children: indexedChildren
95
- })
96
- });
97
- }), {
98
- Item: GroupItem
99
- });
61
+ return (0, import_helpers.withStaticProperties)((0, import_core.createStyledHOC)(GroupFrame, (props, ref) => {
62
+ const { __scopeGroup, children: childrenProp, orientation = verticalDefault ? "vertical" : "horizontal", disabled, ...restProps } = props;
63
+ const vertical = orientation === "vertical";
64
+ const indexedChildren = (0, import_useIndexedChildren.useIndexedChildren)(import_react.default.Children.toArray(childrenProp));
65
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GroupProvider, {
66
+ vertical,
67
+ disabled,
68
+ scope: __scopeGroup,
69
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GroupFrame, {
70
+ ref,
71
+ flexDirection: vertical ? "column" : "row",
72
+ ...restProps,
73
+ children: indexedChildren
74
+ })
75
+ });
76
+ }), { Item: GroupItem });
100
77
  }
101
78
  function GroupItem(props) {
102
- const {
103
- __scopeGroup,
104
- children,
105
- forcePlacement,
106
- ...forwardedProps
107
- } = props;
108
- const context = useGroupContext("GroupItem", __scopeGroup);
109
- const treeIndex = (0, import_useIndexedChildren.useIndex)();
110
- if (!treeIndex) {
111
- throw Error("<Group.Item/> should only be used within a <Group/>");
112
- }
113
- if (!import_react.default.isValidElement(children)) {
114
- return children;
115
- }
116
- const isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0;
117
- const isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex;
118
- const radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical);
119
- const groupProps = {
120
- ...forwardedProps,
121
- ...radiusStyles
122
- };
123
- if (context.disabled != null) {
124
- groupProps.disabled = children.props.disabled ?? context.disabled;
125
- }
126
- const mergedProps = (0, import_core.mergeSlotStyleProps)(groupProps, children.props);
127
- return import_react.default.cloneElement(children, mergedProps);
79
+ const { __scopeGroup, children, forcePlacement, ...forwardedProps } = props;
80
+ const context = useGroupContext("GroupItem", __scopeGroup);
81
+ const treeIndex = (0, import_useIndexedChildren.useIndex)();
82
+ if (!treeIndex) {
83
+ throw Error("<Group.Item/> should only be used within a <Group/>");
84
+ }
85
+ if (!import_react.default.isValidElement(children)) {
86
+ return children;
87
+ }
88
+ const isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0;
89
+ const isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex;
90
+ const radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical);
91
+ const groupProps = {
92
+ ...forwardedProps,
93
+ ...radiusStyles
94
+ };
95
+ if (context.disabled != null) {
96
+ groupProps.disabled = children.props.disabled ?? context.disabled;
97
+ }
98
+ const mergedProps = (0, import_core.mergeSlotStyleProps)(groupProps, children.props);
99
+ return import_react.default.cloneElement(children, mergedProps);
128
100
  }
129
101
  const useGroupItem = (childrenProps, forcePlacement, __scopeGroup) => {
130
- const treeIndex = (0, import_useIndexedChildren.useIndex)();
131
- const context = useGroupContext("GroupItem", __scopeGroup);
132
- if (!treeIndex) {
133
- throw Error("useGroupItem should only be used within a <Group/>");
134
- }
135
- const isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0;
136
- const isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex;
137
- const radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical);
138
- return {
139
- disabled: childrenProps.disabled ?? context.disabled,
140
- ...radiusStyles
141
- };
102
+ const treeIndex = (0, import_useIndexedChildren.useIndex)();
103
+ const context = useGroupContext("GroupItem", __scopeGroup);
104
+ if (!treeIndex) {
105
+ throw Error("useGroupItem should only be used within a <Group/>");
106
+ }
107
+ const isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0;
108
+ const isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex;
109
+ const radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical);
110
+ return {
111
+ disabled: childrenProps.disabled ?? context.disabled,
112
+ ...radiusStyles
113
+ };
142
114
  };
143
115
  const Group = createGroup(true);
144
116
  const YGroup = Group;
145
117
  const XGroup = createGroup(false);
146
118
  function getZeroedRadius(isFirst, isLast, vertical) {
147
- if (vertical) {
148
- return {
149
- ...(isFirst ? null : {
150
- borderTopLeftRadius: 0,
151
- borderTopRightRadius: 0
152
- }),
153
- ...(isLast ? null : {
154
- borderBottomLeftRadius: 0,
155
- borderBottomRightRadius: 0
156
- })
157
- };
158
- }
159
- return {
160
- ...(isFirst ? null : {
161
- borderTopLeftRadius: 0,
162
- borderBottomLeftRadius: 0
163
- }),
164
- ...(isLast ? null : {
165
- borderTopRightRadius: 0,
166
- borderBottomRightRadius: 0
167
- })
168
- };
169
- }
119
+ if (vertical) {
120
+ return {
121
+ ...isFirst ? null : {
122
+ borderTopLeftRadius: 0,
123
+ borderTopRightRadius: 0
124
+ },
125
+ ...isLast ? null : {
126
+ borderBottomLeftRadius: 0,
127
+ borderBottomRightRadius: 0
128
+ }
129
+ };
130
+ }
131
+ return {
132
+ ...isFirst ? null : {
133
+ borderTopLeftRadius: 0,
134
+ borderBottomLeftRadius: 0
135
+ },
136
+ ...isLast ? null : {
137
+ borderTopRightRadius: 0,
138
+ borderBottomRightRadius: 0
139
+ }
140
+ };
141
+ }
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+
3
+
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all) __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
19
+ get: () => from[key],
20
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
21
+ });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
26
+ value: mod,
27
+ enumerable: true
28
+ }) : target, mod));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var Group_exports = {};
31
+ __export(Group_exports, {
32
+ Group: () => Group,
33
+ GroupFrame: () => GroupFrame,
34
+ XGroup: () => XGroup,
35
+ YGroup: () => YGroup,
36
+ createGroupScope: () => createGroupScope,
37
+ useGroupItem: () => useGroupItem
38
+ });
39
+ module.exports = __toCommonJS(Group_exports);
40
+ var import_jsx_runtime = require("react/jsx-runtime");
41
+ var import_core = require("@tamagui/core");
42
+ var import_create_context = require("@tamagui/create-context");
43
+ var import_helpers = require("@tamagui/helpers");
44
+ var import_stacks = require("@tamagui/stacks");
45
+ var import_react = __toESM(require("react"), 1);
46
+ var import_useIndexedChildren = require("./useIndexedChildren.native.js");
47
+ var GROUP_NAME = "Group";
48
+ var [createGroupContext, createGroupScope] = (0, import_create_context.createContextScope)(GROUP_NAME);
49
+ var [GroupProvider, useGroupContext] = createGroupContext(GROUP_NAME);
50
+ var groupSizeVariant = function(val, param) {
51
+ var { tokens } = param;
52
+ var radiusToken = (0, import_core.resolveSizeToken)(val, "radius");
53
+ var _tokens_radius_radiusToken;
54
+ return { borderRadius: (_tokens_radius_radiusToken = tokens.radius[radiusToken]) !== null && _tokens_radius_radiusToken !== void 0 ? _tokens_radius_radiusToken : radiusToken };
55
+ };
56
+ var GroupFrame = (0, import_core.styled)(import_stacks.YStack, {
57
+ displayName: "GroupFrame",
58
+ size: true,
59
+ variants: { size: {
60
+ true: groupSizeVariant,
61
+ any: groupSizeVariant
62
+ } }
63
+ });
64
+ function createGroup(verticalDefault) {
65
+ return (0, import_helpers.withStaticProperties)((0, import_core.createStyledHOC)(GroupFrame, function(props, ref) {
66
+ var { __scopeGroup, children: childrenProp, orientation = verticalDefault ? "vertical" : "horizontal", disabled, ...restProps } = props;
67
+ var vertical = orientation === "vertical";
68
+ var indexedChildren = (0, import_useIndexedChildren.useIndexedChildren)(import_react.default.Children.toArray(childrenProp));
69
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GroupProvider, {
70
+ vertical,
71
+ disabled,
72
+ scope: __scopeGroup,
73
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GroupFrame, {
74
+ ref,
75
+ flexDirection: vertical ? "column" : "row",
76
+ ...restProps,
77
+ children: indexedChildren
78
+ })
79
+ });
80
+ }), { Item: GroupItem });
81
+ }
82
+ function GroupItem(props) {
83
+ var { __scopeGroup, children, forcePlacement, ...forwardedProps } = props;
84
+ var context = useGroupContext("GroupItem", __scopeGroup);
85
+ var treeIndex = (0, import_useIndexedChildren.useIndex)();
86
+ if (!treeIndex) {
87
+ throw Error("<Group.Item/> should only be used within a <Group/>");
88
+ }
89
+ if (!/* @__PURE__ */ import_react.default.isValidElement(children)) {
90
+ return children;
91
+ }
92
+ var isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0;
93
+ var isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex;
94
+ var radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical);
95
+ var groupProps = {
96
+ ...forwardedProps,
97
+ ...radiusStyles
98
+ };
99
+ if (context.disabled != null) {
100
+ var _children_props_disabled;
101
+ groupProps.disabled = (_children_props_disabled = children.props.disabled) !== null && _children_props_disabled !== void 0 ? _children_props_disabled : context.disabled;
102
+ }
103
+ var mergedProps = (0, import_core.mergeSlotStyleProps)(groupProps, children.props);
104
+ return /* @__PURE__ */ import_react.default.cloneElement(children, mergedProps);
105
+ }
106
+ var useGroupItem = function(childrenProps, forcePlacement, __scopeGroup) {
107
+ var treeIndex = (0, import_useIndexedChildren.useIndex)();
108
+ var context = useGroupContext("GroupItem", __scopeGroup);
109
+ if (!treeIndex) {
110
+ throw Error("useGroupItem should only be used within a <Group/>");
111
+ }
112
+ var isFirst = forcePlacement === "first" || forcePlacement !== "last" && treeIndex.index === 0;
113
+ var isLast = forcePlacement === "last" || forcePlacement !== "first" && treeIndex.index === treeIndex.maxIndex;
114
+ var radiusStyles = getZeroedRadius(isFirst, isLast, context.vertical);
115
+ var _childrenProps_disabled;
116
+ return {
117
+ disabled: (_childrenProps_disabled = childrenProps.disabled) !== null && _childrenProps_disabled !== void 0 ? _childrenProps_disabled : context.disabled,
118
+ ...radiusStyles
119
+ };
120
+ };
121
+ var Group = createGroup(true);
122
+ var YGroup = Group;
123
+ var XGroup = createGroup(false);
124
+ function getZeroedRadius(isFirst, isLast, vertical) {
125
+ if (vertical) {
126
+ return {
127
+ ...isFirst ? null : {
128
+ borderTopLeftRadius: 0,
129
+ borderTopRightRadius: 0
130
+ },
131
+ ...isLast ? null : {
132
+ borderBottomLeftRadius: 0,
133
+ borderBottomRightRadius: 0
134
+ }
135
+ };
136
+ }
137
+ return {
138
+ ...isFirst ? null : {
139
+ borderTopLeftRadius: 0,
140
+ borderBottomLeftRadius: 0
141
+ },
142
+ ...isLast ? null : {
143
+ borderTopRightRadius: 0,
144
+ borderBottomRightRadius: 0
145
+ }
146
+ };
147
+ }