panda_cms 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of panda_cms might be problematic. Click here for more details.

Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/app/views/panda_cms/shared/_favicons.html.erb +7 -7
  3. data/app/views/panda_cms/shared/_header.html.erb +1 -4
  4. data/config/importmap.rb +8 -5
  5. data/lib/panda_cms/engine.rb +2 -11
  6. data/lib/panda_cms/version.rb +1 -1
  7. data/lib/tasks/panda_cms.rake +7 -0
  8. data/public/panda-cms-assets/{site.webmanifest → favicons/site.webmanifest} +1 -1
  9. data/public/panda-cms-assets/javascripts/base.js +37 -0
  10. data/public/panda-cms-assets/javascripts/controllers/menu_controller.js +19 -0
  11. data/public/panda-cms-assets/javascripts/controllers/rich_text_editor_controller.js +59 -0
  12. data/public/panda-cms-assets/javascripts/controllers/text_field_update_controller.js +23 -0
  13. data/public/panda-cms-assets/javascripts/vendor/stimulus-components-rails-nested-form.js +2 -0
  14. data/public/panda-cms-assets/javascripts/vendor/tailwindcss-stimulus-components.js +2 -0
  15. metadata +26 -20
  16. /data/app/javascript/{panda_cms/base.js → base.js} +0 -0
  17. /data/app/javascript/{panda_cms/controllers → controllers}/menu_controller.js +0 -0
  18. /data/app/javascript/{panda_cms/controllers → controllers}/rich_text_editor_controller.js +0 -0
  19. /data/app/javascript/{panda_cms/controllers → controllers}/text_field_update_controller.js +0 -0
  20. /data/app/javascript/{panda_cms/vendor → vendor}/stimulus-components-rails-nested-form.js +0 -0
  21. /data/app/javascript/{panda_cms/vendor → vendor}/tailwindcss-stimulus-components.js +0 -0
  22. /data/public/panda-cms-assets/{android-chrome-192x192.png → favicons/android-chrome-192x192.png} +0 -0
  23. /data/public/panda-cms-assets/{android-chrome-512x512.png → favicons/android-chrome-512x512.png} +0 -0
  24. /data/public/panda-cms-assets/{apple-touch-icon.png → favicons/apple-touch-icon.png} +0 -0
  25. /data/public/panda-cms-assets/{browserconfig.xml → favicons/browserconfig.xml} +0 -0
  26. /data/public/panda-cms-assets/{favicon-16x16.png → favicons/favicon-16x16.png} +0 -0
  27. /data/public/panda-cms-assets/{favicon-32x32.png → favicons/favicon-32x32.png} +0 -0
  28. /data/public/panda-cms-assets/{favicon.ico → favicons/favicon.ico} +0 -0
  29. /data/public/panda-cms-assets/{mstile-150x150.png → favicons/mstile-150x150.png} +0 -0
  30. /data/public/panda-cms-assets/{safari-pinned-tab.svg → favicons/safari-pinned-tab.svg} +0 -0
  31. /data/public/panda-cms-assets/{editable.js → javascripts/embed/editable.js} +0 -0
  32. /data/public/panda-cms-assets/{stimulus-loading.js → javascripts/vendor/stimulus-loading.js} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e225c732370a1c93ab1d470ca208adefd5877236dbc88a8ee960205cfc0b1f0
4
- data.tar.gz: 313a38c0e22f25d73d0de5c2345a6c5ebe729ff68aecb7b5dae438beabf03b82
3
+ metadata.gz: d6adc4ee3bc4b6563e2c14f094e267e6194ca4c99b901ff99fc5f4b836372872
4
+ data.tar.gz: 310debefbc532ea5fd593c0584e8571a52a47d8d65ab7688c79cb4d2c39116aa
5
5
  SHA512:
