@loadsmart/loadsmart-ui 5.17.0 → 5.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loadsmart/loadsmart-ui",
3
- "version": "5.17.0",
3
+ "version": "5.19.0",
4
4
  "description": "Miranda UI, a React UI library",
5
5
  "main": "dist",
6
6
  "files": [
@@ -26,39 +26,6 @@
26
26
  "storybook-deployer": {
27
27
  "commitMessage": "chore(docs): deploy storybook to GitHub pages [skip ci]"
28
28
  },
29
- "jest": {
30
- "globals": {
31
- "window": true
32
- },
33
- "verbose": true,
34
- "coverageDirectory": "./coverage/",
35
- "collectCoverage": false,
36
- "setupFiles": [
37
- "./tests/jestsetup.tsx"
38
- ],
39
- "collectCoverageFrom": [
40
- "src/components/**/*.{js,tsx}",
41
- "!src/**/**/*.test.{js,tsx}"
42
- ],
43
- "coverageReporters": [
44
- "text",
45
- "lcov"
46
- ],
47
- "moduleDirectories": [
48
- "node_modules",
49
- "src"
50
- ],
51
- "moduleFileExtensions": [
52
- "ts",
53
- "tsx",
54
- "js",
55
- "json"
56
- ],
57
- "testMatch": [
58
- "**/__tests__/**/*.[jt]s?(x)",
59
- "**/?(*.)+(jest|test).[jt]s?(x)"
60
- ]
61
- },
62
29
  "lint-staged": {
63
30
  "src/**/*.{js,ts,jsx,tsx,json}": [
64
31
  "eslint --fix",
@@ -71,11 +38,10 @@
71
38
  ]
72
39
  },
73
40
  "devDependencies": {
74
- "@babel/cli": "7.13.16",
75
- "@babel/core": "7.14.0",
76
- "@babel/preset-env": "7.14.1",
77
- "@babel/preset-react": "7.13.13",
78
- "@babel/preset-typescript": "7.13.0",
41
+ "@babel/core": "^7.20.12",
42
+ "@babel/preset-env": "^7.20.2",
43
+ "@babel/preset-react": "^7.18.6",
44
+ "@babel/preset-typescript": "^7.18.6",
79
45
  "@commitlint/cli": "16.0.2",
80
46
  "@commitlint/config-conventional": "16.0.0",
81
47
  "@loadsmart/miranda-tokens": "1.3.0",
@@ -109,7 +75,7 @@
109
75
  "@testing-library/react-hooks": "^5.1.3",
110
76
  "@testing-library/user-event": "^13.5.0",
111
77
  "@types/chance": "1.1.1",
112
- "@types/jest": "26.0.23",
78
+ "@types/jest": "^27.5.2",
113
79
  "@types/lodash.debounce": "4.0.6",
114
80
  "@types/lodash.flatten": "4.4.6",
115
81
  "@types/lodash.get": "4.4.6",
@@ -126,7 +92,7 @@
126
92
  "@typescript-eslint/parser": "4.22.1",
127
93
  "@zerollup/ts-transform-paths": "1.7.18",
128
94
  "autoprefixer": "9",
129
- "babel-jest": "26.6.3",
95
+ "babel-jest": "^27.5.1",
130
96
  "babel-loader": "8.2.2",
131
97
  "babel-plugin-react-remove-properties": "0.3.0",
132
98
  "babel-plugin-styled-components": "1.12.0",
@@ -147,8 +113,8 @@
147
113
  "eslint-plugin-testing-library": "^5.9.1",
148
114
  "husky": "7.0.4",
149
115
  "identity-obj-proxy": "3.0.0",
150
- "jest": "26.6.3",
151
- "jest-svg-transformer": "1.0.0",
116
+ "jest": "^27.5.1",
117
+ "jest-transformer-svg": "1.0.2",
152
118
  "lint-staged": "11.0.0",
153
119
  "npm-run-all": "4.1.5",
154
120
  "postcss": "^7.0.39",
@@ -175,7 +141,7 @@
175
141
  "stylelint-no-unsupported-browser-features": "5.0.1",
176
142
  "stylelint-order": "4.1.0",
177
143
  "tailwindcss": "npm:@tailwindcss/postcss7-compat",
178
- "ts-jest": "26.5.6",
144
+ "ts-jest": "^27.1.5",
179
145
  "ts-node": "^10.9.1",
180
146
  "ts-toolbelt": "^9.6.0",
181
147
  "ttypescript": "^1.5.13",
@@ -51,9 +51,30 @@ describe('<Label />', () => {
51
51
  setup(props)
52
52
 
53
53
  const tipAnchor = screen.getByText('?', { selector: 'span' })
54
- expect(() => screen.getByText(/`${props.message}`/i)).toThrow()
54
+ expect(screen.queryByText(/`${props.message}`/i)).not.toBeInTheDocument()
55
55
 
56
56
  userEvent.hover(tipAnchor)
57
57
  screen.getByText(props.tip)
58
58
  })
59
+
60
+ it('renders node tip', () => {
61
+ const sentence = generator.sentence()
62
+ const props = {
63
+ children: generator.word(),
64
+ tip: (
65
+ <div data-testid="tip-div-id">
66
+ <b>{sentence}</b>
67
+ </div>
68
+ ),
69
+ }
70
+
71
+ setup(props)
72
+
73
+ const tipAnchor = screen.getByText('?', { selector: 'span' })
74
+ expect(screen.queryByText(/`${props.message}`/i)).not.toBeInTheDocument()
75
+
76
+ userEvent.hover(tipAnchor)
77
+ expect(screen.getByTestId('tip-div-id')).toBeInTheDocument()
78
+ screen.getByText(sentence)
79
+ })
59
80
  })
