@loomhq/lens 10.62.1 → 10.63.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.
package/README.md CHANGED
@@ -62,7 +62,79 @@ navigate to: http://localhost:3000
62
62
 
63
63
  ### Use conventional commits
64
64
 
65
- Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) to kick off publishing a new version of Lens when PR is merged. To upgrade Lens to the latest published version in the [main Loom repo](http://github.com/loomhq/loom), `cd projects/webapp-client` and `pnpm up @loomhq/lens`.
65
+ Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) to kick off publishing a new version of Lens when PR is merged.
66
+
67
+
68
+ ### Upgrading Lens versions
69
+
70
+ #### loom
71
+ From the root of the [main Loom repo](http://github.com/loomhq/loom)
72
+
73
+ 1. Move into the webapp-client directory.
74
+
75
+ ```
76
+ cd projects/webapp-client
77
+ ```
78
+
79
+ 2. Upgrade the Lens package with pnpm (you can ignore the warnings).
80
+
81
+ ```
82
+ pnpm up @loomhq/lens
83
+ ```
84
+
85
+ 3. From the root, fix dependencies and upgrade Lens globally
86
+ ```
87
+ cd ... && pnpm deps:fix && pnpm i
88
+ ```
89
+
90
+ 4. Run changesets so that it generates the necessary `.md` file for release.
91
+
92
+ ```
93
+ pnpm changeset
94
+ ```
95
+
96
+ 5. Follow the prompts. Hit Spacebar to select all changed packages. The checks should turn green. Hit Enter to commit.
97
+
98
+ ```
99
+ 🦋 Which packages would you like to include?
100
+ ✔ changed packages
101
+ ✔ @loomhq/web-client
102
+ ```
103
+
104
+ 6. Skip major bump. Hit Enter to bypass.
105
+
106
+ ```
107
+ 🦋 Which packages should have a major bump? …
108
+ ```
109
+
110
+ 7. Skip minor bump. Hit Enter to bypass.
111
+
112
+ ```
113
+ 🦋 Which packages should have a minor bump? …
114
+ ```
115
+
116
+ 8. For patch bump, you will be prompted to write a description.
117
+
118
+ ```
119
+ The following packages will be patch bumped:
120
+ 🦋 @loomhq/web-client@0.0.6
121
+ 🦋 Please enter a summary for this change (this will be in the changelogs). Submit empty line to open external editor
122
+ 🦋 Summary › [description goes here, enter to complete]
123
+ ```
124
+
125
+ 9. Write a concise note like `bump Lens v[X.X.X] to add SvgIconName`
126
+
127
+ 10. You will be asked asked if this is your desired change. Type 'Y'.
128
+
129
+ ```
130
+ All dependents of these packages that will be incompatible with the new version will be patch bumped when this changeset is applied.
131
+
132
+ 🦋 Is this your desired changeset? (Y/n) › [type Y]
133
+ ```
134
+
135
+ 11. A new randomly-named `.md` file should be generated into the changesets directory. Commit this file to your changes.
136
+
137
+ 12. For any changes to existing components, do your due diligence and check the component changes locally within the repo.
66
138
 
67
139
  ### Add an icon to the icon set
68
140
 
@@ -1,13 +1,11 @@
1
1
  import React from 'react';
2
2
  declare const SwitchInput: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, SwitchInputProps, object>;
3
- declare const Switch: ({ isActive, isDisabled, onChange, size, ariaLabelledby, ariaLabel, ...props }: SwitchProps & Omit<React.ComponentProps<typeof SwitchInput>, 'size'>) => JSX.Element;
3
+ declare const Switch: ({ isActive, isDisabled, onChange, size, ...props }: SwitchProps & Omit<React.ComponentProps<typeof SwitchInput>, 'size'>) => JSX.Element;
4
4
  declare type SwitchProps = {
5
5
  isActive?: boolean;
6
6
  isDisabled?: boolean;
7
7
  onChange?: React.ReactEventHandler;
8
8
  size?: 'medium' | 'large';
9
- ariaLabelledby?: string;
10
- ariaLabel?: string;
11
9
  };
12
10
  declare type SwitchInputProps = {
13
11
  switchSize?: 'medium' | 'large';
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { getColorValue, getFocusRing } from '../../utilities';
13
- import React, { useRef } from 'react';
13
+ import React from 'react';
14
14
  import styled from '@emotion/styled';
15
15
  const sizes = {
16
16
  medium: {
@@ -53,18 +53,16 @@ const getKnobSize = props => {
53
53
  return (sizes[props.switchSize].switchHeight -
54
54
  sizes[props.switchSize].knobOffset * 2);
55
55
  };
56
- const SwitchWrapper = styled.div `
56
+ const SwitchLabel = styled.label `
57
57
  display: block;
58
58
  position: relative;
59
59
  `;
60
60
  const SwitchInput = styled.input `
61
61
  position: absolute;
62
62
  opacity: 0;
63
-
64
63
  &:focus-visible ~ .SwitchBox {
65
64
  ${getFocusRing()};
66
65
  }
67
-
68
66
  &:not(:checked) {
69
67
  & + .SwitchBox {
70
68
  background-color: ${colorStyles.track.inactive.enabled};
@@ -73,7 +71,6 @@ const SwitchInput = styled.input `
73
71
  background-color: ${colorStyles.track.inactive.disabled};
74
72
  }
75
73
  }
76
-
77
74
  &:checked {
78
75
  & + .SwitchBox {
79
76
  background-color: ${colorStyles.track.active.enabled};
@@ -85,7 +82,6 @@ const SwitchInput = styled.input `
85
82
  transform: translateX(${props => getKnobTravel(props)}px);
86
83
  }
87
84
  }
88
-
89
85
  &:disabled {
90
86
  pointer-events: none;
91
87
  }
@@ -97,7 +93,6 @@ const SwitchBox = styled.div `
97
93
  border-radius: var(--lns-radius-full);
98
94
  transition: 0.2s;
99
95
  cursor: ${props => (props.isDisabled ? 'default' : 'pointer')};
100
-
101
96
  &:after {
102
97
  content: '';
103
98
  position: absolute;
@@ -113,19 +108,9 @@ const SwitchBox = styled.div `
113
108
  }
114
109
  `;
115
110
  const Switch = (_a) => {
116
- var { isActive, isDisabled, onChange, size = 'medium', ariaLabelledby, ariaLabel } = _a, props = __rest(_a, ["isActive", "isDisabled", "onChange", "size", "ariaLabelledby", "ariaLabel"]);
117
- if (ariaLabelledby && ariaLabel) {
118
- throw new Error('ariaLabelledby and ariaLabel serve the same purpose and therefore cannot be used at the same time. Choose the one that best suites your needs.');
119
- }
120
- const ref = useRef(null);
121
- const toggleSwitch = () => {
122
- if (!ref.current || isActive) {
123
- return;
124
- }
125
- ref.current.checked = !ref.current.checked;
126
- };
127
- return (React.createElement(SwitchWrapper, null,
128
- React.createElement(SwitchInput, Object.assign({}, props, { role: "switch", type: "checkbox", ref: ref, checked: isActive, disabled: isDisabled, onChange: onChange, switchSize: size, "aria-labelledby": ariaLabelledby, "aria-label": ariaLabel, "aria-checked": isActive })),
129
- React.createElement(SwitchBox, { className: "SwitchBox", isDisabled: isDisabled, isActive: isActive, switchSize: size, onClick: toggleSwitch })));
111
+ var { isActive, isDisabled, onChange, size = 'medium' } = _a, props = __rest(_a, ["isActive", "isDisabled", "onChange", "size"]);
112
+ return (React.createElement(SwitchLabel, null,
113
+ React.createElement(SwitchInput, Object.assign({}, props, { checked: isActive, disabled: isDisabled, onChange: onChange, type: "checkbox", switchSize: size })),
114
+ React.createElement(SwitchBox, { className: "SwitchBox", isDisabled: isDisabled, isActive: isActive, switchSize: size })));
130
115
  };
131
116
  export default Switch;
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
  declare type DelaySpeed = 'immediate' | 'long';
3
3
  declare const TooltipBoxWrapper: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, TooltipBoxProps, object>;
4
+ declare const ShortcutWrapper: import("@emotion/styled-base").StyledComponent<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Pick<React.ClassAttributes<HTMLDivElement> & React.HTMLAttributes<HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement>>, object>;
5
+ export declare const ShortcutBox: ({ children, }: React.ComponentProps<typeof ShortcutWrapper>) => JSX.Element;
4
6
  export declare const TooltipBox: ({ children, maxWidth, onMouseEnter, onMouseLeave, layerProps, zIndex, ...rest }: TooltipBoxProps & React.ComponentProps<typeof TooltipBoxWrapper>) => JSX.Element;
5
- declare const Tooltip: ({ children, content, placement, keepOpen, triggerOffset, maxWidth, isInline, isDisabled, container, tabIndex, zIndex, verticalAlign, delay, dynamicPosition, ...rest }: TooltipProps) => JSX.Element;
7
+ declare const Tooltip: ({ children, content, shortcut, placement, keepOpen, triggerOffset, maxWidth, isInline, isDisabled, container, tabIndex, zIndex, verticalAlign, delay, dynamicPosition, ...rest }: TooltipProps) => JSX.Element;
6
8
  export declare const availablePlacements: string[];
7
9
  declare type TooltipBoxProps = {
8
10
  children?: React.ReactNode;
@@ -16,6 +18,7 @@ declare type TooltipProps = {
16
18
  children?: React.ReactNode;
17
19
  container?: HTMLElement | (() => HTMLElement) | string;
18
20
  content?: React.ReactNode;
21
+ shortcut?: [];
19
22
  isDisabled?: boolean;
20
23
  isInline?: boolean;
21
24
  keepOpen?: boolean;
@@ -10,6 +10,8 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import React, { useState, useRef, useEffect } from 'react';
13
+ import Arrange from '../arrange/arrange';
14
+ import Text from '../text/text';
13
15
  import { getColorValue, getFontWeight, getRadius, getShadow, getSize, getTextSize, u, } from '../../utilities';
14
16
  import { useHover, useLayer, mergeRefs, useMousePositionAsTrigger, } from 'react-laag';
15
17
  import ResizeObserver from 'resize-observer-polyfill';
@@ -34,8 +36,8 @@ const tooltipMinHeight = 4;
34
36
  const textHeight = textSizes.small.fontSize * textSizes.small.lineHeight;
35
37
  const tooltipYPadding = (tooltipMinHeight - textHeight) / 2;
36
38
  const TooltipBoxWrapper = styled.div `
37
- background-color: ${getColorValue('grey8')};
38
- color: ${getColorValue('grey1')};
39
+ background-color: ${getColorValue('background')};
40
+ color: ${getColorValue('body')};
39
41
  ${getRadius('large')};
40
42
  ${getFontWeight('medium')};
41
43
  ${getTextSize('small')};
@@ -45,9 +47,19 @@ const TooltipBoxWrapper = styled.div `
45
47
  padding: ${u(tooltipYPadding)} ${u(1.5)};
46
48
  z-index: ${props => props.zIndex};
47
49
  `;
50
+ const ShortcutWrapper = styled.div `
51
+ background-color: ${getColorValue('backgroundActive')};
52
+ border-radius: 3px;
53
+ color: ${getColorValue('grey3')};
54
+ ${getFontWeight('medium')};
55
+ ${getTextSize('small')};
56
+ padding-left: ${u(0.5)};
57
+ padding-right: ${u(0.5)};
58
+ `;
59
+ export const ShortcutBox = ({ children, }) => (React.createElement(ShortcutWrapper, null, children));
48
60
  export const TooltipBox = (_a) => {
49
61
  var { children, maxWidth, onMouseEnter, onMouseLeave, layerProps, zIndex } = _a, rest = __rest(_a, ["children", "maxWidth", "onMouseEnter", "onMouseLeave", "layerProps", "zIndex"]);
50
- return (React.createElement(TooltipBoxWrapper, Object.assign({ maxWidth: maxWidth, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, zIndex: zIndex }, layerProps, rest), children));
62
+ return (React.createElement(TooltipBoxWrapper, Object.assign({ "data-lens-theme": "dark", maxWidth: maxWidth, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, zIndex: zIndex }, layerProps, rest), children));
51
63
  };
52
64
  const TooltipChildren = styled.div `
53
65
  display: ${props => (props.isInline ? 'inline-block' : 'block')};
@@ -70,7 +82,7 @@ function getInitialDelaySpeed(delay) {
70
82
  }
71
83
  }
72
84
  const Tooltip = (_a) => {
73
- var { children, content, placement = 'topCenter', keepOpen, triggerOffset = 4, maxWidth = 26, isInline = true, isDisabled, container, tabIndex = 0, zIndex = 1100, verticalAlign = 'middle', delay = 'immediate', dynamicPosition = false } = _a, rest = __rest(_a, ["children", "content", "placement", "keepOpen", "triggerOffset", "maxWidth", "isInline", "isDisabled", "container", "tabIndex", "zIndex", "verticalAlign", "delay", "dynamicPosition"]);
85
+ var { children, content, shortcut, placement = 'topCenter', keepOpen, triggerOffset = 4, maxWidth = 26, isInline = true, isDisabled, container, tabIndex = 0, zIndex = 1100, verticalAlign = 'middle', delay = 'immediate', dynamicPosition = false } = _a, rest = __rest(_a, ["children", "content", "shortcut", "placement", "keepOpen", "triggerOffset", "maxWidth", "isInline", "isDisabled", "container", "tabIndex", "zIndex", "verticalAlign", "delay", "dynamicPosition"]);
74
86
  const [show, hoverProps] = useHover({
75
87
  delayEnter: getInitialDelaySpeed(delay),
76
88
  delayLeave: 200,
@@ -142,7 +154,10 @@ const Tooltip = (_a) => {
142
154
  React.createElement(TooltipChildren, Object.assign({}, triggerProps, hoverProps, { onFocus: handleFocus, onBlur: handleBlur, isInline: isInline, verticalAlign: verticalAlign, tabIndex: isTooltipDisabled ? -1 : tabIndex, ref: mergeRefs(triggerProps.ref, focusRef, parentRef), onMouseMove: allowTrackMousePosition ? handleMouseEvent : null }), children),
143
155
  isOpen &&
144
156
  renderLayer(React.createElement("div", Object.assign({}, layerProps, { style: Object.assign(Object.assign({}, layerProps.style), { zIndex }) }),
145
- React.createElement(TooltipBox, Object.assign({ maxWidth: maxWidth, onMouseEnter: () => setIsOverTooltip(true), onMouseLeave: () => setIsOverTooltip(false) }, rest), content)))));
157
+ React.createElement(TooltipBox, Object.assign({ maxWidth: maxWidth, onMouseEnter: () => setIsOverTooltip(true), onMouseLeave: () => setIsOverTooltip(false) }, rest),
158
+ React.createElement(Arrange, { gap: "small" },
159
+ React.createElement(Text, { size: "small", fontWeight: "medium" }, content),
160
+ shortcut && (React.createElement(Arrange, { gap: "xsmall" }, shortcut.map((char, index) => (React.createElement(ShortcutBox, { key: index }, char)))))))))));
146
161
  };
147
162
  export const availablePlacements = Object.keys(placements);
148
163
  export default Tooltip;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomhq/lens",
3
- "version": "10.62.1",
3
+ "version": "10.63.1",
4
4
  "scripts": {
5
5
  "dev": "next",
6
6
  "build:next": "next build",