@warp-ds/elements 1.4.0-next.1 → 1.4.0-next.3

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.
package/dist/index.js CHANGED
@@ -1045,7 +1045,7 @@ import { html as html3 } from "lit";
1045
1045
  import WarpElement from "@warp-ds/elements-core";
1046
1046
  import { ifDefined } from "lit/directives/if-defined.js";
1047
1047
 
1048
- // node_modules/.pnpm/@warp-ds+css@1.9.3/node_modules/@warp-ds/css/component-classes/index.js
1048
+ // node_modules/.pnpm/@warp-ds+css@1.9.6/node_modules/@warp-ds/css/component-classes/index.js
1049
1049
  var badge = {
1050
1050
  base: "py-4 px-8 border-0 rounded-4 text-xs inline-flex",
1051
1051
  neutral: "bg-[--w-color-badge-neutral-background] s-text",
@@ -1297,15 +1297,24 @@ var alert = {
1297
1297
  infoIcon: "s-icon-info"
1298
1298
  };
1299
1299
  var input = {
1300
- default: "block text-m mb-0 leading-m s-text s-bg s-border hover:s-border-hover active:s-border-selected rounded-4 py-12 px-8 block border-1 w-full focusable focus:[--w-outline-offset:-2px] caret-current",
1301
- textArea: "min-h-[42] sm:min-h-[45]",
1302
- disabled: "s-bg-disabled-subtle s-border-disabled hover:s-border-disabled! s-text-disabled pointer-events-none",
1303
- invalid: "s-border-negative s-text-negative! hover:s-border-negative-hover! outline-[--w-s-color-border-negative]!",
1304
- readOnly: "pl-0 bg-transparent! border-0! pointer-events-none",
1305
- placeholder: "placeholder:s-text-placeholder",
1300
+ // wrapper classes
1306
1301
  wrapper: "relative",
1302
+ // input classes
1303
+ base: "block text-m leading-m mb-0 px-8 py-12 rounded-4 w-full focusable focus:[--w-outline-offset:-2px] caret-current",
1304
+ // true
1305
+ default: "border-1 s-text s-bg s-border hover:s-border-hover active:s-border-selected",
1306
+ // !isInvalid && !isDisabled && !isReadOnly
1307
+ disabled: "border-1 s-text-disabled s-bg-disabled-subtle s-border-disabled pointer-events-none",
1308
+ // !isInvalid && isDisabled && !isReadOnly
1309
+ invalid: "border-1 s-text-negative s-bg s-border-negative hover:s-border-negative-hover outline-[--w-s-color-border-negative]!",
1310
+ // isInvalid && !isDisabled && !isReadOnly
1311
+ readOnly: "pl-0 bg-transparent pointer-events-none",
1312
+ // !isInvalid && !isDisabled && isReadOnly
1313
+ placeholder: "placeholder:s-text-placeholder",
1307
1314
  suffix: "pr-40",
1308
- prefix: "pl-40"
1315
+ prefix: "pl-[var(--w-prefix-width,_40px)]",
1316
+ // textarea classes
1317
+ textArea: "min-h-[42] sm:min-h-[45]"
1309
1318
  };
1310
1319
  var select = {
1311
1320
  default: "block text-m mb-0 leading-m s-text s-bg s-border hover:s-border-hover active:s-border-active rounded-4 py-12 px-8 block border-1 w-full focusable focus:[--w-outline-offset:-2px] appearance-none pr-32 cursor-pointer caret-current",
@@ -2554,8 +2563,6 @@ import { ifDefined as ifDefined2 } from "lit/directives/if-defined.js";
2554
2563
 
2555
2564
  // node_modules/.pnpm/@floating-ui+utils@0.2.1/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2556
2565
  var sides = ["top", "right", "bottom", "left"];
2557
- var alignments = ["start", "end"];
2558
- var placements = /* @__PURE__ */ sides.reduce((acc, side2) => acc.concat(side2, side2 + "-" + alignments[0], side2 + "-" + alignments[1]), []);
2559
2566
  var min = Math.min;
2560
2567
  var max = Math.max;
2561
2568
  var round = Math.round;
@@ -2924,106 +2931,6 @@ var arrow = (options) => ({
2924
2931
  };
2925
2932
  }
2926
2933
  });
