playbook_ui 13.34.0.pre.alpha.PLAY14143357 → 13.34.0.pre.alpha.PLAY14143372

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +2 -5
  3. data/app/pb_kits/playbook/utilities/text.ts +1 -1
  4. data/dist/chunks/{_typeahead-GlErBXlp.js → _typeahead-COUJ88EA.js} +1 -1
  5. data/dist/playbook-rails-react-bindings.js +1 -1
  6. data/dist/playbook-rails.js +1 -1
  7. data/lib/playbook/version.rb +1 -1
  8. metadata +3 -20
  9. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.scss +0 -11
  10. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +0 -83
  11. data/app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_compact.html.erb +0 -3
  12. data/app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_compact.jsx +0 -27
  13. data/app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_default.html.erb +0 -3
  14. data/app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_default.jsx +0 -22
  15. data/app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_variant.html.erb +0 -3
  16. data/app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_variant.jsx +0 -24
  17. data/app/pb_kits/playbook/pb_weekday_stacked/docs/example.yml +0 -12
  18. data/app/pb_kits/playbook/pb_weekday_stacked/docs/index.js +0 -3
  19. data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb +0 -4
  20. data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb +0 -57
  21. data/app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.test.jsx +0 -105
  22. data/dist/chunks/_weekday_stacked-D6DCIGL4.js +0 -45
  23. data/dist/chunks/vendor.js +0 -1
  24. data/dist/playbook-doc.js +0 -1
  25. data/dist/playbook.css +0 -4
