@warp-ds/elements 1.4.0-next.1 → 1.4.0-next.2
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 +80 -180
- package/dist/index.js.map +4 -4
- package/dist/packages/attention/index.d.ts +6 -0
- package/dist/packages/attention/index.js +79 -179
- package/dist/packages/attention/index.js.map +4 -4
- package/dist/packages/breadcrumbs/index.js +1 -1
- package/dist/packages/breadcrumbs/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2554,8 +2554,6 @@ import { ifDefined as ifDefined2 } from "lit/directives/if-defined.js";
|
|
|
2554
2554
|
|
|
2555
2555
|
// node_modules/.pnpm/@floating-ui+utils@0.2.1/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
|
|
2556
2556
|
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
2557
|
var min = Math.min;
|
|
2560
2558
|
var max = Math.max;
|
|
2561
2559
|
var round = Math.round;
|
|
@@ -2924,106 +2922,6 @@ var arrow = (options) => ({
|
|
|
2924
2922
|
};
|
|
2925
2923
|
}
|
|
2926
2924
|
});
|
|
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
2925
|
var flip = function(options) {
|
|
3028
2926
|
if (options === void 0) {
|
|
3029
2927
|
options = {};
|
|
@@ -3124,6 +3022,65 @@ var flip = function(options) {
|
|
|
3124
3022
|
}
|
|
3125
3023
|
};
|
|
3126
3024
|
};
|
|
3025
|
+
function getSideOffsets(overflow, rect) {
|
|
3026
|
+
return {
|
|
3027
|
+
top: overflow.top - rect.height,
|
|
3028
|
+
right: overflow.right - rect.width,
|
|
3029
|
+
bottom: overflow.bottom - rect.height,
|
|
3030
|
+
left: overflow.left - rect.width
|
|
3031
|
+
};
|
|
3032
|
+
}
|
|
3033
|
+
function isAnySideFullyClipped(overflow) {
|
|
3034
|
+
return sides.some((side2) => overflow[side2] >= 0);
|
|
3035
|
+
}
|
|
3036
|
+
var hide = function(options) {
|
|
3037
|
+
if (options === void 0) {
|
|
3038
|
+
options = {};
|
|
3039
|
+
}
|
|
3040
|
+
return {
|
|
3041
|
+
name: "hide",
|
|
3042
|
+
options,
|
|
3043
|
+
async fn(state) {
|
|
3044
|
+
const {
|
|
3045
|
+
rects
|
|
3046
|
+
} = state;
|
|
3047
|
+
const _a = evaluate(options, state), {
|
|
3048
|
+
strategy = "referenceHidden"
|
|
3049
|
+
} = _a, detectOverflowOptions = __objRest(_a, [
|
|
3050
|
+
"strategy"
|
|
3051
|
+
]);
|
|
3052
|
+
switch (strategy) {
|
|
3053
|
+
case "referenceHidden": {
|
|
3054
|
+
const overflow = await detectOverflow(state, __spreadProps(__spreadValues({}, detectOverflowOptions), {
|
|
3055
|
+
elementContext: "reference"
|
|
3056
|
+
}));
|
|
3057
|
+
const offsets = getSideOffsets(overflow, rects.reference);
|
|
3058
|
+
return {
|
|
3059
|
+
data: {
|
|
3060
|
+
referenceHiddenOffsets: offsets,
|
|
3061
|
+
referenceHidden: isAnySideFullyClipped(offsets)
|
|
3062
|
+
}
|
|
3063
|
+
};
|
|
3064
|
+
}
|
|
3065
|
+
case "escaped": {
|
|
3066
|
+
const overflow = await detectOverflow(state, __spreadProps(__spreadValues({}, detectOverflowOptions), {
|
|
3067
|
+
altBoundary: true
|
|
3068
|
+
}));
|
|
3069
|
+
const offsets = getSideOffsets(overflow, rects.floating);
|
|
3070
|
+
return {
|
|
3071
|
+
data: {
|
|
3072
|
+
escapedOffsets: offsets,
|
|
3073
|
+
escaped: isAnySideFullyClipped(offsets)
|
|
3074
|
+
}
|
|
3075
|
+
};
|
|
3076
|
+
}
|
|
3077
|
+
default: {
|
|
3078
|
+
return {};
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
}
|
|
3082
|
+
};
|
|
3083
|
+
};
|
|
3127
3084
|
async function convertValueToCoords(state, options) {
|
|
3128
3085
|
const {
|
|
3129
3086
|
placement,
|
|
@@ -3190,75 +3147,6 @@ var offset = function(options) {
|
|
|
3190
3147
|
}
|
|
3191
3148
|
};
|
|
3192
3149
|
};
|
|
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
3150
|
|
|
3263
3151
|
// node_modules/.pnpm/@floating-ui+utils@0.2.1/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
|
|
3264
3152
|
function getNodeName(node) {
|
|
@@ -3776,9 +3664,8 @@ var platform = {
|
|
|
3776
3664
|
isElement,
|
|
3777
3665
|
isRTL
|
|
3778
3666
|
};
|
|
3779
|
-
var autoPlacement2 = autoPlacement;
|
|
3780
|
-
var shift2 = shift;
|
|
3781
3667
|
var flip2 = flip;
|
|
3668
|
+
var hide2 = hide;
|
|
3782
3669
|
var arrow2 = arrow;
|
|
3783
3670
|
var computePosition2 = (reference, floating, options) => {
|
|
3784
3671
|
const cache2 = /* @__PURE__ */ new Map();
|
|
@@ -3793,7 +3680,7 @@ var computePosition2 = (reference, floating, options) => {
|
|
|
3793
3680
|
}));
|
|
3794
3681
|
};
|
|
3795
3682
|
|
|
3796
|
-
// node_modules/.pnpm/@warp-ds+core@1.1.
|
|
3683
|
+
// 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
3684
|
var TOP_START = "top-start";
|
|
3798
3685
|
var TOP = "top";
|
|
3799
3686
|
var TOP_END = "top-end";
|
|
@@ -3901,12 +3788,12 @@ async function useRecompute(state) {
|
|
|
3901
3788
|
middleware: [
|
|
3902
3789
|
offset({ mainAxis: (_b = state == null ? void 0 : state.distance) != null ? _b : 8, crossAxis: (_c = state == null ? void 0 : state.skidding) != null ? _c : 0 }),
|
|
3903
3790
|
(state == null ? void 0 : state.flip) && flip2({
|
|
3904
|
-
|
|
3791
|
+
crossAxis: state == null ? void 0 : state.crossAxis,
|
|
3905
3792
|
fallbackPlacements: state == null ? void 0 : state.fallbackPlacements
|
|
3906
3793
|
}),
|
|
3907
|
-
!(state == null ? void 0 : state.
|
|
3908
|
-
|
|
3909
|
-
|
|
3794
|
+
!(state == null ? void 0 : state.noArrow) && (state == null ? void 0 : state.arrowEl) && arrow2({ element: state == null ? void 0 : state.arrowEl }),
|
|
3795
|
+
hide2()
|
|
3796
|
+
//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
3797
|
]
|
|
3911
3798
|
}).then(({ x, y, middlewareData, placement }) => {
|
|
3912
3799
|
state.actualDirection = placement;
|
|
@@ -3914,6 +3801,12 @@ async function useRecompute(state) {
|
|
|
3914
3801
|
left: `${x}px`,
|
|
3915
3802
|
top: `${y}px`
|
|
3916
3803
|
});
|
|
3804
|
+
if ((middlewareData == null ? void 0 : middlewareData.hide) && !(state == null ? void 0 : state.isCallout)) {
|
|
3805
|
+
const { referenceHidden } = middlewareData == null ? void 0 : middlewareData.hide;
|
|
3806
|
+
Object.assign(attentionEl == null ? void 0 : attentionEl.style, {
|
|
3807
|
+
visibility: referenceHidden ? "hidden" : ""
|
|
3808
|
+
});
|
|
3809
|
+
}
|
|
3917
3810
|
const isRtl = window.getComputedStyle(attentionEl).direction === "rtl";
|
|
3918
3811
|
const arrowPlacement = arrowDirection(placement).split("-")[1];
|
|
3919
3812
|
if ((middlewareData == null ? void 0 : middlewareData.arrow) && (state == null ? void 0 : state.arrowEl)) {
|
|
@@ -4010,6 +3903,7 @@ var WarpAttention = class extends kebabCaseAttributes(WarpElement3) {
|
|
|
4010
3903
|
this.distance = 8;
|
|
4011
3904
|
this.skidding = 0;
|
|
4012
3905
|
this.flip = false;
|
|
3906
|
+
this.crossAxis = false;
|
|
4013
3907
|
this._initialPlacement = this.placement;
|
|
4014
3908
|
this._actualDirection = this.placement;
|
|
4015
3909
|
}
|
|
@@ -4094,7 +3988,8 @@ ${JSON.stringify(directions)}`);
|
|
|
4094
3988
|
return this.renderRoot.querySelector("#attention");
|
|
4095
3989
|
}
|
|
4096
3990
|
get _targetEl() {
|
|
4097
|
-
|
|
3991
|
+
var _a;
|
|
3992
|
+
const targetSlot = (_a = this.renderRoot) == null ? void 0 : _a.querySelector("slot[name='target']");
|
|
4098
3993
|
return targetSlot ? targetSlot.assignedNodes()[0] : null;
|
|
4099
3994
|
}
|
|
4100
3995
|
get _messageEl() {
|
|
@@ -4140,6 +4035,7 @@ ${JSON.stringify(directions)}`);
|
|
|
4140
4035
|
distance: this.distance,
|
|
4141
4036
|
skidding: this.skidding,
|
|
4142
4037
|
flip: this.flip,
|
|
4038
|
+
crossAxis: this.crossAxis,
|
|
4143
4039
|
fallbackPlacements: this.fallbackPlacements
|
|
4144
4040
|
};
|
|
4145
4041
|
useRecompute(this.attentionState);
|
|
@@ -4244,6 +4140,8 @@ ${JSON.stringify(directions)}`);
|
|
|
4244
4140
|
}
|
|
4245
4141
|
}
|
|
4246
4142
|
render() {
|
|
4143
|
+
if (!this.callout && this._targetEl === void 0)
|
|
4144
|
+
return html9``;
|
|
4247
4145
|
return html9`
|
|
4248
4146
|
<div class=${ifDefined2(this.className ? this.className : void 0)}>
|
|
4249
4147
|
${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 +4187,8 @@ __publicField(WarpAttention, "properties", {
|
|
|
4289
4187
|
skidding: { type: Number, reflect: true },
|
|
4290
4188
|
// Whether Attention element should flip its placement in order to keep it in view
|
|
4291
4189
|
flip: { type: Boolean, reflect: true },
|
|
4190
|
+
// Whether Attention element should ignore cross axis overflow when flip is enabled
|
|
4191
|
+
crossAxis: { type: Boolean, reflect: true },
|
|
4292
4192
|
// Choose which preferred placements the Attention element should flip to
|
|
4293
4193
|
fallbackPlacements: { type: Array, reflect: true }
|
|
4294
4194
|
});
|
|
@@ -4406,7 +4306,7 @@ if (!customElements.get("w-box")) {
|
|
|
4406
4306
|
import { html as html12 } from "lit";
|
|
4407
4307
|
import WarpElement6 from "@warp-ds/elements-core";
|
|
4408
4308
|
|
|
4409
|
-
// node_modules/.pnpm/@warp-ds+core@1.1.
|
|
4309
|
+
// 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
4310
|
function interleave(array, separator2) {
|
|
4411
4311
|
return array.flatMap((el) => [el, separator2]).slice(0, -1);
|
|
4412
4312
|
}
|