wilday_ui 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6aae81001c80b4c0fd86eaca5391e6de697a87b88e38215bd1889a70163dafe7
4
- data.tar.gz: 87cff2dba0f7408ae84456cec4b6aac1927f1bcc27ad09309091c2b43c3df45a
3
+ metadata.gz: 98a6a22d0353bcf51b1a26cc31550fe21562298385fb9b048f00c597d4102bea
4
+ data.tar.gz: 90431c125b51b0e20b8ca77bb28b4a5530235e143091cbaec60ffc3406855d49
5
5
  SHA512:
6
- metadata.gz: '09d8ec007fb7c0757f65ded7d2e059281752c2fdc07cee90aea77dc82b008adb9e07c6161cd527635ceb289121a030b29234a6d5c306a24e68b3d9378e0bfc0e'
7
- data.tar.gz: da49ca71e648b9e527d02668a83cc6130dcb53ada46f195e9bb19dc4e3a5cf716b9d0b7353f4e68cfdc01416c6bdc5b8a15afc8ea349ea9fe8053be3c74bf318
6
+ metadata.gz: d250424a5ecb2fb6228f1d40ec314b4d2df84e6814814cd0ba1a7cba85963197c6cd231ac8befb4afd2de3befe8eaf519562b81f00c64cdd5c0cd28f1e5b3985
7
+ data.tar.gz: 56712497f70a613b790d1b8b2455fbdd055607d4229f582cb68787936e357f5b38d35dd4fa878d2ca78062c9b2c7a22106dcfc363d533942c7da197f4119a05b
data/README.md CHANGED
@@ -36,9 +36,10 @@ Place it in the `<head>` section, before your application's JavaScript:
36
36
  <%= csrf_meta_tags %>
37
37
  <%= csp_meta_tag %>
38
38
 
39
- <%= w_js %> # Add this line in head
40
-
41
39
  <%= stylesheet_link_tag "application" %>
40
+ <%= javascript_importmap_tags %>
41
+
42
+ <%= w_js %> # Add this line in head
42
43
  </head>
43
44
  <body>
44
45
  <%= yield %>