@@ -1 +1 @@
1
- import WebpackerReact from"webpacker-react";import{B as BarGraph,C as CircleChart,D as Dialog,a as DialogBody,b as DialogFooter,c as DialogHeader,d as DistributionBar,M as MultiLevelSelect,L as Legend,e as LineGraph,P as Passphrase,R as RichTextEditor,T as TreemapChart,f as Typeahead,G as Gauge,g as PhoneNumberInput}from"./chunks/_typeahead-GlErBXlp.js";import"react/jsx-runtime";import"react";import"./chunks/lib-Bf_E03gc.js";import"react-dom";import"react-trix";import"trix";import"react-is";var ujs$1={};Object.defineProperty(ujs$1,"__esModule",{value:true});var ujs={handleEvent:function handleEvent(eventName,callback){var _ref=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{once:false},once=_ref.once;var $=typeof window.jQuery!=="undefined"&&window.jQuery;if($){if(once){$(document).one(eventName,callback)}else{$(document).on(eventName,callback)}}else{document.addEventListener(eventName,callback,{once:once})}},setup:function setup(onMount,onUnmount){var $=typeof window.jQuery!=="undefined"&&window.jQuery;var Turbolinks=window.Turbolinks;if(typeof Turbolinks!=="undefined"&&Turbolinks.supported){if(typeof Turbolinks.EVENTS!=="undefined"){this.turbolinksClassic(onMount,onUnmount)}else if(typeof Turbolinks.controller!=="undefined"){this.turbolinks5(onMount,onUnmount)}else{this.turbolinksClassicDeprecated(onMount,onUnmount)}}else if($&&typeof $.pjax==="function"){this.pjax(onMount,onUnmount)}else{this.native(onMount)}},turbolinks5:function turbolinks5(onMount,onUnmount){this.handleEvent("turbolinks:load",onMount,{once:true});this.handleEvent("turbolinks:render",onMount);this.handleEvent("turbolinks:before-render",onUnmount)},turbolinksClassic:function turbolinksClassic(onMount,onUnmount){var Turbolinks=window.Turbolinks;this.handleEvent(Turbolinks.EVENTS.CHANGE,onMount);this.handleEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,onUnmount)},turbolinksClassicDeprecated:function turbolinksClassicDeprecated(onMount,onUnmount){var Turbolinks=window.Turbolinks;Turbolinks.pagesCached(0);this.handleEvent("page:change",onMount);this.handleEvent("page:receive",onUnmount)},pjax:function pjax(onMount,onUnmount){this.handleEvent("ready",onMount);this.handleEvent("pjax:end",onMount);this.handleEvent("pjax:beforeReplace",onUnmount)},native:function native(onMount){var $=typeof window.jQuery!=="undefined"&&window.jQuery;if($){$((function(){return onMount()}))}else if("addEventListener"in window){document.addEventListener("DOMContentLoaded",onMount)}else{window.attachEvent("onload",onMount)}}};var _default=ujs$1.default=ujs;WebpackerReact.registerComponents({BarGraph:BarGraph,CircleChart:CircleChart,Dialog:Dialog,DialogBody:DialogBody,DialogFooter:DialogFooter,DialogHeader:DialogHeader,DistributionBar:DistributionBar,MultiLevelSelect:MultiLevelSelect,Legend:Legend,LineGraph:LineGraph,Passphrase:Passphrase,RichTextEditor:RichTextEditor,TreemapChart:TreemapChart,Typeahead:Typeahead,Gauge:Gauge,PhoneNumberInput:PhoneNumberInput});_default.setup((()=>WebpackerReact.mountComponents()),(()=>WebpackerReact.unmountComponents()));
1
+ import WebpackerReact from"webpacker-react";import{B as BarGraph,C as CircleChart,D as Dialog,a as DialogBody,b as DialogFooter,c as DialogHeader,d as DistributionBar,M as MultiLevelSelect,L as Legend,e as LineGraph,P as Passphrase,R as RichTextEditor,T as TreemapChart,f as Typeahead,G as Gauge,g as PhoneNumberInput}from"./chunks/_typeahead-COUJ88EA.js";import"react/jsx-runtime";import"react";import"./chunks/lib-Bf_E03gc.js";import"react-dom";import"react-trix";import"trix";import"react-is";var ujs$1={};Object.defineProperty(ujs$1,"__esModule",{value:true});var ujs={handleEvent:function handleEvent(eventName,callback){var _ref=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{once:false},once=_ref.once;var $=typeof window.jQuery!=="undefined"&&window.jQuery;if($){if(once){$(document).one(eventName,callback)}else{$(document).on(eventName,callback)}}else{document.addEventListener(eventName,callback,{once:once})}},setup:function setup(onMount,onUnmount){var $=typeof window.jQuery!=="undefined"&&window.jQuery;var Turbolinks=window.Turbolinks;if(typeof Turbolinks!=="undefined"&&Turbolinks.supported){if(typeof Turbolinks.EVENTS!=="undefined"){this.turbolinksClassic(onMount,onUnmount)}else if(typeof Turbolinks.controller!=="undefined"){this.turbolinks5(onMount,onUnmount)}else{this.turbolinksClassicDeprecated(onMount,onUnmount)}}else if($&&typeof $.pjax==="function"){this.pjax(onMount,onUnmount)}else{this.native(onMount)}},turbolinks5:function turbolinks5(onMount,onUnmount){this.handleEvent("turbolinks:load",onMount,{once:true});this.handleEvent("turbolinks:render",onMount);this.handleEvent("turbolinks:before-render",onUnmount)},turbolinksClassic:function turbolinksClassic(onMount,onUnmount){var Turbolinks=window.Turbolinks;this.handleEvent(Turbolinks.EVENTS.CHANGE,onMount);this.handleEvent(Turbolinks.EVENTS.BEFORE_UNLOAD,onUnmount)},turbolinksClassicDeprecated:function turbolinksClassicDeprecated(onMount,onUnmount){var Turbolinks=window.Turbolinks;Turbolinks.pagesCached(0);this.handleEvent("page:change",onMount);this.handleEvent("page:receive",onUnmount)},pjax:function pjax(onMount,onUnmount){this.handleEvent("ready",onMount);this.handleEvent("pjax:end",onMount);this.handleEvent("pjax:beforeReplace",onUnmount)},native:function native(onMount){var $=typeof window.jQuery!=="undefined"&&window.jQuery;if($){$((function(){return onMount()}))}else if("addEventListener"in window){document.addEventListener("DOMContentLoaded",onMount)}else{window.attachEvent("onload",onMount)}}};var _default=ujs$1.default=ujs;WebpackerReact.registerComponents({BarGraph:BarGraph,CircleChart:CircleChart,Dialog:Dialog,DialogBody:DialogBody,DialogFooter:DialogFooter,DialogHeader:DialogHeader,DistributionBar:DistributionBar,MultiLevelSelect:MultiLevelSelect,Legend:Legend,LineGraph:LineGraph,Passphrase:Passphrase,RichTextEditor:RichTextEditor,TreemapChart:TreemapChart,Typeahead:Typeahead,Gauge:Gauge,PhoneNumberInput:PhoneNumberInput});_default.setup((()=>WebpackerReact.mountComponents()),(()=>WebpackerReact.unmountComponents()));
@@ -1 +1 @@
1
- import"./chunks/pb_form_validation-D0dhqeN2.js";import{P as PbEnhancedElement,a as datePickerHelper,b as dialogHelper,c as PbPopover,e as PbTooltip,f as PbTypeahead,g as PbTable,h as PbTextarea}from"./chunks/lib-Bf_E03gc.js";import"./chunks/lazysizes-B7xYodB-.js";import"./playbook-rails-react-bindings.js";import"react";import"webpacker-react";import"./chunks/_typeahead-GlErBXlp.js";import"react/jsx-runtime";import"react-dom";import"react-trix";import"trix";import"react-is";const MAIN_SELECTOR="[data-collapsible-main]";const CONTENT_SELECTOR$1="[data-collapsible-content]";const DOWN_ARROW_SELECTOR$2="#collapsible_open_icon";const UP_ARROW_SELECTOR$2="#collapsible_close_icon";class PbCollapsible extends PbEnhancedElement{static get selector(){return MAIN_SELECTOR}connect(){this.element.addEventListener("click",(()=>{this.toggleElement(this.target)}));if(this.target.classList.contains("is-visible")){this.displayUpArrow()}else{this.displayDownArrow()}document.addEventListener(`${this.target.id}`,(()=>{this.toggleElement(this.target)}))}get target(){return this.element.parentNode.querySelector(CONTENT_SELECTOR$1)}showElement(elem){const getHeight=()=>{elem.style.display="block";const height2=elem.scrollHeight+"px";elem.style.display="";return height2};const height=getHeight();elem.classList.add("is-visible");elem.style.height=height;elem.style.overflow="hidden";window.setTimeout((()=>{elem.style.height="";elem.style.overflow="visible"}),300)}hideElement(elem){elem.style.height=elem.scrollHeight+"px";window.setTimeout((()=>{elem.style.height="0";elem.style.paddingTop="0";elem.style.paddingBottom="0";elem.style.overflow="hidden"}),1);window.setTimeout((()=>{elem.classList.remove("is-visible");elem.style.overflow=""}),300)}toggleElement(elem){if(elem.classList.contains("is-visible")){this.hideElement(elem);this.displayDownArrow();return}this.showElement(elem);this.displayUpArrow()}toggleArrows(showDownArrow){const downArrow=this.element.querySelector(DOWN_ARROW_SELECTOR$2);const upArrow=this.element.querySelector(UP_ARROW_SELECTOR$2);if(downArrow){downArrow.style.display=showDownArrow?"inline-block":"none"}if(upArrow){upArrow.style.display=showDownArrow?"none":"inline-block"}}displayDownArrow(){this.toggleArrows(true)}displayUpArrow(){this.toggleArrows(false)}}class PbFixedConfirmationToast extends PbEnhancedElement{static get selector(){return".remove_toast"}connect(){this.self=this.element;this.autoCloseToast(this.self);this.self.addEventListener("click",(()=>{this.removeToast(this.self)}))}removeToast(elem){elem.parentNode.removeChild(elem)}autoCloseToast(element){const classListValues=element.classList.value;const hasAutoCloseClass=classListValues.includes("auto_close");if(hasAutoCloseClass){const classList=classListValues.split(" ");const autoCloseValue=classList[classList.length-1].split("_")[2];const autoCloseIntValue=parseInt(autoCloseValue);setTimeout((()=>{this.removeToast(element)}),autoCloseIntValue)}}}const OPTION_SELECTOR$1="[data-dropdown-option-label]";class PbDropdownKeyboard{constructor(dropdown){this.dropdown=dropdown;this.dropdownElement=dropdown.element;this.options=Array.from(this.dropdownElement.querySelectorAll(OPTION_SELECTOR$1));this.focusedOptionIndex=-1;this.init()}init(){this.dropdownElement.addEventListener("keydown",this.handleKeyDown.bind(this))}handleKeyDown(event){switch(event.key){case"ArrowDown":event.preventDefault();if(!this.dropdown.target.classList.contains("open")){this.dropdown.showElement(this.dropdown.target);this.dropdown.updateArrowDisplay(true)}this.moveFocus(1);break;case"ArrowUp":event.preventDefault();this.moveFocus(-1);break;case"Enter":event.preventDefault();if(this.focusedOptionIndex!==-1){this.selectOption()}else{if(!this.dropdown.target.classList.contains("open")){this.dropdown.showElement(this.dropdown.target);this.dropdown.updateArrowDisplay(true)}}break;case"Escape":this.dropdown.hideElement(this.dropdown.target);break;case"Tab":this.dropdown.hideElement(this.dropdown.target);this.dropdown.updateArrowDisplay(false);this.resetFocus();break}}moveFocus(direction){if(this.focusedOptionIndex!==-1){this.options[this.focusedOptionIndex].classList.remove("pb_dropdown_option_focused")}this.focusedOptionIndex=(this.focusedOptionIndex+direction+this.options.length)%this.options.length;this.options[this.focusedOptionIndex].classList.add("pb_dropdown_option_focused")}selectOption(){const option=this.options[this.focusedOptionIndex];this.dropdown.onOptionSelected(option.dataset.dropdownOptionLabel,option);this.dropdown.hideElement(this.dropdown.target)}}const DROPDOWN_SELECTOR="[data-pb-dropdown]";const TRIGGER_SELECTOR="[data-dropdown-trigger]";const CONTAINER_SELECTOR="[data-dropdown-container]";const DOWN_ARROW_SELECTOR$1="#dropdown_open_icon";const UP_ARROW_SELECTOR$1="#dropdown_close_icon";const OPTION_SELECTOR="[data-dropdown-option-label]";const CUSTOM_DISPLAY_SELECTOR="[data-dropdown-custom-trigger]";const DROPDOWN_TRIGGER_DISPLAY="#dropdown_trigger_display";const DROPDOWN_PLACEHOLDER="[data-dropdown-placeholder]";const DROPDOWN_INPUT="#dropdown-selected-option";class PbDropdown extends PbEnhancedElement{static get selector(){return DROPDOWN_SELECTOR}get target(){return this.element.parentNode.querySelector(CONTAINER_SELECTOR)}connect(){this.keyboardHandler=new PbDropdownKeyboard(this);this.setDefaultValue();this.bindEventListeners();this.updateArrowDisplay(false);this.handleFormValidation();this.handleFormReset()}bindEventListeners(){const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR)||this.element;customTrigger.addEventListener("click",(()=>this.toggleElement(this.target)));this.target.addEventListener("click",this.handleOptionClick.bind(this));document.addEventListener("click",this.handleDocumentClick.bind(this),true)}handleOptionClick(event){const option=event.target.closest(OPTION_SELECTOR);const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);if(option){const value=option.dataset.dropdownOptionLabel;hiddenInput.value=JSON.parse(value).id;this.clearFormValidation(hiddenInput);this.onOptionSelected(value,option)}}handleDocumentClick(event){if(this.isClickOutside(event)&&this.target.classList.contains("open")){this.hideElement(this.target);this.updateArrowDisplay(false)}}isClickOutside(event){const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);if(customTrigger){return!customTrigger.contains(event.target)}else{const triggerElement=this.element.querySelector(TRIGGER_SELECTOR);const containerElement=this.element.parentNode.querySelector(CONTAINER_SELECTOR);const isOutsideTrigger=triggerElement?!triggerElement.contains(event.target):true;const isOutsideContainer=containerElement?!containerElement.contains(event.target):true;return isOutsideTrigger&&isOutsideContainer}}onOptionSelected(value,selectedOption){const triggerElement=this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);const customDisplayElement=this.element.querySelector("#dropdown_trigger_custom_display");if(triggerElement){const selectedLabel=JSON.parse(value).label;triggerElement.textContent=selectedLabel;if(customDisplayElement){customDisplayElement.style.display="block";customDisplayElement.style.paddingRight="8px"}}const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);if(customTrigger){if(this.target.classList.contains("open")){this.hideElement(this.target);this.updateArrowDisplay(false)}}const options=this.element.querySelectorAll(OPTION_SELECTOR);options.forEach((option=>{option.classList.remove("pb_dropdown_option_selected")}));selectedOption.classList.add("pb_dropdown_option_selected")}showElement(elem){elem.classList.remove("close");elem.classList.add("open");elem.style.height=elem.scrollHeight+"px"}hideElement(elem){elem.style.height=elem.scrollHeight+"px";window.setTimeout((()=>{elem.classList.add("close");elem.classList.remove("open");this.resetFocus()}),0)}resetFocus(){if(this.keyboardHandler){this.keyboardHandler.focusedOptionIndex=-1;const options=this.element.querySelectorAll(OPTION_SELECTOR);options.forEach((option=>option.classList.remove("pb_dropdown_option_focused")))}}toggleElement(elem){if(elem.classList.contains("open")){this.hideElement(elem);this.updateArrowDisplay(false);return}this.showElement(elem);this.updateArrowDisplay(true)}updateArrowDisplay(isOpen){const downArrow=this.element.querySelector(DOWN_ARROW_SELECTOR$1);const upArrow=this.element.querySelector(UP_ARROW_SELECTOR$1);if(downArrow&&upArrow){downArrow.style.display=isOpen?"none":"inline-block";upArrow.style.display=isOpen?"inline-block":"none"}}handleFormValidation(){const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);hiddenInput.addEventListener("invalid",(function(event){if(hiddenInput.hasAttribute("required")&&hiddenInput.value===""){event.preventDefault();hiddenInput.closest(".dropdown_wrapper").classList.add("error")}}),true)}clearFormValidation(input){if(input.checkValidity()){const dropdownWrapperElement=input.closest(".dropdown_wrapper");dropdownWrapperElement.classList.remove("error");const errorLabelElement=dropdownWrapperElement.querySelector(".pb_body_kit_negative");if(errorLabelElement){errorLabelElement.remove()}}}setDefaultValue(){const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);const options=this.element.querySelectorAll(OPTION_SELECTOR);const defaultValue=hiddenInput.dataset.defaultValue||"";hiddenInput.value=defaultValue;if(defaultValue){const selectedOption=Array.from(options).find((option=>JSON.parse(option.dataset.dropdownOptionLabel).id===defaultValue));selectedOption.classList.add("pb_dropdown_option_selected");this.setTriggerElementText(JSON.parse(selectedOption.dataset.dropdownOptionLabel).label)}}handleFormReset(){const form=this.element.closest("form");if(form){form.addEventListener("reset",(()=>{this.resetDropdownValue()}))}}resetDropdownValue(){const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);const options=this.element.querySelectorAll(OPTION_SELECTOR);options.forEach((option=>{option.classList.remove("pb_dropdown_option_selected")}));hiddenInput.value="";const defaultPlaceholder=this.element.querySelector(DROPDOWN_PLACEHOLDER);this.setTriggerElementText(defaultPlaceholder.dataset.dropdownPlaceholder)}setTriggerElementText(text){const triggerElement=this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);if(triggerElement){triggerElement.textContent=text}}}const ADVANCED_TABLE_SELECTOR="[data-advanced-table]";const CONTENT_SELECTOR='[data-advanced-table-content="id"]';const DOWN_ARROW_SELECTOR="#advanced-table_open_icon";const UP_ARROW_SELECTOR="#advanced-table_close_icon";class PbAdvancedTable extends PbEnhancedElement{static get selector(){return ADVANCED_TABLE_SELECTOR}get target(){return document.querySelector(CONTENT_SELECTOR.replace("id",this.element.id))}connect(){this.element.addEventListener("click",(()=>{this.toggleElement(this.target)}))}showElement(elem){const getHeight=()=>{elem.style.display="block";const height2=elem.scrollHeight+"px";elem.style.display="";return height2};const height=getHeight();elem.classList.add("is-visible");elem.style.height=height;elem.style.overflow="hidden";window.setTimeout((()=>{elem.style.height="";elem.style.overflow="visible"}),250)}hideElement(elem){elem.style.height=elem.scrollHeight+"px";window.setTimeout((()=>{elem.style.height="0";elem.style.paddingTop="0";elem.style.paddingBottom="0";elem.style.overflow="hidden"}),1);window.setTimeout((()=>{elem.classList.remove("is-visible");elem.style.overflow=""}),200)}toggleElement(elem){if(elem.classList.contains("is-visible")){this.hideElement(elem);this.displayDownArrow();return}this.showElement(elem);this.displayUpArrow()}displayDownArrow(){this.element.querySelector(DOWN_ARROW_SELECTOR).style.display="inline-block";this.element.querySelector(UP_ARROW_SELECTOR).style.display="none"}displayUpArrow(){this.element.querySelector(UP_ARROW_SELECTOR).style.display="inline-block";this.element.querySelector(DOWN_ARROW_SELECTOR).style.display="none"}}const NAV_SELECTOR="[data-pb-nav-tab]";const NAV_ITEM_SELECTOR="[data-pb-tab-target]";class PbNav extends PbEnhancedElement{static get selector(){return NAV_SELECTOR}connect(){this.hideAndAddEventListeners()}hideAndAddEventListeners(){const navItems=this.element.querySelectorAll(NAV_ITEM_SELECTOR);navItems.forEach((navItem=>{if(!navItem.className.includes("active")){this.changeContentDisplay(navItem.dataset.pbTabTarget,"none")}navItem.addEventListener("click",(event=>this.handleNavItemClick(event)))}))}handleNavItemClick(event){event.preventDefault();const navItem=event.target.closest(NAV_ITEM_SELECTOR);this.changeContentDisplay(navItem.dataset.pbTabTarget,"block");const navItems=this.element.querySelectorAll(NAV_ITEM_SELECTOR);navItems.forEach((navItemSelected=>{if(navItem!==navItemSelected){this.changeContentDisplay(navItemSelected.dataset.pbTabTarget,"none")}}))}changeContentDisplay(contentId,display){const content=document.getElementById(contentId);content.style.display=display}}window.datePickerHelper=datePickerHelper;window.dialogHelper=dialogHelper;PbCollapsible.start();PbPopover.start();PbTooltip.start();PbFixedConfirmationToast.start();PbTypeahead.start();PbTable.start();PbTextarea.start();PbDropdown.start();PbAdvancedTable.start();PbNav.start();
1
+ import"./chunks/pb_form_validation-D0dhqeN2.js";import{P as PbEnhancedElement,a as datePickerHelper,b as dialogHelper,c as PbPopover,e as PbTooltip,f as PbTypeahead,g as PbTable,h as PbTextarea}from"./chunks/lib-Bf_E03gc.js";import"./chunks/lazysizes-B7xYodB-.js";import"./playbook-rails-react-bindings.js";import"react";import"webpacker-react";import"./chunks/_typeahead-COUJ88EA.js";import"react/jsx-runtime";import"react-dom";import"react-trix";import"trix";import"react-is";const MAIN_SELECTOR="[data-collapsible-main]";const CONTENT_SELECTOR$1="[data-collapsible-content]";const DOWN_ARROW_SELECTOR$2="#collapsible_open_icon";const UP_ARROW_SELECTOR$2="#collapsible_close_icon";class PbCollapsible extends PbEnhancedElement{static get selector(){return MAIN_SELECTOR}connect(){this.element.addEventListener("click",(()=>{this.toggleElement(this.target)}));if(this.target.classList.contains("is-visible")){this.displayUpArrow()}else{this.displayDownArrow()}document.addEventListener(`${this.target.id}`,(()=>{this.toggleElement(this.target)}))}get target(){return this.element.parentNode.querySelector(CONTENT_SELECTOR$1)}showElement(elem){const getHeight=()=>{elem.style.display="block";const height2=elem.scrollHeight+"px";elem.style.display="";return height2};const height=getHeight();elem.classList.add("is-visible");elem.style.height=height;elem.style.overflow="hidden";window.setTimeout((()=>{elem.style.height="";elem.style.overflow="visible"}),300)}hideElement(elem){elem.style.height=elem.scrollHeight+"px";window.setTimeout((()=>{elem.style.height="0";elem.style.paddingTop="0";elem.style.paddingBottom="0";elem.style.overflow="hidden"}),1);window.setTimeout((()=>{elem.classList.remove("is-visible");elem.style.overflow=""}),300)}toggleElement(elem){if(elem.classList.contains("is-visible")){this.hideElement(elem);this.displayDownArrow();return}this.showElement(elem);this.displayUpArrow()}toggleArrows(showDownArrow){const downArrow=this.element.querySelector(DOWN_ARROW_SELECTOR$2);const upArrow=this.element.querySelector(UP_ARROW_SELECTOR$2);if(downArrow){downArrow.style.display=showDownArrow?"inline-block":"none"}if(upArrow){upArrow.style.display=showDownArrow?"none":"inline-block"}}displayDownArrow(){this.toggleArrows(true)}displayUpArrow(){this.toggleArrows(false)}}class PbFixedConfirmationToast extends PbEnhancedElement{static get selector(){return".remove_toast"}connect(){this.self=this.element;this.autoCloseToast(this.self);this.self.addEventListener("click",(()=>{this.removeToast(this.self)}))}removeToast(elem){elem.parentNode.removeChild(elem)}autoCloseToast(element){const classListValues=element.classList.value;const hasAutoCloseClass=classListValues.includes("auto_close");if(hasAutoCloseClass){const classList=classListValues.split(" ");const autoCloseValue=classList[classList.length-1].split("_")[2];const autoCloseIntValue=parseInt(autoCloseValue);setTimeout((()=>{this.removeToast(element)}),autoCloseIntValue)}}}const OPTION_SELECTOR$1="[data-dropdown-option-label]";class PbDropdownKeyboard{constructor(dropdown){this.dropdown=dropdown;this.dropdownElement=dropdown.element;this.options=Array.from(this.dropdownElement.querySelectorAll(OPTION_SELECTOR$1));this.focusedOptionIndex=-1;this.init()}init(){this.dropdownElement.addEventListener("keydown",this.handleKeyDown.bind(this))}handleKeyDown(event){switch(event.key){case"ArrowDown":event.preventDefault();if(!this.dropdown.target.classList.contains("open")){this.dropdown.showElement(this.dropdown.target);this.dropdown.updateArrowDisplay(true)}this.moveFocus(1);break;case"ArrowUp":event.preventDefault();this.moveFocus(-1);break;case"Enter":event.preventDefault();if(this.focusedOptionIndex!==-1){this.selectOption()}else{if(!this.dropdown.target.classList.contains("open")){this.dropdown.showElement(this.dropdown.target);this.dropdown.updateArrowDisplay(true)}}break;case"Escape":this.dropdown.hideElement(this.dropdown.target);break;case"Tab":this.dropdown.hideElement(this.dropdown.target);this.dropdown.updateArrowDisplay(false);this.resetFocus();break}}moveFocus(direction){if(this.focusedOptionIndex!==-1){this.options[this.focusedOptionIndex].classList.remove("pb_dropdown_option_focused")}this.focusedOptionIndex=(this.focusedOptionIndex+direction+this.options.length)%this.options.length;this.options[this.focusedOptionIndex].classList.add("pb_dropdown_option_focused")}selectOption(){const option=this.options[this.focusedOptionIndex];this.dropdown.onOptionSelected(option.dataset.dropdownOptionLabel,option);this.dropdown.hideElement(this.dropdown.target)}}const DROPDOWN_SELECTOR="[data-pb-dropdown]";const TRIGGER_SELECTOR="[data-dropdown-trigger]";const CONTAINER_SELECTOR="[data-dropdown-container]";const DOWN_ARROW_SELECTOR$1="#dropdown_open_icon";const UP_ARROW_SELECTOR$1="#dropdown_close_icon";const OPTION_SELECTOR="[data-dropdown-option-label]";const CUSTOM_DISPLAY_SELECTOR="[data-dropdown-custom-trigger]";const DROPDOWN_TRIGGER_DISPLAY="#dropdown_trigger_display";const DROPDOWN_PLACEHOLDER="[data-dropdown-placeholder]";const DROPDOWN_INPUT="#dropdown-selected-option";class PbDropdown extends PbEnhancedElement{static get selector(){return DROPDOWN_SELECTOR}get target(){return this.element.parentNode.querySelector(CONTAINER_SELECTOR)}connect(){this.keyboardHandler=new PbDropdownKeyboard(this);this.setDefaultValue();this.bindEventListeners();this.updateArrowDisplay(false);this.handleFormValidation();this.handleFormReset()}bindEventListeners(){const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR)||this.element;customTrigger.addEventListener("click",(()=>this.toggleElement(this.target)));this.target.addEventListener("click",this.handleOptionClick.bind(this));document.addEventListener("click",this.handleDocumentClick.bind(this),true)}handleOptionClick(event){const option=event.target.closest(OPTION_SELECTOR);const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);if(option){const value=option.dataset.dropdownOptionLabel;hiddenInput.value=JSON.parse(value).id;this.clearFormValidation(hiddenInput);this.onOptionSelected(value,option)}}handleDocumentClick(event){if(this.isClickOutside(event)&&this.target.classList.contains("open")){this.hideElement(this.target);this.updateArrowDisplay(false)}}isClickOutside(event){const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);if(customTrigger){return!customTrigger.contains(event.target)}else{const triggerElement=this.element.querySelector(TRIGGER_SELECTOR);const containerElement=this.element.parentNode.querySelector(CONTAINER_SELECTOR);const isOutsideTrigger=triggerElement?!triggerElement.contains(event.target):true;const isOutsideContainer=containerElement?!containerElement.contains(event.target):true;return isOutsideTrigger&&isOutsideContainer}}onOptionSelected(value,selectedOption){const triggerElement=this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);const customDisplayElement=this.element.querySelector("#dropdown_trigger_custom_display");if(triggerElement){const selectedLabel=JSON.parse(value).label;triggerElement.textContent=selectedLabel;if(customDisplayElement){customDisplayElement.style.display="block";customDisplayElement.style.paddingRight="8px"}}const customTrigger=this.element.querySelector(CUSTOM_DISPLAY_SELECTOR);if(customTrigger){if(this.target.classList.contains("open")){this.hideElement(this.target);this.updateArrowDisplay(false)}}const options=this.element.querySelectorAll(OPTION_SELECTOR);options.forEach((option=>{option.classList.remove("pb_dropdown_option_selected")}));selectedOption.classList.add("pb_dropdown_option_selected")}showElement(elem){elem.classList.remove("close");elem.classList.add("open");elem.style.height=elem.scrollHeight+"px"}hideElement(elem){elem.style.height=elem.scrollHeight+"px";window.setTimeout((()=>{elem.classList.add("close");elem.classList.remove("open");this.resetFocus()}),0)}resetFocus(){if(this.keyboardHandler){this.keyboardHandler.focusedOptionIndex=-1;const options=this.element.querySelectorAll(OPTION_SELECTOR);options.forEach((option=>option.classList.remove("pb_dropdown_option_focused")))}}toggleElement(elem){if(elem.classList.contains("open")){this.hideElement(elem);this.updateArrowDisplay(false);return}this.showElement(elem);this.updateArrowDisplay(true)}updateArrowDisplay(isOpen){const downArrow=this.element.querySelector(DOWN_ARROW_SELECTOR$1);const upArrow=this.element.querySelector(UP_ARROW_SELECTOR$1);if(downArrow&&upArrow){downArrow.style.display=isOpen?"none":"inline-block";upArrow.style.display=isOpen?"inline-block":"none"}}handleFormValidation(){const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);hiddenInput.addEventListener("invalid",(function(event){if(hiddenInput.hasAttribute("required")&&hiddenInput.value===""){event.preventDefault();hiddenInput.closest(".dropdown_wrapper").classList.add("error")}}),true)}clearFormValidation(input){if(input.checkValidity()){const dropdownWrapperElement=input.closest(".dropdown_wrapper");dropdownWrapperElement.classList.remove("error");const errorLabelElement=dropdownWrapperElement.querySelector(".pb_body_kit_negative");if(errorLabelElement){errorLabelElement.remove()}}}setDefaultValue(){const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);const options=this.element.querySelectorAll(OPTION_SELECTOR);const defaultValue=hiddenInput.dataset.defaultValue||"";hiddenInput.value=defaultValue;if(defaultValue){const selectedOption=Array.from(options).find((option=>JSON.parse(option.dataset.dropdownOptionLabel).id===defaultValue));selectedOption.classList.add("pb_dropdown_option_selected");this.setTriggerElementText(JSON.parse(selectedOption.dataset.dropdownOptionLabel).label)}}handleFormReset(){const form=this.element.closest("form");if(form){form.addEventListener("reset",(()=>{this.resetDropdownValue()}))}}resetDropdownValue(){const hiddenInput=this.element.querySelector(DROPDOWN_INPUT);const options=this.element.querySelectorAll(OPTION_SELECTOR);options.forEach((option=>{option.classList.remove("pb_dropdown_option_selected")}));hiddenInput.value="";const defaultPlaceholder=this.element.querySelector(DROPDOWN_PLACEHOLDER);this.setTriggerElementText(defaultPlaceholder.dataset.dropdownPlaceholder)}setTriggerElementText(text){const triggerElement=this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);if(triggerElement){triggerElement.textContent=text}}}const ADVANCED_TABLE_SELECTOR="[data-advanced-table]";const CONTENT_SELECTOR='[data-advanced-table-content="id"]';const DOWN_ARROW_SELECTOR="#advanced-table_open_icon";const UP_ARROW_SELECTOR="#advanced-table_close_icon";class PbAdvancedTable extends PbEnhancedElement{static get selector(){return ADVANCED_TABLE_SELECTOR}get target(){return document.querySelector(CONTENT_SELECTOR.replace("id",this.element.id))}connect(){this.element.addEventListener("click",(()=>{this.toggleElement(this.target)}))}showElement(elem){const getHeight=()=>{elem.style.display="block";const height2=elem.scrollHeight+"px";elem.style.display="";return height2};const height=getHeight();elem.classList.add("is-visible");elem.style.height=height;elem.style.overflow="hidden";window.setTimeout((()=>{elem.style.height="";elem.style.overflow="visible"}),250)}hideElement(elem){elem.style.height=elem.scrollHeight+"px";window.setTimeout((()=>{elem.style.height="0";elem.style.paddingTop="0";elem.style.paddingBottom="0";elem.style.overflow="hidden"}),1);window.setTimeout((()=>{elem.classList.remove("is-visible");elem.style.overflow=""}),200)}toggleElement(elem){if(elem.classList.contains("is-visible")){this.hideElement(elem);this.displayDownArrow();return}this.showElement(elem);this.displayUpArrow()}displayDownArrow(){this.element.querySelector(DOWN_ARROW_SELECTOR).style.display="inline-block";this.element.querySelector(UP_ARROW_SELECTOR).style.display="none"}displayUpArrow(){this.element.querySelector(UP_ARROW_SELECTOR).style.display="inline-block";this.element.querySelector(DOWN_ARROW_SELECTOR).style.display="none"}}const NAV_SELECTOR="[data-pb-nav-tab]";const NAV_ITEM_SELECTOR="[data-pb-tab-target]";class PbNav extends PbEnhancedElement{static get selector(){return NAV_SELECTOR}connect(){this.hideAndAddEventListeners()}hideAndAddEventListeners(){const navItems=this.element.querySelectorAll(NAV_ITEM_SELECTOR);navItems.forEach((navItem=>{if(!navItem.className.includes("active")){this.changeContentDisplay(navItem.dataset.pbTabTarget,"none")}navItem.addEventListener("click",(event=>this.handleNavItemClick(event)))}))}handleNavItemClick(event){event.preventDefault();const navItem=event.target.closest(NAV_ITEM_SELECTOR);this.changeContentDisplay(navItem.dataset.pbTabTarget,"block");const navItems=this.element.querySelectorAll(NAV_ITEM_SELECTOR);navItems.forEach((navItemSelected=>{if(navItem!==navItemSelected){this.changeContentDisplay(navItemSelected.dataset.pbTabTarget,"none")}}))}changeContentDisplay(contentId,display){const content=document.getElementById(contentId);content.style.display=display}}window.datePickerHelper=datePickerHelper;window.dialogHelper=dialogHelper;PbCollapsible.start();PbPopover.start();PbTooltip.start();PbFixedConfirmationToast.start();PbTypeahead.start();PbTable.start();PbTextarea.start();PbDropdown.start();PbAdvancedTable.start();PbNav.start();
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Playbook
4
4
  PREVIOUS_VERSION = "13.34.0"
