playbook_ui 9.8.0 → 9.9.0.alpha.inline1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_badge/_badge.jsx +26 -1
  3. data/app/pb_kits/playbook/pb_date_picker/_date_picker.jsx +6 -1
  4. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.js +3 -0
  5. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +12 -2
  6. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +19 -0
  7. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.html.erb +13 -0
  8. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.jsx +25 -0
  9. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.html.erb +4 -5
  10. data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.jsx +2 -6
  11. data/app/pb_kits/playbook/pb_form_pill/docs/example.yml +2 -0
  12. data/app/pb_kits/playbook/pb_form_pill/docs/index.js +1 -0
  13. data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
  14. data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +5 -0
  15. data/app/pb_kits/playbook/pb_passphrase/_passphrase.jsx +12 -9
  16. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.html.erb +1 -0
  17. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.jsx +24 -0
  18. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_breached.md +3 -0
  19. data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_default.jsx +1 -0
  20. data/app/pb_kits/playbook/pb_passphrase/docs/example.yml +2 -0
  21. data/app/pb_kits/playbook/pb_passphrase/docs/index.js +1 -0
  22. data/app/pb_kits/playbook/pb_passphrase/passphrase.rb +2 -0
  23. data/app/pb_kits/playbook/pb_passphrase/passphrase.test.jsx +12 -0
  24. data/app/pb_kits/playbook/pb_passphrase/useHaveIBeenPwned.js +52 -0
  25. data/app/pb_kits/playbook/pb_passphrase/useZxcvbn.js +58 -0
  26. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.jsx +10 -0
  27. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +61 -0
  28. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline.html.erb +6 -0
  29. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_inline.jsx +16 -0
  30. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_bottom.html.erb +4 -0
  31. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_toolbar_bottom.jsx +14 -0
  32. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +4 -0
  33. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +2 -0
  34. data/app/pb_kits/playbook/pb_rich_text_editor/rich_text_editor.rb +9 -2
  35. data/app/pb_kits/playbook/pb_text_input/_text_input.jsx +3 -0
  36. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +8 -0
  37. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_inline.html.erb +5 -0
  38. data/app/pb_kits/playbook/pb_text_input/docs/_text_input_inline.jsx +22 -0
  39. data/app/pb_kits/playbook/pb_text_input/docs/example.yml +2 -0
  40. data/app/pb_kits/playbook/pb_text_input/docs/index.js +1 -0
  41. data/app/pb_kits/playbook/pb_text_input/text_input.rb +7 -1
  42. data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +11 -2
  43. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +23 -0
  44. data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.jsx +23 -11
  45. data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.jsx +17 -4
  46. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_inline.html.erb +36 -0
  47. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_inline.jsx +43 -0
  48. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_multi_kit.html.erb +35 -0
  49. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_multi_kit.jsx +44 -0
  50. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +4 -0
  51. data/app/pb_kits/playbook/pb_typeahead/docs/index.js +7 -5
  52. data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +1 -1
  53. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +18 -2
  54. data/lib/playbook/version.rb +1 -1
  55. metadata +22 -6
@@ -8,6 +8,8 @@ module Playbook
8
8
  prop :disabled, type: Playbook::Props::Boolean,
9
9
  default: false
10
10
  prop :error
11
+ prop :inline, type: Playbook::Props::Boolean,
12
+ default: false
11
13
  prop :label
12
14
  prop :name
13
15
  prop :placeholder
@@ -19,7 +21,7 @@ module Playbook
19
21
  prop :value
20
22
 
21
23
  def classname
22
- generate_classname("pb_text_input_kit") + error_class
24
+ generate_classname("pb_text_input_kit") + error_class + inline_class
23
25
  end
24
26
 
25
27
  def validation_message
@@ -41,6 +43,10 @@ module Playbook
41
43
  def error_class
42
44
  error ? " error" : ""
43
45
  end
46
+
47
+ def inline_class
48
+ inline ? " inline" : ""
49
+ end
44
50
  end
45
51
  end
46
52
  end
@@ -3,8 +3,10 @@
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'
9
+ import classnames from 'classnames'
8
10
 
9
11
  import Control from './components/Control'