6
- metadata.gz: 1c4f93f37aa438c236172a15d6ed27953f11543eae6e825115b57712441c1790857b325d361f11d8d46249c764cc527ab7719901e5f740ef87ca739954cee19a
7
- data.tar.gz: debfa39d0fc82d950303db5755095b6639b47253bffc6e88ff479e968d4c2d16c4937007b4834de12394dabc004811ee39ca7dd0ed50714c86c380323bc7eff6
6
+ metadata.gz: 88b09f8b29b05e8430bd7701935c602fbb81e1ef75fa2bd5c9f5dfb4092e0d990c9b75c28338725d235041bf29cd7189b8c6ef682da1d3180ddca0b7c8c949ea
7
+ data.tar.gz: 759c310a451b23c637f9074fc39db38a89346115fe6bdb86423274b54b572d5b727753d4cfd60009301de8c5e0726b2247ec0ba7ef8f5d2b14ca368ca9144409
@@ -1,9 +1,9 @@
1
- <link rel="apple-touch-icon" sizes="180x180" href="/panda-cms-assets/apple-touch-icon.png">
2
- <link rel="icon" type="image/png" sizes="32x32" href="/panda-cms-assets/favicon-32x32.png">
3
- <link rel="icon" type="image/png" sizes="16x16" href="/panda-cms-assets/favicon-16x16.png">
4
- <link rel="manifest" href="/panda-cms-assets/site.webmanifest">
5
- <link rel="mask-icon" href="/panda-cms-assets/safari-pinned-tab.svg" color="#5bbad5">
6
- <link rel="shortcut icon" href="/panda-cms-assets/favicon.ico">
1
+ <link rel="apple-touch-icon" sizes="180x180" href="/panda-cms-assets/favicons/apple-touch-icon.png">
2
+ <link rel="icon" type="image/png" sizes="32x32" href="/panda-cms-assets/favicons/favicon-32x32.png">
3
+ <link rel="icon" type="image/png" sizes="16x16" href="/panda-cms-assets/favicons/favicon-16x16.png">
4
+ <link rel="manifest" href="/panda-cms-assets/favicons/site.webmanifest">
5
+ <link rel="mask-icon" href="/panda-cms-assets/favicons/safari-pinned-tab.svg" color="#5bbad5">
6
+ <link rel="shortcut icon" href="/panda-cms-assets/favicons/favicon.ico">
7
7
  <meta name="msapplication-TileColor" content="#b91d47">
8
- <meta name="msapplication-config" content="/panda-cms-assets/browserconfig.xml">
8
+ <meta name="msapplication-config" content="/panda-cms-assets/favicons/browserconfig.xml">
9
9
  <meta name="theme-color" content="#ffffff">
@@ -8,10 +8,7 @@
8
8
  <link rel="stylesheet" href="https://use.typekit.net/him4vgh.css">
9
9
  <script async src="https://ga.jspm.io/npm:es-module-shims@1.10.0/dist/es-module-shims.js" crossorigin="anonymous"></script>
10
10
  <%= stylesheet_link_tag "panda_cms", "data-turbo-track": "reload" %>
11
- <script type="importmap" data-turbo-track="reload"> <%# erblint:disable AllowedScriptType %>
12
- <%= raw(PandaCms::Engine.importmap.to_json(resolver: self)) %>
13
- </script>
14
- <%= javascript_import_module_tag "panda_cms/base" %>
11
+ <%= javascript_importmap_tags "panda_cms/base" %>
15
12
  <%= render "panda_cms/shared/favicons" %>
16
13
  </head>
17
14
 
data/config/importmap.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  pin "@hotwired/stimulus", to: "https://ga.jspm.io/npm:stimulus@3.2.2/dist/stimulus.js"
2
- # TODO: Pin to a URL on our CDN
3
- pin "@hotwired/stimulus-loading", to: "/panda-cms-assets/stimulus-loading.js" # 3.2.2
2
+ pin "@hotwired/stimulus-loading", to: "/panda-cms-assets/javascripts/vendor/stimulus-loading.js" # 3.2.2
4
3
 