5
- VERSION = "13.34.0.pre.alpha.PLAY14143357"
5
+ VERSION = "13.34.0.pre.alpha.PLAY14143372"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playbook_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.34.0.pre.alpha.PLAY14143357
4
+ version: 13.34.0.pre.alpha.PLAY14143372
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: 2024-07-27 00:00:00.000000000 Z
12
+ date: 2024-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -2899,19 +2899,6 @@ files:
2899
2899
  - app/pb_kits/playbook/pb_walkthrough/docs/example.yml
2900
2900
  - app/pb_kits/playbook/pb_walkthrough/docs/index.js
2901
2901
  - app/pb_kits/playbook/pb_walkthrough/walkthrough.test.jsx
2902
- - app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.scss
2903
- - app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx
2904
- - app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_compact.html.erb
2905
- - app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_compact.jsx
2906
- - app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_default.html.erb
2907
- - app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_default.jsx
2908
- - app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_variant.html.erb
2909
- - app/pb_kits/playbook/pb_weekday_stacked/docs/_weekday_stacked_variant.jsx
2910
- - app/pb_kits/playbook/pb_weekday_stacked/docs/example.yml
2911
- - app/pb_kits/playbook/pb_weekday_stacked/docs/index.js
2912
- - app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.html.erb
2913
- - app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.rb
2914
- - app/pb_kits/playbook/pb_weekday_stacked/weekday_stacked.test.jsx
2915
2902
  - app/pb_kits/playbook/tokens/_animation-curves.scss