10
12
  import ClearIndicator from './components/ClearIndicator'
@@ -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,
@@ -55,9 +58,13 @@ const Typeahead = (props: Props) => {
55
58
  },
56
59
  defaultOptions: true,
57
60
  id: 'react-select-input',
61
+ inline: false,
58
62
  isClearable: true,
59
63
  isSearchable: true,
60
64
  name,
65
+ multiKit: '',
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') {
@@ -84,9 +92,10 @@ const Typeahead = (props: Props) => {
84
92
  }
85
93
 
86
94
  const classes = `pb_typeahead_kit react-select ${globalProps(props)}`
95
+ const inlineClass = selectProps.inline ? 'inline' : null
87
96
 
88
97
  return (
89
- <div className={classes}>
98
+ <div className={classnames(classes, inlineClass)}>
90
99
  <Tag
91
100
  classNamePrefix="typeahead-kit-select"
92
101
  onChange={handleOnChange}
@@ -154,4 +154,27 @@
154
154
  box-sizing: border-box;
155
155
  }
156
156
  }
157
+ .placeholder+.input-wrapper .typeahead-plus-icon {
158
+ display: none;
159
+ }
160
+ .typeahead-kit-select__control--is-focused .typeahead-plus-icon {
161
+ display: none;
162
+ }
163
+ .typeahead-plus-icon {
164
+ color: $text_lt_lighter;
165
+ }
166
+ [class^=pb_badge_kit] span {
167
+ line-height: 16.5px;
168
+ letter-spacing: normal;
169
+ }
170
+ &.inline {
171
+ &:not(:hover) {
172
+ .text_input {
173
+ border-color: transparent;
174
+ }
175
+ .text_input_indicators .css-tlfecz-indicatorContainer {
176
+ color: transparent;
177
+ }
178
+ }
179
+ }
157
180
  }
@@ -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 { multiKit } = props.selectProps
18
19
 
19
20
  const formPillProps = {
20
21
  marginRight: 'xs',
@@ -28,19 +29,30 @@ 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={multiKit === 'badge'}>
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
+ size={multiKit === 'smallPill' ? 'small' : ''}
47
+ />
48
+ <Else />
49
+ <FormPill
50
+ closeProps={removeProps}
51
+ marginRight="xs"
52
+ size={multiKit === 'smallPill' ? 'small' : ''}
53
+ text={label}
54
+ />
55
+ </If>
44
56
  </If>
45
57
  </components.MultiValueContainer>
46
58
  )
