playbook_ui 14.3.0.pre.rc.7 → 14.3.0.pre.rc.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +4 -1
  3. data/app/pb_kits/playbook/pb_dialog/dialog.rb +3 -0
  4. data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +21 -0
  5. data/app/pb_kits/playbook/pb_dialog/dialog_footer.html.erb +4 -2
  6. data/app/pb_kits/playbook/pb_dialog/dialog_footer.rb +10 -1
  7. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.html.erb +13 -0
  8. data/app/pb_kits/playbook/pb_dialog/docs/_dialog_loading.md +3 -0
  9. data/app/pb_kits/playbook/pb_dialog/docs/example.yml +1 -0
  10. data/app/pb_kits/playbook/pb_hashtag/_hashtag.tsx +16 -2
  11. data/app/pb_kits/playbook/pb_hashtag/docs/_hashtag_link.html.erb +1 -1
  12. data/app/pb_kits/playbook/pb_hashtag/docs/_hashtag_link.jsx +1 -1
  13. data/app/pb_kits/playbook/pb_hashtag/docs/_hashtag_link.md +1 -1
  14. data/app/pb_kits/playbook/pb_hashtag/hashtag.html.erb +1 -1
  15. data/app/pb_kits/playbook/pb_hashtag/hashtag.rb +9 -2
  16. data/app/pb_kits/playbook/pb_home_address_street/_home_address_street.tsx +16 -0
  17. data/app/pb_kits/playbook/pb_home_address_street/city_emphasis.html.erb +1 -0
  18. data/app/pb_kits/playbook/pb_home_address_street/city_emphasis.rb +11 -0
  19. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_link.html.erb +1 -1
  20. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_link.jsx +1 -1
  21. data/app/pb_kits/playbook/pb_home_address_street/docs/_home_address_street_link.md +1 -1
  22. data/app/pb_kits/playbook/pb_home_address_street/home_address_street.rb +13 -0
  23. data/app/pb_kits/playbook/pb_home_address_street/home_adress_street.test.js +2 -2
  24. data/app/pb_kits/playbook/pb_home_address_street/street_emphasis.html.erb +2 -1
  25. data/app/pb_kits/playbook/pb_home_address_street/street_emphasis.rb +11 -0
  26. data/dist/chunks/{_typeahead-LJmEV1CI.js → _typeahead-BWUFVlae.js} +1 -1
  27. data/dist/chunks/{_weekday_stacked-mN_WkUcx.js → _weekday_stacked-DpRkKl3_.js} +2 -2
  28. data/dist/chunks/{lib-DErGXNy3.js → lib-D9uVVKnh.js} +1 -1
  29. data/dist/chunks/{pb_form_validation-BC6kh7Hu.js → pb_form_validation-u2wnZ3oe.js} +1 -1
  30. data/dist/chunks/vendor.js +1 -1
  31. data/dist/playbook-doc.js +1 -1
  32. data/dist/playbook-rails-react-bindings.js +1 -1
  33. data/dist/playbook-rails.js +1 -1
  34. data/lib/playbook/version.rb +1 -1
  35. metadata +7 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 530f9c91d5fd53e1ca76ed8378ec524a49081a4bbc6e5e54cd1d22e8b0ac48cf
4
- data.tar.gz: 026702fd9f5e55debf943b62f532787d4c5af837bce708c6d7ea6defed3f058a
3
+ metadata.gz: d27bc0773d0b2b97125ccaf0b86f53cc44090fc1e7e7c77c39027bd0be7dd093
4
+ data.tar.gz: 5e4253b6ed65adcbe071d8581e9aa3b92b512a28aba751fe379d50f1587255c5
5
5
  SHA512:
