@tamagui/helpers 1.0.1-beta.21 → 1.0.1-beta.210

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 (68) hide show
  1. package/dist/cjs/clamp.js +1 -2
  2. package/dist/cjs/clamp.js.map +1 -1
  3. package/dist/cjs/composeEventHandlers.js +4 -5
  4. package/dist/cjs/composeEventHandlers.js.map +2 -2
  5. package/dist/cjs/concatClassName.js +4 -5
  6. package/dist/cjs/concatClassName.js.map +2 -2
  7. package/dist/cjs/index.js +2 -1
  8. package/dist/cjs/index.js.map +2 -2
  9. package/dist/cjs/log.js +3 -3
  10. package/dist/cjs/log.js.map +1 -1
  11. package/dist/cjs/types.js +1 -0
  12. package/dist/cjs/types.js.map +2 -2
  13. package/dist/cjs/validStyleProps.js +37 -58
  14. package/dist/cjs/validStyleProps.js.map +2 -2
  15. package/dist/esm/clamp.js +0 -3
  16. package/dist/esm/clamp.js.map +1 -1
  17. package/dist/esm/composeEventHandlers.js +3 -6
  18. package/dist/esm/composeEventHandlers.js.map +2 -2
  19. package/dist/esm/concatClassName.js +3 -6
  20. package/dist/esm/concatClassName.js.map +2 -2
  21. package/dist/esm/index.js +1 -1
  22. package/dist/esm/index.js.map +2 -2
  23. package/dist/esm/log.js +2 -4
  24. package/dist/esm/log.js.map +1 -1
  25. package/dist/esm/types.js +0 -0
  26. package/dist/esm/types.js.map +0 -0
  27. package/dist/esm/validStyleProps.js +3 -18
  28. package/dist/esm/validStyleProps.js.map +2 -2
  29. package/dist/jsx/clamp.js +1 -3
  30. package/dist/jsx/clamp.js.map +7 -0
  31. package/dist/jsx/composeEventHandlers.js +6 -8
  32. package/dist/jsx/composeEventHandlers.js.map +7 -0
  33. package/dist/jsx/concatClassName.js +4 -6
  34. package/dist/jsx/concatClassName.js.map +7 -0
  35. package/dist/jsx/index.js +2 -1
  36. package/dist/jsx/index.js.map +7 -0
  37. package/dist/jsx/log.js +3 -4
  38. package/dist/jsx/log.js.map +7 -0
  39. package/dist/jsx/types.js +1 -0
  40. package/dist/jsx/types.js.map +7 -0
  41. package/dist/jsx/validStyleProps.js +4 -18
  42. package/dist/jsx/validStyleProps.js.map +7 -0
  43. package/package.json +13 -8
  44. package/src/clamp.ts +3 -0
  45. package/src/composeEventHandlers.ts +22 -0
  46. package/src/concatClassName.ts +97 -0
  47. package/src/index.ts +6 -0
  48. package/src/types.ts +7 -0
  49. package/src/validStyleProps.ts +165 -0
  50. package/types/composeEventHandlers.d.ts +4 -4
  51. package/types/concatClassName.d.ts +6 -0
  52. package/types/index.d.ts +1 -1
  53. package/types/simpleHash.d.ts +2 -1
  54. package/types/types.d.ts +1 -1
  55. package/types/validStyleProps.d.ts +503 -507
  56. package/dist/cjs/simpleHash.js +0 -37
  57. package/dist/cjs/simpleHash.js.map +0 -7
  58. package/dist/esm/simpleHash.js +0 -15
  59. package/dist/esm/simpleHash.js.map +0 -7
  60. package/dist/jsx/simpleHash.js +0 -14
  61. package/types/clamp.d.ts.map +0 -1
  62. package/types/composeEventHandlers.d.ts.map +0 -1
  63. package/types/concatClassName.d.ts.map +0 -1
  64. package/types/index.d.ts.map +0 -1
  65. package/types/log.d.ts.map +0 -1
  66. package/types/simpleHash.d.ts.map +0 -1
  67. package/types/types.d.ts.map +0 -1
  68. package/types/validStyleProps.d.ts.map +0 -1
package/dist/jsx/clamp.js CHANGED
@@ -1,9 +1,7 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  function clamp(value, [min, max]) {
4
2
  return Math.min(max, Math.max(min, value));
5
3
  }
