playbook_ui 8.2.1.alpha.iconacc → 8.2.1.pre.alpha5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7526c42c57c64b2f20becc559569747cda234e5478190b62e170ad5be74ac4a
4
- data.tar.gz: c2167d4d617d1fa829b96ee32d6b8ca490734b416dabd261806756868b6b4431
3
+ metadata.gz: 4a51ba5ee8e976845e84ecf877719d0e520aaec19cbc8a38afdbeaf2cb29917f
4
+ data.tar.gz: 97896528a851b64bd127b17bc1019a01ee5792c9b72aef5d86b130fb605e2ffe
5
5
  SHA512:
6
- metadata.gz: 61791c852673487ced56bfa3eb2e47c336017172b79ecb447ff48fb02d5b800ce85cb335f93347d7771c7e5dbe5ce2c92ba8ddf4d4dc07d776516de703d47e77
7
- data.tar.gz: af3ccf64210ecba24d6898579f51333f3b9be8e8f85d6d4feb6cf1ca5002e927f63e70eb2c51188270dde52b85f228c1f789acda840a7931b7b39327e6c23539
6
+ metadata.gz: 901809eb6df1c4d038fa5f660a96427325cdbd31e99327c1d650aad64c046b5d2de127d585ff8db43380fc52ce72104476a118f2eca3297071c9a68ee4bc26da
7
+ data.tar.gz: d5b1ea7c134a326c681ba7c8b4b63813fe18d7d9f7b6f1f57309f8aa7511d973ccef356d3ca205c040cd1e237133fc9c701f56a6b37146183be6d1cf3024875c
@@ -3,6 +3,7 @@
3
3
  import React from 'react'
4
4
  import classnames from 'classnames'
5
5
  import { globalProps } from '../utilities/globalProps.js'
6
+ import { Icon } from '../'
6
7
 