6
- metadata.gz: b40a7eb59a4bc43c2d3512ed9f51561428efac3cea70b73a5bef8653629c41032d1b6d7f73bd8600b27ff224a73c141854a153ca5ea6f490ec8805160fc01d35
7
- data.tar.gz: 54a1494d1a4a8b198430d996e0ecbf33c9a8ad33ed536788a8067e5b4b3dc995e5ddf8bcc100bf54d33e324e7196dd0e834d413bc38dd51305661172883b0e6d
6
+ metadata.gz: 54b2d14f3b2d4aab0f1f8fa0fbf106ffe53fa504cc4e07c51cb840fafbfe5ed903bab2a6a30c77a9342dce1452998914b2fbb0261da01bf8a557e9e7b37bba46
7
+ data.tar.gz: 879f68fe40a025427d08849c019874d9e62905d69020f478edfd8871781f0f5e2095d37748b3c986d0bab02c5ae56e2aa1c8382d4c2159af584ba7bdbefd3709
@@ -22,8 +22,11 @@
22
22
  <% if object.cancel_button && object.confirm_button %>
23
23
  <%= pb_rails("dialog/dialog_footer", props: {
24
24
  cancel_button: object.cancel_button,
25
+ cancel_button_id: object.cancel_button_id,
25
26
  confirm_button: object.confirm_button,
26
- id: object.id
27
+ confirm_button_id: object.confirm_button_id,
28
+ id: object.id,
29
+ loading: object.loading
27
30
  }) %>
28
31
  <% end %>
29
32
 
@@ -13,8 +13,11 @@ module Playbook
13
13
  prop :should_close_on_overlay_click, type: Playbook::Props::Boolean, default: true
14
14
  prop :title
15
15
  prop :text
16
+ prop :loading
16
17
  prop :confirm_button
18
+ prop :confirm_button_id
17
19
  prop :cancel_button
20
+ prop :cancel_button_id
18
21
  prop :status, type: Playbook::Props::Enum,
19
22
  values: ["info", "caution", "delete", "error", "success", "default", ""],
20
23
  default: ""
