playbook_ui 13.32.0.pre.alpha.PLAY14143272 → 13.32.0.pre.alpha.PLAY14143288
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +3 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_value.html.erb +10 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_value.jsx +31 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +2 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +5 -0
- data/app/pb_kits/playbook/pb_dropdown/index.js +25 -0
- data/dist/chunks/_typeahead.js +14 -32
- data/dist/chunks/_weekday_stacked.js +7 -7
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +83 -83
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +4 -2
@@ -1 +1 @@
|
|
1
|
-
import r from"webpacker-react";import{B as d,C as l,D as u,a as
|
1
|
+
import r from"webpacker-react";import{B as d,C as l,D as u,a as p,b as f,c as h,d as c,M as v,L as E,e as b,P as w,R as m,T as k,f as y,G as g,g as C}from"./chunks/_typeahead.js";import"react/jsx-runtime";import"react";import"./chunks/lib.js";import"react-dom";import"react-is";var o={};Object.defineProperty(o,"__esModule",{value:!0});var j={handleEvent:function(e,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{once:!1},t=i.once,s=typeof window.jQuery<"u"&&window.jQuery;s?t?s(document).one(e,n):s(document).on(e,n):document.addEventListener(e,n,{once:t})},setup:function(e,n){var i=typeof window.jQuery<"u"&&window.jQuery,t=window.Turbolinks;typeof t<"u"&&t.supported?typeof t.EVENTS<"u"?this.turbolinksClassic(e,n):typeof t.controller<"u"?this.turbolinks5(e,n):this.turbolinksClassicDeprecated(e,n):i&&typeof i.pjax=="function"?this.pjax(e,n):this.native(e)},turbolinks5:function(e,n){this.handleEvent("turbolinks:load",e,{once:!0}),this.handleEvent("turbolinks:render",e),this.handleEvent("turbolinks:before-render",n)},turbolinksClassic:function(e,n){var i=window.Turbolinks;this.handleEvent(i.EVENTS.CHANGE,e),this.handleEvent(i.EVENTS.BEFORE_UNLOAD,n)},turbolinksClassicDeprecated:function(e,n){var i=window.Turbolinks;i.pagesCached(0),this.handleEvent("page:change",e),this.handleEvent("page:receive",n)},pjax:function(e,n){this.handleEvent("ready",e),this.handleEvent("pjax:end",e),this.handleEvent("pjax:beforeReplace",n)},native:function(e){var n=typeof window.jQuery<"u"&&window.jQuery;n?n(function(){return e()}):"addEventListener"in window?document.addEventListener("DOMContentLoaded",e):window.attachEvent("onload",e)}},T=o.default=j;r.registerComponents({BarGraph:d,CircleChart:l,Dialog:u,DialogBody:p,DialogFooter:f,DialogHeader:h,DistributionBar:c,MultiLevelSelect:v,Legend:E,LineGraph:b,Passphrase:w,RichTextEditor:m,TreemapChart:k,Typeahead:y,Gauge:g,PhoneNumberInput:C});T.setup(()=>r.mountComponents(),()=>r.unmountComponents());
|
data/dist/playbook-rails.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import"./chunks/pb_form_validation.js";import{P as
|
1
|
+
import"./chunks/pb_form_validation.js";import{P as a,d as w,a as y,b as E,c as m,e as b,f,g as _}from"./chunks/lib.js";import"./chunks/lazysizes.js";import"./playbook-rails-react-bindings.js";import"react";import"webpacker-react";import"./chunks/_typeahead.js";import"react/jsx-runtime";import"react-dom";import"react-is";const O="[data-collapsible-main]",v="[data-collapsible-content]",L="#collapsible_open_icon",T="#collapsible_close_icon";class S extends a{static get selector(){return O}connect(){this.element.addEventListener("click",()=>{this.toggleElement(this.target)}),this.target.classList.contains("is-visible")?this.displayUpArrow():this.displayDownArrow(),document.addEventListener(`${this.target.id}`,()=>{this.toggleElement(this.target)})}get target(){return this.element.parentNode.querySelector(v)}showElement(t){const s=(()=>{t.style.display="block";const o=t.scrollHeight+"px";return t.style.display="",o})();t.classList.add("is-visible"),t.style.height=s,t.style.overflow="hidden",window.setTimeout(()=>{t.style.height="",t.style.overflow="visible"},300)}hideElement(t){t.style.height=t.scrollHeight+"px",window.setTimeout(()=>{t.style.height="0",t.style.paddingTop="0",t.style.paddingBottom="0",t.style.overflow="hidden"},1),window.setTimeout(()=>{t.classList.remove("is-visible"),t.style.overflow=""},300)}toggleElement(t){if(t.classList.contains("is-visible")){this.hideElement(t),this.displayDownArrow();return}this.showElement(t),this.displayUpArrow()}toggleArrows(t){const e=this.element.querySelector(L),s=this.element.querySelector(T);e&&(e.style.display=t?"inline-block":"none"),s&&(s.style.display=t?"none":"inline-block")}displayDownArrow(){this.toggleArrows(!0)}displayUpArrow(){this.toggleArrows(!1)}}class A extends a{static get selector(){return".remove_toast"}connect(){this.self=this.element,this.autoCloseToast(this.self),this.self.addEventListener("click",()=>{this.removeToast(this.self)})}removeToast(t){t.parentNode.removeChild(t)}autoCloseToast(t){const e=t.classList.value;if(e.includes("auto_close")){const o=e.split(" "),i=o[o.length-1].split("_")[2],n=parseInt(i);setTimeout(()=>{this.removeToast(t)},n)}}}const C="[data-dropdown-option-label]";class D{constructor(t){this.dropdown=t,this.dropdownElement=t.element,this.options=Array.from(this.dropdownElement.querySelectorAll(C)),this.focusedOptionIndex=-1,this.init()}init(){this.dropdownElement.addEventListener("keydown",this.handleKeyDown.bind(this))}handleKeyDown(t){switch(t.key){case"ArrowDown":t.preventDefault(),this.dropdown.target.classList.contains("open")||(this.dropdown.showElement(this.dropdown.target),this.dropdown.updateArrowDisplay(!0)),this.moveFocus(1);break;case"ArrowUp":t.preventDefault(),this.moveFocus(-1);break;case"Enter":t.preventDefault(),this.focusedOptionIndex!==-1?this.selectOption():this.dropdown.target.classList.contains("open")||(this.dropdown.showElement(this.dropdown.target),this.dropdown.updateArrowDisplay(!0));break;case"Escape":this.dropdown.hideElement(this.dropdown.target);break;case"Tab":this.dropdown.hideElement(this.dropdown.target),this.dropdown.updateArrowDisplay(!1),this.resetFocus();break}}moveFocus(t){this.focusedOptionIndex!==-1&&this.options[this.focusedOptionIndex].classList.remove("pb_dropdown_option_focused"),this.focusedOptionIndex=(this.focusedOptionIndex+t+this.options.length)%this.options.length,this.options[this.focusedOptionIndex].classList.add("pb_dropdown_option_focused")}selectOption(){const t=this.options[this.focusedOptionIndex];this.dropdown.onOptionSelected(t.dataset.dropdownOptionLabel,t),this.dropdown.hideElement(this.dropdown.target)}}const k="[data-pb-dropdown]",R="[data-dropdown-trigger]",h="[data-dropdown-container]",q="#dropdown_open_icon",N="#dropdown_close_icon",l="[data-dropdown-option-label]",c="[data-dropdown-custom-trigger]",p="#dropdown-form-validation";class x extends a{static get selector(){return k}get target(){return this.element.parentNode.querySelector(h)}connect(){this.keyboardHandler=new D(this),this.setDefaultValue(),this.bindEventListeners(),this.updateArrowDisplay(!1),this.handleFormValidation()}bindEventListeners(){(this.element.querySelector(c)||this.element).addEventListener("click",()=>this.toggleElement(this.target)),this.target.addEventListener("click",this.handleOptionClick.bind(this)),document.addEventListener("click",this.handleDocumentClick.bind(this),!0)}handleOptionClick(t){const e=t.target.closest(l),s=this.element.querySelector("#dropdown-selected-option"),o=this.element.querySelector(p);if(e){const i=e.dataset.dropdownOptionLabel;s.value=JSON.parse(i).id,o.value=JSON.parse(i).id,this.clearFormValidation(o),this.onOptionSelected(i,e)}}handleDocumentClick(t){this.isClickOutside(t)&&this.target.classList.contains("open")&&(this.hideElement(this.target),this.updateArrowDisplay(!1))}isClickOutside(t){const e=this.element.querySelector(c);if(e)return!e.contains(t.target);{const s=this.element.querySelector(R),o=this.element.parentNode.querySelector(h),i=s?!s.contains(t.target):!0,n=o?!o.contains(t.target):!0;return i&&n}}onOptionSelected(t,e){const s=this.element.querySelector("#dropdown_trigger_display"),o=this.element.querySelector("#dropdown_trigger_custom_display");if(s){const d=JSON.parse(t).label;s.textContent=d,o&&(o.style.display="block",o.style.paddingRight="8px")}this.element.querySelector(c)&&this.target.classList.contains("open")&&(this.hideElement(this.target),this.updateArrowDisplay(!1)),this.element.querySelectorAll(l).forEach(d=>{d.classList.remove("pb_dropdown_option_selected")}),e.classList.add("pb_dropdown_option_selected")}showElement(t){t.classList.remove("close"),t.classList.add("open"),t.style.height=t.scrollHeight+"px"}hideElement(t){t.style.height=t.scrollHeight+"px",window.setTimeout(()=>{t.classList.add("close"),t.classList.remove("open"),this.resetFocus()},0)}resetFocus(){this.keyboardHandler&&(this.keyboardHandler.focusedOptionIndex=-1,this.element.querySelectorAll(l).forEach(e=>e.classList.remove("pb_dropdown_option_focused")))}toggleElement(t){if(t.classList.contains("open")){this.hideElement(t),this.updateArrowDisplay(!1);return}this.showElement(t),this.updateArrowDisplay(!0)}updateArrowDisplay(t){const e=this.element.querySelector(q),s=this.element.querySelector(N);e&&s&&(e.style.display=t?"none":"inline-block",s.style.display=t?"inline-block":"none")}handleFormValidation(){const t=this.element.querySelector(p);t.addEventListener("invalid",function(e){t.hasAttribute("required")&&t.value===""&&(e.preventDefault(),t.closest(".dropdown_wrapper").classList.add("error"))},!0)}clearFormValidation(t){if(t.checkValidity()){const e=t.closest(".dropdown_wrapper");e.classList.remove("error");const s=e.querySelector(".pb_body_kit_negative");s&&s.remove()}}setDefaultValue(){const t=this.element.querySelector("#dropdown-selected-option");if(t.value){const e=this.element.querySelector(p),s=JSON.parse(t.value.replaceAll("=>",":"));this.element.querySelectorAll(l).forEach(n=>{s.id===JSON.parse(n.dataset.dropdownOptionLabel).id&&n.classList.add("pb_dropdown_option_selected")});const i=this.element.querySelector("#dropdown_trigger_display");i&&(i.textContent=s.label),t.value=s.id,e.value=s.id}}}const P="[data-advanced-table]",I='[data-advanced-table-content="id"]',u="#advanced-table_open_icon",g="#advanced-table_close_icon";class H extends a{static get selector(){return P}get target(){return document.querySelector(I.replace("id",this.element.id))}connect(){this.element.addEventListener("click",()=>{this.toggleElement(this.target)})}showElement(t){const s=(()=>{t.style.display="block";const o=t.scrollHeight+"px";return t.style.display="",o})();t.classList.add("is-visible"),t.style.height=s,t.style.overflow="hidden",window.setTimeout(()=>{t.style.height="",t.style.overflow="visible"},250)}hideElement(t){t.style.height=t.scrollHeight+"px",window.setTimeout(()=>{t.style.height="0",t.style.paddingTop="0",t.style.paddingBottom="0",t.style.overflow="hidden"},1),window.setTimeout(()=>{t.classList.remove("is-visible"),t.style.overflow=""},200)}toggleElement(t){if(t.classList.contains("is-visible")){this.hideElement(t),this.displayDownArrow();return}this.showElement(t),this.displayUpArrow()}displayDownArrow(){this.element.querySelector(u).style.display="inline-block",this.element.querySelector(g).style.display="none"}displayUpArrow(){this.element.querySelector(g).style.display="inline-block",this.element.querySelector(u).style.display="none"}}window.datePickerHelper=w;window.dialogHelper=y;S.start();E.start();m.start();A.start();b.start();f.start();_.start();x.start();H.start();
|