playbook_ui_docs 16.10.0.pre.alpha.play300617505 → 16.10.0.pre.alpha.typeaheaddraggablepills17453
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_file_upload/docs/example.yml +1 -3
- data/app/pb_kits/playbook/pb_file_upload/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_popover/docs/_popover_list.html.erb +2 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_playground.json +8 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.html.erb +39 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.jsx +63 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.md +7 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills_rails.md +7 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +1 -0
- metadata +6 -5
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_remove_replace.html.erb +0 -66
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_remove_replace.jsx +0 -53
- data/app/pb_kits/playbook/pb_file_upload/docs/_file_upload_remove_replace.md +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bcd2df77ad2ade21904f5a4d6e502213b8651180b556cac9f54b20da328db651
|
|
4
|
+
data.tar.gz: 4ab0319cb9cae9e28a5781e657521cf51b2b39922c8fd0217f07e5f06356677a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d687856944c4239ef22a934c182f7cfb2c425b2f0ed341d300a42f339b42cc186896e40ec94f32048adf41728295d3ebbd81e0e8f1d78e4a81e0504167d4b2c
|
|
7
|
+
data.tar.gz: 8f5dd2e1127fb5870419d93457ac187cad555a5a88a5ab822952bf27fb21a83e3b73d6a7504fd057a94e258765b982e47bde3b0aa263b12b6fd90bccbb7a4f3e
|
|
@@ -4,7 +4,6 @@ examples:
|
|
|
4
4
|
- file_upload_default: File Upload
|
|
5
5
|
- file_upload_custom: Custom
|
|
6
6
|
- file_upload_error: Error
|
|
7
|
-
- file_upload_remove_replace: Remove and Replace
|
|
8
7
|
|
|
9
8
|
react:
|
|
10
9
|
- file_upload_default: Default List of files to upload
|
|
@@ -12,5 +11,4 @@ examples:
|
|
|
12
11
|
- file_upload_custom_message: Add a custom message
|
|
13
12
|
- file_upload_custom_description: Add your one accepted files description
|
|
14
13
|
- file_upload_max_size: Set a file size limit
|
|
15
|
-
- file_upload_error: Error
|
|
16
|
-
- file_upload_remove_replace: Remove and Replace
|
|
14
|
+
- file_upload_error: Error
|
|
@@ -4,4 +4,3 @@ export { default as FileUploadCustomMessage } from './_file_upload_custom_messag
|
|
|
4
4
|
export { default as FileUploadCustomDescription } from './_file_upload_custom_description.jsx'
|
|
5
5
|
export { default as FileUploadMaxSize } from './_file_upload_max_size.jsx'
|
|
6
6
|
export { default as FileUploadError } from './_file_upload_error.jsx'
|
|
7
|
-
export { default as FileUploadRemoveReplace } from './_file_upload_remove_replace.jsx'
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
popoverButton.onclick = () => {
|
|
29
29
|
buttonClicked = !buttonClicked
|
|
30
30
|
if (buttonClicked) {
|
|
31
|
-
arrowDiv.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 31 25" fill="none" class="pb_custom_icon svg-inline--fa pb_icon_kit svg_fw" id="" data="{}" aria="{}" tabindex=""><path d="M14.2031 5.70312C14.625 5.28125 15.3281 5.28125 15.75 5.70312L24.7969 14.7031C25.2188 15.1719 25.2188 15.875 24.7969 16.2969C24.3281 16.7656 23.625 16.7656 23.2031 16.2969L15 8.09375L6.79688 16.2969C6.32812 16.7656 5.625 16.7656 5.20312 16.2969C4.73438 15.875 4.73438 15.1719 5.20312 14.75L14.2031 5.70312Z" fill="currentColor"/></svg>'
|
|
31
|
+
arrowDiv.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="auto" height="auto" viewBox="0 0 31 25" fill="none" class="pb_custom_icon svg-inline--fa pb_icon_kit svg_fw" id="" data="{}" aria="{}" tabindex=""><path d="M14.2031 5.70312C14.625 5.28125 15.3281 5.28125 15.75 5.70312L24.7969 14.7031C25.2188 15.1719 25.2188 15.875 24.7969 16.2969C24.3281 16.7656 23.625 16.7656 23.2031 16.2969L15 8.09375L6.79688 16.2969C6.32812 16.7656 5.625 16.7656 5.20312 16.2969C4.73438 15.875 4.73438 15.1719 5.20312 14.75L14.2031 5.70312Z" fill="currentColor"/></svg>'
|
|
32
32
|
} else {
|
|
33
|
-
arrowDiv.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 31 25" fill="none" class="pb_custom_icon svg-inline--fa pb_icon_kit svg_fw" id="" data="{}" aria="{}" tabindex=""><path d="M14.2031 19.2969L5.20312 10.2969C4.73438 9.875 4.73438 9.17188 5.20312 8.70312C5.625 8.28125 6.32812 8.28125 6.79688 8.70312L15 16.9531L23.2031 8.75C23.625 8.28125 24.3281 8.28125 24.7969 8.75C25.2188 9.17188 25.2188 9.875 24.7969 10.2969L15.75 19.2969C15.3281 19.7656 14.625 19.7656 14.2031 19.2969Z" fill="currentColor"/></svg>'
|
|
33
|
+
arrowDiv.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="auto" height="auto" viewBox="0 0 31 25" fill="none" class="pb_custom_icon svg-inline--fa pb_icon_kit svg_fw" id="" data="{}" aria="{}" tabindex=""><path d="M14.2031 19.2969L5.20312 10.2969C4.73438 9.875 4.73438 9.17188 5.20312 8.70312C5.625 8.28125 6.32812 8.28125 6.79688 8.70312L15 16.9531L23.2031 8.75C23.625 8.28125 24.3281 8.28125 24.7969 8.75C25.2188 9.17188 25.2188 9.875 24.7969 10.2969L15.75 19.2969C15.3281 19.7656 14.625 19.7656 14.2031 19.2969Z" fill="currentColor"/></svg>'
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
</script>
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
"required": false,
|
|
11
11
|
"requiredIndicator": false,
|
|
12
12
|
"clearOnContextChange": true,
|
|
13
|
-
"preserveSearchInput": false
|
|
13
|
+
"preserveSearchInput": false,
|
|
14
|
+
"enablePillReorder": false,
|
|
15
|
+
"showPillIndex": false,
|
|
16
|
+
"pillDragHandle": true
|
|
14
17
|
},
|
|
15
18
|
"groups": [
|
|
16
19
|
{
|
|
@@ -58,7 +61,10 @@
|
|
|
58
61
|
"props": [
|
|
59
62
|
"components",
|
|
60
63
|
"dark",
|
|
61
|
-
"marginBottom"
|
|
64
|
+
"marginBottom",
|
|
65
|
+
"enablePillReorder",
|
|
66
|
+
"showPillIndex",
|
|
67
|
+
"pillDragHandle"
|
|
62
68
|
]
|
|
63
69
|
}
|
|
64
70
|
],
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<%
|
|
2
|
+
options = [
|
|
3
|
+
{ label: 'Year', value: 'year' },
|
|
4
|
+
{ label: 'Territory', value: 'territory' },
|
|
5
|
+
{ label: 'Branch', value: 'branch' },
|
|
6
|
+
{ label: 'Product', value: 'product' },
|
|
7
|
+
]
|
|
8
|
+
%>
|
|
9
|
+
|
|
10
|
+
<%= pb_rails("body", props: { text: "Select services, then drag the pills to reorder them.", margin_bottom: "xs" }) %>
|
|
11
|
+
|
|
12
|
+
<%= pb_rails("typeahead", props: {
|
|
13
|
+
id: "typeahead-draggable-pills-example",
|
|
14
|
+
default_options: [options[0], options[1], options[2]],
|
|
15
|
+
enable_pill_reorder: true,
|
|
16
|
+
pill_drag_handle: false,
|
|
17
|
+
show_pill_index: true,
|
|
18
|
+
is_multi: true,
|
|
19
|
+
label: "Services",
|
|
20
|
+
name: :services,
|
|
21
|
+
options: options,
|
|
22
|
+
pills: true,
|
|
23
|
+
placeholder: "Add services...",
|
|
24
|
+
}) %>
|
|
25
|
+
|
|
26
|
+
<%= pb_rails("body", props: {
|
|
27
|
+
id: "typeahead-draggable-order",
|
|
28
|
+
color: "lighter",
|
|
29
|
+
margin_top: "xs",
|
|
30
|
+
text: "Current order: Year -> Territory -> Branch",
|
|
31
|
+
}) %>
|
|
32
|
+
|
|
33
|
+
<%= javascript_tag defer: "defer" do %>
|
|
34
|
+
document.addEventListener('pb-typeahead-kit-typeahead-draggable-pills-example-result-option-reorder', function(event) {
|
|
35
|
+
const orderText = event.detail.map((item) => item.label).join(' -> ');
|
|
36
|
+
const orderElement = document.querySelector('#typeahead-draggable-order');
|
|
37
|
+
if (orderElement) orderElement.textContent = `Current order: ${orderText}`;
|
|
38
|
+
});
|
|
39
|
+
<% end %>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { Body, Button, Flex, Typeahead } from 'playbook-ui'
|
|
3
|
+
|
|
4
|
+
const options = [
|
|
5
|
+
{ label: 'Year', value: 'year' },
|
|
6
|
+
{ label: 'Territory', value: 'territory' },
|
|
7
|
+
{ label: 'Branch', value: 'branch' },
|
|
8
|
+
{ label: 'Product', value: 'product' },
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
const TypeaheadDraggablePills = (props) => {
|
|
12
|
+
const [value, setValue] = useState([
|
|
13
|
+
options[0],
|
|
14
|
+
options[1],
|
|
15
|
+
options[2],
|
|
16
|
+
])
|
|
17
|
+
|
|
18
|
+
const currentOrder = value.map((item) => item.label).join(' -> ')
|
|
19
|
+
|
|
20
|
+
const handleReset = () => {
|
|
21
|
+
setValue([options[0], options[1], options[2]])
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Flex
|
|
26
|
+
align="stretch"
|
|
27
|
+
gap="sm"
|
|
28
|
+
orientation="column"
|
|
29
|
+
>
|
|
30
|
+
<Flex
|
|
31
|
+
align="center"
|
|
32
|
+
justify="between"
|
|
33
|
+
>
|
|
34
|
+
<Body text="Select services, then drag the pills to reorder them." />
|
|
35
|
+
<Button
|
|
36
|
+
onClick={handleReset}
|
|
37
|
+
text="Reset"
|
|
38
|
+
variant="secondary"
|
|
39
|
+
/>
|
|
40
|
+
</Flex>
|
|
41
|
+
|
|
42
|
+
<Typeahead
|
|
43
|
+
enablePillReorder
|
|
44
|
+
isMulti
|
|
45
|
+
label="Services"
|
|
46
|
+
onChange={setValue}
|
|
47
|
+
options={options}
|
|
48
|
+
placeholder="Add services..."
|
|
49
|
+
showPillIndex
|
|
50
|
+
value={value}
|
|
51
|
+
{...props}
|
|
52
|
+
pillDragHandle={false}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
<Body
|
|
56
|
+
color="lighter"
|
|
57
|
+
text={`Current order: ${currentOrder}`}
|
|
58
|
+
/>
|
|
59
|
+
</Flex>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default TypeaheadDraggablePills
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Use `enablePillReorder` to let users drag selected pills into a new order. Pair with `showPillIndex` to display numbered prefixes that update automatically after reorder.
|
|
2
|
+
|
|
3
|
+
Set `pillDragHandle` to `false` to hide the grip icon and drag the whole pill instead.
|
|
4
|
+
|
|
5
|
+
Order is committed on drop. The `onChange` callback and `pb-typeahead-kit-{id}-result-option-reorder` custom event both receive the reordered value array.
|
|
6
|
+
|
|
7
|
+
Keyboard reorder: focus a pill, then press Control+Shift+ArrowLeft or Control+Shift+ArrowRight to move it one position.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Use `enable_pill_reorder: true` with `show_pill_index: true` to let users drag selected pills into a new order. Set `pill_drag_handle: false` to hide the grip icon and drag the whole pill instead.
|
|
2
|
+
|
|
3
|
+
Order is committed on drop.
|
|
4
|
+
|
|
5
|
+
The `pb-typeahead-kit-{id}-result-option-reorder` custom event receives the reordered value array.
|
|
6
|
+
|
|
7
|
+
Keyboard reorder: focus a pill, then press Control+Shift+ArrowLeft or Control+Shift+ArrowRight to move it one position.
|
|
@@ -21,6 +21,7 @@ examples:
|
|
|
21
21
|
- typeahead_disabled: Disabled
|
|
22
22
|
- typeahead_preserve_input: Preserve Search Input
|
|
23
23
|
- typeahead_required_indicator: Required Indicator
|
|
24
|
+
- typeahead_draggable_pills: Draggable Pills
|
|
24
25
|
|
|
25
26
|
react:
|
|
26
27
|
- typeahead_default: Default
|
|
@@ -45,3 +46,4 @@ examples:
|
|
|
45
46
|
- typeahead_disabled: Disabled
|
|
46
47
|
- typeahead_preserve_input: Preserve Search Input
|
|
47
48
|
- typeahead_required_indicator: Required Indicator
|
|
49
|
+
- typeahead_draggable_pills: Draggable Pills
|
|
@@ -20,3 +20,4 @@ export {default as TypeaheadDefaultValue} from "./_typeahead_default_value.jsx"
|
|
|
20
20
|
export {default as TypeaheadCustomOptions} from "./_typeahead_custom_options.jsx"
|
|
21
21
|
export {default as TypeaheadInputDisplay} from "./_typeahead_input_display.jsx"
|
|
22
22
|
export {default as TypeaheadRequiredIndicator} from "./_typeahead_required_indicator.jsx"
|
|
23
|
+
export {default as TypeaheadDraggablePills} from "./_typeahead_draggable_pills.jsx"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: playbook_ui_docs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 16.10.0.pre.alpha.
|
|
4
|
+
version: 16.10.0.pre.alpha.typeaheaddraggablepills17453
|
|
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: 2026-07-
|
|
12
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: playbook_ui
|
|
@@ -1092,9 +1092,6 @@ files:
|
|
|
1092
1092
|
- app/pb_kits/playbook/pb_file_upload/docs/_file_upload_error.html.erb
|
|
1093
1093
|
- app/pb_kits/playbook/pb_file_upload/docs/_file_upload_error.jsx
|
|
1094
1094
|
- app/pb_kits/playbook/pb_file_upload/docs/_file_upload_max_size.jsx
|
|
1095
|
-
- app/pb_kits/playbook/pb_file_upload/docs/_file_upload_remove_replace.html.erb
|
|
1096
|
-
- app/pb_kits/playbook/pb_file_upload/docs/_file_upload_remove_replace.jsx
|
|
1097
|
-
- app/pb_kits/playbook/pb_file_upload/docs/_file_upload_remove_replace.md
|
|
1098
1095
|
- app/pb_kits/playbook/pb_file_upload/docs/_playground.json
|
|
1099
1096
|
- app/pb_kits/playbook/pb_file_upload/docs/_playground.overrides.json
|
|
1100
1097
|
- app/pb_kits/playbook/pb_file_upload/docs/example.yml
|
|
@@ -2906,6 +2903,10 @@ files:
|
|
|
2906
2903
|
- app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default_value.md
|
|
2907
2904
|
- app/pb_kits/playbook/pb_typeahead/docs/_typeahead_disabled.html.erb
|
|
2908
2905
|
- app/pb_kits/playbook/pb_typeahead/docs/_typeahead_disabled.jsx
|
|
2906
|
+
- app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.html.erb
|
|
2907
|
+
- app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.jsx
|
|
2908
|
+
- app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills.md
|
|
2909
|
+
- app/pb_kits/playbook/pb_typeahead/docs/_typeahead_draggable_pills_rails.md
|
|
2909
2910
|
- app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb
|
|
2910
2911
|
- app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md
|
|
2911
2912
|
- app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<div id="file-upload-remove-replace">
|
|
2
|
-
<%= pb_rails("list", props: { id: "selected-files-list", margin_bottom: "sm" }) %>
|
|
3
|
-
|
|
4
|
-
<%= pb_rails("file_upload", props: {
|
|
5
|
-
id: "remove_replace",
|
|
6
|
-
input_options: { multiple: true },
|
|
7
|
-
}) %>
|
|
8
|
-
</div>
|
|
9
|
-
|
|
10
|
-
<template id="file-list-item-template">
|
|
11
|
-
<%= pb_rails("list/item") do %>
|
|
12
|
-
<%= pb_rails("flex", props: { align: "center", justify: "between", width: "100%" }) do %>
|
|
13
|
-
<%= pb_rails("body", props: { data: { file_name: true } }) %>
|
|
14
|
-
<%= pb_rails("circle_icon_button", props: {
|
|
15
|
-
icon: "times",
|
|
16
|
-
variant: "secondary",
|
|
17
|
-
input_options: { classname: "remove-file-button" },
|
|
18
|
-
}) %>
|
|
19
|
-
<% end %>
|
|
20
|
-
<% end %>
|
|
21
|
-
</template>
|
|
22
|
-
|
|
23
|
-
<%= javascript_tag defer: "defer" do %>
|
|
24
|
-
document.addEventListener("DOMContentLoaded", function () {
|
|
25
|
-
const fileInput = document.getElementById("upload-remove_replace")
|
|
26
|
-
const list = document.getElementById("selected-files-list")
|
|
27
|
-
const template = document.getElementById("file-list-item-template")
|
|
28
|
-
let files = []
|
|
29
|
-
|
|
30
|
-
if (!fileInput || !list || !template) return
|
|
31
|
-
|
|
32
|
-
function syncInput() {
|
|
33
|
-
const dataTransfer = new DataTransfer()
|
|
34
|
-
files.forEach((file) => dataTransfer.items.add(file))
|
|
35
|
-
fileInput.files = dataTransfer.files
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function render() {
|
|
39
|
-
list.innerHTML = ""
|
|
40
|
-
|
|
41
|
-
files.forEach((file, index) => {
|
|
42
|
-
const clone = template.content.cloneNode(true)
|
|
43
|
-
const nameElement = clone.querySelector("[data-file-name]")
|
|
44
|
-
const removeButton = clone.querySelector(".remove-file-button")
|
|
45
|
-
|
|
46
|
-
nameElement.textContent = file.name
|
|
47
|
-
removeButton.addEventListener("click", function (event) {
|
|
48
|
-
event.preventDefault()
|
|
49
|
-
event.stopPropagation()
|
|
50
|
-
files = files.filter((_, fileIndex) => fileIndex !== index)
|
|
51
|
-
syncInput()
|
|
52
|
-
render()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
list.appendChild(clone)
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
fileInput.addEventListener("change", function () {
|
|
60
|
-
const newFiles = Array.from(fileInput.files)
|
|
61
|
-
files = [...files, ...newFiles]
|
|
62
|
-
syncInput()
|
|
63
|
-
render()
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
<% end %>
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import React, { useState } from 'react'
|
|
3
|
-
|
|
4
|
-
import Body from '../../pb_body/_body'
|
|
5
|
-
import CircleIconButton from '../../pb_circle_icon_button/_circle_icon_button'
|
|
6
|
-
import FileUpload from '../../pb_file_upload/_file_upload'
|
|
7
|
-
import Flex from '../../pb_flex/_flex'
|
|
8
|
-
import List from '../../pb_list/_list'
|
|
9
|
-
import ListItem from '../../pb_list/_list_item'
|
|
10
|
-
|
|
11
|
-
const FileUploadRemoveReplace = (props) => {
|
|
12
|
-
const [filesToUpload, setFilesToUpload] = useState([])
|
|
13
|
-
|
|
14
|
-
const handleOnFilesAccepted = (files) => {
|
|
15
|
-
setFilesToUpload([...filesToUpload, ...files])
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const handleRemoveFile = (index) => {
|
|
19
|
-
setFilesToUpload(filesToUpload.filter((_, fileIndex) => fileIndex !== index))
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div>
|
|
24
|
-
{filesToUpload.length > 0 && (
|
|
25
|
-
<List marginBottom="sm">
|
|
26
|
-
{filesToUpload.map((file, index) => (
|
|
27
|
-
<ListItem key={`${file.name}-${index}`}>
|
|
28
|
-
<Flex
|
|
29
|
-
align="center"
|
|
30
|
-
justify="between"
|
|
31
|
-
width="100%"
|
|
32
|
-
>
|
|
33
|
-
<Body text={file.name} />
|
|
34
|
-
<CircleIconButton
|
|
35
|
-
aria={{ label: `Remove ${file.name}` }}
|
|
36
|
-
icon="times"
|
|
37
|
-
onClick={() => handleRemoveFile(index)}
|
|
38
|
-
variant="secondary"
|
|
39
|
-
/>
|
|
40
|
-
</Flex>
|
|
41
|
-
</ListItem>
|
|
42
|
-
))}
|
|
43
|
-
</List>
|
|
44
|
-
)}
|
|
45
|
-
<FileUpload
|
|
46
|
-
onFilesAccepted={handleOnFilesAccepted}
|
|
47
|
-
{...props}
|
|
48
|
-
/>
|
|
49
|
-
</div>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export default FileUploadRemoveReplace
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
The File Upload kit does not include built-in remove or replace behavior. Manage selected files in application state and compose the kit with other Playbook components.
|
|
2
|
-
|
|
3
|
-
**Remove** — Track accepted files in state and filter out the file to remove. In React, pair `List` with `CircleIconButton`. In Rails, listen for `change` on the file input, keep files in a JavaScript array, and use `DataTransfer` to sync the input when a file is removed.
|
|
4
|
-
|
|
5
|
-
**Replace** — Selecting a new file on the native Rails input replaces the current selection. For single-file React workflows, set state to the newly accepted files instead of appending: `setFilesToUpload(files)`.
|