7
8
  import {
8
9
  buildAriaProps,
@@ -13,8 +14,15 @@ import {
13
14
  type BadgeProps = {
14
15
  aria?: object,
15
16
  className?: string,
17
+ closeProps?: {
18
+ onClick?: EventHandler,
19
+ onMouseDown?: EventHandler,
20
+ onTouchEnd?: EventHandler,
21
+ },
16
22
  data?: object,
17
23
  id?: string,
24
+ removeIcon?: Boolean,
25
+ removeOnClick?: EventHandler,
18
26
  rounded?: boolean,
19
27
  text?: string,
20
28
  variant?: "error" | "info" | "neutral" | "primary" | "success" | "warning",
@@ -23,8 +31,11 @@ const Badge = (props: BadgeProps) => {
23
31
  const {
24
32
  aria = {},
25
33
  className,
34
+ closeProps = {},
26
35
  data = {},
27
36
  id,
37
+ removeIcon = false,
38
+ removeOnClick = () => {},
28
39
  rounded = false,
29
40
  text,
30
41
  variant = 'neutral',
@@ -44,7 +55,21 @@ const Badge = (props: BadgeProps) => {
44
55
  className={css}
45
56
  id={id}
46
57
  >
47
- <span>{text}</span>
58
+ <span>
59
+ {text}
60
+ <If condition={removeIcon}>
61
+ <span
62
+ onClick={removeOnClick}
63
+ style={{ cursor: 'pointer' }}
64
+ {...closeProps}
65
+ >
66
+ <Icon
67
+ fixedWidth
68
+ icon="times"
69
+ />
70
+ </span>
71
+ </If>
72
+ </span>
48
73
  </div>
49
74
  )
50
75
  }
@@ -25,6 +25,8 @@ type DatePickerProps = {
25
25
  id?: String,
26
26
  inputAria?: object,
27
27
  inputData?: object,
28
+ inputOnChange?: (String) => void,
29
+ inputValue?: any,
28
30
  label?: String,
29
31
  maxDate: String,
30
32
  minDate: String,
@@ -55,6 +57,8 @@ const DatePicker = (props: DatePickerProps) => {
55
57
  id,
56
58
  inputAria,
57
59
  inputData,
60
+ inputOnChange,
61
+ inputValue,
58
62
  label = 'Date Picker',
59
63
  maxDate,
60
64
  minDate,
@@ -114,7 +118,6 @@ const DatePicker = (props: DatePickerProps) => {
114
118
  className={classes}
115
119
  id={id}
116
120
  >
117
- {className}
118
121
  <div className="input_wrapper">
119
122
  <TextInput
120
123
  aria={inputAria}
@@ -126,7 +129,9 @@ const DatePicker = (props: DatePickerProps) => {
126
129
  id={pickerId}
127
130
  label={hideLabel ? null : label}
128
131
  name={name}
132
+ onChange={inputOnChange}
129
133
  placeholder={placeholder}
134
+ value={inputValue}
130
135
  />
131
136
  <If condition={!hideIcon}>
132
137
  <div
@@ -166,6 +166,9 @@ const datePickerHelper = (config) => {
166
166
  picker.input.style.caretColor = 'transparent'
167
167
  picker.input.style.cursor = 'pointer'
168
168
  }
169
+
170
+ // Fix event bubbling bug on wrapper
171
+ document.querySelector(`#${pickerId}`).parentElement.addEventListener('click', (e) => e.stopPropagation())
169
172
  }
170
173
 
171
174
  export default datePickerHelper
@@ -1,6 +1,6 @@
1
1
  /* @flow */
2
2
 
3
- import React from 'react'
3
+ import React, { forwardRef } from 'react'
4
4
  import classnames from 'classnames'
5
5
  import { buildCss } from '../utilities/props'
6
6
  import { globalProps } from '../utilities/globalProps.js'
@@ -22,11 +22,12 @@ type FlexProps = {
22
22
  wrap?: boolean,
23
23
  }
24
24
 
25
- const Flex = (props: FlexProps) => {
25
+ const Flex = (props: FlexProps, ref: React.ElementRef<"div">) => {
26
26
  const {
27
27
  align = 'none',
28
28
  children,
29
29
  className,
30
+ id,
30
31
  inline = false,
31
32
  horizontal = 'left',
32
33
  justify = 'none',
@@ -70,10 +71,12 @@ const Flex = (props: FlexProps) => {
70
71
  globalProps(props),
71
72
  className
72
73
  )}
74
+ id={id}
75
+ ref={ref}
73
76
  >
74
77
  {children}
75
78
  </div>
76
79
  )
77
80
  }
78
81
 
79
- export default Flex
82
+ export default forwardRef(Flex)
@@ -2,14 +2,12 @@
2
2
 
3
3
  import React from 'react'
4
4
  import classnames from 'classnames'
5
- import { buildAriaProps, buildDataProps } from '../utilities/props'
6
5
  import { globalProps } from '../utilities/globalProps.js'
7
6
 
8
7
  type IconProps = {
9
- aria?: object,
8
+ aria?: Object,
10
9
  border?: boolean,
11
10
  className?: string,
12
- data?: object,
13
11
  fixedWidth?: boolean,
14
12
  flip?: "horizontal" | "vertical" | "both" | "none",
15
13
  icon: string,
@@ -43,10 +41,8 @@ const flipMap = {
43
41
 
44
42
  const Icon = (props: IconProps) => {
45
43
  const {
46
- aria = {},
47
44
  border = false,
48
45
  className,
49
- data = {},
50
46
  fixedWidth = true,
51
47
  flip = false,
52
48
  icon,
@@ -79,22 +75,11 @@ const Icon = (props: IconProps) => {
79
75
  className
80
76
  )
81
77
 
82
- aria.label ? null : aria.label = `${icon} icon`
83
- const ariaProps = buildAriaProps(aria)
84
- const dataProps = buildDataProps(data)
85
-
86
78
  return (
87
- <>
88
- <i
89
- {...dataProps}
90
- className={classes}
91
- id={id}
92
- />
93
- <span
94
- {...ariaProps}
95
- hidden="true"
96
- />
97
- </>
79
+ <i
80
+ className={classes}
81
+ id={id}
82
+ />
98
83
  )
99
84
  }
100
85
 
@@ -1,7 +1,5 @@
1
1
  <%= content_tag(:i, nil,
2
2
  id: object.id,
3
3
  data: object.data,
4
- class: object.classname ) %>
5
- <%= content_tag(:span, nil,
6
- aria: { label: "#{object.icon} icon" }.merge(object.aria),
7
- hidden: true ) %>
4
+ class: object.classname,
5
+ aria: object.aria) %>
@@ -22,7 +22,6 @@ const LoadingInline = (props: LoadingInlineProps) => {
22
22
  >
23
23
  <Body color="light">
24
24
  <Icon
25
- aria={{ label: 'loading icon' }}
26
25
  fixedWidth
27
26
  icon="spinner"
28
27
  pulse
@@ -4,6 +4,6 @@
4
4
  class: object.classname) do %>
5
5
 
6
6
  <%= pb_rails("body", props: { color: "light", dark: object.dark }) do %>
7
- <%= pb_rails("icon", props: { aria: { label: "loading icon" }, fixed_width: true, icon: "spinner", pulse: true }) %> Loading
7
+ <%= pb_rails("icon", props: { fixed_width: true, icon: "spinner", pulse: true }) %> Loading
8
8
  <% end %>
9
9
  <% end %>
@@ -75,6 +75,7 @@ const NavItem = (props: NavItemProps) => {
75
75
  key={iconLeft}
76
76
  >
77
77
  <Icon
78
+ aria={{ label: iconLeft }}
78
79
  className="pb_nav_list_item_icon_left"
79
80
  fixedWidth
80
81
  icon={iconLeft}
@@ -90,6 +91,7 @@ const NavItem = (props: NavItemProps) => {
90
91
  key={iconRight}
91
92
  >
92
93
  <Icon
94
+ aria={{ label: iconRight }}
93
95
  className="pb_nav_list_item_icon_right"
94
96
  fixedWidth
95
97
  icon={iconRight}
@@ -9,13 +9,13 @@
9
9
  <%= pb_rails("image", props: { url: object.image_url, classname: "pb_nav_img_wrapper" }) %>
10
10
  <% end %>
11
11
  <% if object.icon_left %>
12
- <%= pb_rails("icon", props: { icon: object.icon_left, classname: "pb_nav_list_item_icon_left", fixed_width: true}) %>
12
+ <%= pb_rails("icon", props: { aria: { label: object.icon_left }, icon: object.icon_left, classname: "pb_nav_list_item_icon_left", fixed_width: true}) %>
13
13
  <% end %>
14
14
  <span class="pb_nav_list_item_text">
15
15
  <%= object.text %><%= content.presence %>
16
16
  </span>
17
17
  <% if object.icon_right %>
18
- <%= pb_rails("icon", props: { icon: object.icon_right, classname: "pb_nav_list_item_icon_right", fixed_width: true}) %>
18
+ <%= pb_rails("icon", props: { aria: { label: object.icon_right }, icon: object.icon_right, classname: "pb_nav_list_item_icon_right", fixed_width: true}) %>
19
19
  <% end %>
20
20
  <% end %>
21
21
  <% end %>
@@ -1,6 +1,6 @@
1
1
  /* @flow */
2
2
 
3
- import React, { useEffect, useRef } from 'react'
3
+ import React, { forwardRef, useEffect, useRef } from 'react'
4
4
  import classnames from 'classnames'
5
5
  import useFocus from './useFocus.js'
6
6
  import Trix from 'trix'
@@ -22,7 +22,7 @@ type RichTextEditorProps = {
22
22
  value?: string,
23
23
  }
24
24
 
25
- const RichTextEditor = (props: RichTextEditorProps) => {
25
+ const RichTextEditor = (props: RichTextEditorProps, ref: React.ElementRef<"input">) => {
26
26
  const {
27
27
  aria = {},
28
28
  className,
@@ -120,6 +120,7 @@ const RichTextEditor = (props: RichTextEditorProps) => {
120
120
  <input
121
121
  id={id}
122
122
  name={name}
123
+ ref={ref}
123
124
  type="hidden"
124
125
  value={value}
125
126
  />
@@ -133,4 +134,4 @@ const RichTextEditor = (props: RichTextEditorProps) => {
133
134
  )
134
135
  }
135
136
 
136
- export default RichTextEditor
137
+ export default forwardRef(RichTextEditor)
@@ -19,6 +19,7 @@ type TextInputProps = {
19
19
  id?: string,
20
20
  name: string,
21
21
  label: string,
22
+ onBlur: (String) => void,
22
23
  onChange: (String) => void,
23
24
  placeholder: string,
24
25
  required?: boolean,
@@ -41,6 +42,7 @@ const TextInput = (
41
42
  id,
42
43
  name,
43
44
  label,
45
+ onBlur = () => {},
44
46
  onChange = () => {},
45
47
  placeholder,
46
48
  required,
@@ -79,6 +81,7 @@ const TextInput = (
79
81
  disabled={disabled}
80
82
  id={id}
81
83
  name={name}
84
+ onBlur={onBlur}
82
85
  onChange={onChange}
83
86
  placeholder={placeholder}
84
87
  ref={ref}
@@ -24,6 +24,7 @@ type TextareaProps = {
24
24
  required?: boolean,
25
25
  rows?: number,
26
26
  resize: 'none' | 'both' | 'horizontal' | 'vertical' | 'auto',
27
+ onBlur?: InputCallback<HTMLTextAreaElement>,
27
28
  onChange?: InputCallback<HTMLTextAreaElement>,
28
29
  }
29
30
 
@@ -37,6 +38,7 @@ const Textarea = ({
37
38
  label,
38
39
  maxCharacters,
39
40
  name,
41
+ onBlur = () => {},
40
42
  onChange = () => {},
41
43
  placeholder,
42
44
  required,
@@ -75,6 +77,7 @@ const Textarea = ({
75
77
  className="pb_textarea_kit"
76
78
  disabled={disabled}
77
79
  name={name}
80
+ onBlur={onBlur}
78
81
  onChange={onChange}
79
82
  placeholder={placeholder}
80
83
  ref={ref}
@@ -3,12 +3,14 @@
3
3
  import React from 'react'
4
4
  import Select from 'react-select'
5
5
  import AsyncSelect from 'react-select/async'
6
+ import CreateableSelect from 'react-select/creatable'
6
7
  import { get } from 'lodash'
7
8
  import { globalProps } from '../utilities/globalProps.js'
8
9
 
9
10
  import Control from './components/Control'
10
11
  import ClearIndicator from './components/ClearIndicator'
11
12
  import IndicatorsContainer from './components/IndicatorsContainer'
13
+ import Input from './components/Input'
12
14
  import MenuList from './components/MenuList'
13
15
  import MultiValue from './components/MultiValue'
14
16
  import Option from './components/Option'
@@ -26,6 +28,7 @@ import { noop } from '../utilities/props'
26
28
 
27
29
  type Props = {
28
30
  async?: boolean,
31
+ createable?: boolean,
29
32
  dark?: boolean,
30
33
  label?: string,
31
34
  loadOptions?: noop | string,
@@ -41,12 +44,14 @@ type Props = {
41
44
 
42
45
  const Typeahead = (props: Props) => {
43
46
  const selectProps = {
47
+ badges: false,
44
48
  cacheOptions: true,
45
49
  components: {
46
50
  Control,
47
51
  ClearIndicator,
48
52
  IndicatorsContainer,
49
53
  IndicatorSeparator: null,
54
+ Input,
50
55
  MenuList,
51
56
  MultiValue,
52
57
  Option,
@@ -58,6 +63,8 @@ const Typeahead = (props: Props) => {
58
63
  isClearable: true,
59
64
  isSearchable: true,
60
65
  name,
66
+ onCreate: () => {},
67
+ plusIcon: false,
61
68
  ...props,
62
69
  }
63
70
 
@@ -65,7 +72,8 @@ const Typeahead = (props: Props) => {
65
72
  if (typeof(props.getOptionLabel) === 'string') selectProps.getOptionLabel = get(window, props.getOptionLabel)
66
73
  if (typeof(props.getOptionValue) === 'string') selectProps.getOptionValue = get(window, props.getOptionValue)
67
74
 
68
- const Tag = props.async ? AsyncSelect : Select
75
+ let Tag = props.async ? AsyncSelect : Select
76
+ if (props.createable) Tag = CreateableSelect
69
77
 
70
78
  const handleOnChange = (data, { action, option, removedValue }) => {
71
79
  if (action === 'select-option') {
@@ -148,4 +148,17 @@
148
148
  box-sizing: border-box;
149
149
  }
150
150
  }
151
+ .placeholder+.input-wrapper .typeahead-plus-icon {
152
+ display: none;
153
+ }
154
+ .typeahead-kit-select__control--is-focused .typeahead-plus-icon {
155
+ display: none;
156
+ }
157
+ .typeahead-plus-icon {
158
+ color: $text_lt_lighter;
159
+ }
160
+ [class^=pb_badge_kit] span {
161
+ line-height: 16.5px;
162
+ letter-spacing: normal;
163
+ }
151
164
  }
@@ -0,0 +1,27 @@
1
+ /* @flow */
2
+
3
+ import React from 'react'
4
+ import { components } from 'react-select'
5
+ import { Flex, Icon } from '../../'
6
+
7
+ const Input = (props: any) => (
8
+ <>
9
+ <Flex
10
+ align="center"
11
+ className="input-wrapper"
12
+ >
13
+ <If condition={props.selectProps.plusIcon}>
14
+ <Icon
15
+ className="typeahead-plus-icon"
16
+ icon="plus"
17
+ />
18
+ </If>
19
+ <components.Input
20
+ className="input"
21
+ {...props}
22
+ />
23
+ </Flex>
24
+ </>
25
+ )
26
+
27
+ export default Input
@@ -3,7 +3,7 @@
3
3
  import React from 'react'
4
4
  import { components } from 'react-select'
5
5
 
6
- import { FormPill } from '../../'
6
+ import { Badge, FormPill } from '../../'
7
7
 
8
8
  type Props = {
9
9
  data: object,
@@ -15,6 +15,7 @@ type Props = {
15
15
  const MultiValue = (props: Props) => {
16
16
  const { removeProps } = props
17
17
  const { imageUrl, label } = props.data
18
+ const { badges } = props.selectProps
18
19
 
19
20
  const formPillProps = {
20
21
  marginRight: 'xs',
@@ -28,19 +29,28 @@ const MultiValue = (props: Props) => {
28
29
  className="text_input_multivalue_container"
29
30
  {...props}
30
31
  >
31
- <If condition={imageUrl}>
32
- <FormPill
33
- avatarUrl={imageUrl}
32
+ <If condition={badges}>
33
+ <Badge
34
34
  closeProps={removeProps}
35
- marginRight="xs"
36
- name={label}
37
- />
38
- <Else />
39
- <FormPill
40
- closeProps={removeProps}
41
- marginRight="xs"
35
+ removeIcon
42
36
  text={label}
37
+ variant="primary"
43
38
  />
39
+ <Else />
40
+ <If condition={imageUrl}>
41
+ <FormPill
42
+ avatarUrl={imageUrl}
43
+ closeProps={removeProps}
44
+ marginRight="xs"
45
+ name={label}
46
+ />
47
+ <Else />
48
+ <FormPill
49
+ closeProps={removeProps}
50
+ marginRight="xs"
51
+ text={label}
52
+ />
53
+ </If>
44
54
  </If>
45
55
  </components.MultiValueContainer>
46
56
  )
@@ -1,13 +1,26 @@
1
1
  /* @flow */
2
2
 
3
3
  import React from 'react'
4
+ import { Flex, Icon } from '../../'
4
5
  import { components } from 'react-select'
5
6
 
6
7
  const Placeholder = (props: any) => (
7
- <components.IndicatorsContainer
8
- className="placeholder"
9
- {...props}
10
- />
8
+ <>
9
+ <Flex
10
+ align="center"
11
+ className="placeholder"
12
+ >
13
+ <components.IndicatorsContainer
14
+ {...props}
15
+ />
16
+ <If condition={props.selectProps.plusIcon}>
17
+ <Icon
18
+ className="typeahead-plus-icon"
19
+ icon="plus"
20
+ />
21
+ </If>
22
+ </Flex>
23
+ </>
11
24
  )
12
25
 
13
26
  export default Placeholder
@@ -13,6 +13,7 @@ const options = [
13
13
  const TypeaheadDefault = (props) => {
14
14
  return (
15
15
  <Typeahead
16
+ // badges
16
17
  label="Colors"
17
18
  options={options}
18
19
  {...props}
@@ -3,7 +3,7 @@
3
3
  import React from 'react'
4
4
  import { Typeahead } from '../..'
5
5
 
6
- const options = [
6
+ const initOptions = [
7
7
  { label: 'Windows', value: '#FFA500' },
8
8
  { label: 'Siding', value: '#FF0000' },
9
9
  { label: 'Doors', value: '#00FF00' },
@@ -11,13 +11,18 @@ const options = [
11
11
  ]
12
12
 
13
13
  const TypeaheadWithPills = (props) => {
14
+ // const [values, setValues] = useState([])
14
15
  return (
15
16
  <>
16
17
  <Typeahead
18
+ badges
19
+ createable
17
20
  isMulti
18
21
  label="Colors"
19
- options={options}
20
- placeholder=""
22
+ // onChange={(value) => console.log(value)}
23
+ options={initOptions}
24
+ placeholder="Placeholder"
25
+ plusIcon
21
26
  {...props}
22
27
  />
23
28
  </>
@@ -7,8 +7,8 @@ examples:
7
7
  - typeahead_with_pills_async_users: With Pills (Async Data w/ Users)
8
8
 
9
9
  react:
10
- - typeahead_default: Default
10
+ # - typeahead_default: Default
11
11
  - typeahead_with_pills: With Pills
12
- - typeahead_with_pills_async: With Pills (Async Data)
13
- - typeahead_with_pills_async_users: With Pills (Async Data w/ Users)
14
- - typeahead_with_pills_async_custom_options: With Pills (Async Data w/ Custom Options)
12
+ # - typeahead_with_pills_async: With Pills (Async Data)
13
+ # - typeahead_with_pills_async_users: With Pills (Async Data w/ Users)
14
+ # - typeahead_with_pills_async_custom_options: With Pills (Async Data w/ Custom Options)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playbook
4
- VERSION = "8.2.1.alpha.iconacc"
4
+ VERSION = "8.2.1.pre.alpha5"
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.2.1.alpha.iconacc
4
+ version: 8.2.1.pre.alpha5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Power UX
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-31 00:00:00.000000000 Z
12
+ date: 2021-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -1961,6 +1961,7 @@ files:
1961
1961
  - app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.jsx
1962
1962
  - app/pb_kits/playbook/pb_typeahead/components/Control.jsx
1963
1963
  - app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.jsx
1964
+ - app/pb_kits/playbook/pb_typeahead/components/Input.jsx
1964
1965
  - app/pb_kits/playbook/pb_typeahead/components/MenuList.jsx
1965
1966
  - app/pb_kits/playbook/pb_typeahead/components/MultiValue.jsx
1966
1967
  - app/pb_kits/playbook/pb_typeahead/components/Option.jsx