2927
- function getPlacementList(alignment, autoAlignment, allowedPlacements) {
2928
- const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter((placement) => getAlignment(placement) === alignment), ...allowedPlacements.filter((placement) => getAlignment(placement) !== alignment)] : allowedPlacements.filter((placement) => getSide(placement) === placement);
2929
- return allowedPlacementsSortedByAlignment.filter((placement) => {
2930
- if (alignment) {
2931
- return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);
2932
- }
2933
- return true;
2934
- });
2935
- }
2936
- var autoPlacement = function(options) {
2937
- if (options === void 0) {
2938
- options = {};
2939
- }
2940
- return {
2941
- name: "autoPlacement",
2942
- options,
2943
- async fn(state) {
2944
- var _middlewareData$autoP, _middlewareData$autoP2, _placementsThatFitOnE;
2945
- const {
2946
- rects,
2947
- middlewareData,
2948
- placement,
2949
- platform: platform2,
2950
- elements
2951
- } = state;
2952
- const _a = evaluate(options, state), {
2953
- crossAxis = false,
2954
- alignment,
2955
- allowedPlacements = placements,
2956
- autoAlignment = true
2957
- } = _a, detectOverflowOptions = __objRest(_a, [
2958
- "crossAxis",
2959
- "alignment",
2960
- "allowedPlacements",
2961
- "autoAlignment"
2962
- ]);
2963
- const placements$1 = alignment !== void 0 || allowedPlacements === placements ? getPlacementList(alignment || null, autoAlignment, allowedPlacements) : allowedPlacements;
2964
- const overflow = await detectOverflow(state, detectOverflowOptions);
2965
- const currentIndex = ((_middlewareData$autoP = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP.index) || 0;
2966
- const currentPlacement = placements$1[currentIndex];
2967
- if (currentPlacement == null) {
2968
- return {};
2969
- }
2970
- const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating)));
2971
- if (placement !== currentPlacement) {
2972
- return {
2973
- reset: {
2974
- placement: placements$1[0]
2975
- }
2976
- };
2977
- }
2978
- const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
2979
- const allOverflows = [...((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || [], {
2980
- placement: currentPlacement,
2981
- overflows: currentOverflows
2982
- }];
2983
- const nextPlacement = placements$1[currentIndex + 1];
2984
- if (nextPlacement) {
2985
- return {
2986
- data: {
2987
- index: currentIndex + 1,
2988
- overflows: allOverflows
2989
- },
2990
- reset: {
2991
- placement: nextPlacement
2992
- }
2993
- };
2994
- }
2995
- const placementsSortedByMostSpace = allOverflows.map((d) => {
2996
- const alignment2 = getAlignment(d.placement);
2997
- return [d.placement, alignment2 && crossAxis ? (
2998
- // Check along the mainAxis and main crossAxis side.
2999
- d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0)
3000
- ) : (
3001
- // Check only the mainAxis.
3002
- d.overflows[0]
3003
- ), d.overflows];
3004
- }).sort((a, b) => a[1] - b[1]);
3005
- const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter((d) => d[2].slice(
3006
- 0,
3007
- // Aligned placements should not check their opposite crossAxis
3008
- // side.
3009
- getAlignment(d[0]) ? 2 : 3
3010
- ).every((v) => v <= 0));
3011
- const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
3012
- if (resetPlacement !== placement) {
3013
- return {
3014
- data: {
3015
- index: currentIndex + 1,
3016
- overflows: allOverflows
3017
- },
3018
- reset: {
3019
- placement: resetPlacement
3020
- }
3021
- };
3022
- }
3023
- return {};
3024
- }
3025
- };
3026
- };
3027
2934
  var flip = function(options) {
3028
2935
  if (options === void 0) {
3029
2936
  options = {};
@@ -3124,6 +3031,65 @@ var flip = function(options) {
3124
3031
  }
3125
3032
  };
3126
3033
  };