@@ -1,4 +1,4 @@
1
- import React from 'react'
1
+ import React, { ReactNode } from 'react'
2
2
  import type { LabelHTMLAttributes } from 'react'
3
3
  import styled from 'styled-components'
4
4
  import clsx from 'clsx'
@@ -11,7 +11,7 @@ import ellipsizable from 'styles/ellipsizable'
11
11
  import font from 'styles/font'
12
12
  import { getToken as token } from 'theming'
13
13
 
14
- import { Tooltip } from '../Tooltip'
14
+ import { Tooltip, TooltipProps } from '../Tooltip'
15
15
 
16
16
  type AcceptedType = 'label' | 'div' | 'span'
17
17
 
@@ -20,7 +20,8 @@ interface WithAdditionalProps {
20
20
  disabled?: boolean
21
21
  required?: boolean
22
22
  scheme?: ColorScheme
23
- tip?: string
23
+ tip?: ReactNode
24
+ tipProps?: Omit<TooltipProps, 'message'>
24
25
  }
25
26
 
26
27
  export interface LabelProps
@@ -91,6 +92,7 @@ function Label({
91
92
  required,
92
93
  scheme = 'light',
93
94
  tip,
95
+ tipProps = {},
94
96
  ...others
95
97
  }: LabelProps): JSX.Element {
96
98
  const tag = String(as || 'label') as AcceptedType
@@ -107,7 +109,7 @@ function Label({
107
109
  <StyledChildren scheme={scheme}>{children}</StyledChildren>
108
110
  {required && <StyledRequired>*</StyledRequired>}
109
111
  {!isNil(tip) && (
110
- <Tooltip scheme={scheme} message={tip || ''}>
112
+ <Tooltip scheme={scheme} message={tip || ''} {...tipProps}>
111
113
  <StyledTooltipAnchor scheme={scheme}>?</StyledTooltipAnchor>
112
114
  </Tooltip>
113
115
  )}
@@ -41,14 +41,6 @@ function Experiment(overrides: Partial<SelectProps>) {
41
41
  }
42
42
 
43
43
  describe('SelectEvent', () => {
44
- beforeEach(() => {
45
- jest.useFakeTimers()
46
- })
47
- afterEach(() => {
48
- jest.runOnlyPendingTimers()
49
- jest.useRealTimers()
50
- })
51
-
52
44
  const setup = (overrides: Partial<SelectProps>) =>
53
45
  renderer(<Experiment {...overrides} />).render()
54
46