@@ -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
@@ -0,0 +1,36 @@
1
+ <%
2
+ synths = [
3
+ { label: 'Oberheim', value: 'OBXa' },
4
+ { label: 'Moog', value: 'Minimoog' },
5
+ { label: 'Roland', value: 'Juno' },
6
+ { label: 'Korg', value: 'MS-20' },
7
+ ]
8
+ %>
9
+ <%
10
+ cities = [
11
+ { label: 'Budapest', value: 'Hungary' },
12
+ { label: 'Singapore', value: 'Singapore' },
13
+ { label: 'Oslo', value: 'Norway' },
14
+ { label: 'Lagos', value: 'Nigeria' },
15
+ ]
16
+ %>
17
+
18
+ <%= pb_rails("typeahead", props: {
19
+ default_options: [synths.first],
20
+ id: "typeahead-inline-example1",
21
+ inline: true,
22
+ options: synths,
23
+ label: "Synths",
24
+ placeholder: "Add synths",
25
+ pills: true
26
+ }) %>
27
+
28
+ <%= pb_rails("typeahead", props: {
29
+ id: "typeahead-inline-example2",
30
+ inline: true,
31
+ options: cities,
32
+ label: "Cities",
33
+ pills: true,
34
+ placeholder: "Add cities",
35
+ plus_icon: true
36
+ }) %>
@@ -0,0 +1,43 @@
1
+ // @flow
2
+
3
+ import React from 'react'
4
+ import { Typeahead } from '../../'
5
+
6
+ const synths = [
7
+ { label: 'Oberheim', value: 'OBXa' },
8
+ { label: 'Moog', value: 'Minimoog' },
9
+ { label: 'Roland', value: 'Juno' },
10
+ { label: 'Korg', value: 'MS-20' },
11
+ ]
12
+
13
+ const cities = [
14
+ { label: 'Budapest', value: 'Hungary' },
15
+ { label: 'Singapore', value: 'Singapore' },
16
+ { label: 'Oslo', value: 'Norway' },
17
+ { label: 'Lagos', value: 'Nigeria' },
18
+ ]
19
+
20
+ const TypeaheadInline = (props) => {
21
+ return (
22
+ <>
23
+ <Typeahead
24
+ inline
25
+ isMulti
26
+ label="Synths"
27
+ options={synths}
28
+ {...props}
29
+ />
30
+ <Typeahead
31
+ inline
32
+ isMulti
33
+ label="Placeholder Plus Icon"
34
+ options={cities}
35
+ placeholder="Add cities"
36
+ plusIcon
37
+ {...props}
38
+ />
39
+ </>
40
+ )
41
+ }
42
+
43
+ export default TypeaheadInline
@@ -0,0 +1,35 @@
1
+ <%
2
+ labels = [
3
+ { label: 'Verve', value: '1956' },
4
+ { label: 'Stax', value: '1957' },
5
+ { label: 'Motown', value: '1959' },
6
+ { label: 'Kudu', value: '1971' },
7
+ { label: 'Stones Throw', value: '1996' },
8
+ ]
9
+ %>
10
+ <%
11
+ expressionists = [
12
+ { label: 'Kandinsky', value: 'Russia' },
13
+ { label: 'Klee', value: 'Switzerland' },
14
+ { label: 'Kokoschka', value: 'Austria' },
15
+ { label: 'Kirchner', value: 'Germany' },
16
+ ]
17
+ %>
18
+
19
+ <%= pb_rails("typeahead", props: {
20
+ default_options: [labels.first],
21
+ id: "typeahead-multi-kit-example1",
22
+ options: labels,
23
+ label: "Badges",
24
+ multi_kit: "badge",
25
+ pills: true
26
+ }) %>
27
+
28
+ <%= pb_rails("typeahead", props: {
29
+ default_options: [expressionists.first],
30
+ id: "typeahead-multi-kit-example2",
31
+ options: expressionists,
32
+ label: "Small Pills",
33
+ multi_kit: "smallPill",
34
+ pills: true,
35
+ }) %>
@@ -0,0 +1,44 @@
1
+ // @flow
2
+
3
+ import React from 'react'
4
+ import { Typeahead } from '../../'
5
+
6
+ const labels = [
7
+ { label: 'Verve', value: '1956' },
8
+ { label: 'Stax', value: '1957' },
9
+ { label: 'Motown', value: '1959' },
10
+ { label: 'Kudu', value: '1971' },
11
+ { label: 'Stones Throw', value: '1996' },
12
+ ]
13
+
14
+ const expressionists = [
15
+ { label: 'Kandinsky', value: 'Russia' },
16
+ { label: 'Klee', value: 'Switzerland' },
17
+ { label: 'Kokoschka', value: 'Austria' },
18
+ { label: 'Kirchner', value: 'Germany' },
19
+ ]
20
+
21
+ const TypeaheadMultiKit = (props) => {
22
+ return (
23
+ <>
24
+ <Typeahead
25
+ defaultValue={[labels[0]]}
26
+ isMulti
27
+ label="Badges"
28
+ multiKit="badge"
29
+ options={labels}
30
+ {...props}
31
+ />
32
+ <Typeahead
33
+ defaultValue={[expressionists[0]]}
34
+ isMulti
35
+ label="Small Pills"
36
+ multiKit="smallPill"
37
+ options={expressionists}
38
+ {...props}
39
+ />
40
+ </>
41
+ )
42
+ }
43
+
44
+ export default TypeaheadMultiKit
@@ -5,6 +5,8 @@ examples:
5
5
  - typeahead_with_pills: With Pills
6
6
  - typeahead_with_pills_async: With Pills (Async Data)
7
7
  - typeahead_with_pills_async_users: With Pills (Async Data w/ Users)
