lookbook 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 741dcc6296e79ba365a64945fb70b7ba7e8b8df2eee9e83e72ef4e32c619b2fc
4
- data.tar.gz: aa5d6647abc755e54b37837847f5929803eba7545272e6c33b887f2f7c5ef54e
3
+ metadata.gz: fd24f301fb1e05131ba58a2d236b15155f38b372c52ada4823ea6f76111dc0b1
4
+ data.tar.gz: 8675198f147aa93461a89964ad2b28461facdd672088b3edfe0880ea1b293545
5
5
  SHA512:
6
- metadata.gz: d19a7567121be4be2c010f61d9c7d62ecff33d53d034a138124516883cbb190102aa0f8c9e9457a0aaf1d33c6d9d5250d3a60ad507af9973348f3c08c03c26bb
7
- data.tar.gz: 8cc77046623125e88550cfd7ff4dd626a2deda064fee6cf3171d5a5cd59bed8ec2277e8091d48d995763db7b3fe66c730e99bde1380a4e5703986e7cc0808ff4
6
+ metadata.gz: 5a9e80161cf8880083c2138144304dfc5427478c8114073f9409e3fb883eddf9abe7e055aea33b16625316c15be15fd139b8ab3607d808ff90419b5ad95b4eab
7
+ data.tar.gz: 1e1836fdad458167f63e3736d3d99107b1a0346da530fe57f9be03eb188c029d5891c8534999475673aa78fd02c645c37edb181b5960165316172bcf5cded59b
@@ -31,11 +31,19 @@ module Lookbook
31
31
  nil
32
32
  end
33
33
 
34
+ def alpine_encode(data)
35
+ if data.is_a? String
36
+ "\'#{json_escape data}\'"
37
+ else
38
+ json_escape data.to_json.tr("\"", "\'")
39
+ end
40
+ end
41
+
34
42
  def prepare_alpine_data(x_data = nil)
35
43
  alpine_component_name = x_data || @html_attrs&.dig(:"x-data") || alpine_component
36
44
  if alpine_component_name.present?
37
- args = Array.wrap(alpine_data)
38
- args.any? ? "#{alpine_component_name}(#{safe_join(args)})" : alpine_component_name
45
+ args = Array.wrap(alpine_data).compact
46
+ args.any? ? "#{alpine_component_name}(#{args.join(",")})" : alpine_component_name
39
47
  end
40
48
  end
41
49
  end
@@ -13,7 +13,7 @@ module Lookbook
13
13
  protected
14
14
 
15
15
  def alpine_data
16
- content ? nil : @target.to_json
16
+ content ? nil : alpine_encode(@target)
17
17
  end
18
18
 
19
19
  def alpine_component
@@ -2,15 +2,12 @@ module Lookbook
2
2
  class DimensionsDisplay::Component < Lookbook::BaseComponent
3
3
  def initialize(target:, **html_attrs)
4
4
  @target = target
5
+ @alpine_data = alpine_encode(@target)
5
6
  super(**html_attrs)
6
7
  end
7
8
 
8
9
  protected
9
10
 
10
- def alpine_data
11
- @target.to_json
12
- end
13
-
14
11
  def alpine_component
15
12
  "dimensionsDisplayComponent"
16
13
  end
@@ -20,7 +20,7 @@ module Lookbook
20
20
  end
21
21
 
22
22
  def alpine_data
23
- [@id.to_json, "$store.pages.embeds"].join(",")
23
+ [alpine_encode(@id), "$store.pages.embeds"].join(",")
24
24
  end
25
25
 
26
26
  def alpine_component
@@ -1,7 +1,7 @@
1
1
  module Lookbook
2
2
  class Icon::Component < Lookbook::BaseComponent
3
3
  def initialize(name:, size: 4, **html_attrs)
4
- @icon_name = name.is_a?(Symbol) ? name.to_s.tr("_", "-").to_json : name
4
+ @alpine_data = name.is_a?(Symbol) ? alpine_encode(name.to_s.tr("_", "-")) : name
5
5
  @size = size || 4
