@superdispatch/ui-lab 0.13.0 → 0.16.0-alpha.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,21 @@
1
+ import { createContext, useContext, useMemo } from 'react';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ var context = /*#__PURE__*/createContext({});
4
+ export function useSidebarMenuItemContext() {
5
+ return useContext(context);
6
+ }
7
+ export function SidebarMenuItemContextProvider(_ref) {
8
+ var {
9
+ children,
10
+ hovered = false,
11
+ disabled = false
12
+ } = _ref;
13
+ var ctx = useMemo(() => ({
14
+ hovered,
15
+ disabled
16
+ }), [hovered, disabled]);
17
+ return /*#__PURE__*/_jsx(context.Provider, {
18
+ value: ctx,
19
+ children: children
20
+ });
21
+ }
@@ -0,0 +1,41 @@
1
+ import { v5 } from '@superdispatch/ui';
2
+ import { forwardRef } from 'react';
3
+ import styled from 'styled-components';
4
+ import { TextBox } from "../text-box/TextBox.js";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { jsxs as _jsxs } from "react/jsx-runtime";
7
+ var {
8
+ Column,
9
+ Columns
10
+ } = v5;
11
+ var SidebarSubheaderRoot = /*#__PURE__*/styled.div.withConfig({
12
+ displayName: "SidebarSubheader__SidebarSubheaderRoot",
13
+ componentId: "SD__sc-7njpmq-0"
14
+ })(["display:flex;align-items:center;height:40px;max-height:40px;padding-left:24px;padding-right:24px;"]);
15
+ export var SidebarSubheader = /*#__PURE__*/forwardRef((_ref, ref) => {
16
+ var {
17
+ id,
18
+ action,
19
+ children
20
+ } = _ref;
21
+ return /*#__PURE__*/_jsx(SidebarSubheaderRoot, {
22
+ ref: ref,
23
+ children: /*#__PURE__*/_jsxs(Columns, {
24
+ space: "xsmall",
25
+ align: "center",
26
+ children: [/*#__PURE__*/_jsx(Column, {
27
+ children: /*#__PURE__*/_jsx(TextBox, {
28
+ id: id,
29
+ variant: "heading-6",
30
+ color: "secondary",
31
+ noWrap: true,
32
+ children: children
33
+ })
34
+ }), !!action && /*#__PURE__*/_jsx(Column, {
35
+ width: "content",
36
+ children: action
37
+ })]
38
+ })
39
+ });
40
+ });
41
+ if (process.env.NODE_ENV !== "production") SidebarSubheader.displayName = "SidebarSubheader";
@@ -0,0 +1,133 @@
1
+ import _objectSpread from "@babel/runtime/helpers/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["variant", "as", "align", "color", "display", "noWrap", "wrapOverflow"];
4
+ import { v5 } from '@superdispatch/ui';
5
+ import { forwardRef } from 'react';
6
+ import styled, { css } from 'styled-components';
7
+ import { mergeStyles } from "../utils/mergeStyles.js";
8
+ import { createRuleNormalizer } from "../utils/RuleNormalizer.js";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ var {
11
+ Color,
12
+ parseResponsiveProp
13
+ } = v5;
14
+ var normalizeTextColor = /*#__PURE__*/createRuleNormalizer({
15
+ inherit: 'inherit',
16
+ primary: Color.Dark500,
17
+ secondary: Color.Dark200,
18
+ white: Color.White,
19
+ blue: Color.Blue300,
20
+ green: Color.Green300,
21
+ purple: Color.Purple500,
22
+ red: Color.Red300,
23
+ teal: Color.Teal300,
24
+ yellow: Color.Yellow300
25
+ });
26
+ var VARIANT_TYPE_MAPPING = {
27
+ 'heading-1': 'h1',
28
+ 'heading-2': 'h2',
29
+ 'heading-3': 'h3',
30
+ 'heading-4': 'h4',
31
+ 'heading-5': 'h5',
32
+ 'heading-6': 'h6',
33
+ body: 'span',
34
+ 'body-block': 'p',
35
+ 'body-semibold': 'span',
36
+ caption: 'span'
37
+ };
38
+
39
+ function variantMixin(_ref, variant) {
40
+ var {
41
+ typography,
42
+ breakpoints
43
+ } = _ref;
44
+
45
+ switch (variant) {
46
+ case 'heading-1':
47
+ return typography.h1;
48
+
49
+ case 'heading-2':
50
+ return typography.h2;
51
+
52
+ case 'heading-3':
53
+ return typography.h3;
54
+
55
+ case 'heading-4':
56
+ return typography.h4;
57
+
58
+ case 'heading-5':
59
+ return typography.h5;
60
+
61
+ case 'heading-6':
62
+ return typography.h6;
63
+
64
+ case 'body':
65
+ default:
66
+ return typography.body2;
67
+
68
+ case 'body-block':
69
+ {
70
+ return mergeStyles({}, typography.body2, {
71
+ lineHeight: '24px',
72
+ [breakpoints.only('xs')]: {
73
+ lineHeight: '28px'
74
+ }
75
+ });
76
+ }
77
+
78
+ case 'body-semibold':
79
+ return typography.body1;
80
+
81
+ case 'caption':
82
+ return typography.caption;
83
+ }
84
+ }
85
+
86
+ function textBoxMixin(noWrap, align, color, display, wrapOverflow) {
87
+ return css(["text-align:", ";color:", ";display:", ";overflow:", ";white-space:", ";overflow-wrap:", ";"], align, normalizeTextColor(color), display === 'initial' && (noWrap || align !== 'left') ? 'block' : display, noWrap ? 'hidden' : 'visible', noWrap ? 'nowrap' : 'normal', wrapOverflow ? 'break-word' : 'normal');
88
+ }
89
+
90
+ var TextBoxRoot = /*#__PURE__*/styled.span.withConfig({
91
+ displayName: "TextBox__TextBoxRoot",
92
+ componentId: "SD__sc-1geakdj-0"
93
+ })(_ref2 => {
94
+ var {
95
+ theme,
96
+ $noWrap,
97
+ $variant,
98
+ $align,
99
+ $color,
100
+ $display,
101
+ $wrapOverflow
102
+ } = _ref2;
103
+ return css(["margin:0;padding:0;text-overflow:ellipsis;", ";", ";", "{", ";}", "{", ";}"], variantMixin(theme, $variant), textBoxMixin($noWrap[0], $align[0], $color[0], $display[0], $wrapOverflow[0]), theme.breakpoints.up('sm'), textBoxMixin($noWrap[1], $align[1], $color[1], $display[1], $wrapOverflow[1]), theme.breakpoints.up('md'), textBoxMixin($noWrap[2], $align[2], $color[2], $display[2], $wrapOverflow[2]));
104
+ });
105
+ export var TextBox = /*#__PURE__*/forwardRef((_ref3, ref) => {
106
+ var {
107
+ variant: $variant = 'body',
108
+ as = VARIANT_TYPE_MAPPING[$variant],
109
+ align = 'left',
110
+ color = 'primary',
111
+ display = 'initial',
112
+ noWrap = false,
113
+ wrapOverflow = false
114
+ } = _ref3,
115
+ props = _objectWithoutProperties(_ref3, _excluded);
116
+
117
+ var $align = parseResponsiveProp(align);
118
+ var $color = parseResponsiveProp(color);
119
+ var $noWrap = parseResponsiveProp(noWrap);
120
+ var $display = parseResponsiveProp(display);
121
+ var $wrapOverflow = parseResponsiveProp(wrapOverflow);
122
+ return /*#__PURE__*/_jsx(TextBoxRoot, _objectSpread(_objectSpread({}, props), {}, {
123
+ as: as,
124
+ ref: ref,
125
+ $align: $align,
126
+ $color: $color,
127
+ $noWrap: $noWrap,
128
+ $display: $display,
129
+ $variant: $variant,
130
+ $wrapOverflow: $wrapOverflow
131
+ }));
132
+ });
133
+ if (process.env.NODE_ENV !== "production") TextBox.displayName = "TextBox";
@@ -0,0 +1,17 @@
1
+ export function createRuleNormalizer(rules) {
2
+ return input => {
3
+ if (typeof input == 'string') {
4
+ var value = rules[input];
5
+
6
+ if (typeof value == 'number') {
7
+ return "".concat(value, "px");
8
+ }
9
+
10
+ if (typeof value == 'string') {
11
+ return value;
12
+ }
13
+ }
14
+
15
+ return undefined;
16
+ };
17
+ }
@@ -0,0 +1,24 @@
1
+ export function mergeStyles(styles) {
2
+ for (var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
3
+ sources[_key - 1] = arguments[_key];
4
+ }
5
+
6
+ for (var source of sources) {
7
+ if (source) {
8
+ for (var key in source) {
9
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
10
+ var stylesValue = styles[key];
11
+ var sourceValue = source[key];
12
+
13
+ if (typeof stylesValue == 'object' && typeof sourceValue == 'object') {
14
+ mergeStyles(stylesValue, sourceValue);
15
+ } else {
16
+ styles[key] = source[key];
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
22
+
23
+ return styles;
24
+ }