3034
+ function getSideOffsets(overflow, rect) {
3035
+ return {
3036
+ top: overflow.top - rect.height,
3037
+ right: overflow.right - rect.width,
3038
+ bottom: overflow.bottom - rect.height,
3039
+ left: overflow.left - rect.width
3040
+ };
3041
+ }
3042
+ function isAnySideFullyClipped(overflow) {
3043
+ return sides.some((side2) => overflow[side2] >= 0);
3044
+ }
3045
+ var hide = function(options) {
3046
+ if (options === void 0) {
3047
+ options = {};
3048
+ }
3049
+ return {
3050
+ name: "hide",
3051
+ options,
3052
+ async fn(state) {
3053
+ const {
3054
+ rects
3055
+ } = state;
3056
+ const _a = evaluate(options, state), {
3057
+ strategy = "referenceHidden"
3058
+ } = _a, detectOverflowOptions = __objRest(_a, [
3059
+ "strategy"
3060
+ ]);
3061
+ switch (strategy) {
3062
+ case "referenceHidden": {
3063
+ const overflow = await detectOverflow(state, __spreadProps(__spreadValues({}, detectOverflowOptions), {
3064
+ elementContext: "reference"
3065
+ }));
3066
+ const offsets = getSideOffsets(overflow, rects.reference);
3067
+ return {
3068
+ data: {
3069
+ referenceHiddenOffsets: offsets,
3070
+ referenceHidden: isAnySideFullyClipped(offsets)
3071
+ }
3072
+ };
3073
+ }
3074
+ case "escaped": {
3075
+ const overflow = await detectOverflow(state, __spreadProps(__spreadValues({}, detectOverflowOptions), {
3076
+ altBoundary: true
3077
+ }));
3078
+ const offsets = getSideOffsets(overflow, rects.floating);
3079
+ return {
3080
+ data: {
3081
+ escapedOffsets: offsets,
3082
+ escaped: isAnySideFullyClipped(offsets)
3083
+ }
3084
+ };
3085
+ }
3086
+ default: {
3087
+ return {};
3088
+ }
3089
+ }
3090
+ }
3091
+ };
3092
+ };
3127
3093
  async function convertValueToCoords(state, options) {
3128
3094
  const {
3129
3095
  placement,
@@ -3190,75 +3156,6 @@ var offset = function(options) {
3190
3156
  }
3191
3157
  };
3192
3158
  };
3193
- var shift = function(options) {
3194
- if (options === void 0) {
3195
- options = {};
3196
- }
3197
- return {
3198
- name: "shift",
3199
- options,
3200
- async fn(state) {
3201
- const {
3202
- x,
3203
- y,
3204
- placement
3205
- } = state;
3206
- const _a = evaluate(options, state), {
3207
- mainAxis: checkMainAxis = true,
3208
- crossAxis: checkCrossAxis = false,
3209
- limiter = {
3210
- fn: (_ref) => {
3211
- let {
3212
- x: x2,
3213
- y: y2
3214
- } = _ref;
3215
- return {
3216
- x: x2,
3217
- y: y2
3218
- };
3219
- }
3220
- }
3221
- } = _a, detectOverflowOptions = __objRest(_a, [
3222
- "mainAxis",
3223
- "crossAxis",
3224
- "limiter"
3225
- ]);
3226
- const coords = {
3227
- x,
3228
- y
3229
- };
3230
- const overflow = await detectOverflow(state, detectOverflowOptions);
3231
- const crossAxis = getSideAxis(getSide(placement));
3232
- const mainAxis = getOppositeAxis(crossAxis);
3233
- let mainAxisCoord = coords[mainAxis];
3234
- let crossAxisCoord = coords[crossAxis];
3235
- if (checkMainAxis) {
3236
- const minSide = mainAxis === "y" ? "top" : "left";
3237
- const maxSide = mainAxis === "y" ? "bottom" : "right";
3238
- const min2 = mainAxisCoord + overflow[minSide];
3239
- const max2 = mainAxisCoord - overflow[maxSide];
3240
- mainAxisCoord = clamp(min2, mainAxisCoord, max2);
3241
- }
3242
- if (checkCrossAxis) {
3243
- const minSide = crossAxis === "y" ? "top" : "left";
3244
- const maxSide = crossAxis === "y" ? "bottom" : "right";
3245
- const min2 = crossAxisCoord + overflow[minSide];
3246
- const max2 = crossAxisCoord - overflow[maxSide];
3247
- crossAxisCoord = clamp(min2, crossAxisCoord, max2);
3248
- }
3249
- const limitedCoords = limiter.fn(__spreadProps(__spreadValues({}, state), {
3250
- [mainAxis]: mainAxisCoord,
3251
- [crossAxis]: crossAxisCoord
3252
- }));
3253
- return __spreadProps(__spreadValues({}, limitedCoords), {
3254
- data: {
3255
- x: limitedCoords.x - x,
3256
- y: limitedCoords.y - y
3257
- }
3258
- });
3259
- }
3260
- };
3261
- };
3262
3159
 
3263
3160
  // node_modules/.pnpm/@floating-ui+utils@0.2.1/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