5
- pin_all_from PandaCms::Engine.root.join("app/javascript/panda_cms/vendor"), under: "vendor", to: "panda_cms/vendor"
6
- pin_all_from PandaCms::Engine.root.join("app/javascript/panda_cms"), under: "panda_cms", to: "panda_cms"
7
- pin_all_from PandaCms::Engine.root.join("app/javascript/panda_cms/controllers"), under: "panda_cms/controllers", to: "panda_cms/controllers"
4
+ pin "panda_cms/vendor/stimulus-components-rails-nested-form", to: "/panda-cms-assets/javascripts/vendor/stimulus-components-rails-nested-form.js", preload: false
5
+ pin "panda_cms/vendor/tailwindcss-stimulus-components", to: "/panda-cms-assets/javascripts/vendor/tailwindcss-stimulus-components.js", preload: false
6
+ pin "panda_cms/controllers/menu_controller", to: "/panda-cms-assets/javascripts/controllers/menu_controller.js", preload: false
7
+ pin "panda_cms/controllers/rich_text_editor_controller", to: "/panda-cms-assets/javascripts/controllers/rich_text_editor_controller.js", preload: false
8
+ pin "panda_cms/controllers/text_field_update_controller", to: "/panda-cms-assets/javascripts/controllers/text_field_update_controller.js", preload: false
9
+ pin "panda_cms/embed/editable", to: "/panda-cms-assets/javascripts/embed/editable.js", preload: false
10
+ pin "panda_cms/base", to: "/panda-cms-assets/javascripts/base.js", preload: false
@@ -15,8 +15,6 @@ module PandaCms
15
15
  isolate_namespace PandaCms
16
16
  engine_name "panda_cms"
17
17
 
18
- attr_accessor :importmap
19
-
20
18
  config.to_prepare do
21
19
  ApplicationController.helper(::ApplicationHelper)
22
20
  end
@@ -44,15 +42,8 @@ module PandaCms
44
42
 
45
43
  # Create an importmap for the engine's JS
46
44
  initializer "panda_cms.importmap", before: "importmap" do |app|
47
- map = Importmap::Map.new
48
- map.draw(PandaCms::Engine.root.join("config/importmap.rb"))
49
- map.cache_sweeper(watches: PandaCms::Engine.root.join("app/javascript"))
50
- # TODO: Sort in production?
51
- app.config.assets.paths << PandaCms::Engine.root.join("app/javascript") if Rails.env.development?
52
- PandaCms::Engine.importmap = map
53
- ActiveSupport.on_load(:action_controller_base, run_once: true) do
54
- before_action { PandaCms::Engine.importmap.cache_sweeper.execute_if_updated }
55
- end
45
+ app.config.importmap.cache_sweeper(watches: PandaCms::Engine.root.join("public/panda-cms-assets"))
46
+ app.config.importmap.paths << PandaCms::Engine.root.join("config/importmap.rb")
56
47
  end
57
48
 
58
49
  # Append routes to the routes file
@@ -1,3 +1,3 @@
1
1
  module PandaCms
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -5,6 +5,13 @@ ENV["TAILWIND_PATH"] ||= Tailwindcss::Engine.root.join("exe/tailwindcss").to_s
5
5
 
6
6
  namespace :panda_cms do
7
7
  namespace :assets do
8
+ desc "Compile assets for release"
9
+ task :compile do
10
+ # Copy all the JS files into public
11
+ admin_js_path = PandaCms::Engine.root.join("app/javascript/panda_cms")
12
+ FileUtils.cp_r "#{admin_js_path}/.", PandaCms::Engine.root.join("public/panda-cms-assets/javascripts")
13
+ end
14
+
8
15
  desc "Build admin assets for Panda CMS"
9
16
  task :admin do