2916
2903
  - app/pb_kits/playbook/tokens/_border_radius.scss
2917
2904
  - app/pb_kits/playbook/tokens/_colors.scss
@@ -2991,17 +2978,13 @@ files:
2991
2978
  - app/pb_kits/playbook/utilities/test/globalProps/truncate.test.js
2992
2979
  - app/pb_kits/playbook/utilities/text.ts
2993
2980
  - app/pb_kits/playbook/utilities/validEmojiChecker.ts
2994
- - dist/chunks/_typeahead-GlErBXlp.js
2995
- - dist/chunks/_weekday_stacked-D6DCIGL4.js
2981
+ - dist/chunks/_typeahead-COUJ88EA.js
2996
2982
  - dist/chunks/lazysizes-B7xYodB-.js
2997
2983
  - dist/chunks/lib-Bf_E03gc.js
2998
2984
  - dist/chunks/pb_form_validation-D0dhqeN2.js
2999
- - dist/chunks/vendor.js
3000
2985
  - dist/menu.yml
3001
- - dist/playbook-doc.js
3002
2986
  - dist/playbook-rails-react-bindings.js
3003
2987
  - dist/playbook-rails.js
3004
- - dist/playbook.css
3005
2988
  - dist/reset.css
3006
2989
  - lib/playbook.rb
