@idds/js 1.2.1 → 1.2.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.iife.js +72 -30
- package/dist/index.js +72 -30
- package/package.json +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -3006,15 +3006,14 @@ var InaUI = (() => {
|
|
|
3006
3006
|
);
|
|
3007
3007
|
});
|
|
3008
3008
|
if (showCustomization) {
|
|
3009
|
-
const
|
|
3009
|
+
const isToggleBtn2 = (i) => i.hasAttribute("data-customization-toggle") || i.textContent.trim() === customizationLabel;
|
|
3010
|
+
const standardValues = Array.from(items).filter((item) => !isToggleBtn2(item)).map((item) => item.getAttribute("data-value"));
|
|
3010
3011
|
const customValues = normSelected.filter(
|
|
3011
3012
|
(val) => !standardValues.includes(val) && val !== ""
|
|
3012
3013
|
);
|
|
3013
3014
|
const isStandard = customValues.length === 0;
|
|
3014
3015
|
const primaryCustomValue = customValues[customValues.length - 1] || "";
|
|
3015
|
-
const toggleBtn = Array.from(items).find(
|
|
3016
|
-
(i) => i.textContent.trim() === customizationLabel
|
|
3017
|
-
);
|
|
3016
|
+
const toggleBtn = Array.from(items).find(isToggleBtn2);
|
|
3018
3017
|
const showInput = toggleBtn && normSelected.includes(toggleBtn.getAttribute("data-value")) || !isStandard && normSelected.length > 0;
|
|
3019
3018
|
if (showInput) {
|
|
3020
3019
|
if (!customFieldContainer) {
|
|
@@ -3035,16 +3034,11 @@ var InaUI = (() => {
|
|
|
3035
3034
|
`;
|
|
3036
3035
|
input = customFieldContainer.querySelector("input");
|
|
3037
3036
|
input.addEventListener("blur", (e) => {
|
|
3038
|
-
|
|
3039
|
-
if (val.trim()) {
|
|
3040
|
-
handleSelect(val.trim());
|
|
3041
|
-
}
|
|
3037
|
+
commitCustomValue(e.target);
|
|
3042
3038
|
});
|
|
3043
3039
|
input.addEventListener("keydown", (e) => {
|
|
3044
3040
|
if (e.key === "Enter") {
|
|
3045
|
-
|
|
3046
|
-
handleSelect(e.target.value.trim());
|
|
3047
|
-
}
|
|
3041
|
+
commitCustomValue(e.target);
|
|
3048
3042
|
e.target.blur();
|
|
3049
3043
|
}
|
|
3050
3044
|
});
|
|
@@ -3103,14 +3097,77 @@ var InaUI = (() => {
|
|
|
3103
3097
|
currentFocusedIndex = index2;
|
|
3104
3098
|
}
|
|
3105
3099
|
};
|
|
3100
|
+
const commitCustomValue = (inputEl) => {
|
|
3101
|
+
const finalValue = inputEl.value.trim();
|
|
3102
|
+
let normSelected = getNormalizedSelected();
|
|
3103
|
+
const toggleBtn = Array.from(items).find(isToggleBtn);
|
|
3104
|
+
const toggleVal = toggleBtn ? toggleBtn.getAttribute("data-value") : null;
|
|
3105
|
+
const standardValues = Array.from(items).filter((i) => !isToggleBtn(i)).map((i) => i.getAttribute("data-value"));
|
|
3106
|
+
const customValues = normSelected.filter(
|
|
3107
|
+
(val) => !standardValues.includes(val) && val !== "" && val !== toggleVal
|
|
3108
|
+
);
|
|
3109
|
+
const primaryCustomValue = customValues[customValues.length - 1];
|
|
3110
|
+
if (primaryCustomValue) {
|
|
3111
|
+
normSelected = normSelected.filter((v) => v !== primaryCustomValue);
|
|
3112
|
+
}
|
|
3113
|
+
if (finalValue !== "") {
|
|
3114
|
+
if (!normSelected.includes(finalValue)) {
|
|
3115
|
+
normSelected.push(finalValue);
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
if (isMultiple) {
|
|
3119
|
+
selectedValue = normSelected.join(",");
|
|
3120
|
+
} else {
|
|
3121
|
+
selectedValue = finalValue;
|
|
3122
|
+
}
|
|
3123
|
+
updateUI();
|
|
3124
|
+
const changeEvent = new CustomEvent(`${PREFIX4}-chip:change`, {
|
|
3125
|
+
detail: { value: isMultiple ? getNormalizedSelected() : selectedValue },
|
|
3126
|
+
bubbles: true
|
|
3127
|
+
});
|
|
3128
|
+
container.dispatchEvent(changeEvent);
|
|
3129
|
+
};
|
|
3106
3130
|
items.forEach((item, index2) => {
|
|
3107
3131
|
item.addEventListener("click", (e) => {
|
|
3108
3132
|
if (item.hasAttribute("disabled")) return;
|
|
3109
3133
|
currentFocusedIndex = index2;
|
|
3110
3134
|
const val = item.getAttribute("data-value");
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3135
|
+
if (showCustomization && isToggleBtn(item)) {
|
|
3136
|
+
const normSelected = getNormalizedSelected();
|
|
3137
|
+
let newSelected = [...normSelected];
|
|
3138
|
+
const standardValues = Array.from(items).filter((i) => !isToggleBtn(i)).map((i) => i.getAttribute("data-value"));
|
|
3139
|
+
const customValues = normSelected.filter(
|
|
3140
|
+
(v) => !standardValues.includes(v) && v !== "" && v !== val
|
|
3141
|
+
);
|
|
3142
|
+
const primaryCustomValue = customValues[customValues.length - 1];
|
|
3143
|
+
const isInputVisible = normSelected.includes(val) || customValues.length > 0;
|
|
3144
|
+
if (isInputVisible) {
|
|
3145
|
+
newSelected = newSelected.filter((v) => v !== val);
|
|
3146
|
+
if (primaryCustomValue) {
|
|
3147
|
+
if (isMultiple) {
|
|
3148
|
+
newSelected = newSelected.filter(
|
|
3149
|
+
(v) => v !== primaryCustomValue
|
|
3150
|
+
);
|
|
3151
|
+
} else {
|
|
3152
|
+
newSelected = [];
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
if (isMultiple) {
|
|
3156
|
+
selectedValue = newSelected.join(",");
|
|
3157
|
+
} else {
|
|
3158
|
+
selectedValue = newSelected.length ? newSelected[0] : "";
|
|
3159
|
+
}
|
|
3160
|
+
updateUI();
|
|
3161
|
+
const changeEvent = new CustomEvent(`${PREFIX4}-chip:change`, {
|
|
3162
|
+
detail: {
|
|
3163
|
+
value: isMultiple ? getNormalizedSelected() : selectedValue
|
|
3164
|
+
},
|
|
3165
|
+
bubbles: true
|
|
3166
|
+
});
|
|
3167
|
+
container.dispatchEvent(changeEvent);
|
|
3168
|
+
} else {
|
|
3169
|
+
handleSelect(val);
|
|
3170
|
+
}
|
|
3114
3171
|
} else {
|
|
3115
3172
|
handleSelect(val);
|
|
3116
3173
|
}
|
|
@@ -3134,22 +3191,7 @@ var InaUI = (() => {
|
|
|
3134
3191
|
}
|
|
3135
3192
|
if (e.key === " " || e.key === "Enter") {
|
|
3136
3193
|
e.preventDefault();
|
|
3137
|
-
|
|
3138
|
-
const label = item.textContent.trim();
|
|
3139
|
-
if (showCustomization && label === customizationLabel) {
|
|
3140
|
-
handleSelect(val);
|
|
3141
|
-
setTimeout(() => {
|
|
3142
|
-
const customFieldContainer2 = container.querySelector(
|
|
3143
|
-
`.${PREFIX4}-chip__custom-field`
|
|
3144
|
-
);
|
|
3145
|
-
if (customFieldContainer2) {
|
|
3146
|
-
const inputEl = customFieldContainer2.querySelector("input");
|
|
3147
|
-
if (inputEl) inputEl.focus();
|
|
3148
|
-
}
|
|
3149
|
-
}, 50);
|
|
3150
|
-
} else {
|
|
3151
|
-
handleSelect(val);
|
|
3152
|
-
}
|
|
3194
|
+
item.click();
|
|
3153
3195
|
}
|
|
3154
3196
|
});
|
|
3155
3197
|
});
|
package/dist/index.js
CHANGED
|
@@ -3086,15 +3086,14 @@ function initChip(rootSelector = `.${PREFIX5}-chip`) {
|
|
|
3086
3086
|
);
|
|
3087
3087
|
});
|
|
3088
3088
|
if (showCustomization) {
|
|
3089
|
-
const
|
|
3089
|
+
const isToggleBtn2 = (i) => i.hasAttribute("data-customization-toggle") || i.textContent.trim() === customizationLabel;
|
|
3090
|
+
const standardValues = Array.from(items).filter((item) => !isToggleBtn2(item)).map((item) => item.getAttribute("data-value"));
|
|
3090
3091
|
const customValues = normSelected.filter(
|
|
3091
3092
|
(val) => !standardValues.includes(val) && val !== ""
|
|
3092
3093
|
);
|
|
3093
3094
|
const isStandard = customValues.length === 0;
|
|
3094
3095
|
const primaryCustomValue = customValues[customValues.length - 1] || "";
|
|
3095
|
-
const toggleBtn = Array.from(items).find(
|
|
3096
|
-
(i) => i.textContent.trim() === customizationLabel
|
|
3097
|
-
);
|
|
3096
|
+
const toggleBtn = Array.from(items).find(isToggleBtn2);
|
|
3098
3097
|
const showInput = toggleBtn && normSelected.includes(toggleBtn.getAttribute("data-value")) || !isStandard && normSelected.length > 0;
|
|
3099
3098
|
if (showInput) {
|
|
3100
3099
|
if (!customFieldContainer) {
|
|
@@ -3115,16 +3114,11 @@ function initChip(rootSelector = `.${PREFIX5}-chip`) {
|
|
|
3115
3114
|
`;
|
|
3116
3115
|
input = customFieldContainer.querySelector("input");
|
|
3117
3116
|
input.addEventListener("blur", (e) => {
|
|
3118
|
-
|
|
3119
|
-
if (val.trim()) {
|
|
3120
|
-
handleSelect(val.trim());
|
|
3121
|
-
}
|
|
3117
|
+
commitCustomValue(e.target);
|
|
3122
3118
|
});
|
|
3123
3119
|
input.addEventListener("keydown", (e) => {
|
|
3124
3120
|
if (e.key === "Enter") {
|
|
3125
|
-
|
|
3126
|
-
handleSelect(e.target.value.trim());
|
|
3127
|
-
}
|
|
3121
|
+
commitCustomValue(e.target);
|
|
3128
3122
|
e.target.blur();
|
|
3129
3123
|
}
|
|
3130
3124
|
});
|
|
@@ -3183,14 +3177,77 @@ function initChip(rootSelector = `.${PREFIX5}-chip`) {
|
|
|
3183
3177
|
currentFocusedIndex = index2;
|
|
3184
3178
|
}
|
|
3185
3179
|
};
|
|
3180
|
+
const commitCustomValue = (inputEl) => {
|
|
3181
|
+
const finalValue = inputEl.value.trim();
|
|
3182
|
+
let normSelected = getNormalizedSelected();
|
|
3183
|
+
const toggleBtn = Array.from(items).find(isToggleBtn);
|
|
3184
|
+
const toggleVal = toggleBtn ? toggleBtn.getAttribute("data-value") : null;
|
|
3185
|
+
const standardValues = Array.from(items).filter((i) => !isToggleBtn(i)).map((i) => i.getAttribute("data-value"));
|
|
3186
|
+
const customValues = normSelected.filter(
|
|
3187
|
+
(val) => !standardValues.includes(val) && val !== "" && val !== toggleVal
|
|
3188
|
+
);
|
|
3189
|
+
const primaryCustomValue = customValues[customValues.length - 1];
|
|
3190
|
+
if (primaryCustomValue) {
|
|
3191
|
+
normSelected = normSelected.filter((v) => v !== primaryCustomValue);
|
|
3192
|
+
}
|
|
3193
|
+
if (finalValue !== "") {
|
|
3194
|
+
if (!normSelected.includes(finalValue)) {
|
|
3195
|
+
normSelected.push(finalValue);
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
if (isMultiple) {
|
|
3199
|
+
selectedValue = normSelected.join(",");
|
|
3200
|
+
} else {
|
|
3201
|
+
selectedValue = finalValue;
|
|
3202
|
+
}
|
|
3203
|
+
updateUI();
|
|
3204
|
+
const changeEvent = new CustomEvent(`${PREFIX5}-chip:change`, {
|
|
3205
|
+
detail: { value: isMultiple ? getNormalizedSelected() : selectedValue },
|
|
3206
|
+
bubbles: true
|
|
3207
|
+
});
|
|
3208
|
+
container.dispatchEvent(changeEvent);
|
|
3209
|
+
};
|
|
3186
3210
|
items.forEach((item, index2) => {
|
|
3187
3211
|
item.addEventListener("click", (e) => {
|
|
3188
3212
|
if (item.hasAttribute("disabled")) return;
|
|
3189
3213
|
currentFocusedIndex = index2;
|
|
3190
3214
|
const val = item.getAttribute("data-value");
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3215
|
+
if (showCustomization && isToggleBtn(item)) {
|
|
3216
|
+
const normSelected = getNormalizedSelected();
|
|
3217
|
+
let newSelected = [...normSelected];
|
|
3218
|
+
const standardValues = Array.from(items).filter((i) => !isToggleBtn(i)).map((i) => i.getAttribute("data-value"));
|
|
3219
|
+
const customValues = normSelected.filter(
|
|
3220
|
+
(v) => !standardValues.includes(v) && v !== "" && v !== val
|
|
3221
|
+
);
|
|
3222
|
+
const primaryCustomValue = customValues[customValues.length - 1];
|
|
3223
|
+
const isInputVisible = normSelected.includes(val) || customValues.length > 0;
|
|
3224
|
+
if (isInputVisible) {
|
|
3225
|
+
newSelected = newSelected.filter((v) => v !== val);
|
|
3226
|
+
if (primaryCustomValue) {
|
|
3227
|
+
if (isMultiple) {
|
|
3228
|
+
newSelected = newSelected.filter(
|
|
3229
|
+
(v) => v !== primaryCustomValue
|
|
3230
|
+
);
|
|
3231
|
+
} else {
|
|
3232
|
+
newSelected = [];
|
|
3233
|
+
}
|
|
3234
|
+
}
|
|
3235
|
+
if (isMultiple) {
|
|
3236
|
+
selectedValue = newSelected.join(",");
|
|
3237
|
+
} else {
|
|
3238
|
+
selectedValue = newSelected.length ? newSelected[0] : "";
|
|
3239
|
+
}
|
|
3240
|
+
updateUI();
|
|
3241
|
+
const changeEvent = new CustomEvent(`${PREFIX5}-chip:change`, {
|
|
3242
|
+
detail: {
|
|
3243
|
+
value: isMultiple ? getNormalizedSelected() : selectedValue
|
|
3244
|
+
},
|
|
3245
|
+
bubbles: true
|
|
3246
|
+
});
|
|
3247
|
+
container.dispatchEvent(changeEvent);
|
|
3248
|
+
} else {
|
|
3249
|
+
handleSelect(val);
|
|
3250
|
+
}
|
|
3194
3251
|
} else {
|
|
3195
3252
|
handleSelect(val);
|
|
3196
3253
|
}
|
|
@@ -3214,22 +3271,7 @@ function initChip(rootSelector = `.${PREFIX5}-chip`) {
|
|
|
3214
3271
|
}
|
|
3215
3272
|
if (e.key === " " || e.key === "Enter") {
|
|
3216
3273
|
e.preventDefault();
|
|
3217
|
-
|
|
3218
|
-
const label = item.textContent.trim();
|
|
3219
|
-
if (showCustomization && label === customizationLabel) {
|
|
3220
|
-
handleSelect(val);
|
|
3221
|
-
setTimeout(() => {
|
|
3222
|
-
const customFieldContainer2 = container.querySelector(
|
|
3223
|
-
`.${PREFIX5}-chip__custom-field`
|
|
3224
|
-
);
|
|
3225
|
-
if (customFieldContainer2) {
|
|
3226
|
-
const inputEl = customFieldContainer2.querySelector("input");
|
|
3227
|
-
if (inputEl) inputEl.focus();
|
|
3228
|
-
}
|
|
3229
|
-
}, 50);
|
|
3230
|
-
} else {
|
|
3231
|
-
handleSelect(val);
|
|
3232
|
-
}
|
|
3274
|
+
item.click();
|
|
3233
3275
|
}
|
|
3234
3276
|
});
|
|
3235
3277
|
});
|