8
+ - typeahead_inline: Inline
9
+ - typeahead_multi_kit: Multi Kit Options
8
10
 
9
11
  react:
10
12
  - typeahead_default: Default
@@ -12,3 +14,5 @@ examples:
12
14
  - typeahead_with_pills_async: With Pills (Async Data)
13
15
  - typeahead_with_pills_async_users: With Pills (Async Data w/ Users)
14
16
  - typeahead_with_pills_async_custom_options: With Pills (Async Data w/ Custom Options)
17
+ - typeahead_inline: Inline
18
+ - typeahead_multi_kit: Multi Kit Options
@@ -1,5 +1,7 @@
1
- export { default as TypeaheadDefault } from './_typeahead_default'
2
- export { default as TypeaheadWithPills } from './_typeahead_with_pills'
3
- export { default as TypeaheadWithPillsAsync } from './_typeahead_with_pills_async'
4
- export { default as TypeaheadWithPillsAsyncUsers } from './_typeahead_with_pills_async_users'
5
- export { default as TypeaheadWithPillsAsyncCustomOptions } from './_typeahead_with_pills_async_custom_options'
1
+ export { default as TypeaheadDefault } from './_typeahead_default.jsx'
2
+ export { default as TypeaheadWithPills } from './_typeahead_with_pills.jsx'
3
+ export { default as TypeaheadWithPillsAsync } from './_typeahead_with_pills_async.jsx'
4
+ export { default as TypeaheadWithPillsAsyncUsers } from './_typeahead_with_pills_async_users.jsx'
5
+ export { default as TypeaheadWithPillsAsyncCustomOptions } from './_typeahead_with_pills_async_custom_options.jsx'
6
+ export { default as TypeaheadInline } from './_typeahead_inline.jsx'
7
+ export { default as TypeaheadMultiKit } from './_typeahead_multi_kit.jsx'
@@ -4,7 +4,7 @@
4
4
  <%= content_tag(:div,
5
5
  id: object.id,
6
6
  data: object.data,
7
- class: object.classname) do %>
7
+ class: object.classname + object.inline_class) do %>
8
8
  <div class="pb_typeahead_wrapper">
9
9
  <div class="pb_typeahead_loading_indicator" data-pb-typeahead-kit-loading-indicator>
10
10
  <%= pb_rails("icon", props: {
@@ -8,12 +8,21 @@ module Playbook
8
8
  prop :get_option_label
9
9
  prop :get_option_value
10
10
  prop :id
11
+ prop :inline, type: Playbook::Props::Boolean,
12
+ default: false
11
13
  prop :label
12
14
  prop :load_options
15
+ prop :multi_kit, type: Playbook::Props::String,
16
+ default: ""
13
17
  prop :name
14
- prop :options, type: Playbook::Props::HashArray, default: []
15
- prop :pills, type: Playbook::Props::Boolean, default: false
18
+ prop :options, type: Playbook::Props::HashArray,
19
+ default: []
20
+ prop :pills, type: Playbook::Props::Boolean,
21
+ default: false
22
+
16
23
  prop :placeholder
24
+ prop :plus_icon, type: Playbook::Props::Boolean,
25
+ default: false
17
26
  prop :search_term_minimum_length, default: 3
18
27
  prop :search_debounce_timeout, default: 250
19
28
  prop :value
@@ -22,6 +31,10 @@ module Playbook
22
31
  generate_classname("pb_typeahead_kit")
23
32
  end
24
33
 
34
+ def inline_class
35
+ inline ? " inline" : ""
36
+ end
37
+
25
38
  def data
26
39
  Hash(values[:data]).merge(
27
40
  pb_typeahead_kit: true,
@@ -35,11 +48,14 @@ module Playbook
35
48
  dark: dark,
36
49
  defaultValue: default_options,
37
50
  id: id,
51
+ inline: inline,
38
52
  isMulti: true,
39
53
  label: label,
54
+ multiKit: multi_kit,
40
55
  name: name,
41
56
  options: options,
42
57
  placeholder: placeholder,
58
+ plusIcon: plus_icon,
43
59
  }
44
60
 
45
61
  base_options.merge!({ getOptionLabel: get_option_label }) if get_option_label.present?