@@ -3051,15 +3051,6 @@ var tooltip_controller_default = class extends Controller {
3051
3051
  const arrowOffset = this.arrowValue ? 2 : 0;
3052
3052
  const scrollX = window.pageXOffset || document.documentElement.scrollLeft;
3053
3053
  const scrollY = window.pageYOffset || document.documentElement.scrollTop;
3054
- console.log("=== Initial Values ===");
3055
- console.log("Viewport Height:", viewportHeight);
3056
- console.log("Viewport Width:", viewportWidth);
3057
- console.log("Trigger Top:", triggerRect.top);
3058
- console.log("Trigger Bottom:", triggerRect.bottom);
3059
- console.log("Trigger Left:", triggerRect.left);
3060
- console.log("Trigger Right:", triggerRect.right);
3061
- console.log("Tooltip Height:", tooltipRect.height);
3062
- console.log("Tooltip Width:", tooltipRect.width);
3063
3054
  let position = this.positionValue;
3064
3055
  let top, left;
3065
3056
  const spaceBelow = viewportHeight - triggerRect.bottom;
@@ -3068,31 +3059,18 @@ var tooltip_controller_default = class extends Controller {
3068
3059
  const spaceLeft = triggerRect.left;
3069
3060
  const requiredSpaceVertical = tooltipRect.height + this.offsetValue + arrowOffset;
3070
3061
  const requiredSpaceHorizontal = tooltipRect.width + this.offsetValue + arrowOffset;
3071
- console.log("\n=== Space Calculation ===");
3072
- console.log("Space Above:", spaceAbove);
3073
- console.log("Space Below:", spaceBelow);
3074
- console.log("Space Left:", spaceLeft);
3075
- console.log("Space Right:", spaceRight);
3076
- console.log("Required Space Vertical:", requiredSpaceVertical);
3077
- console.log("Required Space Horizontal:", requiredSpaceHorizontal);
3078
3062
  if (position === "right" && spaceRight >= requiredSpaceHorizontal) {
3079
3063
  position = "right";
3080
- console.log("Using right - sufficient space");
3081
3064
  } else if (position === "left" && spaceLeft >= requiredSpaceHorizontal) {
3082
3065
  position = "left";
3083
- console.log("Using left - sufficient space");
3084
3066
  } else if (position === "top" && spaceAbove >= requiredSpaceVertical) {
3085
3067
  position = "top";
3086
- console.log("Using top - sufficient space");
3087
3068
  } else if (position === "bottom" && spaceBelow >= requiredSpaceVertical) {
3088
3069
  position = "bottom";
3089
- console.log("Using bottom - sufficient space");
3090
3070
  } else if (spaceBelow >= requiredSpaceVertical) {
3091
3071
  position = "bottom";
3092
- console.log("Fallback to bottom - sufficient space");
3093
3072
  } else {
3094
3073
  position = "top";
3095
- console.log("Fallback to top - insufficient space below");
3096
3074
  }
3097
3075
  switch (position) {
3098
3076
  case "top":
@@ -3146,11 +3124,6 @@ var tooltip_controller_default = class extends Controller {
3146
3124
  } else if (left + tooltipRect.width > viewportWidth) {
3147
3125
  left = viewportWidth - tooltipRect.width - this.offsetValue;
3148
3126
  }
3149
- console.log("\n=== Final Position ===");
3150
- console.log("Position:", position);
3151
- console.log("Top:", top);
3152
- console.log("Left:", left);
3153
- console.log("Alignment:", this.alignValue);
3154
3127
  top += scrollY;
3155
3128
  left += scrollX;
3156
3129
  this.tooltipElement.setAttribute("data-position", position);
@@ -3165,6 +3138,83 @@ var tooltip_controller_default = class extends Controller {
3165
3138
  }
3166
3139
  };
3167
3140
 
3141
+ // app/javascript/wilday_ui/controllers/animation_controller.js
3142
+ var animation_controller_default = class extends Controller {
3143
+ connect() {
3144
+ console.log("AnimationController connected");
3145
+ this.setupAnimation();
3146
+ }
3147
+ setupAnimation() {
3148
+ const animationData = JSON.parse(this.element.dataset.animation || "{}");
3149
+ if (!animationData.name) return;
3150
+ const {
3151
+ name,
3152
+ trigger,
3153
+ duration = 0.3,
3154
+ timing = "ease",
3155
+ delay = 0,
3156
+ // Add default value here
3157
+ iteration = 1,
3158
+ direction = "normal",
3159
+ fill_mode = "none",
3160
+ properties
3161
+ } = animationData;
3162
+ this.element.style.setProperty("--animation-name", name);
3163
+ this.element.style.setProperty("--animation-duration", `${duration}s`);
3164
+ this.element.style.setProperty("--animation-delay", `${delay}s`);
3165
+ this.element.style.setProperty(
3166
+ "--animation-timing",
3167
+ this.getTimingFunction(timing, properties)
3168
+ );
3169
+ this.element.style.setProperty(
3170
+ "--animation-iteration",
3171
+ iteration === "infinite" ? "infinite" : iteration || 1
3172
+ );
3173
+ this.element.style.setProperty(
3174
+ "--animation-direction",
3175
+ direction.replace(/_/g, "-")
3176
+ );
3177
+ this.element.style.setProperty(
3178
+ "--animation-fill-mode",
3179
+ fill_mode.replace(/_/g, "-")
3180
+ );
3181
+ if (properties && name === "custom") {
3182
+ Object.entries(properties).forEach(([key, value]) => {
3183
+ this.element.style.setProperty(`--animation-custom-${key}`, value);
3184
+ });
3185
+ }
3186
+ if (trigger === "click") {
3187
+ this.element.addEventListener("click", () => this.animate());
3188
+ } else if (trigger === "load") {
3189
+ this.animate();
3190
+ }
3191
+ }
3192
+ animate() {
3193
+ const animationData = JSON.parse(this.element.dataset.animation || "{}");
3194
+ if (!animationData.name) return;
3195
+ this.element.classList.remove("is-animating");
3196
+ void this.element.offsetWidth;
3197
+ this.element.classList.add("is-animating");
3198
+ }
3199
+ getTimingFunction(timing, properties) {
3200
+ if (!timing) return "ease";
3201
+ if (timing === "cubic_bezier" && properties?.cubic_bezier) {
3202
+ const [x1, y1, x2, y2] = properties.cubic_bezier;
3203
+ return `cubic-bezier(${x1}, ${y1}, ${x2}, ${y2})`;
3204
+ }
3205
+ return timing.replace(/_/g, "-");
3206
+ }
3207
+ disableAfterAnimation() {
3208
+ const animationConfig = JSON.parse(this.element.dataset.animation || "{}");
3209
+ if (!animationConfig.disabled) return;
3210
+ const duration = parseFloat(this.element.style.getPropertyValue("--animation-duration")) * 1e3;
3211
+ const delay = parseFloat(this.element.style.getPropertyValue("--animation-delay")) * 1e3;
3212
+ setTimeout(() => {
3213
+ this.element.disabled = true;
3214
+ }, duration + delay);
3215
+ }
3216
+ };
3217
+
3168
3218
  // app/javascript/wilday_ui/controllers/index.js
3169
3219
  var application = Application.start();
3170
3220
  window.Stimulus = application;
@@ -3173,6 +3223,7 @@ application.register("dropdown", dropdown_controller_default);
3173
3223
  application.register("clipboard", clipboard_controller_default);
3174
3224
  application.register("confirmation", confirmation_controller_default);
3175
3225
  application.register("tooltip", tooltip_controller_default);
3226
+ application.register("animation", animation_controller_default);
3176
3227
 
3177
3228
  // app/javascript/wilday_ui/components/button.js
3178
3229
  document.addEventListener("DOMContentLoaded", () => {