regor 1.7.0 → 1.7.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/README.md +3 -2
- package/dist/regor.d.ts +24 -0
- package/dist/regor.es2015.cjs.js +141 -121
- package/dist/regor.es2015.cjs.prod.js +3 -3
- package/dist/regor.es2015.esm.js +141 -121
- package/dist/regor.es2015.esm.prod.js +3 -3
- package/dist/regor.es2015.iife.js +141 -121
- package/dist/regor.es2015.iife.prod.js +3 -3
- package/dist/regor.es2019.cjs.js +141 -121
- package/dist/regor.es2019.cjs.prod.js +3 -3
- package/dist/regor.es2019.esm.js +141 -121
- package/dist/regor.es2019.esm.prod.js +3 -3
- package/dist/regor.es2019.iife.js +141 -121
- package/dist/regor.es2019.iife.prod.js +3 -3
- package/dist/regor.es2022.cjs.js +140 -120
- package/dist/regor.es2022.cjs.prod.js +3 -3
- package/dist/regor.es2022.esm.js +140 -120
- package/dist/regor.es2022.esm.prod.js +3 -3
- package/dist/regor.es2022.iife.js +140 -120
- package/dist/regor.es2022.iife.prod.js +3 -3
- package/package.json +1 -1
package/dist/regor.es2022.esm.js
CHANGED
|
@@ -1115,6 +1115,131 @@ var isScope = (value) => {
|
|
|
1115
1115
|
return scopeSymbol2 in value;
|
|
1116
1116
|
};
|
|
1117
1117
|
|
|
1118
|
+
// src/reactivity/unref.ts
|
|
1119
|
+
var unref = (value) => {
|
|
1120
|
+
const anyValue = value;
|
|
1121
|
+
return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
// src/directives/attr.ts
|
|
1125
|
+
var xlinkNS = "http://www.w3.org/1999/xlink";
|
|
1126
|
+
var booleanAttributes = {
|
|
1127
|
+
itemscope: 2,
|
|
1128
|
+
allowfullscreen: 2,
|
|
1129
|
+
formnovalidate: 2,
|
|
1130
|
+
ismap: 2,
|
|
1131
|
+
nomodule: 2,
|
|
1132
|
+
novalidate: 2,
|
|
1133
|
+
readonly: 2,
|
|
1134
|
+
async: 1,
|
|
1135
|
+
autofocus: 1,
|
|
1136
|
+
autoplay: 1,
|
|
1137
|
+
controls: 1,
|
|
1138
|
+
default: 1,
|
|
1139
|
+
defer: 1,
|
|
1140
|
+
disabled: 1,
|
|
1141
|
+
hidden: 1,
|
|
1142
|
+
inert: 1,
|
|
1143
|
+
loop: 1,
|
|
1144
|
+
open: 1,
|
|
1145
|
+
required: 1,
|
|
1146
|
+
reversed: 1,
|
|
1147
|
+
scoped: 1,
|
|
1148
|
+
seamless: 1,
|
|
1149
|
+
checked: 1,
|
|
1150
|
+
muted: 1,
|
|
1151
|
+
multiple: 1,
|
|
1152
|
+
selected: 1
|
|
1153
|
+
};
|
|
1154
|
+
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
1155
|
+
if (option) {
|
|
1156
|
+
option = unref(option);
|
|
1157
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
1158
|
+
patchAttr(
|
|
1159
|
+
el,
|
|
1160
|
+
option,
|
|
1161
|
+
unref(values[0]),
|
|
1162
|
+
unref(previousOption)
|
|
1163
|
+
);
|
|
1164
|
+
return;
|
|
1165
|
+
}
|
|
1166
|
+
const len = values.length;
|
|
1167
|
+
for (let i = 0; i < len; ++i) {
|
|
1168
|
+
const next = values[i];
|
|
1169
|
+
if (isArray(next)) {
|
|
1170
|
+
const previousKey = unref(previousValues?.[i]?.[0]);
|
|
1171
|
+
const key = unref(next[0]);
|
|
1172
|
+
const value = unref(next[1]);
|
|
1173
|
+
patchAttr(el, key, value, previousKey);
|
|
1174
|
+
} else if (isObject(next)) {
|
|
1175
|
+
for (const item of Object.entries(next)) {
|
|
1176
|
+
const key = item[0];
|
|
1177
|
+
const value = unref(item[1]);
|
|
1178
|
+
const p = unref(previousValues?.[i]);
|
|
1179
|
+
const previousKey = p && key in p ? key : void 0;
|
|
1180
|
+
patchAttr(el, key, value, previousKey);
|
|
1181
|
+
}
|
|
1182
|
+
} else {
|
|
1183
|
+
const previousKey = unref(previousValues?.[i]);
|
|
1184
|
+
const key = unref(values[i++]);
|
|
1185
|
+
const value = unref(values[i]);
|
|
1186
|
+
patchAttr(el, key, value, previousKey);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
var attrDirective = {
|
|
1191
|
+
mount: () => ({
|
|
1192
|
+
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
1193
|
+
updateAttr(
|
|
1194
|
+
el,
|
|
1195
|
+
values,
|
|
1196
|
+
previousValues,
|
|
1197
|
+
option,
|
|
1198
|
+
previousOption,
|
|
1199
|
+
flags
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1202
|
+
})
|
|
1203
|
+
};
|
|
1204
|
+
var patchAttr = (el, key, value, previousKey) => {
|
|
1205
|
+
if (previousKey && previousKey !== key) {
|
|
1206
|
+
el.removeAttribute(previousKey);
|
|
1207
|
+
}
|
|
1208
|
+
if (isNullOrUndefined(key)) {
|
|
1209
|
+
warning(3 /* KeyIsEmpty */, "r-bind", el);
|
|
1210
|
+
return;
|
|
1211
|
+
}
|
|
1212
|
+
if (!isString(key)) {
|
|
1213
|
+
warning(
|
|
1214
|
+
6 /* ErrorLog */,
|
|
1215
|
+
`Attribute key is not string at ${el.outerHTML}`,
|
|
1216
|
+
key
|
|
1217
|
+
);
|
|
1218
|
+
return;
|
|
1219
|
+
}
|
|
1220
|
+
if (key.startsWith("xlink:")) {
|
|
1221
|
+
if (isNullOrUndefined(value)) {
|
|
1222
|
+
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
1223
|
+
} else {
|
|
1224
|
+
el.setAttributeNS(xlinkNS, key, value);
|
|
1225
|
+
}
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
if (isNullOrUndefined(value)) {
|
|
1229
|
+
el.removeAttribute(key);
|
|
1230
|
+
return;
|
|
1231
|
+
}
|
|
1232
|
+
if (key in booleanAttributes) {
|
|
1233
|
+
if (toBoolean(value)) {
|
|
1234
|
+
el.setAttribute(key, "");
|
|
1235
|
+
} else {
|
|
1236
|
+
el.removeAttribute(key);
|
|
1237
|
+
}
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
el.setAttribute(key, value);
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1118
1243
|
// src/directives/context.ts
|
|
1119
1244
|
var contextDirective = {
|
|
1120
1245
|
collectRefObj: true,
|
|
@@ -1845,10 +1970,11 @@ var ComponentBinder = class {
|
|
|
1845
1970
|
} else if (attrName === ":style" || attrName === bindStyleName) {
|
|
1846
1971
|
mergeBinding(":style", bindStyleName, value);
|
|
1847
1972
|
} else {
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1973
|
+
const normalizedName = normalizeAttributeName(
|
|
1974
|
+
attrName,
|
|
1975
|
+
binder.__config
|
|
1851
1976
|
);
|
|
1977
|
+
patchAttr(inheritor, normalizedName, value);
|
|
1852
1978
|
}
|
|
1853
1979
|
};
|
|
1854
1980
|
for (const { name, value } of inheritedPropAttrs) {
|
|
@@ -2184,12 +2310,6 @@ var DynamicBinder = class {
|
|
|
2184
2310
|
}
|
|
2185
2311
|
};
|
|
2186
2312
|
|
|
2187
|
-
// src/reactivity/unref.ts
|
|
2188
|
-
var unref = (value) => {
|
|
2189
|
-
const anyValue = value;
|
|
2190
|
-
return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
|
|
2191
|
-
};
|
|
2192
|
-
|
|
2193
2313
|
// src/directives/html.ts
|
|
2194
2314
|
var updateHtml = (el, values) => {
|
|
2195
2315
|
const [value, replacer] = values;
|
|
@@ -3125,115 +3245,6 @@ var Binder = class {
|
|
|
3125
3245
|
}
|
|
3126
3246
|
};
|
|
3127
3247
|
|
|
3128
|
-
// src/directives/attr.ts
|
|
3129
|
-
var xlinkNS = "http://www.w3.org/1999/xlink";
|
|
3130
|
-
var booleanAttributes = {
|
|
3131
|
-
itemscope: 2,
|
|
3132
|
-
allowfullscreen: 2,
|
|
3133
|
-
formnovalidate: 2,
|
|
3134
|
-
ismap: 2,
|
|
3135
|
-
nomodule: 2,
|
|
3136
|
-
novalidate: 2,
|
|
3137
|
-
readonly: 2,
|
|
3138
|
-
async: 1,
|
|
3139
|
-
autofocus: 1,
|
|
3140
|
-
autoplay: 1,
|
|
3141
|
-
controls: 1,
|
|
3142
|
-
default: 1,
|
|
3143
|
-
defer: 1,
|
|
3144
|
-
disabled: 1,
|
|
3145
|
-
hidden: 1,
|
|
3146
|
-
inert: 1,
|
|
3147
|
-
loop: 1,
|
|
3148
|
-
open: 1,
|
|
3149
|
-
required: 1,
|
|
3150
|
-
reversed: 1,
|
|
3151
|
-
scoped: 1,
|
|
3152
|
-
seamless: 1,
|
|
3153
|
-
checked: 1,
|
|
3154
|
-
muted: 1,
|
|
3155
|
-
multiple: 1,
|
|
3156
|
-
selected: 1
|
|
3157
|
-
};
|
|
3158
|
-
function includeBooleanAttr(value) {
|
|
3159
|
-
return !!value || value === "";
|
|
3160
|
-
}
|
|
3161
|
-
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
3162
|
-
if (option) {
|
|
3163
|
-
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3164
|
-
patchAttribute(el, option, values[0], previousOption);
|
|
3165
|
-
return;
|
|
3166
|
-
}
|
|
3167
|
-
const len = values.length;
|
|
3168
|
-
for (let i = 0; i < len; ++i) {
|
|
3169
|
-
const next = values[i];
|
|
3170
|
-
if (isArray(next)) {
|
|
3171
|
-
const previousKey = previousValues?.[i]?.[0];
|
|
3172
|
-
const key = next[0];
|
|
3173
|
-
const value = next[1];
|
|
3174
|
-
patchAttribute(el, key, value, previousKey);
|
|
3175
|
-
} else if (isObject(next)) {
|
|
3176
|
-
for (const item of Object.entries(next)) {
|
|
3177
|
-
const key = item[0];
|
|
3178
|
-
const value = item[1];
|
|
3179
|
-
const p = previousValues?.[i];
|
|
3180
|
-
const previousKey = p && key in p ? key : void 0;
|
|
3181
|
-
patchAttribute(el, key, value, previousKey);
|
|
3182
|
-
}
|
|
3183
|
-
} else {
|
|
3184
|
-
const previousKey = previousValues?.[i];
|
|
3185
|
-
const key = values[i++];
|
|
3186
|
-
const value = values[i];
|
|
3187
|
-
patchAttribute(el, key, value, previousKey);
|
|
3188
|
-
}
|
|
3189
|
-
}
|
|
3190
|
-
};
|
|
3191
|
-
var attrDirective = {
|
|
3192
|
-
mount: () => ({
|
|
3193
|
-
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
3194
|
-
updateAttr(
|
|
3195
|
-
el,
|
|
3196
|
-
values,
|
|
3197
|
-
previousValues,
|
|
3198
|
-
option,
|
|
3199
|
-
previousOption,
|
|
3200
|
-
flags
|
|
3201
|
-
);
|
|
3202
|
-
}
|
|
3203
|
-
})
|
|
3204
|
-
};
|
|
3205
|
-
var patchAttribute = (el, key, value, previousKey) => {
|
|
3206
|
-
if (previousKey && previousKey !== key) {
|
|
3207
|
-
el.removeAttribute(previousKey);
|
|
3208
|
-
}
|
|
3209
|
-
if (isNullOrUndefined(key)) {
|
|
3210
|
-
warning(3 /* KeyIsEmpty */, "r-bind", el);
|
|
3211
|
-
return;
|
|
3212
|
-
}
|
|
3213
|
-
if (!isString(key)) {
|
|
3214
|
-
warning(
|
|
3215
|
-
6 /* ErrorLog */,
|
|
3216
|
-
`Attribute key is not string at ${el.outerHTML}`,
|
|
3217
|
-
key
|
|
3218
|
-
);
|
|
3219
|
-
return;
|
|
3220
|
-
}
|
|
3221
|
-
if (key.startsWith("xlink:")) {
|
|
3222
|
-
if (isNullOrUndefined(value)) {
|
|
3223
|
-
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
3224
|
-
} else {
|
|
3225
|
-
el.setAttributeNS(xlinkNS, key, value);
|
|
3226
|
-
}
|
|
3227
|
-
return;
|
|
3228
|
-
}
|
|
3229
|
-
const isBoolean2 = key in booleanAttributes;
|
|
3230
|
-
if (isNullOrUndefined(value) || isBoolean2 && !includeBooleanAttr(value)) {
|
|
3231
|
-
el.removeAttribute(key);
|
|
3232
|
-
} else {
|
|
3233
|
-
el.setAttribute(key, isBoolean2 ? "" : value);
|
|
3234
|
-
}
|
|
3235
|
-
};
|
|
3236
|
-
|
|
3237
3248
|
// src/directives/class.ts
|
|
3238
3249
|
var updateClass = (el, values, previousValues) => {
|
|
3239
3250
|
const len = values.length;
|
|
@@ -3878,7 +3889,7 @@ var propDirective = {
|
|
|
3878
3889
|
}
|
|
3879
3890
|
})
|
|
3880
3891
|
};
|
|
3881
|
-
function
|
|
3892
|
+
function includeBooleanAttr(value) {
|
|
3882
3893
|
return !!value || value === "";
|
|
3883
3894
|
}
|
|
3884
3895
|
var patchProp = (el, key, value) => {
|
|
@@ -3910,7 +3921,7 @@ var patchProp = (el, key, value) => {
|
|
|
3910
3921
|
if (value === "" || value == null) {
|
|
3911
3922
|
const type = typeof el[key];
|
|
3912
3923
|
if (type === "boolean") {
|
|
3913
|
-
value =
|
|
3924
|
+
value = includeBooleanAttr(value);
|
|
3914
3925
|
} else if (value == null && type === "string") {
|
|
3915
3926
|
value = "";
|
|
3916
3927
|
needRemove = true;
|
|
@@ -4076,6 +4087,8 @@ var flatten = (reference) => {
|
|
|
4076
4087
|
var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
|
|
4077
4088
|
if (!value) return value;
|
|
4078
4089
|
if (!isObject(value)) return value;
|
|
4090
|
+
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
4091
|
+
return value;
|
|
4079
4092
|
if (isArray(value)) {
|
|
4080
4093
|
return value.map(flatten);
|
|
4081
4094
|
}
|
|
@@ -4163,6 +4176,11 @@ function ref(value) {
|
|
|
4163
4176
|
return result;
|
|
4164
4177
|
}
|
|
4165
4178
|
|
|
4179
|
+
// src/reactivity/cref.ts
|
|
4180
|
+
function cref(value) {
|
|
4181
|
+
return ref(flatten(value));
|
|
4182
|
+
}
|
|
4183
|
+
|
|
4166
4184
|
// src/app/RegorConfig.ts
|
|
4167
4185
|
var RegorConfig = class _RegorConfig {
|
|
4168
4186
|
static getDefault() {
|
|
@@ -4230,6 +4248,7 @@ var RegorConfig = class _RegorConfig {
|
|
|
4230
4248
|
obj[key] = global[key];
|
|
4231
4249
|
}
|
|
4232
4250
|
obj.ref = ref;
|
|
4251
|
+
obj.cref = cref;
|
|
4233
4252
|
obj.sref = sref;
|
|
4234
4253
|
obj.flatten = flatten;
|
|
4235
4254
|
return obj;
|
|
@@ -6884,6 +6903,7 @@ export {
|
|
|
6884
6903
|
computeRef,
|
|
6885
6904
|
computed,
|
|
6886
6905
|
createApp,
|
|
6906
|
+
cref,
|
|
6887
6907
|
defineComponent,
|
|
6888
6908
|
drainUnbind,
|
|
6889
6909
|
endBatch,
|