3264
3161
  function getNodeName(node) {
@@ -3776,9 +3673,8 @@ var platform = {
3776
3673
  isElement,
3777
3674
  isRTL
3778
3675
  };
3779
- var autoPlacement2 = autoPlacement;
3780
- var shift2 = shift;
3781
3676
  var flip2 = flip;
3677
+ var hide2 = hide;
3782
3678
  var arrow2 = arrow;
3783
3679
  var computePosition2 = (reference, floating, options) => {
3784
3680
  const cache2 = /* @__PURE__ */ new Map();
@@ -3793,7 +3689,7 @@ var computePosition2 = (reference, floating, options) => {
3793
3689
  }));
3794
3690
  };
3795
3691
 
3796
- // node_modules/.pnpm/@warp-ds+core@1.1.0_@floating-ui+dom@1.6.3/node_modules/@warp-ds/core/dist/attention/utils/helpers.js
3692
+ // node_modules/.pnpm/@warp-ds+core@1.1.1_@floating-ui+dom@1.6.3/node_modules/@warp-ds/core/dist/attention/utils/helpers.js
3797
3693
  var TOP_START = "top-start";
3798
3694
  var TOP = "top";
3799
3695
  var TOP_END = "top-end";
@@ -3901,12 +3797,12 @@ async function useRecompute(state) {
3901
3797
  middleware: [
3902
3798
  offset({ mainAxis: (_b = state == null ? void 0 : state.distance) != null ? _b : 8, crossAxis: (_c = state == null ? void 0 : state.skidding) != null ? _c : 0 }),
3903
3799
  (state == null ? void 0 : state.flip) && flip2({
3904
- fallbackAxisSideDirection: "start",
3800
+ crossAxis: state == null ? void 0 : state.crossAxis,
3905
3801
  fallbackPlacements: state == null ? void 0 : state.fallbackPlacements
3906
3802
  }),
3907
- !(state == null ? void 0 : state.flip) && autoPlacement2(),
3908
- shift2({ padding: 16 }),
3909
- !(state == null ? void 0 : state.noArrow) && (state == null ? void 0 : state.arrowEl) && arrow2({ element: state == null ? void 0 : state.arrowEl })
3803
+ !(state == null ? void 0 : state.noArrow) && (state == null ? void 0 : state.arrowEl) && arrow2({ element: state == null ? void 0 : state.arrowEl }),
3804
+ hide2()
3805
+ //will hide the attentionEl when it appears detached from the targetEl. Can be called multiple times in the middleware-array if you want to use several strategies. Default strategy is 'referenceHidden'.
3910
3806
  ]
3911
3807
  }).then(({ x, y, middlewareData, placement }) => {
3912
3808
  state.actualDirection = placement;
@@ -3914,6 +3810,12 @@ async function useRecompute(state) {
3914
3810
  left: `${x}px`,
3915
3811
  top: `${y}px`
3916
3812
  });
3813
+ if ((middlewareData == null ? void 0 : middlewareData.hide) && !(state == null ? void 0 : state.isCallout)) {
3814
+ const { referenceHidden } = middlewareData == null ? void 0 : middlewareData.hide;
3815
+ Object.assign(attentionEl == null ? void 0 : attentionEl.style, {
3816
+ visibility: referenceHidden ? "hidden" : ""
3817
+ });
3818
+ }
3917
3819
  const isRtl = window.getComputedStyle(attentionEl).direction === "rtl";
3918
3820
  const arrowPlacement = arrowDirection(placement).split("-")[1];
3919
3821
  if ((middlewareData == null ? void 0 : middlewareData.arrow) && (state == null ? void 0 : state.arrowEl)) {
@@ -4010,6 +3912,7 @@ var WarpAttention = class extends kebabCaseAttributes(WarpElement3) {
4010
3912
  this.distance = 8;
4011
3913
  this.skidding = 0;
4012
3914
  this.flip = false;
3915
+ this.crossAxis = false;
4013
3916
  this._initialPlacement = this.placement;
4014
3917
  this._actualDirection = this.placement;
4015
3918
  }
@@ -4094,7 +3997,8 @@ ${JSON.stringify(directions)}`);
4094
3997
  return this.renderRoot.querySelector("#attention");
4095
3998
  }
4096
3999
  get _targetEl() {
4097
- const targetSlot = this.renderRoot.querySelector("slot[name='target']");
4000
+ var _a;
4001
+ const targetSlot = (_a = this.renderRoot) == null ? void 0 : _a.querySelector("slot[name='target']");
4098
4002
  return targetSlot ? targetSlot.assignedNodes()[0] : null;
4099
4003
  }
4100
4004
  get _messageEl() {
@@ -4140,6 +4044,7 @@ ${JSON.stringify(directions)}`);
4140
4044
  distance: this.distance,
4141
4045
  skidding: this.skidding,
4142
4046
  flip: this.flip,
4047
+ crossAxis: this.crossAxis,
4143
4048
  fallbackPlacements: this.fallbackPlacements
4144
4049
  };
