@planningcenter/tapestry-react 2.0.0-rc.0 → 2.0.1-rc.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.
Files changed (52) hide show
  1. package/dist/cjs/DataTable/hooks/useCollapsibleRows.js +1 -1
  2. package/dist/cjs/Dropdown/Dropdown.test.js +194 -19
  3. package/dist/cjs/Group/Group.js +6 -4
  4. package/dist/cjs/Modal/Modal.test.js +156 -0
  5. package/dist/cjs/Popover/Popover.js +4 -0
  6. package/dist/cjs/Popover/Popover.test.js +65 -0
  7. package/dist/cjs/Popover/rewireTabOrder.js +13 -30
  8. package/dist/cjs/Scrim/Scrim.js +1 -1
  9. package/dist/cjs/Select/Select.js +9 -0
  10. package/dist/cjs/Sidebar/Sidebar.js +4 -3
  11. package/dist/cjs/Table/Table.js +3 -5
  12. package/dist/cjs/ThemeProvider/ThemeProvider.js +5 -5
  13. package/dist/cjs/hooks/useConstant.js +23 -0
  14. package/dist/cjs/system/utils.js +2 -2
  15. package/dist/cjs/utils.js +3 -3
  16. package/dist/esm/DataTable/hooks/useCollapsibleRows.js +1 -1
  17. package/dist/esm/Dropdown/Dropdown.test.js +158 -17
  18. package/dist/esm/Group/Group.js +6 -4
  19. package/dist/esm/Modal/Modal.test.js +122 -0
  20. package/dist/esm/Popover/Popover.js +4 -0
  21. package/dist/esm/Popover/Popover.test.js +51 -0
  22. package/dist/esm/Popover/rewireTabOrder.js +13 -33
  23. package/dist/esm/Scrim/Scrim.js +1 -1
  24. package/dist/esm/Select/Select.js +9 -0
  25. package/dist/esm/Sidebar/Sidebar.js +4 -2
  26. package/dist/esm/Table/Table.js +1 -2
  27. package/dist/esm/ThemeProvider/ThemeProvider.js +1 -1
  28. package/dist/esm/hooks/useConstant.js +15 -0
  29. package/dist/esm/system/utils.js +1 -1
  30. package/dist/esm/utils.js +3 -3
  31. package/dist/types/Dropdown/Dropdown.test.d.ts +1 -1
  32. package/dist/types/Group/Group.d.ts +5 -1
  33. package/dist/types/Modal/Modal.test.d.ts +1 -0
  34. package/dist/types/Popover/Popover.test.d.ts +1 -0
  35. package/dist/types/hooks/useConstant.d.ts +1 -0
  36. package/package.json +15 -24
  37. package/src/DataTable/hooks/useCollapsibleRows.js +1 -1
  38. package/src/Dropdown/Dropdown.test.tsx +128 -17
  39. package/src/Group/Group.tsx +9 -3
  40. package/src/Modal/Modal.test.tsx +113 -0
  41. package/src/Popover/Popover.test.tsx +62 -0
  42. package/src/Popover/Popover.tsx +3 -0
  43. package/src/Popover/rewireTabOrder.ts +24 -42
  44. package/src/Scrim/Scrim.tsx +3 -3
  45. package/src/Select/Select.js +6 -0
  46. package/src/Sidebar/Sidebar.js +7 -5
  47. package/src/Table/Table.js +1 -2
  48. package/src/ThemeProvider/ThemeProvider.tsx +1 -1
  49. package/src/hooks/useConstant.ts +17 -0
  50. package/src/system/utils.js +1 -1
  51. package/src/utils.js +3 -3
  52. package/src/utils.test.js +29 -0
@@ -4,7 +4,6 @@
4
4
  import { jsx } from '@emotion/core'
5
5
  import { Children } from 'react'
6
6
  import StickyBox from 'react-sticky-box'
7
- import warning from 'warning'
8
7
 
9
8
  import { css } from '../system'
10
9
  import StackView from '../StackView'