6
6
  super(**html_attrs)
7
7
  end
@@ -12,10 +12,6 @@ module Lookbook
12
12
 
13
13
  protected
14
14
 
15
- def alpine_data
16
- @icon_name
17
- end
18
-
19
15
  def alpine_component
20
16
  "iconComponent"
21
17
  end
@@ -78,10 +78,10 @@ module Lookbook
78
78
  protected
79
79
 
80
80
  def alpine_data
81
- {
81
+ alpine_encode({
82
82
  id: @item.id,
83
83
  matchers: item.is_a?(Lookbook::Collection) ? nil : item.matchers
84
- }.to_json
84
+ })
85
85
  end
86
86
 
87
87
  def alpine_component
@@ -33,7 +33,7 @@ module Lookbook
33
33
  protected
34
34
 
35
35
  def alpine_data
36
- escaped_value = helpers.raw json_escape(value.to_json)
36
+ escaped_value = json_escape(value.to_json)
37
37
  "{name: '#{name}', value: #{escaped_value}}"
38
38
  end
39
39
 
@@ -6,7 +6,8 @@ module Lookbook
6
6
  render Lookbook::Icon::Component.new(name: name, **attrs)
7
7
  end
8
8
 
9
- def code(**attrs, &block)
9
+ def code(language = :html, **attrs, &block)
10
+ attrs[:language] = language
10
11
  render Lookbook::Code::Component.new(**attrs), &block
11
12
  end
12
13
 
@@ -171,7 +171,7 @@ module Lookbook
171
171
  def websocket
172
172
  config = Lookbook.config
173
173
  return @websocket unless @websocket.nil?
174
- return unless config.auto_refresh == true
174
+ return unless config.auto_refresh == true && !Rails.env.test?
175
175
  Lookbook.logger.info "Initializing websocket"
176
176
 
177
177
  cable = ActionCable::Server::Configuration.new
@@ -1,3 +1,3 @@
1
1
  module Lookbook
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4"
3
3
  end
@@ -7701,7 +7701,7 @@ function $5439cede634b2921$var$toCamel(s) {
7701
7701
  }
7702
7702
 
7703
7703
 
7704
- var $6d30a58562f349fe$exports = {};
7704
+ var $d865a31e17cd1079$exports = {};
7705
7705
  var $cbd28b10fa9798c7$exports = {};
7706
7706
 
7707
7707
  $parcel$defineInteropFlag($cbd28b10fa9798c7$exports);
@@ -11364,57 +11364,34 @@ function $99486586f6691564$export$2e2bcd8739ae039() {
11364
11364
  }
11365
11365
 
11366
11366
 
11367
- var $47a1c62621be0c54$exports = {};
11368
-
11369
- $parcel$defineInteropFlag($47a1c62621be0c54$exports);
11370
-
11371
- $parcel$export($47a1c62621be0c54$exports, "default", () => $47a1c62621be0c54$export$2e2bcd8739ae039);
11372
- var $122263eab94cad08$exports = {};
11373
-
11374
- $parcel$defineInteropFlag($122263eab94cad08$exports);
11375
-
11376
- $parcel$export($122263eab94cad08$exports, "initClipboard", () => $122263eab94cad08$export$c6684e6159b21de3);
11377
- $parcel$export($122263eab94cad08$exports, "default", () => $122263eab94cad08$export$2e2bcd8739ae039);
11378
-
11379
- function $122263eab94cad08$export$c6684e6159b21de3(context = {}) {
11380
- let copyTimeout = null;
11381
- return Object.assign(context, {
11382
- copied: false,
11383
- async copyToClipboard (target = null) {
11384
- let targetEl;
11385
- if (this.$refs.copyTarget) targetEl = this.$refs.copyTarget;
11386
- else if (typeof target === "string") targetEl = document.querySelector(target);
11387
- if (!targetEl) {
11388
- this.warn("Could not find copy target");
11389
- return false;
11390
- }
11391
- const content = (0, $7ae6ae39c2ec9059$export$6cb344a21ca18aec)(targetEl.innerHTML.trim());
11392
- await window.navigator.clipboard.writeText(content);
11393
- this.copied = true;
11394
- if (copyTimeout) clearTimeout(copyTimeout);
11395
- copyTimeout = setTimeout(()=>{
11396
- this.copied = false;
11397
- this.onCopyComplete();
11398
- }, 1000);
11399
- return content;
11400
- },
11401
- onCopyComplete () {}
11402
- });
11403
- }
11404
- function $122263eab94cad08$export$2e2bcd8739ae039() {
11405
- return $122263eab94cad08$export$c6684e6159b21de3({});
11406
- }
11367
+ var $e398acaded942bbe$exports = {};
11407
11368
 