10
17
  run_tailwind(
@@ -3,7 +3,7 @@
3
3
  "short_name": "",
4
4
  "icons": [
5
5
  {
6
- "src": "/panda-cms-assets/android-chrome-192x192.png",
6
+ "src": "/panda-cms-assets/favicons/android-chrome-192x192.png",
7
7
  "sizes": "192x192",
8
8
  "type": "image/png"
9
9
  }
@@ -0,0 +1,37 @@
1
+ import { Application as PandaCmsApplication } from "@hotwired/stimulus";
2
+
3
+ const panda_cms = PandaCmsApplication.start();
4
+
5
+ // Configure Stimulus development experience
6
+ panda_cms.debug = location.hostname === "localhost";
7
+ window.pandaStimulus = panda_cms;
8
+
9
+ export { panda_cms };
10
+
11
+ // Eager load all controllers defined in the import map under controllers/**/*_controller
12
+ import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading";
13
+ eagerLoadControllersFrom("panda_cms/controllers", panda_cms);
14
+
15
+ import {
16
+ Alert,
17
+ Autosave,
18
+ ColorPreview,
19
+ Dropdown,
20
+ Modal,
21
+ Tabs,
22
+ Popover,
23
+ Toggle,
24
+ Slideover,
25
+ } from "panda_cms/vendor/tailwindcss-stimulus-components";
26
+ panda_cms.register("alert", Alert);
27
+ panda_cms.register("autosave", Autosave);
28
+ panda_cms.register("color-preview", ColorPreview);
29
+ panda_cms.register("dropdown", Dropdown);
30
+ panda_cms.register("modal", Modal);
31
+ panda_cms.register("popover", Popover);
32
+ panda_cms.register("slideover", Slideover);
33
+ panda_cms.register("tabs", Tabs);
34
+ panda_cms.register("toggle", Toggle);
35
+
36
+ import RailsNestedForm from "panda_cms/vendor/stimulus-components-rails-nested-form";
37
+ panda_cms.register("nested-form", RailsNestedForm);
@@ -0,0 +1,19 @@
1
+ import { Controller as PandaCmsController } from "@hotwired/stimulus"
2
+
3
+ export default class extends PandaCmsController {
4
+ static targets = ["pandaCmsMenu"]
5
+ static values = {
6
+ open: { type: Boolean, default: false }
7
+ }
8
+
9
+ toggle(event) {
10
+ this.openValue = !this.openValue
11
+ this.animate()
12
+ }
13
+
14
+ animate() {
15
+ this.toggleableTargets.forEach(target => {
16
+ transition(target, this.openValue)
17
+ })
18
+ }
19
+ }
@@ -0,0 +1,59 @@
1
+ import { Controller as PandaCmsController } from "@hotwired/stimulus";
2
+
3
+ export default class extends PandaCmsController {
4
+ static targets = ["container", "hidden", "toolbar", "form"];
5
+
6
+ connect() {
7
+ this.quillInit();
8
+ }
9
+
10
+ /**
11
+ * Fire up quill wyswig editor
12
+ */
13
+ quillInit() {
14
+ const quill = new Quill(this.containerTarget, this.quillOption);
15
+ let _this = this;
16
+
17
+ // While we type, copy the text to our hidden form field so it can be saved.
18
+ quill.on("text-change", function (delta) {
19
+ _this.hiddenTarget.value = quill.root.innerHTML;
20
+ });
21
+
22
+ // Capture focus on and off events
23
+ quill.on("selection-change", function (range, oldRange, source) {
24
+ if (range === null && oldRange !== null) {
25
+ _this.onFocusOut();
26
+ } else if (range !== null && oldRange === null) _this.onFocus();
27
+ });
28
+ }
29
+
30
+ /**
31
+ * Fires when the editor receives focus
32
+ */
33
+ onFocus() {
34
+ // Add a border and reveal the toolbar
35
+ this.element.classList.add("border-gray-200");
36
+ this.toolbarTarget.classList.add("opacity-100");
37
+ }
38
+
39
+ /**
40
+ * Fires when the editor loses focus
41
+ */
42
+ onFocusOut() {
43
+ // Hide the border and toolbar
44
+ this.element.classList.remove("border-gray-200");
45
+ this.toolbarTarget.classList.remove("opacity-100");
46
+
47
+ // Submit the form to save our updates
48
+ this.formTarget.requestSubmit();
49
+ }
50
+
51
+ // Quill configuration options
52
+ get quillOption() {
53
+ return {
54
+ modules: {
55
+ toolbar: this.toolbarTarget,
56
+ },
57
+ };
58
+ }
59
+ }
@@ -0,0 +1,23 @@
1
+ import { Controller as PandaCmsController } from "@hotwired/stimulus"
2
+ export default class extends PandaCmsController {
3
+ static targets = [ "existing_root", "input_select", "input_text", "output_text" ]
4
+
5
+ connect() {
6
+ }
7
+
8
+ generatePath() {
9
+ this.output_textTarget.value = "/" + this.createSlug(this.input_textTarget.value);
10
+ }
11
+
12
+ setPrePath() {
13
+ this.parent_slugs = this.input_selectTarget.options[this.input_selectTarget.selectedIndex].text.match(/.*\((.*)\)$/)[1];
14
+ this.output_textTarget.previousSibling.innerHTML = (this.existing_rootTarget.value + this.parent_slugs).replace(/\/$/, '');;
15
+ }
16
+
17
+ createSlug(input) {
18
+ return input.toLowerCase().trim()
19
+ .replace(/[^\w\s-]/g, "-")
20
+ .replace(/&/, "and")
21
+ .replace(/[\s_-]+/g, "-");
22
+ }
23
+ }
@@ -0,0 +1,2 @@
1
+ import{Controller as e}from"@hotwired/stimulus";const t=class _RailsNestedForm extends e{add(e){e.preventDefault();const t=this.templateTarget.innerHTML.replace(/NEW_RECORD/g,(new Date).getTime().toString());this.targetTarget.insertAdjacentHTML("beforebegin",t);const r=new CustomEvent("rails-nested-form:add",{bubbles:!0});this.element.dispatchEvent(r)}remove(e){e.preventDefault();const t=e.target.closest(this.wrapperSelectorValue);if(t.dataset.newRecord==="true")t.remove();else{t.style.display="none";const e=t.querySelector("input[name*='_destroy']");e.value="1"}const r=new CustomEvent("rails-nested-form:remove",{bubbles:!0});this.element.dispatchEvent(r)}};t.targets=["target","template"],t.values={wrapperSelector:{type:String,default:".nested-form-wrapper"}};let r=t;export{r as default};
2
+
@@ -0,0 +1,2 @@
1
+ import{Controller as e}from"@hotwired/stimulus";var t=Object.defineProperty;var V=(e,a,i)=>a in e?t(e,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[a]=i;var s=(e,t,a)=>(V(e,typeof t!="symbol"?t+"":t,a),a);async function r(e,t,a={}){t?T(e,a):b(e,a)}async function T(e,t={}){let a=e.dataset.transitionEnter||t.enter||"enter",i=e.dataset.transitionEnterFrom||t.enterFrom||"enter-from",n=e.dataset.transitionEnterTo||t.enterTo||"enter-to",o=e.dataset.toggleClass||t.toggleClass||"hidden";e.classList.add(...a.split(" ")),e.classList.add(...i.split(" ")),e.classList.remove(...n.split(" ")),e.classList.remove(...o.split(" ")),await v(),e.classList.remove(...i.split(" ")),e.classList.add(...n.split(" "));try{await x(e)}finally{e.classList.remove(...a.split(" "))}}async function b(e,t={}){let a=e.dataset.transitionLeave||t.leave||"leave",i=e.dataset.transitionLeaveFrom||t.leaveFrom||"leave-from",n=e.dataset.transitionLeaveTo||t.leaveTo||"leave-to",o=e.dataset.toggleClass||t.toggle||"hidden";e.classList.add(...a.split(" ")),e.classList.add(...i.split(" ")),e.classList.remove(...n.split(" ")),await v(),e.classList.remove(...i.split(" ")),e.classList.add(...n.split(" "));try{await x(e)}finally{e.classList.remove(...a.split(" ")),e.classList.add(...o.split(" "))}}function v(){return new Promise((e=>{requestAnimationFrame((()=>{requestAnimationFrame(e)}))}))}function x(e){return Promise.all(e.getAnimations().map((e=>e.finished)))}var a=class extends e{connect(){setTimeout((()=>{T(this.element)}),this.showDelayValue),this.hasDismissAfterValue&&setTimeout((()=>{this.close()}),this.dismissAfterValue)}close(){b(this.element).then((()=>{this.element.remove()}))}};s(a,"values",{dismissAfter:Number,showDelay:{type:Number,default:0}});var i=class extends e{connect(){this.timeout=null}save(){clearTimeout(this.timeout),this.timeout=setTimeout((()=>{this.statusTarget.textContent=this.submittingTextValue,this.formTarget.requestSubmit()}),this.submitDurationValue)}success(){this.setStatus(this.successTextValue)}error(){this.setStatus(this.errorTextValue)}setStatus(e){this.statusTarget.textContent=e,this.timeout=setTimeout((()=>{this.statusTarget.textContent=""}),this.statusDurationValue)}};s(i,"targets",["form","status"]),s(i,"values",{submitDuration:{type:Number,default:1e3},statusDuration:{type:Number,default:2e3},submittingText:{type:String,default:"Saving..."},successText:{type:String,default:"Saved!"},errorText:{type:String,default:"Unable to save."}});var n=class extends e{update(){this.preview=this.colorTarget.value}set preview(e){this.previewTarget.style[this.styleValue]=e;let t=this._getContrastYIQ(e);this.styleValue==="color"?this.previewTarget.style.backgroundColor=t:this.previewTarget.style.color=t}_getContrastYIQ(e){e=e.replace("#","");let t=128,a=parseInt(e.substr(0,2),16),i=parseInt(e.substr(2,2),16),n=parseInt(e.substr(4,2),16);return(a*299+i*587+n*114)/1e3>=t?"#000":"#fff"}};s(n,"targets",["preview","color"]),s(n,"values",{style:{type:String,default:"backgroundColor"}});var o=class extends e{connect(){document.addEventListener("turbo:before-cache",this.beforeCache.bind(this))}disconnect(){document.removeEventListener("turbo:before-cache",this.beforeCache.bind(this))}openValueChanged(){r(this.menuTarget,this.openValue,this.transitionOptions),this.openValue===!0&&this.hasMenuItemTarget&&this.menuItemTargets[0].focus()}show(){this.openValue=!0}close(){this.openValue=!1}hide(e){this.closeOnClickOutsideValue&&e.target.nodeType&&this.element.contains(e.target)===!1&&this.openValue&&(this.openValue=!1),this.closeOnEscapeValue&&e.key==="Escape"&&this.openValue&&(this.openValue=!1)}toggle(){this.openValue=!this.openValue}nextItem(e){e.preventDefault(),this.menuItemTargets[this.nextIndex].focus()}previousItem(e){e.preventDefault(),this.menuItemTargets[this.previousIndex].focus()}get currentItemIndex(){return this.menuItemTargets.indexOf(document.activeElement)}get nextIndex(){return Math.min(this.currentItemIndex+1,this.menuItemTargets.length-1)}get previousIndex(){return Math.max(this.currentItemIndex-1,0)}get transitionOptions(){return{enter:this.hasEnterClass?this.enterClass:"transition ease-out duration-100",enterFrom:this.hasEnterFromClass?this.enterFromClass:"transform opacity-0 scale-95",enterTo:this.hasEnterToClass?this.enterToClass:"transform opacity-100 scale-100",leave:this.hasLeaveClass?this.leaveClass:"transition ease-in duration-75",leaveFrom:this.hasLeaveFromClass?this.leaveFromClass:"transform opacity-100 scale-100",leaveTo:this.hasLeaveToClass?this.leaveToClass:"transform opacity-0 scale-95",toggleClass:this.hasToggleClass?this.toggleClass:"hidden"}}beforeCache(){this.openValue=!1,this.menuTarget.classList.add("hidden")}};s(o,"targets",["menu","button","menuItem"]),s(o,"values",{open:{type:Boolean,default:!1},closeOnEscape:{type:Boolean,default:!0},closeOnClickOutside:{type:Boolean,default:!0}}),s(o,"classes",["enter","enterFrom","enterTo","leave","leaveFrom","leaveTo","toggle"]);var l=class extends e{connect(){this.openValue&&this.open(),document.addEventListener("turbo:before-cache",this.beforeCache.bind(this))}disconnect(){document.removeEventListener("turbo:before-cache",this.beforeCache.bind(this))}open(){this.dialogTarget.showModal()}close(){this.dialogTarget.setAttribute("closing",""),Promise.all(this.dialogTarget.getAnimations().map((e=>e.finished))).then((()=>{this.dialogTarget.removeAttribute("closing"),this.dialogTarget.close()}))}backdropClose(e){e.target.nodeName=="DIALOG"&&this.close()}show(){this.dialogTarget.show()}hide(){this.close()}beforeCache(){this.close()}};s(l,"targets",["dialog"]),s(l,"values",{open:Boolean});var h=class extends e{openValueChanged(){r(this.contentTarget,this.openValue),this.shouldAutoDismiss&&this.scheduleDismissal()}show(e){this.shouldAutoDismiss&&this.scheduleDismissal(),this.openValue=!0}hide(){this.openValue=!1}toggle(){this.openValue=!this.openValue}get shouldAutoDismiss(){return this.openValue&&this.hasDismissAfterValue}scheduleDismissal(){this.hasDismissAfterValue&&(this.cancelDismissal(),this.timeoutId=setTimeout((()=>{this.hide(),this.timeoutId=void 0}),this.dismissAfterValue))}cancelDismissal(){typeof this.timeoutId=="number"&&(clearTimeout(this.timeoutId),this.timeoutId=void 0)}};s(h,"targets",["content"]),s(h,"values",{dismissAfter:Number,open:{type:Boolean,default:!1}});var u=class extends e{connect(){this.openValue&&this.open(),document.addEventListener("turbo:before-cache",this.beforeCache.bind(this))}disconnect(){document.removeEventListener("turbo:before-cache",this.beforeCache.bind(this))}open(){this.dialogTarget.showModal()}close(){this.dialogTarget.setAttribute("closing",""),Promise.all(this.dialogTarget.getAnimations().map((e=>e.finished))).then((()=>{this.dialogTarget.removeAttribute("closing"),this.dialogTarget.close()}))}backdropClose(e){e.target.nodeName=="DIALOG"&&this.close()}show(){this.open()}hide(){this.close()}beforeCache(){this.close()}};s(u,"targets",["dialog"]),s(u,"values",{open:Boolean});var c=class extends e{initialize(){this.anchor&&(this.indexValue=this.tabTargets.findIndex((e=>e.id===this.anchor)))}connect(){this.showTab()}change(e){e.currentTarget.tagName==="SELECT"?this.indexValue=e.currentTarget.selectedIndex:e.currentTarget.dataset.index?this.indexValue=e.currentTarget.dataset.index:e.currentTarget.dataset.id?this.indexValue=this.tabTargets.findIndex((t=>t.id==e.currentTarget.dataset.id)):this.indexValue=this.tabTargets.indexOf(e.currentTarget)}nextTab(){this.indexValue=Math.min(this.indexValue+1,this.tabsCount-1)}previousTab(){this.indexValue=Math.max(this.indexValue-1,0)}firstTab(){this.indexValue=0}lastTab(){this.indexValue=this.tabsCount-1}indexValueChanged(){if(this.showTab(),this.dispatch("tab-change",{target:this.tabTargets[this.indexValue],detail:{activeIndex:this.indexValue}}),this.updateAnchorValue){let e=this.tabTargets[this.indexValue].id;if(this.scrollToAnchorValue)location.hash=e;else{let t=window.location.href.split("#")[0]+"#"+e;history.replaceState({},document.title,t)}}}showTab(){this.panelTargets.forEach(((e,t)=>{let a=this.tabTargets[t];t===this.indexValue?(e.classList.remove("hidden"),a.ariaSelected="true",a.dataset.active=!0,this.hasInactiveTabClass&&a?.classList?.remove(...this.inactiveTabClasses),this.hasActiveTabClass&&a?.classList?.add(...this.activeTabClasses)):(e.classList.add("hidden"),a.ariaSelected=null,delete a.dataset.active,this.hasActiveTabClass&&a?.classList?.remove(...this.activeTabClasses),this.hasInactiveTabClass&&a?.classList?.add(...this.inactiveTabClasses))})),this.hasSelectTarget&&(this.selectTarget.selectedIndex=this.indexValue),this.scrollActiveTabIntoViewValue&&this.scrollToActiveTab()}scrollToActiveTab(){let e=this.element.querySelector("[aria-selected]");e&&e.scrollIntoView({inline:"center"})}get tabsCount(){return this.tabTargets.length}get anchor(){return document.URL.split("#").length>1?document.URL.split("#")[1]:null}};s(c,"classes",["activeTab","inactiveTab"]),s(c,"targets",["tab","panel","select"]),s(c,"values",{index:0,updateAnchor:Boolean,scrollToAnchor:Boolean,scrollActiveTabIntoView:Boolean});var d=class extends e{toggle(e){this.openValue=!this.openValue,this.animate()}toggleInput(e){this.openValue=e.target.checked,this.animate()}hide(){this.openValue=!1,this.animate()}show(){this.openValue=!0,this.animate()}animate(){this.toggleableTargets.forEach((e=>{r(e,this.openValue)}))}};s(d,"targets",["toggleable"]),s(d,"values",{open:{type:Boolean,default:!1}});export{a as Alert,i as Autosave,n as ColorPreview,o as Dropdown,l as Modal,h as Popover,u as Slideover,c as Tabs,d as Toggle};
2
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Otaina Limited
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-18 00:00:00.000000000 Z
11
+ date: 2024-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activestorage-office-previewer
@@ -713,12 +713,12 @@ files:
713
713
  - app/helpers/panda_cms/application_helper.rb
714
714
  - app/helpers/panda_cms/pages_helper.rb
715
715
  - app/helpers/panda_cms/theme_helper.rb
716
- - app/javascript/panda_cms/base.js
717
- - app/javascript/panda_cms/controllers/menu_controller.js
718
- - app/javascript/panda_cms/controllers/rich_text_editor_controller.js
719
- - app/javascript/panda_cms/controllers/text_field_update_controller.js
720
- - app/javascript/panda_cms/vendor/stimulus-components-rails-nested-form.js
721
- - app/javascript/panda_cms/vendor/tailwindcss-stimulus-components.js
716
+ - app/javascript/base.js
717
+ - app/javascript/controllers/menu_controller.js
718
+ - app/javascript/controllers/rich_text_editor_controller.js
719
+ - app/javascript/controllers/text_field_update_controller.js
720
+ - app/javascript/vendor/stimulus-components-rails-nested-form.js
721
+ - app/javascript/vendor/tailwindcss-stimulus-components.js
722
722
  - app/jobs/panda_cms/application_job.rb
723
723
  - app/lib/panda_cms/demo_site_generator.rb
724
724
  - app/lib/panda_cms/slug.rb
@@ -801,20 +801,26 @@ files:
801
801
  - lib/templates/erb/scaffold/new.html.erb.tt
802
802
  - lib/templates/erb/scaffold/partial.html.erb.tt
803
803
  - lib/templates/erb/scaffold/show.html.erb.tt
804
- - public/panda-cms-assets/android-chrome-192x192.png
805
- - public/panda-cms-assets/android-chrome-512x512.png
806
- - public/panda-cms-assets/apple-touch-icon.png
807
- - public/panda-cms-assets/browserconfig.xml
808
- - public/panda-cms-assets/editable.js
809
- - public/panda-cms-assets/favicon-16x16.png
810
- - public/panda-cms-assets/favicon-32x32.png
811
- - public/panda-cms-assets/favicon.ico
812
- - public/panda-cms-assets/mstile-150x150.png
804
+ - public/panda-cms-assets/favicons/android-chrome-192x192.png
805
+ - public/panda-cms-assets/favicons/android-chrome-512x512.png
806
+ - public/panda-cms-assets/favicons/apple-touch-icon.png
807
+ - public/panda-cms-assets/favicons/browserconfig.xml
808
+ - public/panda-cms-assets/favicons/favicon-16x16.png
809
+ - public/panda-cms-assets/favicons/favicon-32x32.png
810
+ - public/panda-cms-assets/favicons/favicon.ico
811
+ - public/panda-cms-assets/favicons/mstile-150x150.png
812
+ - public/panda-cms-assets/favicons/safari-pinned-tab.svg
813
+ - public/panda-cms-assets/favicons/site.webmanifest
814
+ - public/panda-cms-assets/javascripts/base.js
815
+ - public/panda-cms-assets/javascripts/controllers/menu_controller.js
816
+ - public/panda-cms-assets/javascripts/controllers/rich_text_editor_controller.js
817
+ - public/panda-cms-assets/javascripts/controllers/text_field_update_controller.js
818
+ - public/panda-cms-assets/javascripts/embed/editable.js
819
+ - public/panda-cms-assets/javascripts/vendor/stimulus-components-rails-nested-form.js
820
+ - public/panda-cms-assets/javascripts/vendor/stimulus-loading.js
821
+ - public/panda-cms-assets/javascripts/vendor/tailwindcss-stimulus-components.js
813
822
  - public/panda-cms-assets/panda-logo-screenprint.png
814
823
  - public/panda-cms-assets/panda-nav.png
815
- - public/panda-cms-assets/safari-pinned-tab.svg
816
- - public/panda-cms-assets/site.webmanifest
817
- - public/panda-cms-assets/stimulus-loading.js
818
824
  homepage: https://pandacms.io
819
825
  licenses:
820
826
  - BSD-3-Clause
File without changes