6
- __name(clamp, "clamp");
7
4
  export {
8
5
  clamp
9
6
  };
7
+ //# sourceMappingURL=clamp.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/clamp.ts"],
4
+ "sourcesContent": ["export function clamp(value: number, [min, max]: [number, number]): number {\n return Math.min(max, Math.max(min, value))\n}\n"],
5
+ "mappings": "AAAO,SAAS,MAAM,OAAe,CAAC,KAAK,GAAG,GAA6B;AACzE,SAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;AAC3C;",
6
+ "names": []
7
+ }
@@ -1,14 +1,12 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  function composeEventHandlers(og, next, { checkDefaultPrevented = true } = {}) {
4
- return /* @__PURE__ */ __name(function composedEventHandler(event) {
5
- og == null ? void 0 : og(event);
6
- if (!checkDefaultPrevented || !event.defaultPrevented) {
7
- return next == null ? void 0 : next(event);
2
+ return function composedEventHandler(event) {
3
+ og?.(event);
4
+ if (!checkDefaultPrevented || !("defaultPrevented" in event) || "defaultPrevented" in event && !event.defaultPrevented) {
5
+ return next?.(event);
8
6
  }
9
- }, "composedEventHandler");
7
+ };
10
8
  }
11
- __name(composeEventHandlers, "composeEventHandlers");
12
9
  export {
13
10
  composeEventHandlers
14
11
  };
12
+ //# sourceMappingURL=composeEventHandlers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/composeEventHandlers.ts"],
4
+ "sourcesContent": ["import type { FocusEvent } from 'react'\nimport type { GestureResponderEvent, NativeScrollEvent, NativeSyntheticEvent } from 'react-native'\n\ntype Events = Event | GestureResponderEvent | FocusEvent | NativeSyntheticEvent<NativeScrollEvent>\n\nexport type EventHandler<E extends Events> = (event: E) => void\n\nexport function composeEventHandlers<E extends Events>(\n og?: EventHandler<E>,\n next?: EventHandler<E>,\n { checkDefaultPrevented = true } = {}\n) {\n return function composedEventHandler(event: E) {\n og?.(event)\n if (\n !checkDefaultPrevented ||\n !('defaultPrevented' in event) ||\n ('defaultPrevented' in event && !event.defaultPrevented)\n ) {\n return next?.(event)\n }\n }\n}\n"],
5
+ "mappings": "AAOO,SAAS,qBACd,IACA,MACA,EAAE,wBAAwB,KAAK,IAAI,CAAC,GACpC;AACA,SAAO,SAAS,qBAAqB,OAAU;AAC7C,SAAK,KAAK;AACV,QACE,CAAC,yBACD,EAAE,sBAAsB,UACvB,sBAAsB,SAAS,CAAC,MAAM,kBACvC;AACA,aAAO,OAAO,KAAK;AAAA,IACrB;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
@@ -1,13 +1,11 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  function concatClassName(_cn) {
4
- const cnOrPropObjcet = arguments;
2
+ const args = arguments;
5
3
  const usedPrefixes = [];
6
4
  let final = "";
7
- const len = cnOrPropObjcet.length;
5
+ const len = args.length;
8
6
  let propObjects = null;
9
7
  for (let x = len; x >= 0; x--) {
10
- const cns = cnOrPropObjcet[x];
8
+ const cns = args[x];
11
9
  if (!cns)
12
10
  continue;
13
11
  if (!Array.isArray(cns) && typeof cns !== "string") {
@@ -57,7 +55,6 @@ function concatClassName(_cn) {
57
55
  }
58
56
  return final;
59
57
  }
60
- __name(concatClassName, "concatClassName");
61
58
  const pseudoInvert = {
62
59
  hover: "hoverStyle",
63
60
  focus: "focusStyle",
@@ -66,3 +63,4 @@ const pseudoInvert = {
66
63
  export {
67
64
  concatClassName
68
65
  };
66
+ //# sourceMappingURL=concatClassName.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/concatClassName.ts"],
4
+ "sourcesContent": ["// perf sensitive so doing some weird stuff\n\nimport type { ViewStyle } from 'react-native'\n\n/**\n * next - take objects:\n *\n * { _shorthand: 'postfix' }\n *\n */\n\nexport function concatClassName(...args: any[]): any\nexport function concatClassName(_cn: ViewStyle | null | undefined): string {\n const args = arguments\n const usedPrefixes: string[] = []\n let final = ''\n\n const len = args.length\n let propObjects: any = null\n for (let x = len; x >= 0; x--) {\n const cns = args[x]\n\n if (!cns) continue\n if (!Array.isArray(cns) && typeof cns !== 'string') {\n // is prop object\n propObjects = propObjects || []\n propObjects.push(cns)\n continue\n }\n\n const names = Array.isArray(cns) ? cns : cns.split(' ')\n const numNames = names.length\n for (let i = numNames - 1; i >= 0; i--) {\n const name = names[i]\n\n if (!name || name === ' ') continue\n if (name[0] !== '_') {\n // not snack style (todo slightly stronger heuristic)\n final = name + ' ' + final\n continue\n }\n\n const splitIndex = name.indexOf('-')\n if (splitIndex < 1) {\n final = name + ' ' + final\n // if (shouldDebug) console.log('debug exclude:', name, final)\n continue\n }\n\n const nextChar = name[splitIndex + 1]\n // synced to static-ui constants\n // MEDIA_SEP\n const isMediaQuery = nextChar === '_'\n // PSEUDO_SEP\n // commenting out three things to make pseudos override properly\n // (leave in for a bit to see if other bugs pop up later):\n // 1. const isPseudoQuery = nextChar === '0'\n const styleKey = name.slice(1, name.lastIndexOf('-'))\n // 2. isMediaQuery || isPseudoQuery\n const mediaKey = isMediaQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null\n const uid = mediaKey ? styleKey + mediaKey : styleKey\n // 3. && !isPseudoQuery\n\n if (usedPrefixes.indexOf(uid) > -1) {\n // if (shouldDebug) console.log('debug exclude:', usedPrefixes, name)\n continue\n }\n usedPrefixes.push(uid)\n\n // overrides for full safety\n const propName = styleKey\n if (propName && propObjects) {\n if (\n propObjects.some((po) => {\n if (mediaKey) {\n const propKey = pseudoInvert[mediaKey]\n return po && po[propKey] && propName in po[propKey] && po[propKey] !== null\n }\n const res = po && propName in po && po[propName] !== null\n return res\n })\n ) {\n // if (shouldDebug) console.log('debug exclude:', name)\n continue\n }\n }\n\n final = name + ' ' + final\n }\n }\n\n return final\n}\n\nconst pseudoInvert = {\n hover: 'hoverStyle',\n focus: 'focusStyle',\n press: 'pressStyle',\n}\n"],
5
+ "mappings": "AAYO,SAAS,gBAAgB,KAA2C;AACzE,QAAM,OAAO;AACb,QAAM,eAAyB,CAAC;AAChC,MAAI,QAAQ;AAEZ,QAAM,MAAM,KAAK;AACjB,MAAI,cAAmB;AACvB,WAAS,IAAI,KAAK,KAAK,GAAG,KAAK;AAC7B,UAAM,MAAM,KAAK;AAEjB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AAA,EACnB,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACT;",
6
+ "names": []
7
+ }
package/dist/jsx/index.js CHANGED
@@ -3,4 +3,5 @@ export * from "./composeEventHandlers";
3
3
  export * from "./concatClassName";
4
4
  export * from "./validStyleProps";
5
5
  export * from "./types";
6
- export * from "./log";
6
+ export * from "@tamagui/simple-hash";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["export * from './clamp'\nexport * from './composeEventHandlers'\nexport * from './concatClassName'\nexport * from './validStyleProps'\nexport * from './types'\nexport * from '@tamagui/simple-hash'\n"],
5
+ "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
+ "names": []
7
+ }
package/dist/jsx/log.js CHANGED
@@ -1,9 +1,8 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- const log = /* @__PURE__ */ __name((...args) => {
1
+ const log = (...args) => {
4
2
  console.log(...args);
5
3
  return args[0];
6
- }, "log");
4
+ };
7
5
  export {
8
6
  log
9
7
  };
8
+ //# sourceMappingURL=log.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/log.ts"],
4
+ "sourcesContent": ["export const log = (...args: any) => {\n console.log(...args)\n return args[0]\n}\n"],
5
+ "mappings": "AAAO,MAAM,MAAM,IAAI,SAAc;AACnC,UAAQ,IAAI,GAAG,IAAI;AACnB,SAAO,KAAK;AACd;",
6
+ "names": []
7
+ }
package/dist/jsx/types.js CHANGED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,5 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
1
  const stylePropsTransform = Object.freeze({
4
2
  x: true,
5
3
  y: true,
@@ -133,7 +131,9 @@ const stylePropsTextOnly = Object.freeze({
133
131
  textDecorationDistance: true,
134
132
  userSelect: true,
135
133
  selectable: true,
136
- cursor: true
134
+ cursor: true,
135
+ WebkitLineClamp: true,
136
+ WebkitBoxOrient: true
137
137
  }
138
138
  });
139
139
  const stylePropsText = Object.freeze({
@@ -152,22 +152,7 @@ const validStyles = Object.freeze({
152
152
  ...validPseudoKeys,
153
153
  ...stylePropsView
154
154
  });
155
- const mapTransformKeys = {
156
- x: "translateX",
157
- y: "translateY"
158
- };
159
- const invertMapTransformKeys = {
160
- translateX: "x",
161
- translateY: "y"
162
- };
163
- const mergeTransform = /* @__PURE__ */ __name((obj, key, val) => {
164
- obj.transform || (obj.transform = []);
165
- obj.transform.push({ [mapTransformKeys[key] || key]: val });
166
- }, "mergeTransform");
167
155
  export {
168
- invertMapTransformKeys,
169
- mapTransformKeys,
170
- mergeTransform,
171
156
  stylePropsAll,
172
157
  stylePropsText,
173
158
  stylePropsTextOnly,
@@ -176,3 +161,4 @@ export {
176
161
  validPseudoKeys,
177
162
  validStyles
178
163
  };
164
+ //# sourceMappingURL=validStyleProps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/validStyleProps.ts"],
4
+ "sourcesContent": ["// flat transform props\nexport const stylePropsTransform = Object.freeze({\n x: true,\n y: true,\n scale: true,\n perspective: true,\n scaleX: true,\n scaleY: true,\n skewX: true,\n skewY: true,\n matrix: true,\n rotate: true,\n rotateY: true,\n rotateX: true,\n rotateZ: true,\n})\n\nexport const stylePropsView = Object.freeze({\n backfaceVisibility: true,\n backgroundColor: true,\n borderBottomColor: true,\n borderBottomStyle: true,\n borderTopStyle: true,\n borderLeftStyle: true,\n borderRightStyle: true,\n borderBottomEndRadius: true,\n borderBottomLeftRadius: true,\n borderBottomRightRadius: true,\n borderBottomStartRadius: true,\n borderBottomWidth: true,\n borderColor: true,\n borderEndColor: true,\n borderLeftColor: true,\n borderLeftWidth: true,\n borderRadius: true,\n borderRightColor: true,\n borderRightWidth: true,\n borderStartColor: true,\n borderStyle: true,\n borderTopColor: true,\n borderTopEndRadius: true,\n borderTopLeftRadius: true,\n borderTopRightRadius: true,\n borderTopStartRadius: true,\n borderTopWidth: true,\n borderWidth: true,\n opacity: true,\n transform: true,\n alignContent: true,\n alignItems: true,\n alignSelf: true,\n aspectRatio: true,\n borderEndWidth: true,\n borderStartWidth: true,\n bottom: true,\n display: true,\n end: true,\n flex: true,\n flexBasis: true,\n flexDirection: true,\n flexGrow: true,\n flexShrink: true,\n flexWrap: true,\n height: true,\n justifyContent: true,\n left: true,\n margin: true,\n marginBottom: true,\n marginEnd: true,\n marginHorizontal: true,\n marginLeft: true,\n marginRight: true,\n marginStart: true,\n marginTop: true,\n marginVertical: true,\n maxHeight: true,\n maxWidth: true,\n minHeight: true,\n minWidth: true,\n overflow: true,\n padding: true,\n paddingBottom: true,\n paddingEnd: true,\n paddingHorizontal: true,\n paddingLeft: true,\n paddingRight: true,\n paddingStart: true,\n paddingTop: true,\n paddingVertical: true,\n position: true,\n right: true,\n start: true,\n top: true,\n width: true,\n zIndex: true,\n direction: true,\n shadowColor: true,\n shadowOffset: true,\n shadowOpacity: true,\n shadowRadius: true,\n ...stylePropsTransform,\n\n // allow a few web only ones\n ...(process.env.TAMAGUI_TARGET === 'web' && {\n overflowX: true,\n overflowY: true,\n userSelect: true,\n cursor: true,\n contain: true,\n pointerEvents: true,\n boxSizing: true,\n boxShadow: true,\n }),\n})\n\nexport const stylePropsTextOnly = Object.freeze({\n color: true,\n fontFamily: true,\n fontSize: true,\n fontStyle: true,\n fontWeight: true,\n letterSpacing: true,\n lineHeight: true,\n textAlign: true,\n textDecorationLine: true,\n textDecorationStyle: true,\n textDecorationColor: true,\n textShadowColor: true,\n textShadowOffset: true,\n textShadowRadius: true,\n textTransform: true,\n\n // allow some web only ones\n ...(process.env.TAMAGUI_TARGET === 'web' && {\n whiteSpace: true,\n wordWrap: true,\n textOverflow: true,\n textDecorationDistance: true,\n userSelect: true,\n selectable: true,\n cursor: true,\n WebkitLineClamp: true,\n WebkitBoxOrient: true,\n }),\n})\n\nexport const stylePropsText = Object.freeze({\n ...stylePropsView,\n ...stylePropsTextOnly,\n})\n\nexport const stylePropsAll = stylePropsText\n\nexport const validPseudoKeys = Object.freeze({\n enterStyle: true,\n exitStyle: true,\n hoverStyle: true,\n pressStyle: true,\n focusStyle: true,\n})\n\nexport const validStyles = Object.freeze({\n ...validPseudoKeys,\n ...stylePropsView,\n})\n"],
5
+ "mappings": "AACO,MAAM,sBAAsB,OAAO,OAAO;AAAA,EAC/C,GAAG;AAAA,EACH,GAAG;AAAA,EACH,OAAO;AAAA,EACP,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AACX,CAAC;AAEM,MAAM,iBAAiB,OAAO,OAAO;AAAA,EAC1C,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,mBAAmB;AAAA,EACnB,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,sB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C;AAEM,MAAM,qBAAqB,OAAO,OAAO;AAAA,EAC9C,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EAGf,GAAI,QAAQ,IAAI,mBAAmB,SAAS;AAAA,IAC1C,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,cAAc;AAAA,IACd,wBAAwB;AAAA,IACxB,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,iBAAiB;AAAA,IACjB,iBAAiB;AAAA,EACnB;AACF,CAAC;AAEM,MAAM,iBAAiB,OAAO,OAAO;AAAA,EAC1C,GAAG;AAAA,EACH,GAAG;AACL,CAAC;AAEM,MAAM,gBAAgB;AAEtB,MAAM,kBAAkB,OAAO,OAAO;AAAA,EAC3C,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACd,CAAC;AAEM,MAAM,cAAc,OAAO,OAAO;AAAA,EACvC,GAAG;AAAA,EACH,GAAG;AACL,CAAC;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,30 +1,35 @@
1
1
  {
2
2
  "name": "@tamagui/helpers",
3
- "version": "1.0.1-beta.21",
3
+ "version": "1.0.1-beta.210",
4
4
  "source": "src/index.ts",
5
- "types": "types",
5
+ "types": "./types/index.d.ts",
6
6
  "main": "dist/cjs",
7
7
  "module": "dist/esm",
8
- "module:jsx": "dist/jsx",
9
8
  "files": [
9
+ "src",
10
10
  "types",
11
11
  "dist"
12
12
  ],
13
13
  "scripts": {
14
14
  "build": "tamagui-build",
15
15
  "watch": "tamagui-build --watch",
16
+ "lint": "eslint",
17
+ "lint:fix": "yarn lint --fix",
16
18
  "clean": "tamagui-build clean",
17
19
  "clean:build": "tamagui-build clean:build"
18
20
  },
19
21
  "devDependencies": {
20
- "@tamagui/build": "^1.0.1-beta.21",
21
- "react-native": "*"
22
- },
23
- "peerDependencies": {
24
- "react-native": "*"
22
+ "@tamagui/build": "^1.0.1-beta.210"
25
23
  },
26
24
  "publishConfig": {
27
25
  "access": "public"
28
26
  },
27
+ "exports": {
28
+ "./package.json": "./package.json",
29
+ ".": {
30
+ "import": "./dist/esm/index.js",
31
+ "require": "./dist/cjs/index.js"
32
+ }
33
+ },
29
34
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14"
30
35
  }
package/src/clamp.ts ADDED
@@ -0,0 +1,3 @@
1
+ export function clamp(value: number, [min, max]: [number, number]): number {
2
+ return Math.min(max, Math.max(min, value))
3
+ }
@@ -0,0 +1,22 @@
1
+ type Events = any
2
+
3
+ export type EventHandler<E extends Events> = (event: E) => void
4
+
5
+ export function composeEventHandlers<E extends Events>(
6
+ og?: EventHandler<E>,
7
+ next?: EventHandler<E>,
8
+ { checkDefaultPrevented = true } = {}
9
+ ) {
10
+ return function composedEventHandler(event: E) {
11
+ og?.(event)
12
+ if (
13
+ !checkDefaultPrevented ||
14
+ // @ts-ignore
15
+ !('defaultPrevented' in event) ||
16
+ // @ts-ignore
17
+ ('defaultPrevented' in event && !event.defaultPrevented)
18
+ ) {
19
+ return next?.(event)
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,97 @@
1
+ // perf sensitive so doing some weird stuff
2
+
3
+ /**
4
+ * next - take objects:
5
+ *
6
+ * { _shorthand: 'postfix' }
7
+ *
8
+ */
9
+
10
+ export function concatClassName(...args: any[]): any
11
+ export function concatClassName(_cn: Record<string, any> | null | undefined): string {
12
+ const args = arguments
13
+ const usedPrefixes: string[] = []
14
+ let final = ''
15
+
16
+ const len = args.length
17
+ let propObjects: any = null
18
+ for (let x = len; x >= 0; x--) {
19
+ const cns = args[x]
20
+
21
+ if (!cns) continue
22
+ if (!Array.isArray(cns) && typeof cns !== 'string') {
23
+ // is prop object
24
+ propObjects = propObjects || []
25
+ propObjects.push(cns)
26
+ continue
27
+ }
28
+
29
+ const names = Array.isArray(cns) ? cns : cns.split(' ')
30
+ const numNames = names.length
31
+ for (let i = numNames - 1; i >= 0; i--) {
32
+ const name = names[i]
33
+
34
+ if (!name || name === ' ') continue
35
+ if (name[0] !== '_') {
36
+ // not snack style (todo slightly stronger heuristic)
37
+ final = name + ' ' + final
38
+ continue
39
+ }
40
+
41
+ const splitIndex = name.indexOf('-')
42
+ if (splitIndex < 1) {
43
+ final = name + ' ' + final
44
+ // if (shouldDebug) console.log('debug exclude:', name, final)
45
+ continue
46
+ }
47
+
48
+ const nextChar = name[splitIndex + 1]
49
+ // synced to static-ui constants
50
+ // MEDIA_SEP
51
+ const isMediaQuery = nextChar === '_'
52
+ // PSEUDO_SEP
53
+ // commenting out three things to make pseudos override properly
54
+ // (leave in for a bit to see if other bugs pop up later):
55
+ // 1. const isPseudoQuery = nextChar === '0'
56
+ const styleKey = name.slice(1, name.lastIndexOf('-'))
57
+ // 2. isMediaQuery || isPseudoQuery
58
+ const mediaKey = isMediaQuery ? name.slice(splitIndex + 2, splitIndex + 7) : null
59
+ const uid = mediaKey ? styleKey + mediaKey : styleKey
60
+ // 3. && !isPseudoQuery
61
+
62
+ if (usedPrefixes.indexOf(uid) > -1) {
63
+ // if (shouldDebug) console.log('debug exclude:', usedPrefixes, name)
64
+ continue
65
+ }
66
+ usedPrefixes.push(uid)
67
+
68
+ // overrides for full safety
69
+ const propName = styleKey
70
+ if (propName && propObjects) {
71
+ if (
72
+ propObjects.some((po) => {
73
+ if (mediaKey) {
74
+ const propKey = pseudoInvert[mediaKey]
75
+ return po && po[propKey] && propName in po[propKey] && po[propKey] !== null
76
+ }
77
+ const res = po && propName in po && po[propName] !== null
78
+ return res
79
+ })
80
+ ) {
81
+ // if (shouldDebug) console.log('debug exclude:', name)
82
+ continue
83
+ }
84
+ }
85
+
86
+ final = name + ' ' + final
87
+ }
88
+ }
89
+
90
+ return final
91
+ }
92
+
93
+ const pseudoInvert = {
94
+ hover: 'hoverStyle',
95
+ focus: 'focusStyle',
96
+ press: 'pressStyle',
97
+ }
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from './clamp'
2
+ export * from './composeEventHandlers'
3
+ export * from './concatClassName'
4
+ export * from './validStyleProps'
5
+ export * from './types'
6
+ export * from '@tamagui/simple-hash'
package/src/types.ts ADDED
@@ -0,0 +1,7 @@
1
+ export type StyleObject = {
2
+ property: string
3
+ pseudo?: 'hover' | 'focus' | 'active'
4
+ value: string
5
+ identifier: string
6
+ rules: string[]
7
+ }
@@ -0,0 +1,165 @@
1
+ // flat transform props
2
+ export const stylePropsTransform = Object.freeze({
3
+ x: true,
4
+ y: true,
5
+ scale: true,
6
+ perspective: true,
7
+ scaleX: true,
8
+ scaleY: true,
9
+ skewX: true,
10
+ skewY: true,
11
+ matrix: true,
12
+ rotate: true,
13
+ rotateY: true,
14
+ rotateX: true,
15
+ rotateZ: true,
16
+ })
17
+
18
+ export const stylePropsView = Object.freeze({
19
+ backfaceVisibility: true,
20
+ backgroundColor: true,
21
+ borderBottomColor: true,
22
+ borderBottomStyle: true,
23
+ borderTopStyle: true,
24
+ borderLeftStyle: true,
25
+ borderRightStyle: true,
26
+ borderBottomEndRadius: true,
27
+ borderBottomLeftRadius: true,
28
+ borderBottomRightRadius: true,
29
+ borderBottomStartRadius: true,
30
+ borderBottomWidth: true,
31
+ borderColor: true,
32
+ borderEndColor: true,
33
+ borderLeftColor: true,
34
+ borderLeftWidth: true,
35
+ borderRadius: true,
36
+ borderRightColor: true,
37
+ borderRightWidth: true,
38
+ borderStartColor: true,
39
+ borderStyle: true,
40
+ borderTopColor: true,
41
+ borderTopEndRadius: true,
42
+ borderTopLeftRadius: true,
43
+ borderTopRightRadius: true,
44
+ borderTopStartRadius: true,
45
+ borderTopWidth: true,
46
+ borderWidth: true,
47
+ opacity: true,
48
+ transform: true,
49
+ alignContent: true,
50
+ alignItems: true,
51
+ alignSelf: true,
52
+ aspectRatio: true,
53
+ borderEndWidth: true,
54
+ borderStartWidth: true,
55
+ bottom: true,
56
+ display: true,
57
+ end: true,
58
+ flex: true,
59
+ flexBasis: true,
60
+ flexDirection: true,
61
+ flexGrow: true,
62
+ flexShrink: true,
63
+ flexWrap: true,
64
+ height: true,
65
+ justifyContent: true,
66
+ left: true,
67
+ margin: true,
68
+ marginBottom: true,
69
+ marginEnd: true,
70
+ marginHorizontal: true,
71
+ marginLeft: true,
72
+ marginRight: true,
73
+ marginStart: true,
74
+ marginTop: true,
75
+ marginVertical: true,
76
+ maxHeight: true,
77
+ maxWidth: true,
78
+ minHeight: true,
79
+ minWidth: true,
80
+ overflow: true,
81
+ padding: true,
82
+ paddingBottom: true,
83
+ paddingEnd: true,
84
+ paddingHorizontal: true,
85
+ paddingLeft: true,
86
+ paddingRight: true,
87
+ paddingStart: true,
88
+ paddingTop: true,
89
+ paddingVertical: true,
90
+ position: true,
91
+ right: true,
92
+ start: true,
93
+ top: true,
94
+ width: true,
95
+ zIndex: true,
96
+ direction: true,
97
+ shadowColor: true,
98
+ shadowOffset: true,
99
+ shadowOpacity: true,
100
+ shadowRadius: true,
101
+ ...stylePropsTransform,
102
+
103
+ // allow a few web only ones
104
+ ...(process.env.TAMAGUI_TARGET === 'web' && {
105
+ overflowX: true,
106
+ overflowY: true,
107
+ userSelect: true,
108
+ cursor: true,
109
+ contain: true,
110
+ pointerEvents: true,
111
+ boxSizing: true,
112
+ boxShadow: true,
113
+ }),
114
+ })
115
+
116
+ export const stylePropsTextOnly = Object.freeze({
117
+ color: true,
118
+ fontFamily: true,
119
+ fontSize: true,
120
+ fontStyle: true,
121
+ fontWeight: true,
122
+ letterSpacing: true,
123
+ lineHeight: true,
124
+ textAlign: true,
125
+ textDecorationLine: true,
126
+ textDecorationStyle: true,
127
+ textDecorationColor: true,
128
+ textShadowColor: true,
129
+ textShadowOffset: true,
130
+ textShadowRadius: true,
131
+ textTransform: true,
132
+
133
+ // allow some web only ones
134
+ ...(process.env.TAMAGUI_TARGET === 'web' && {
135
+ whiteSpace: true,
136
+ wordWrap: true,
137
+ textOverflow: true,
138
+ textDecorationDistance: true,
139
+ userSelect: true,
140
+ selectable: true,
141
+ cursor: true,
142
+ WebkitLineClamp: true,
143
+ WebkitBoxOrient: true,
144
+ }),
145
+ })
146
+
147
+ export const stylePropsText = Object.freeze({
148
+ ...stylePropsView,
149
+ ...stylePropsTextOnly,
150
+ })
151
+
152
+ export const stylePropsAll = stylePropsText
153
+
154
+ export const validPseudoKeys = Object.freeze({
155
+ enterStyle: true,
156
+ exitStyle: true,
157
+ hoverStyle: true,
158
+ pressStyle: true,
159
+ focusStyle: true,
160
+ })
161
+
162
+ export const validStyles = Object.freeze({
163
+ ...validPseudoKeys,
164
+ ...stylePropsView,
165
+ })
@@ -1,7 +1,7 @@
1
- import { FocusEvent } from 'react';
2
- import { GestureResponderEvent } from 'react-native';
3
- export declare type EventHandler<E extends Event | GestureResponderEvent | FocusEvent> = (event: E) => void;
4
- export declare function composeEventHandlers<E extends Event | GestureResponderEvent | FocusEvent>(og?: EventHandler<E>, next?: EventHandler<E>, { checkDefaultPrevented }?: {
1
+ declare type Events = any;
2
+ export declare type EventHandler<E extends Events> = (event: E) => void;
3
+ export declare function composeEventHandlers<E extends Events>(og?: EventHandler<E>, next?: EventHandler<E>, { checkDefaultPrevented }?: {
5
4
  checkDefaultPrevented?: boolean | undefined;
6
5
  }): (event: E) => void;
6
+ export {};
7
7
  //# sourceMappingURL=composeEventHandlers.d.ts.map
@@ -1,2 +1,8 @@
1
+ /**
2
+ * next - take objects:
3
+ *
4
+ * { _shorthand: 'postfix' }
5
+ *
6
+ */
1
7
  export declare function concatClassName(...args: any[]): any;
2
8
  //# sourceMappingURL=concatClassName.d.ts.map
package/types/index.d.ts CHANGED
@@ -3,5 +3,5 @@ export * from './composeEventHandlers';
3
3
  export * from './concatClassName';
4
4
  export * from './validStyleProps';
5
5
  export * from './types';
6
- export * from './log';
6
+ export * from '@tamagui/simple-hash';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,3 @@
1
- export declare const simpleHash: (str: string) => string;
1
+ export declare const simpleHash: (str: string, hashMin?: number) => string;
2
+ export declare function isValidCSSCharCode(code: number): boolean;
2
3
  //# sourceMappingURL=simpleHash.d.ts.map
package/types/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export declare type StyleObject = {
2
2
  property: string;
3
+ pseudo?: 'hover' | 'focus' | 'active';
3
4
  value: string;
4
- className: string;
5
5
  identifier: string;
6
6
  rules: string[];
7
7
  };