11369
+ $parcel$defineInteropFlag($e398acaded942bbe$exports);
11408
11370
 
11371
+ $parcel$export($e398acaded942bbe$exports, "default", () => $e398acaded942bbe$export$2e2bcd8739ae039);
11409
11372
 
11410
- function $47a1c62621be0c54$export$2e2bcd8739ae039() {
11411
- const button = (0, $cbd28b10fa9798c7$export$2e2bcd8739ae039)();
11373
+ function $e398acaded942bbe$export$2e2bcd8739ae039(targetSelector) {
11412
11374
  return {
11413
- ...button,
11414
- copied: false,
11375
+ width: 0,
11376
+ height: 0,
11377
+ resizing: false,
11378
+ target: null,
11415
11379
  init () {
11416
- button.init.bind(this)();
11417
- (0, $122263eab94cad08$export$c6684e6159b21de3)(this);
11380
+ this.target = document.querySelector(targetSelector);
11381
+ if (this.target) {
11382
+ this.width = Math.round(this.target.clientWidth);
11383
+ this.height = Math.round(this.target.clientHeight);
11384
+ this.createObserver();
11385
+ }
11386
+ },
11387
+ createObserver () {
11388
+ if (this.target) this.observer = (0, $9930d46698775b42$export$a2214cc2adb2dc44)(document.querySelector(targetSelector), ({ width: width , height: height })=>{
11389
+ this.width = width;
11390
+ this.height = height;
11391
+ });
11392
+ },
11393
+ tearDown () {
11394
+ if (this.observer) this.observer.disconnect();
11418
11395
  }
11419
11396
  };
11420
11397
  }
@@ -12285,39 +12262,6 @@ function $e1f51f020443edd4$export$2e2bcd8739ae039(id, embedStore) {
12285
12262
  }
12286
12263
 
12287
12264
 
12288
- var $e398acaded942bbe$exports = {};
12289
-
12290
- $parcel$defineInteropFlag($e398acaded942bbe$exports);
12291
-
12292
- $parcel$export($e398acaded942bbe$exports, "default", () => $e398acaded942bbe$export$2e2bcd8739ae039);
12293
-
12294
- function $e398acaded942bbe$export$2e2bcd8739ae039(targetSelector) {
12295
- return {
12296
- width: 0,
12297
- height: 0,
12298
- resizing: false,
12299
- target: null,
12300
- init () {
12301
- this.target = document.querySelector(targetSelector);
12302
- if (this.target) {
12303
- this.width = Math.round(this.target.clientWidth);
12304
- this.height = Math.round(this.target.clientHeight);
12305
- this.createObserver();
12306
- }
12307
- },
12308
- createObserver () {
12309
- if (this.target) this.observer = (0, $9930d46698775b42$export$a2214cc2adb2dc44)(document.querySelector(targetSelector), ({ width: width , height: height })=>{
12310
- this.width = width;
12311
- this.height = height;
12312
- });
12313
- },
12314
- tearDown () {
12315
- if (this.observer) this.observer.disconnect();
12316
- }
12317
- };
12318
- }
12319
-
12320
-
12321
12265
  var $e9904a14dabf652d$exports = {};
12322
12266
 
12323
12267
  $parcel$defineInteropFlag($e9904a14dabf652d$exports);
@@ -12343,6 +12287,62 @@ function $e9904a14dabf652d$export$2e2bcd8739ae039(store) {
12343
12287
  }
12344
12288
 
12345
12289
 
12290
+ var $47a1c62621be0c54$exports = {};
12291
+
12292
+ $parcel$defineInteropFlag($47a1c62621be0c54$exports);
12293
+
12294
+ $parcel$export($47a1c62621be0c54$exports, "default", () => $47a1c62621be0c54$export$2e2bcd8739ae039);
12295
+ var $122263eab94cad08$exports = {};
12296
+
12297
+ $parcel$defineInteropFlag($122263eab94cad08$exports);
12298
+
12299
+ $parcel$export($122263eab94cad08$exports, "initClipboard", () => $122263eab94cad08$export$c6684e6159b21de3);
12300
+ $parcel$export($122263eab94cad08$exports, "default", () => $122263eab94cad08$export$2e2bcd8739ae039);
12301
+
12302
+ function $122263eab94cad08$export$c6684e6159b21de3(context = {}) {
12303
+ let copyTimeout = null;
12304
+ return Object.assign(context, {
12305
+ copied: false,
12306
+ async copyToClipboard (target = null) {
12307
+ let targetEl;
12308
+ if (this.$refs.copyTarget) targetEl = this.$refs.copyTarget;
12309
+ else if (typeof target === "string") targetEl = document.querySelector(target);
12310
+ if (!targetEl) {
12311
+ this.warn("Could not find copy target");
12312
+ return false;
12313
+ }
12314
+ const content = (0, $7ae6ae39c2ec9059$export$6cb344a21ca18aec)(targetEl.innerHTML.trim());
12315
+ await window.navigator.clipboard.writeText(content);
12316
+ this.copied = true;
12317
+ if (copyTimeout) clearTimeout(copyTimeout);
12318
+ copyTimeout = setTimeout(()=>{
12319
+ this.copied = false;
12320
+ this.onCopyComplete();
12321
+ }, 1000);
12322
+ return content;
12323
+ },
12324
+ onCopyComplete () {}
12325
+ });
12326
+ }
12327
+ function $122263eab94cad08$export$2e2bcd8739ae039() {
12328
+ return $122263eab94cad08$export$c6684e6159b21de3({});
12329
+ }
12330
+
12331
+
12332
+
12333
+ function $47a1c62621be0c54$export$2e2bcd8739ae039() {
12334
+ const button = (0, $cbd28b10fa9798c7$export$2e2bcd8739ae039)();
12335
+ return {
12336
+ ...button,
12337
+ copied: false,
12338
+ init () {
12339
+ button.init.bind(this)();
12340
+ (0, $122263eab94cad08$export$c6684e6159b21de3)(this);
12341
+ }
12342
+ };
12343
+ }
12344
+
12345
+
12346
12346
  var $36506012e0c6e9e3$exports = {};
12347
12347
 
12348
12348
  $parcel$defineInteropFlag($36506012e0c6e9e3$exports);
@@ -12964,33 +12964,6 @@ function $506dabb2bf255b38$var$sizeSplits(sizes) {
12964
12964
  }
12965
12965
 
12966
12966
 
12967
- var $a87dacf5139b5e2f$exports = {};
12968
-
12969
- $parcel$defineInteropFlag($a87dacf5139b5e2f$exports);
12970
-
12971
- $parcel$export($a87dacf5139b5e2f$exports, "default", () => $a87dacf5139b5e2f$export$2e2bcd8739ae039);
12972
- function $a87dacf5139b5e2f$export$2e2bcd8739ae039(store) {
12973
- return {
12974
- get store () {
12975
- return store || this;
12976
- },
12977
- get id () {
12978
- return this.$root.id;
12979
- },
12980
- get panels () {
12981
- return Array.from(this.$refs.panels.children);
12982
- },
12983
- isActive (el) {
12984
- return this.store.activeTab === this._getRef(el);
12985
- },
12986
- // protected
12987
- _getRef (el) {
12988
- return el.getAttribute("x-ref");
12989
- }
12990
- };
12991
- }
12992
-
12993
-
12994
12967
  var $0db07828cadc68e0$exports = {};
12995
12968
 
12996
12969
  $parcel$defineInteropFlag($0db07828cadc68e0$exports);
@@ -13083,6 +13056,33 @@ function $0db07828cadc68e0$export$2e2bcd8739ae039(store) {
13083
13056
  }
13084
13057
 
13085
13058
 
13059
+ var $a87dacf5139b5e2f$exports = {};
13060
+
13061
+ $parcel$defineInteropFlag($a87dacf5139b5e2f$exports);
13062
+
13063
+ $parcel$export($a87dacf5139b5e2f$exports, "default", () => $a87dacf5139b5e2f$export$2e2bcd8739ae039);
13064
+ function $a87dacf5139b5e2f$export$2e2bcd8739ae039(store) {
13065
+ return {
13066
+ get store () {
13067
+ return store || this;
13068
+ },
13069
+ get id () {
13070
+ return this.$root.id;
13071
+ },
13072
+ get panels () {
13073
+ return Array.from(this.$refs.panels.children);
13074
+ },
13075
+ isActive (el) {
13076
+ return this.store.activeTab === this._getRef(el);
13077
+ },
13078
+ // protected
13079
+ _getRef (el) {
13080
+ return el.getAttribute("x-ref");
13081
+ }
13082
+ };
13083
+ }
13084
+
13085
+
13086
13086
  var $6d64716f0b34fdf4$exports = {};
13087
13087
 
13088
13088
  $parcel$defineInteropFlag($6d64716f0b34fdf4$exports);
@@ -13210,19 +13210,19 @@ function $6d64716f0b34fdf4$export$2e2bcd8739ae039(store) {
13210
13210
  }
13211
13211
 
13212
13212
 
13213
- $6d30a58562f349fe$exports = {
13213
+ $d865a31e17cd1079$exports = {
13214
13214
  "button": $cbd28b10fa9798c7$exports,
13215
13215
  "code": $99486586f6691564$exports,
13216
- "copy_button": $47a1c62621be0c54$exports,
13217
- "embed": $e1f51f020443edd4$exports,
13218
13216
  "dimensions_display": $e398acaded942bbe$exports,
13217
+ "embed": $e1f51f020443edd4$exports,
13219
13218
  "filter": $e9904a14dabf652d$exports,
13219
+ "copy_button": $47a1c62621be0c54$exports,
13220
13220
  "icon": $36506012e0c6e9e3$exports,
13221
13221
  "nav": $d92d9d5253f84566$exports,
13222
13222
  "params_editor": $b63b9c6d236b3f65$exports,
13223
13223
  "split_layout": $506dabb2bf255b38$exports,
13224
- "tab_panels": $a87dacf5139b5e2f$exports,
13225
13224
  "tabs": $0db07828cadc68e0$exports,
13225
+ "tab_panels": $a87dacf5139b5e2f$exports,
13226
13226
  "viewport": $6d64716f0b34fdf4$exports
13227
13227
  };
13228
13228
 
@@ -13367,7 +13367,7 @@ const $d73574cc5e9b9e72$var$prefix = window.APP_NAME;
13367
13367
  // Components
13368
13368
  (0, $caa9439642c6336c$export$2e2bcd8739ae039).data("app", (0, $d709d0f4027033b2$export$2e2bcd8739ae039));
13369
13369
  [
13370
- $6d30a58562f349fe$exports,
13370
+ $d865a31e17cd1079$exports,
13371
13371
  $e4eab7529959b73b$exports,
13372
13372
  $4979d2d897a1c01f$exports
13373
13373
  ].forEach((scripts)=>{