@jobber/components 4.49.2 → 4.50.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.
package/Flex.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./dist/Flex";
package/Flex.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true,
5
+ });
6
+
7
+ var Flex = require("./dist/Flex");
8
+
9
+ Object.keys(Flex).forEach(function(key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ Object.defineProperty(exports, key, {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return Flex[key];
15
+ },
16
+ });
17
+ });
@@ -12,7 +12,7 @@ interface ContentProps {
12
12
  * Change the wrapping element to be one of the available
13
13
  * semantic tags.
14
14
  *
15
- * @default 'div'
15
+ * @default "div"
16
16
  */
17
17
  readonly type?: "section" | "aside" | "header" | "footer" | "article" | "main" | "div";
18
18
  }
@@ -0,0 +1,32 @@
1
+ import { PropsWithChildren } from "react";
2
+ import { ColumnKeys, Direction, Spacing } from "./Flex.types";
3
+ interface FlexProps extends PropsWithChildren {
4
+ /**
5
+ * Determine how the children gets laid out
6
+ *
7
+ * **Supported keys**
8
+ * - `"grow"` - Grows to the space available. If all children are set to
9
+ * grow, then they'll have equal width.
10
+ * - `"shrink"` - Shrinks to the smallest size possible. Normally the size of
11
+ * the child.
12
+ */
13
+ readonly template: ColumnKeys[];
14
+ /**
15
+ * Adjusts the alignment of the Flex children.
16
+ */
17
+ readonly align?: "start" | "end" | "center";
18
+ /**
19
+ * The spacing between the children.
20
+ *
21
+ * @default "base"
22
+ */
23
+ readonly gap?: Spacing;
24
+ /**
25
+ * The direction of the content.
26
+ *
27
+ * @default "row"
28
+ */
29
+ readonly direction?: Direction;
30
+ }
31
+ export declare function Flex({ align, children, direction, gap, template, }: FlexProps): JSX.Element;
32
+ export {};
@@ -0,0 +1,6 @@
1
+ export type ColumnKeys = "shrink" | "grow";
2
+ export type Direction = "row" | "column";
3
+ export declare const spacing: readonly ["none", "smallest", "smaller", "small", "base", "large"];
4
+ type ValuesOfSpacing<T extends typeof spacing> = T[number];
5
+ export type Spacing = ValuesOfSpacing<typeof spacing>;
6
+ export {};
@@ -0,0 +1 @@
1
+ export { Flex } from "./Flex";
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var classnames = require('classnames');
7
+ var styleInject_es = require('../style-inject.es-9d2f5f4e.js');
8
+
9
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
+
11
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
12
+ var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
13
+
14
+ var css_248z = "._8VpnrMKmsqQ- {\n display: grid;\n /* If this gets wrapped in a flex container, it should take the remaining space */\n -ms-flex: 1;\n flex: 1;\n}\n\n.ooF1YfV4Usc- {\n gap: calc(16px / 8);\n gap: var(--space-smallest);\n}\n\n.ppCZfXq-Kqc- {\n gap: calc(16px / 4);\n gap: var(--space-smaller);\n}\n\n.tElkBalXH3g- {\n gap: calc(16px / 2);\n gap: var(--space-small);\n}\n\n._4u3OwUKxxbg- {\n gap: calc(16px * 1);\n gap: var(--space-base);\n}\n\n.RL7CJla0AAI- {\n gap: calc(16px * 1.5);\n gap: var(--space-large);\n}\n\n.fV4cvFYkhgo- {\n gap: 0;\n}\n\n._04xVVjZgr-0- {\n -ms-flex-align: start;\n align-items: start;\n}\n\n.Nc3zrqHHYSg- {\n -ms-flex-align: center;\n align-items: center;\n}\n\n.qA-v50wBX1U- {\n -ms-flex-align: end;\n align-items: end;\n}\n";
15
+ var styles = {"flexible":"_8VpnrMKmsqQ-","smallestGap":"ooF1YfV4Usc-","smallerGap":"ppCZfXq-Kqc-","smallGap":"tElkBalXH3g-","baseGap":"_4u3OwUKxxbg-","largeGap":"RL7CJla0AAI-","noneGap":"fV4cvFYkhgo-","startAlign":"_04xVVjZgr-0-","centerAlign":"Nc3zrqHHYSg-","endAlign":"qA-v50wBX1U-"};
16
+ styleInject_es.styleInject(css_248z);
17
+
18
+ function Flex({ align = "center", children, direction = "row", gap = "base", template, }) {
19
+ return (React__default["default"].createElement("div", { className: classnames__default["default"](styles.flexible, {
20
+ [styles[`${gap}Gap`]]: Boolean(gap),
21
+ [styles[`${align}Align`]]: Boolean(align),
22
+ }), style: generateGridStylesFromTemplate(direction, template) }, children));
23
+ }
24
+ function generateGridStylesFromTemplate(direction, layoutTemplate) {
25
+ const containerStyles = {};
26
+ const templateKeys = {
27
+ row: "gridTemplateColumns",
28
+ column: "gridTemplateRows",
29
+ };
30
+ const templateValues = {
31
+ grow: "1fr",
32
+ shrink: "max-content",
33
+ };
34
+ containerStyles[templateKeys[direction]] = layoutTemplate
35
+ .map(key => templateValues[key])
36
+ .join(" ");
37
+ return containerStyles;
38
+ }
39
+
40
+ exports.Flex = Flex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components",
3
- "version": "4.49.2",
3
+ "version": "4.50.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -84,5 +84,5 @@
84
84
  "> 1%",
85
85
  "IE 10"
86
86
  ],
87
- "gitHead": "363a8b6e95f8fe46e6f7482be321c513377714ae"
87
+ "gitHead": "c1696e9d61aa0f7d34d97703337b96569be0589a"
88
88
  }