playbook_ui 7.3.0 → 7.4.0.pre.test3
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +12 -1
- data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.jsx +19 -0
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.jsx +8 -15
- data/app/pb_kits/playbook/pb_typeahead/components/Option.jsx +1 -6
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills.html.erb +7 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills.md +10 -1
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +2 -0
- data/lib/playbook/version.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4211d32c465852e435e15c2ef8f84f09eb8c3b7a1688fe716cd8e5a7dbe3010
|
4
|
+
data.tar.gz: aa2b0edb1d453cfa833e456d05ba66cd3d673c03aefb489e1354f30fbf896a95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b485cc3abd09ab954532ac9dd39a97c841b58be95a35b1e2ae1d6fc985d081131431f552eb50be5e9254257895041b0f278941f0a7d17810244d6742f5d34024
|
7
|
+
data.tar.gz: fc0c06ccb718a5b0b77ac77080836a3865f27f98ad63ed5cb4cf7e584114de508e95384307d535855aef5214cbb6e74bc9415f37049c1e3117ba193a2de2297d
|
@@ -6,6 +6,7 @@ import AsyncSelect from 'react-select/async'
|
|
6
6
|
import { get } from 'lodash'
|
7
7
|
|
8
8
|
import Control from './components/Control'
|
9
|
+
import ClearIndicator from './components/ClearIndicator'
|
9
10
|
import IndicatorsContainer from './components/IndicatorsContainer'
|
10
11
|
import MenuList from './components/MenuList'
|
11
12
|
import MultiValue from './components/MultiValue'
|
@@ -40,6 +41,7 @@ const Typeahead = (props: Props) => {
|
|
40
41
|
defaultOptions: true,
|
41
42
|
components: {
|
42
43
|
Control,
|
44
|
+
ClearIndicator,
|
43
45
|
IndicatorsContainer,
|
44
46
|
IndicatorSeparator: null,
|
45
47
|
MenuList,
|
@@ -58,7 +60,16 @@ const Typeahead = (props: Props) => {
|
|
58
60
|
|
59
61
|
const Tag = props.async ? AsyncSelect : Select
|
60
62
|
|
61
|
-
const handleOnChange = (data, { action }) => {
|
63
|
+
const handleOnChange = (data, { action, option, removedValue }) => {
|
64
|
+
if (action === 'select-option') {
|
65
|
+
if (selectProps.onMultiValueClick) selectProps.onMultiValueClick(option)
|
66
|
+
const multiValueClearEvent = new CustomEvent('pb-typeahead-kit-result-option-select', { detail: option })
|
67
|
+
document.dispatchEvent(multiValueClearEvent)
|
68
|
+
}
|
69
|
+
if (action === 'remove-value' || action === 'pop-value') {
|
70
|
+
const multiValueRemoveEvent = new CustomEvent('pb-typeahead-kit-result-option-remove', { detail: removedValue })
|
71
|
+
document.dispatchEvent(multiValueRemoveEvent)
|
72
|
+
}
|
62
73
|
if (action === 'clear') {
|
63
74
|
const multiValueClearEvent = new CustomEvent('pb-typeahead-kit-result-clear')
|
64
75
|
document.dispatchEvent(multiValueClearEvent)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/* @flow */
|
2
|
+
|
3
|
+
import React, { useEffect } from 'react'
|
4
|
+
import { components } from 'react-select'
|
5
|
+
|
6
|
+
const ClearContainer = (props: any) => {
|
7
|
+
useEffect(() => {
|
8
|
+
document.addEventListener('pb-typeahead-kit:clear', props.clearValue)
|
9
|
+
}, true)
|
10
|
+
|
11
|
+
return (
|
12
|
+
<components.ClearIndicator
|
13
|
+
className="clear_indicator"
|
14
|
+
{...props}
|
15
|
+
/>
|
16
|
+
)
|
17
|
+
}
|
18
|
+
|
19
|
+
export default ClearContainer
|
@@ -13,24 +13,17 @@ type Props = {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
const MultiValue = (props: Props) => {
|
16
|
-
const {
|
17
|
-
|
18
|
-
removeProps,
|
19
|
-
selectProps,
|
20
|
-
} = props
|
16
|
+
const { removeProps } = props
|
17
|
+
const { imageUrl, label } = props.data
|
21
18
|
|
22
|
-
const
|
23
|
-
|
24
|
-
|
25
|
-
const multiValueRemoveEvent = new CustomEvent('pb-typeahead-kit-result-option-remove', { detail: data })
|
26
|
-
document.dispatchEvent(multiValueRemoveEvent)
|
19
|
+
const formPillProps = {
|
20
|
+
marginRight: 'xs',
|
21
|
+
name: label,
|
27
22
|
}
|
28
23
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
removeProps.onClick()
|
33
|
-
}
|
24
|
+
if (typeof imageUrl === 'string') formPillProps.avatarUrl = imageUrl
|
25
|
+
|
26
|
+
const handleOnClick = removeProps.onClick
|
34
27
|
|
35
28
|
return (
|
36
29
|
<components.MultiValueContainer
|
@@ -13,14 +13,9 @@ const Option = (props: any) => {
|
|
13
13
|
label,
|
14
14
|
} = props.data
|
15
15
|
|
16
|
-
const handleOptionClicked = () => {
|
17
|
-
const resultSelectedEvent = new CustomEvent('pb-typeahead-kit-result-option-select', { detail: props.data })
|
18
|
-
document.dispatchEvent(resultSelectedEvent)
|
19
|
-
}
|
20
|
-
|
21
16
|
return (
|
22
17
|
<components.Option {...props}>
|
23
|
-
<div
|
18
|
+
<div>
|
24
19
|
<Choose>
|
25
20
|
<When condition={imageUrl}>
|
26
21
|
<User
|
@@ -7,7 +7,9 @@
|
|
7
7
|
]
|
8
8
|
%>
|
9
9
|
|
10
|
-
<%= pb_rails("typeahead", props: { options: options, label: "Colors", name: :foo, pills: true }) %>
|
10
|
+
<%= pb_rails("typeahead", props: { default_options: [options.first], options: options, label: "Colors", name: :foo, pills: true }) %>
|
11
|
+
|
12
|
+
<%= pb_rails("button", props: {id: "clear-pills", text: "Clear All Options", variant: "secondary"}) %>
|
11
13
|
|
12
14
|
<!-- This section is an example of the available JavaScript event hooks -->
|
13
15
|
<%= javascript_tag defer: "defer" do %>
|
@@ -22,4 +24,8 @@
|
|
22
24
|
document.addEventListener("pb-typeahead-kit-result-clear", function() {
|
23
25
|
console.log('All options cleared')
|
24
26
|
})
|
27
|
+
|
28
|
+
document.querySelector('#clear-pills').addEventListener('click', function() {
|
29
|
+
document.dispatchEvent(new CustomEvent('pb-typeahead-kit:clear'))
|
30
|
+
})
|
25
31
|
<% end %>
|
@@ -1,8 +1,17 @@
|
|
1
1
|
Typeahead kit is data-driven. The minimum default fields are `label` and `value`.
|
2
2
|
|
3
|
-
`{ label:
|
3
|
+
This is an example of an option: `{ label: 'Windows', value: '#FFA500' }`
|
4
|
+
|
5
|
+
#### Rails: Default Options
|
6
|
+
|
7
|
+
You can also pass `default_options` which will populate the initial pill selections:
|
8
|
+
|
9
|
+
`default_options: [{ label: 'Windows', value: '#FFA500' }]`
|
4
10
|
|
5
11
|
#### Rails: Subscribing to JS Events
|
6
12
|
`pb-typeahead-kit-result-option-select` event to perform custom work when an option is clicked.
|
7
13
|
`pb-typeahead-kit-result-option-remove` event to perform custom work when a pill is clicked.
|
8
14
|
`pb-typeahead-kit-result-option-clear` event to perform custom work when all pills are removed upon clicking the X.
|
15
|
+
|
16
|
+
#### Rails: Publishing JS Events
|
17
|
+
`pb-typeahead-kit:clear` event to clear all options.
|
@@ -7,6 +7,7 @@ module Playbook
|
|
7
7
|
|
8
8
|
prop :async, type: Playbook::Props::Boolean,
|
9
9
|
default: false
|
10
|
+
prop :default_options, type: Playbook::Props::HashArray, default: []
|
10
11
|
prop :label
|
11
12
|
prop :load_options
|
12
13
|
prop :name
|
@@ -35,6 +36,7 @@ module Playbook
|
|
35
36
|
|
36
37
|
def typeahead_with_pills_options
|
37
38
|
base_options = {
|
39
|
+
defaultValue: default_options,
|
38
40
|
isMulti: true,
|
39
41
|
label: label,
|
40
42
|
options: options,
|
data/lib/playbook/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playbook_ui
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.4.0.pre.test3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Power UX
|
8
8
|
- Power Devs
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-10-
|
12
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -1770,6 +1770,7 @@ files:
|
|
1770
1770
|
- app/pb_kits/playbook/pb_typeahead/_typeahead.html.erb
|
1771
1771
|
- app/pb_kits/playbook/pb_typeahead/_typeahead.jsx
|
1772
1772
|
- app/pb_kits/playbook/pb_typeahead/_typeahead.scss
|
1773
|
+
- app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.jsx
|
1773
1774
|
- app/pb_kits/playbook/pb_typeahead/components/Control.jsx
|
1774
1775
|
- app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.jsx
|
1775
1776
|
- app/pb_kits/playbook/pb_typeahead/components/MenuList.jsx
|
@@ -1889,7 +1890,7 @@ homepage: http://playbook.powerapp.cloud
|
|
1889
1890
|
licenses:
|
1890
1891
|
- MIT
|
1891
1892
|
metadata: {}
|
1892
|
-
post_install_message:
|
1893
|
+
post_install_message:
|
1893
1894
|
rdoc_options: []
|
1894
1895
|
require_paths:
|
1895
1896
|
- lib
|
@@ -1900,13 +1901,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1900
1901
|
version: '0'
|
1901
1902
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1902
1903
|
requirements:
|
1903
|
-
- - "
|
1904
|
+
- - ">"
|
1904
1905
|
- !ruby/object:Gem::Version
|
1905
|
-
version:
|
1906
|
+
version: 1.3.1
|
1906
1907
|
requirements: []
|
1907
|
-
rubyforge_project:
|
1908
|
+
rubyforge_project:
|
1908
1909
|
rubygems_version: 2.7.3
|
1909
|
-
signing_key:
|
1910
|
+
signing_key:
|
1910
1911
|
specification_version: 4
|
1911
1912
|
summary: Playbook Design System
|
1912
1913
|
test_files: []
|