4145
4050
  useRecompute(this.attentionState);
@@ -4244,6 +4149,8 @@ ${JSON.stringify(directions)}`);
4244
4149
  }
4245
4150
  }
4246
4151
  render() {
4152
+ if (!this.callout && this._targetEl === void 0)
4153
+ return html9``;
4247
4154
  return html9`
4248
4155
  <div class=${ifDefined2(this.className ? this.className : void 0)}>
4249
4156
  ${this.placement === "right-start" || this.placement === "right" || this.placement === "right-end" || this.placement === "bottom-start" || this.placement === "bottom" || this.placement === "bottom-end" ? html9`
@@ -4289,6 +4196,8 @@ __publicField(WarpAttention, "properties", {
4289
4196
  skidding: { type: Number, reflect: true },
4290
4197
  // Whether Attention element should flip its placement in order to keep it in view
4291
4198
  flip: { type: Boolean, reflect: true },
4199
+ // Whether Attention element should ignore cross axis overflow when flip is enabled
4200
+ crossAxis: { type: Boolean, reflect: true },
4292
4201
  // Choose which preferred placements the Attention element should flip to
4293
4202
  fallbackPlacements: { type: Array, reflect: true }
4294
4203
  });
@@ -4406,7 +4315,7 @@ if (!customElements.get("w-box")) {
4406
4315
  import { html as html12 } from "lit";
4407
4316
  import WarpElement6 from "@warp-ds/elements-core";
4408
4317
 
4409
- // node_modules/.pnpm/@warp-ds+core@1.1.0_@floating-ui+dom@1.6.3/node_modules/@warp-ds/core/dist/breadcrumbs/index.js
4318
+ // node_modules/.pnpm/@warp-ds+core@1.1.1_@floating-ui+dom@1.6.3/node_modules/@warp-ds/core/dist/breadcrumbs/index.js
4410
4319
  function interleave(array, separator2) {
4411
4320
  return array.flatMap((el) => [el, separator2]).slice(0, -1);
4412
4321
  }
@@ -5252,19 +5161,18 @@ var WarpTextField = class extends WarpElement13 {
5252
5161
  this.type = "text";
5253
5162
  }
5254
5163
  get _inputStyles() {
5255
- return fclasses({
5256
- [input.default]: true,
5257
- [input.invalid]: this.invalid,
5258
- [input.disabled]: this.disabled,
5259
- [input.readOnly]: this.readOnly,
5164
+ return classes({
5165
+ [input.base]: true,
5166
+ [input.default]: !this.invalid && !this.disabled && !this.readOnly,
5167
+ [input.invalid]: this.invalid && !this.disabled && !this.readOnly,
5168
+ [input.disabled]: !this.invalid && this.disabled && !this.readOnly,
5169
+ [input.readOnly]: !this.invalid && !this.disabled && this.readOnly,
5260
5170
  [input.suffix]: this._hasSuffix,
5261
- // we style input with prefix here because we cannot use
5262
- // arbitrary values with commas in UnoCSS like pl-[var(--w-prefix-width, 40px)]
5263
- "warp-input-with-prefix": this._hasPrefix
5171
+ [input.prefix]: this._hasPrefix
5264
5172
  });
5265
5173
  }
5266
5174
  get _helpTextStyles() {
5267
- return fclasses({
5175
+ return classes({
5268
5176
  [helpText.helpText]: true,
5269
5177
  [helpText.helpTextColor]: !this.invalid,
5270
5178
  [helpText.helpTextColorInvalid]: this.invalid
@@ -5355,9 +5263,6 @@ __publicField(WarpTextField, "styles", [
5355
5263
  ::slotted(:last-child) {
5356
5264
  margin-bottom: 0px !important;
5357
5265
  }
5358
- .warp-input-with-prefix {
5359
- padding-left: var(--w-prefix-width, 40px);
5360
- }
5361
5266
  `
5362
5267
  ]);
5363
5268
  if (!customElements.get("w-textfield")) {