3007
2990
  - lib/playbook/align_content.rb
@@ -1,11 +0,0 @@
1
- [class^='pb_weekday_stacked'] {
2
- &[class*='_left'] {
3
- text-align: left;
4
- }
5
- &[class*='_center'] {
6
- text-align: center;
7
- }
8
- &[class*='_right'] {
9
- text-align: right;
10
- }
11
- }
@@ -1,83 +0,0 @@
1
- import React from 'react'
2
- import classnames from 'classnames'
3
- import { globalProps } from '../utilities/globalProps'
4
- import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
5
-
6
- import Caption from '../pb_caption/_caption'
7
- import Title from '../pb_title/_title'
8
- import DateTime from '../pb_kit/dateTime';
9
- import { GenericObject } from '../types'
10
-
11
- type WeekdayStackedProps = {
12
- align?: "left" | "center" | "right",
13
- aria?: {[key:string]:string },
14
- className?: string,
15
- dark?: boolean,
16
- data?: GenericObject,
17
- date: Date,
18
- htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
19
- id?: string,
20
- variant?: "day_only" | "month_day" | "expanded",
21
- compact?: boolean,
22
- }
23
-
24
- const getDayOfWeek = (value: Date, compact: boolean) => {
25
- if (compact) {
26
- return DateTime.toDayAbbr(value)
27
- } else {
28
- return DateTime.toWeekday(value)
29
- }
30
- }
31
-
32
- const getFormattedDate = (value: Date, variant: "day_only" | "month_day" | "expanded") => {
33
- if (variant === 'day_only') {
34
- return DateTime.toDay(value).toString()
35
- } else {
36
- const format = variant === 'expanded' ? 'expanded' : 'month_day'
37
- return DateTime.toCustomFormat(value, format)
38
- }
39
- }
40
-
41
- const WeekdayStacked = (props: WeekdayStackedProps) => {
42
- const {
43
- align = 'left',
44
- aria = {},
45
- className,
46
- dark = false,
47
- data = {},
48
- date = new Date(),
49
- htmlOptions = {},
50
- id,
51
- variant = 'month_day',
52
- compact = false,
53
- } = props
54
-
55
- const ariaProps = buildAriaProps(aria)
56
- const dataProps = buildDataProps(data)
57
- const htmlProps = buildHtmlProps(htmlOptions)
58
- const classes = classnames(
59
- buildCss('pb_weekday_stacked_kit', align),
60
- globalProps(props),
61
- className
62
- )
63
-
64
- return (
65
- <div
66
- {...ariaProps}
67
- {...dataProps}
68
- {...htmlProps}
69
- className={classes}
70
- id={id}
71
- >
72
- <Caption dark={dark}>{getDayOfWeek(date, compact)}</Caption>
73
- <Title
74
- dark={dark}
75
- size={4}
76
- tag="span"
77
- text={getFormattedDate(date, variant)}
78
- />
79
- </div>
80
- )
81
- }
82
-
83
- export default WeekdayStacked
@@ -1,3 +0,0 @@
1
- <%= pb_rails("weekday_stacked", props: {variant: "expanded", compact: true}) %>
2
- <%= pb_rails("weekday_stacked", props: { variant: "day_only" , compact: true, align: "center"}) %>
3
- <%= pb_rails("weekday_stacked", props: { variant: "month_day", compact: true, align: "right" }) %>
@@ -1,27 +0,0 @@
1
- import React from 'react'
2
-
3
- import WeekdayStacked from '../_weekday_stacked'
4
-
5
- const WeekdayStackedCompact = (props) => (
6
- <div>
7
- <WeekdayStacked
8
- compact
9
- variant="day_only"
10
- {...props}
11
- />
12
- <WeekdayStacked
13
- align="center"
14
- compact
15
- variant="month_day"
16
- {...props}
17
- />
18
- <WeekdayStacked
19
- align="right"
20
- compact
21
- variant="expanded"
22
- {...props}
23
- />
24
- </div>
25
- )
26
-
27
- export default WeekdayStackedCompact
@@ -1,3 +0,0 @@
1
- <%= pb_rails("weekday_stacked") %>
2
- <%= pb_rails("weekday_stacked", props: {align: 'center'}) %>
3
- <%= pb_rails("weekday_stacked", props: {align: 'right'}) %>
@@ -1,22 +0,0 @@
1
- import React from 'react'
2
-
3
- import WeekdayStacked from '../_weekday_stacked'
4
-
5
- const WeekdayStackedDefault = (props) => (
6
- <div>
7
- <WeekdayStacked
8
- className="test"
9
- {...props}
10
- />
11
- <WeekdayStacked
12
- align="center"
13
- {...props}
14
- />
15
- <WeekdayStacked
16
- align="right"
17
- {...props}
18
- />
19
- </div>
20
- )
21
-
22
- export default WeekdayStackedDefault
@@ -1,3 +0,0 @@
1
- <%= pb_rails("weekday_stacked", props: {variant: "expanded", }) %>
2
- <%= pb_rails("weekday_stacked", props: { variant: "day_only", align: "center" }) %>
3
- <%= pb_rails("weekday_stacked", props: { variant: "month_day", align: "right" }) %>
@@ -1,24 +0,0 @@
1
- import React from 'react'
2
-
3
- import WeekdayStacked from '../_weekday_stacked'
4
-
5
- const WeekdayStackedVariant = (props) => (
6
- <div>
7
- <WeekdayStacked
8
- variant="day_only"
9
- {...props}
10
- />
11
- <WeekdayStacked
12
- align="center"
13
- variant="month_day"
14
- {...props}
15
- />
16
- <WeekdayStacked
17
- align="right"
18
- variant="expanded"
19
- {...props}
20
- />
21
- </div>
22
- )
23
-
24
- export default WeekdayStackedVariant
@@ -1,12 +0,0 @@
1
- examples:
2
-
3
- rails:
4
- - weekday_stacked_default: Default
5
- - weekday_stacked_compact: Compact
6
- - weekday_stacked_variant: Variant
7
-
8
-
9
- react:
10
- - weekday_stacked_default: Default
11
- - weekday_stacked_compact: Compact
12
- - weekday_stacked_variant: Variant
@@ -1,3 +0,0 @@
1
- export { default as WeekdayStackedDefault } from './_weekday_stacked_default.jsx'
2
- export { default as WeekdayStackedVariant } from './_weekday_stacked_variant.jsx'
3
- export { default as WeekdayStackedCompact } from './_weekday_stacked_compact.jsx'
@@ -1,4 +0,0 @@
1
- <%= pb_content_tag do %>
2
- <%= pb_rails("caption", props: {dark: object.dark, text: object.day_of_week}) %>
3
- <%= pb_rails("title", props: {dark: object.dark, size: 4, tag: "span", text: object.formatted_month_and_day}) %>
4
- <% end %>
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Playbook
4
- module PbWeekdayStacked
5
- class WeekdayStacked < Playbook::KitBase
6
- prop :align, type: Playbook::Props::Enum,
7
- values: %w[left center right],
8
- default: "left"
9
-
10
- prop :date, type: Playbook::Props::Date,
11
- default: ::Date.current
12
-
13
- prop :compact, type: Playbook::Props::Boolean,
14
- default: false
15
-
16
- prop :variant, type: Playbook::Props::Enum,
17
- values: %w[day_only expanded month_day],
18
- default: "month_day"
19
-
20
- def classname
21
- generate_classname("pb_weekday_stacked_kit", align)
22
- end
23
-
24
- def day_of_week
25
- day = Playbook::PbKit::PbDateTime.new(date)
26
- formatted_day = compact ? day.to_day_of_week_compact : day.to_day_of_week
27
- content_tag(:time, datetime: day.to_iso) do
28
- formatted_day
29
- end
30
- end
31
-
32
- def formatted_month_and_day
33
- case variant
34
- when "day_only" then day
35
- when "expanded" then month_and_day(format: "%b %-d")
36
- else month_and_day
37
- end
38
- end
39
-
40
- private
41
-
42
- def month_and_day(format: "%-m/%-d")
43
- month_and_day = Playbook::PbKit::PbDateTime.new(date)
44
- content_tag(:time, datetime: month_and_day.to_iso) do
45
- date.strftime(format)
46
- end
47
- end
48
-
49
- def day
50
- day = Playbook::PbKit::PbDateTime.new(date)
51
- content_tag(:time, datetime: day.to_iso) do
52
- day.to_unpadded_day
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,105 +0,0 @@
1
- import React from "react";
2
- import { render, screen } from "../utilities/test-utils";
3
-
4
- import WeekdayStacked from "./_weekday_stacked";
5
-
6
- const TEST_DATE = "01/01/2020 00:00:000 GMT-0500";
7
- jest.setSystemTime(new Date(TEST_DATE));
8
- const testId = "weekdaystacked-kit";
9
- const realDate = Date;
10
-
11
- beforeEach(() => {
12
- global.Date.now = jest.fn(() => new Date(TEST_DATE));
13
- });
14
-
15
- afterEach(() => {
16
- global.Date = realDate;
17
- });
18
-
19
- describe("WeekdayStacked Kit", () => {
20
- test("renders className", () => {
21
- render(
22
- <WeekdayStacked
23
- data={{ testid: testId }}
24
- />
25
- );
26
-
27
- const kit = screen.getByTestId(testId);
28
- expect(kit).toHaveClass("pb_weekday_stacked_kit_left");
29
- });
30
-
31
- test("renders Caption with weekday", () => {
32
- render(
33
- <WeekdayStacked
34
- data={{ testid: testId }}
35
- />
36
- );
37
-
38
- const kit = screen.getByTestId(testId);
39
- const text = kit.querySelector(".pb_caption_kit_md");
40
- expect(text.textContent).toEqual("Wed")
41
- });
42
-
43
- test("renders Title with date", () => {
44
- render(
45
- <WeekdayStacked
46
- data={{ testid: testId }}
47
- />
48
- );
49
-
50
- const kit = screen.getByTestId(testId);
51
- const text = kit.querySelector(".pb_title_kit_size_4");
52
- expect(text.textContent).toEqual("1/1")
53
- });
54
-
55
- test("renders compact prop", () => {
56
- render(
57
- <WeekdayStacked
58
- compact
59
- data={{ testid: testId }}
60
- />
61
- );
62
-
63
- const kit = screen.getByTestId(testId);
64
- const text = kit.querySelector(".pb_caption_kit_md");
65
- expect(text.textContent).toEqual("W")
66
- });
67
-
68
- test("renders align prop", () => {
69
- render(
70
- <WeekdayStacked
71
- align="left"
72
- data={{ testid: testId }}
73
- />
74
- );
75
-
76
- const kit = screen.getByTestId(testId);
77
- expect(kit).toHaveClass("pb_weekday_stacked_kit_left")
78
- });
79
-
80
- test("renders day_only variant prop", () => {
81
- render(
82
- <WeekdayStacked
83
- data={{ testid: testId }}
84
- variant="day_only"
85
- />
86
- );
87
-
88
- const kit = screen.getByTestId(testId);
89
- const text = kit.querySelector(".pb_title_kit_size_4");
90
- expect(text.textContent).toEqual("1")
91
- });
92
-
93
- test("renders expanded variant prop", () => {
94
- render(
95
- <WeekdayStacked
96
- data={{ testid: testId }}
97
- variant="expanded"
98
- />
99
- );
100
-
101
- const kit = screen.getByTestId(testId);
102
- const text = kit.querySelector(".pb_title_kit_size_4");
103
- expect(text.textContent).toEqual("Jan 1")
104
- });
105
- });