@@ -30,11 +29,14 @@ function Sidebar({ children, ...restProps }: Props) {
30
29
  >
31
30
  <StickyBox css={flexColumnCss}>
32
31
  {Children.map(children, (child) => {
33
- warning(
32
+ if (
34
33
  (child && child.type !== Sidebar.List) ||
35
- (child && child.type !== Sidebar.Item),
36
- `Invalid component nesting. ${child.type} cannot appear as a child of <Sidebar>. Only <Sidebar.List/> or <Sidebar.Item/> may be used.`
37
- )
34
+ (child && child.type !== Sidebar.Item)
35
+ ) {
36
+ console.warn(
37
+ `Invalid component nesting. ${child.type} cannot appear as a child of <Sidebar>. Only <Sidebar.List/> or <Sidebar.Item/> may be used.`
38
+ )
39
+ }
38
40
  return child
39
41
  })}
40
42
  </StickyBox>
@@ -1,8 +1,7 @@
1
1
  // @flow
2
2
  import React, { PureComponent, Children, Fragment } from 'react'
3
3
  import { Global } from '@emotion/core'
4
- import camelCase from 'lodash.camelcase'
5
- import snakeCase from 'lodash.snakecase'
4
+ import { camelCase, snakeCase } from 'lodash'
6
5
 
7
6
  import type { PaginationProps } from '../Pagination/Pagination'
8
7
 
@@ -2,7 +2,7 @@ import React, { useLayoutEffect, useState } from 'react'
2
2
  import { ThemeProvider as EmotionThemeProvider } from 'emotion-theming'
3
3
  import { CacheProvider } from '@emotion/core'
4
4
  import createCache from '@emotion/cache'
5
- import merge from 'deepmerge'
5
+ import { merge } from 'lodash'
6
6
 
7
7
  import defaultTheme from '../system/default-theme'
8
8
  import { flattenPalette } from '../system'
@@ -0,0 +1,17 @@
1
+ // A copy/paste of the source of the `use-constant` package.
2
+ // https://github.com/Andarist/use-constant/blob/main/src/index.ts
3
+ // This is done to reduce dependencies.
4
+
5
+ import * as React from 'react'
6
+
7
+ type ResultBox<T> = { v: T }
8
+
9
+ export default function useConstant<T>(fn: () => T): T {
10
+ const ref = React.useRef<ResultBox<T>>()
11
+
12
+ if (!ref.current) {
13
+ ref.current = { v: fn() }
14
+ }
15
+
16
+ return ref.current.v
17
+ }
@@ -1,7 +1,7 @@
1
1
  import { useContext, useCallback } from 'react'
2
2
  import { ThemeContext } from '@emotion/core'
3
3
  import { darken, getLuminance, lighten, parseToRgb } from 'polished'
4
- import get from 'lodash.get'
4
+ import { get } from 'lodash'
5
5
 
6
6
  import { getColor } from './colors'
7
7
  import defaultTheme from './default-theme'
package/src/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Children, cloneElement } from 'react'
2
2
  import { tabbable } from 'tabbable'
3
- import camelToKebabCase from 'camel-to-kebab'
3
+ import { kebabCase } from 'lodash'
4
4
 
5
5
  /**
6
6
  * Returns true if user platform is an iOS device
@@ -682,12 +682,12 @@ function createCSSProperty(key, value) {
682
682
  if (!createdCSSProperties.has(key)) {
683
683
  createdCSSProperties.add(key)
684
684
  }
685
- return `--${camelToKebabCase(key)}-${camelToKebabCase(value)}`
685
+ return `--${kebabCase(key)}-${kebabCase(value)}`
686
686
  }
687
687
 
688
688
  function getCSSProperty(key, value) {
689
689
  return key && value
690
- ? `var(--${camelToKebabCase(key)}-${camelToKebabCase(value)})`
690
+ ? `var(--${kebabCase(key)}-${kebabCase(value)})`
691
691
  : undefined
692
692
  }
693
693
 
@@ -0,0 +1,29 @@
1
+ import { createCSSProperty, getCSSProperty } from './utils'
2
+
3
+ describe('createCSSProperty', () => {
4
+ test('kebab cases the key and value', () => {
5
+ expect(createCSSProperty('theCamelCasedKey', 'theCamelCasedValue')).toEqual(
6
+ '--the-camel-cased-key-the-camel-cased-value'
7
+ )
8
+ })
9
+
10
+ test("does not mess with already kebab'd keys and values", () => {
11
+ expect(
12
+ createCSSProperty('mixedCamel-and-kebab', 'only-kebab-case')
13
+ ).toEqual('--mixed-camel-and-kebab-only-kebab-case')
14
+ })
15
+ })
16
+
17
+ describe('getCSSProperty', () => {
18
+ test('kebab cases the key and value', () => {
19
+ expect(getCSSProperty('theCamelCasedKey', 'theCamelCasedValue')).toEqual(
20
+ 'var(--the-camel-cased-key-the-camel-cased-value)'
21
+ )
22
+ })
23
+
24
+ test("does not mess with already kebab'd keys and values", () => {
25
+ expect(getCSSProperty('mixedCamel-and-kebab', 'only-kebab-case')).toEqual(
26
+ 'var(--mixed-camel-and-kebab-only-kebab-case)'
27
+ )
28
+ })
29
+ })