@@ -3,6 +3,27 @@ const dialogHelper = () => {
3
3
  const closeTrigger = document.querySelectorAll("[data-close-dialog]");
4
4
  const dialogs = document.querySelectorAll(".pb_dialog_rails")
5
5
 
6
+ const loadingButton = document.querySelector('[data-disable-with="Loading"]');
7
+ if (loadingButton) {
8
+ loadingButton.addEventListener("click", function() {
9
+ const okayLoadingButton = document.querySelector('[data-disable-with="Loading"]');
10
+ const cancelButton = document.querySelector('[data-disable-cancel-with="Loading"]');
11
+ let currentClass = okayLoadingButton.className;
12
+ let cancelClass = cancelButton ? cancelButton.className : "";
13
+
14
+ let newClass = currentClass.replace("_enabled", "_disabled_loading");
15
+ let newCancelClass = cancelClass.replace("_enabled", "_disabled");
16
+
17
+ // Disable the buttons
18
+ okayLoadingButton.disabled = true;
19
+ if (cancelButton) cancelButton.disabled = true;
20
+
21
+ okayLoadingButton.className = newClass;
22
+ if (cancelButton) cancelButton.className = newCancelClass;
23
+ });
24
+ }
25
+
26
+
6
27
  openTrigger.forEach((open) => {
7
28
  open.addEventListener("click", () => {
8
29
  var openTriggerData = open.dataset.openDialog;
@@ -3,10 +3,12 @@
3
3
  <% if object.confirm_button && object.cancel_button %>
4
4
  <div class="dialog-pseudo-footer"></div>
5
5
  <%= pb_rails("flex", props: { classname:object.classname, spacing:"between", padding_x:"sm", padding:"sm", padding_bottom:"sm" }) do %>
6
- <%= pb_rails("button", props: { type: "submit", id: object.confirm_button_id }) do %>
6
+
7
+ <%= pb_rails("button", props: { type: "submit", id: object.confirm_button_id, data: loading_data,
8
+ }) do %>
7
9
  <%= object.confirm_button %>
8
10
  <% end %>
9
- <%= pb_rails("button", props: { type: "button", data: {"close-dialog": "#{object.id}" }, id: object.cancel_button_id, variant: "link"}) do %>
11
+ <%= pb_rails("button", props: { type: "button", data: {"close-dialog": "#{object.id}", "disable_cancel_with": cancel_loading }, id: object.cancel_button_id, variant: "link" }) do %>
10
12
  <%= object.cancel_button %>
11
13
  <% end %>
12
14
  <% end %>
@@ -4,13 +4,22 @@ module Playbook
4
4
  module PbDialog
5
5
  class DialogFooter < Playbook::KitBase
6
6
  prop :cancel_button
7
+ prop :cancel_button_id
7
8
  prop :confirm_button
8
9
  prop :confirm_button_id
9
- prop :cancel_button_id
10
+ prop :loading
10
11
 
11
12
  def classname
12
13
  generate_classname("dialog_footer")
13
14
  end
15
+
16
+ def cancel_loading
17
+ loading ? "Loading" : ""
18
+ end
19
+
20
+ def loading_data
21
+ loading ? { disable_with: "Loading" } : {}
22
+ end
14
23
  end
15
24
  end
16
25
  end
@@ -0,0 +1,13 @@
1
+ <%= pb_rails("button", props: { text: "Open Dialog", data: {"open-dialog": "dialog-loading"} }) %>
2
+
3
+ <%= pb_rails("dialog", props: {
4
+ id:"dialog-loading",
5
+ size: "sm",
6
+ title: "Loading Exmaple",
7
+ text: "Make a loading request?",
8
+ cancel_button: "Cancel Button",
9
+ cancel_button_id: "cancel-button-loading",
10
+ confirm_button: "Okay",
11
+ confirm_button_id: "confirm-button-loading",
12
+ loading: true,
13
+ }) %>
@@ -0,0 +1,3 @@
1
+ Pressing the "Okay" button will trigger a loading state where the button content is replaced by a spinner icon and both buttons are disabled.
2
+
3
+ Currently, the loading state cannot be undone and will require a page refresh to reset the dialog.
@@ -10,6 +10,7 @@ examples:
10
10
  - dialog_stacked_alert: Stacked Button Alert
11
11
  - dialog_full_height: Full Height
12
12
  - dialog_full_height_placement: Full Height Placement
13
+ - dialog_loading: Loading
13
14
 
14
15
 
15
16
  react:
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react/jsx-no-target-blank */
2
- /* eslint-disable react/no-multi-comp, flowtype/space-before-type-colon */
2
+ /* eslint-disable react/no-multi-comp */
3
3
 
4
4
  import React from 'react'
5
5
  import classnames from 'classnames'
@@ -18,6 +18,7 @@ type HashtagProps = {
18
18
  id?: string,
19
19
  newWindow?: boolean,
20
20
  rel?: string,
21
+ target?: string,
21
22
  text?: string,
22
23
  type: "default" | "home" | "project" | "appointment",
23
24
  url?: string,
@@ -40,6 +41,7 @@ const Hashtag = (props: HashtagProps) => {
40
41
  id,
41
42
  newWindow,
42
43
  rel,
44
+ target,
43
45
  text,
44
46
  type = 'default',
45
47
  url,
@@ -50,6 +52,18 @@ const Hashtag = (props: HashtagProps) => {
50
52
  const htmlProps = buildHtmlProps(htmlOptions)
51
53
  const classes = classnames(buildCss('pb_hashtag_kit'), globalProps(props), className)
52
54
 
55
+ const getTargetAttribute = () => {
56
+ if (target && url) {
57
+ return target
58
+ } else if (newWindow) {
59
+ return '_blank'
60
+ } else {
61
+ return '_self'
62
+ }
63
+
64
+ return null
65
+ }
66
+
53
67
  return (
54
68
  <span
55
69
  {...ariaProps}
@@ -61,7 +75,7 @@ const Hashtag = (props: HashtagProps) => {
61
75
  <a
62
76
  href={url}
63
77
  rel={(newWindow ? "noreferrer" : rel)}
64
- target={(newWindow ? '_blank' : '_self')}
78
+ target={getTargetAttribute()}
65
79
  >
66
80
  <Badge
67
81
  dark={dark}
@@ -2,4 +2,4 @@
2
2
 
3
3
  <br/><br/>
4
4
 
5
- <%= pb_rails("hashtag", props: {text: "Open in a new Window", url: "https://google.com", type: "project", new_window: true}) %>
5
+ <%= pb_rails("hashtag", props: {text: "Open in a new Window", url: "https://google.com", type: "project", target: "_blank"}) %>
@@ -13,7 +13,7 @@ const HashtagLink = (props) => {
13
13
  <br />
14
14
  <br />
15
15
  <Hashtag
16
- newWindow
16
+ target="_blank"
17
17
  text="Open in a new window"
18
18
  type="project"
19
19
  url="https://google.com"
@@ -1 +1 @@
1
- Use the newWindow/new_window prop to control whether the link opens on the same page or a new tab (same page is the default behavior)
1
+ Use the `target` prop to control whether the link opens on the same or a new tab (same page is the default behavior). You can use any [web/standard](https://www.w3schools.com/tags/att_a_target.asp) values or a custom string to specify your link target.
@@ -1,5 +1,5 @@
1
1
  <%= pb_content_tag(:span) do %>
2
- <%= link_to object.url, target: object.link_option do %>
2
+ <%= link_to object.url, target: object.target_option do %>
3
3
  <%= pb_rails("badge", props: { dark: object.dark, variant: "primary", text: object.hashtag_text }) %>
4
4
  <% end %>
5
5
  <% end %>
@@ -10,6 +10,7 @@ module Playbook
10
10
  values: %w[default project home appointment],
11
11
  default: "default"
12
12
  prop :url
13
+ prop :target
13
14
 
14
15
  def classname
15
16
  generate_classname("pb_hastag_kit")
@@ -19,8 +20,14 @@ module Playbook
19
20
  type_text + text
20
21
  end
21
22
 
22
- def link_option
23
- new_window ? "_blank" : "_self"
23
+ def target_option
24
+ if target && url
25
+ target
26
+ elsif new_window
27
+ "_blank"
28
+ else
29
+ "_self"
30
+ end
24
31
  end
25
32
 
26
33
  private
@@ -23,6 +23,7 @@ type HomeAddressStreetProps = {
23
23
  homeId: string,
24
24
  houseStyle: string,
25
25
  homeUrl: string,
26
+ target: string,
26
27
  newWindow: boolean,
27
28
  state: string,
28
29
  zipcode: string,
@@ -42,6 +43,7 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
42
43
  htmlOptions = {},
43
44
  homeId,
44
45
  homeUrl,
46
+ target,
45
47
  newWindow,
46
48
  houseStyle,
47
49
  state,
@@ -62,6 +64,19 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
62
64
  const dataProps: GenericObject = buildDataProps(data)
63
65
  const ariaProps: GenericObject = buildAriaProps(aria)
64
66
  const htmlProps = buildHtmlProps(htmlOptions)
67
+
68
+ const getTargetAttribute = () => {
69
+ if (target && homeUrl) {
70
+ return target
71
+ } else if (newWindow) {
72
+ return '_blank'
73
+ } else {
74
+ return '_self'
75
+ }
76
+
77
+ return null
78
+ }
79
+
65
80
  return (
66
81
  <div
67
82
  className={classes(className, dark)}
@@ -120,6 +135,7 @@ const HomeAddressStreet = (props: HomeAddressStreetProps): React.ReactElement =>
120
135
  dark={dark}
121
136
  marginRight="xxs"
122
137
  newWindow={newWindow}
138
+ target={getTargetAttribute()}
123
139
  text={homeId}
124
140
  type="home"
125
141
  url={homeUrl || '#'}
@@ -33,6 +33,7 @@
33
33
  type: "home",
34
34
  dark: object.dark,
35
35
  classname: "home-hashtag",
36
+ target: object.target_option,
36
37
  new_window: object.new_window}) %>
37
38
  <% end %>
38
39
 
@@ -10,9 +10,20 @@ module Playbook
10
10
  prop :home_url
11
11
  prop :new_window, type: Playbook::Props::Boolean,
12
12
  default: false
13
+ prop :target
13
14
  prop :territory
14
15
  prop :zip
15
16
  prop :dark, type: Playbook::Props::Boolean, default: false
17
+
18
+ def target_option
19
+ if target && home_url
20
+ target
21
+ elsif new_window
22
+ "_blank"
23
+ else
24
+ "_self"
25
+ end
26
+ end
16
27
  end
17
28
  end
18
29
  end
@@ -5,7 +5,7 @@
5
5
  home_id: 8250263,
6
6
  home_url: "https://powerhrg.com/",
7
7
  house_style: "Colonial",
8
- new_window: true,
8
+ target: "_blank",
9
9
  state: "PA",
10
10
  zipcode: "19382",
11
11
  territory: "PHL",
@@ -11,8 +11,8 @@ const HomeAddressStreetLink= (props) => {
11
11
  homeId={8250263}
12
12
  homeUrl="https://powerhrg.com/"
13
13
  houseStyle="Colonial"
14
- newWindow
15
14
  state="PA"
15
+ target="_blank"
16
16
  territory="PHL"
17
17
  zipcode="19382"
18
18
  {...props}
@@ -1 +1 @@
1
- Use the `newWindow` / `new_window` prop to control whether the link opens on the same page or a new tab (same page is the default behavior)
1
+ Use the `target` prop to control whether the link opens on the same or a new tab (same page is the default behavior). You can use any [web/standard](https://www.w3schools.com/tags/att_a_target.asp) values or a custom string to specify your link target.
@@ -14,6 +14,7 @@ module Playbook
14
14
  prop :house_style
15
15
  prop :new_window, type: Playbook::Props::Boolean,
16
16
  default: false
17
+ prop :target
17
18
  prop :state
18
19
  prop :zipcode
19
20
  prop :territory
@@ -55,6 +56,7 @@ module Playbook
55
56
  dark: dark,
56
57
  home_id: home_id,
57
58
  home_url: home_url,
59
+ target: target_option,
58
60
  new_window: new_window,
59
61
  territory: territory,
60
62
  zip: zip,
@@ -69,11 +71,22 @@ module Playbook
69
71
  dark: dark,
70
72
  home_id: home_id,
71
73
  home_url: home_url,
74
+ target: target_option,
72
75
  new_window: new_window,
73
76
  territory: territory,
74
77
  }
75
78
  end
76
79
 
80
+ def target_option
81
+ if target && home_url
82
+ target
83
+ elsif new_window
84
+ "_blank"
85
+ else
86
+ "_self"
87
+ end
88
+ end
89
+
77
90
  private
78
91
 
79
92
  def dark_class
@@ -23,10 +23,10 @@ function HomeAdressStreetTest(props) {
23
23
  territory="PHL"
24
24
  zipcode="19382"
25
25
  {...props}
26
- />
26
+ />
27
27
  );
28
28
  }
29
-
29
+
30
30
  test("renders the component", () => {
31
31
  render(<HomeAdressStreetTest />);
32
32
  const kit = screen.getByTestId("primary-test");
@@ -23,7 +23,8 @@
23
23
  type: "home",
24
24
  dark: object.dark,
25
25
  classname: "home-hashtag",
26
- new_window: object.new_window}) %>
26
+ new_window: object.new_window,
27
+ target: object.target_option}) %>
27
28
  <% end %>
28
29
 
29
30
  <%= pb_rails "body", props: { color: "light", tag: "span", dark: object.dark } do %>
@@ -10,9 +10,20 @@ module Playbook
10
10
  prop :home_url
11
11
  prop :new_window, type: Playbook::Props::Boolean,
12
12
  default: false
13
+ prop :target
13
14
  prop :territory
14
15
  prop :dark, type: Playbook::Props::Boolean,
15
16
  default: false
17
+
18
+ def target_option
19
+ if target && home_url
20
+ target
21
+ elsif new_window
22
+ "_blank"
23
+ else
24
+ "_self"
25
+ end
26
+ end
16
27
  end
17
28
  end
18
29
  end
@@ -1,4 +1,4 @@
1
- import{jsx as jsx$1,Fragment,jsxs}from"react/jsx-runtime";import*as React from"react";import React__default,{createContext,useReducer,useEffect,useMemo,useContext,createElement,useState,useRef,forwardRef,isValidElement,useCallback,useImperativeHandle,useLayoutEffect,Component,Fragment as Fragment$1}from"react";import{l as getDefaultExportFromCjs,t as filter,v as omit,w as get,k as commonjsGlobal,s as colors$1,q as highchartsTheme,x as merge,n as highchartsDarkTheme,y as useCollapsible,z as getAugmentedNamespace,A as createPopper,B as uniqueId,C as typography,E as cloneDeep,F as isString}from"./lib-DErGXNy3.js";import*as ReactDOM from"react-dom";import ReactDOM__default,{createPortal}from"react-dom";import{TrixEditor}from"react-trix";import Trix from"trix";import require$$0 from"react-is";const initialState={items:[],dragData:{id:"",initialGroup:""},isDragging:"",activeContainer:""};const reducer=(state,action)=>{switch(action.type){case"SET_ITEMS":return Object.assign(Object.assign({},state),{items:action.payload});case"SET_DRAG_DATA":return Object.assign(Object.assign({},state),{dragData:action.payload});case"SET_IS_DRAGGING":return Object.assign(Object.assign({},state),{isDragging:action.payload});case"SET_ACTIVE_CONTAINER":return Object.assign(Object.assign({},state),{activeContainer:action.payload});case"CHANGE_CATEGORY":return Object.assign(Object.assign({},state),{items:state.items.map((item=>item.id===action.payload.itemId?Object.assign(Object.assign({},item),{container:action.payload.container}):item))});case"REORDER_ITEMS":{const{dragId:dragId,targetId:targetId}=action.payload;const newItems=[...state.items];const draggedItem=newItems.find((item=>item.id===dragId));const draggedIndex=newItems.indexOf(draggedItem);const targetIndex=newItems.findIndex((item=>item.id===targetId));newItems.splice(draggedIndex,1);newItems.splice(targetIndex,0,draggedItem);return Object.assign(Object.assign({},state),{items:newItems})}default:return state}};const DragContext=createContext({});const DraggableContext=()=>useContext(DragContext);const DraggableProvider=({children:children,initialItems:initialItems,onReorder:onReorder,onDragStart:onDragStart,onDragEnter:onDragEnter,onDragEnd:onDragEnd,onDrop:onDrop,onDragOver:onDragOver})=>{const[state,dispatch]=useReducer(reducer,initialState);useEffect((()=>{dispatch({type:"SET_ITEMS",payload:initialItems})}),[initialItems]);useEffect((()=>{onReorder(state.items)}),[state.items]);const handleDragStart=(id,container)=>{dispatch({type:"SET_DRAG_DATA",payload:{id:id,initialGroup:container}});dispatch({type:"SET_IS_DRAGGING",payload:id});if(onDragStart)onDragStart(id,container)};const handleDragEnter=(id,container)=>{if(state.dragData.id!==id){dispatch({type:"REORDER_ITEMS",payload:{dragId:state.dragData.id,targetId:id}});dispatch({type:"SET_DRAG_DATA",payload:{id:state.dragData.id,initialGroup:container}})}if(onDragEnter)onDragEnter(id,container)};const handleDragEnd=()=>{dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});if(onDragEnd)onDragEnd()};const changeCategory=(itemId,container)=>{dispatch({type:"CHANGE_CATEGORY",payload:{itemId:itemId,container:container}})};const handleDrop=container=>{dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});changeCategory(state.dragData.id,container);if(onDrop)onDrop(container)};const handleDragOver=(e2,container)=>{e2.preventDefault();dispatch({type:"SET_ACTIVE_CONTAINER",payload:container});if(onDragOver)onDragOver(e2,container)};const contextValue=useMemo((()=>({items:state.items,dragData:state.dragData,isDragging:state.isDragging,activeContainer:state.activeContainer,handleDragStart:handleDragStart,handleDragEnter:handleDragEnter,handleDragEnd:handleDragEnd,handleDrop:handleDrop,handleDragOver:handleDragOver})),[state]);return jsx$1(DragContext.Provider,Object.assign({value:contextValue},{children:children}),void 0)};var classnames$1={exports:{}};
1
+ import{jsx as jsx$1,Fragment,jsxs}from"react/jsx-runtime";import*as React from"react";import React__default,{createContext,useReducer,useEffect,useMemo,useContext,createElement,useState,useRef,forwardRef,isValidElement,useCallback,useImperativeHandle,useLayoutEffect,Component,Fragment as Fragment$1}from"react";import{l as getDefaultExportFromCjs,t as filter,v as omit,w as get,k as commonjsGlobal,s as colors$1,q as highchartsTheme,x as merge,n as highchartsDarkTheme,y as useCollapsible,z as getAugmentedNamespace,A as createPopper,B as uniqueId,C as typography,E as cloneDeep,F as isString}from"./lib-D9uVVKnh.js";import*as ReactDOM from"react-dom";import ReactDOM__default,{createPortal}from"react-dom";import{TrixEditor}from"react-trix";import Trix from"trix";import require$$0 from"react-is";const initialState={items:[],dragData:{id:"",initialGroup:""},isDragging:"",activeContainer:""};const reducer=(state,action)=>{switch(action.type){case"SET_ITEMS":return Object.assign(Object.assign({},state),{items:action.payload});case"SET_DRAG_DATA":return Object.assign(Object.assign({},state),{dragData:action.payload});case"SET_IS_DRAGGING":return Object.assign(Object.assign({},state),{isDragging:action.payload});case"SET_ACTIVE_CONTAINER":return Object.assign(Object.assign({},state),{activeContainer:action.payload});case"CHANGE_CATEGORY":return Object.assign(Object.assign({},state),{items:state.items.map((item=>item.id===action.payload.itemId?Object.assign(Object.assign({},item),{container:action.payload.container}):item))});case"REORDER_ITEMS":{const{dragId:dragId,targetId:targetId}=action.payload;const newItems=[...state.items];const draggedItem=newItems.find((item=>item.id===dragId));const draggedIndex=newItems.indexOf(draggedItem);const targetIndex=newItems.findIndex((item=>item.id===targetId));newItems.splice(draggedIndex,1);newItems.splice(targetIndex,0,draggedItem);return Object.assign(Object.assign({},state),{items:newItems})}default:return state}};const DragContext=createContext({});const DraggableContext=()=>useContext(DragContext);const DraggableProvider=({children:children,initialItems:initialItems,onReorder:onReorder,onDragStart:onDragStart,onDragEnter:onDragEnter,onDragEnd:onDragEnd,onDrop:onDrop,onDragOver:onDragOver})=>{const[state,dispatch]=useReducer(reducer,initialState);useEffect((()=>{dispatch({type:"SET_ITEMS",payload:initialItems})}),[initialItems]);useEffect((()=>{onReorder(state.items)}),[state.items]);const handleDragStart=(id,container)=>{dispatch({type:"SET_DRAG_DATA",payload:{id:id,initialGroup:container}});dispatch({type:"SET_IS_DRAGGING",payload:id});if(onDragStart)onDragStart(id,container)};const handleDragEnter=(id,container)=>{if(state.dragData.id!==id){dispatch({type:"REORDER_ITEMS",payload:{dragId:state.dragData.id,targetId:id}});dispatch({type:"SET_DRAG_DATA",payload:{id:state.dragData.id,initialGroup:container}})}if(onDragEnter)onDragEnter(id,container)};const handleDragEnd=()=>{dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});if(onDragEnd)onDragEnd()};const changeCategory=(itemId,container)=>{dispatch({type:"CHANGE_CATEGORY",payload:{itemId:itemId,container:container}})};const handleDrop=container=>{dispatch({type:"SET_IS_DRAGGING",payload:""});dispatch({type:"SET_ACTIVE_CONTAINER",payload:""});changeCategory(state.dragData.id,container);if(onDrop)onDrop(container)};const handleDragOver=(e2,container)=>{e2.preventDefault();dispatch({type:"SET_ACTIVE_CONTAINER",payload:container});if(onDragOver)onDragOver(e2,container)};const contextValue=useMemo((()=>({items:state.items,dragData:state.dragData,isDragging:state.isDragging,activeContainer:state.activeContainer,handleDragStart:handleDragStart,handleDragEnter:handleDragEnter,handleDragEnd:handleDragEnd,handleDrop:handleDrop,handleDragOver:handleDragOver})),[state]);return jsx$1(DragContext.Provider,Object.assign({value:contextValue},{children:children}),void 0)};var classnames$1={exports:{}};
2
2
  /*!
3
3
  Copyright (c) 2018 Jed Watson.
4
4
  Licensed under the MIT License (MIT), see