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.cjs.js
CHANGED
|
@@ -30,6 +30,7 @@ __export(index_exports, {
|
|
|
30
30
|
computeRef: () => computeRef,
|
|
31
31
|
computed: () => computed,
|
|
32
32
|
createApp: () => createApp,
|
|
33
|
+
cref: () => cref,
|
|
33
34
|
defineComponent: () => defineComponent,
|
|
34
35
|
drainUnbind: () => drainUnbind,
|
|
35
36
|
endBatch: () => endBatch,
|
|
@@ -1185,6 +1186,131 @@ var isScope = (value) => {
|
|
|
1185
1186
|
return scopeSymbol2 in value;
|
|
1186
1187
|
};
|
|
1187
1188
|
|
|
1189
|
+
// src/reactivity/unref.ts
|
|
1190
|
+
var unref = (value) => {
|
|
1191
|
+
const anyValue = value;
|
|
1192
|
+
return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
// src/directives/attr.ts
|
|
1196
|
+
var xlinkNS = "http://www.w3.org/1999/xlink";
|
|
1197
|
+
var booleanAttributes = {
|
|
1198
|
+
itemscope: 2,
|
|
1199
|
+
allowfullscreen: 2,
|
|
1200
|
+
formnovalidate: 2,
|
|
1201
|
+
ismap: 2,
|
|
1202
|
+
nomodule: 2,
|
|
1203
|
+
novalidate: 2,
|
|
1204
|
+
readonly: 2,
|
|
1205
|
+
async: 1,
|
|
1206
|
+
autofocus: 1,
|
|
1207
|
+
autoplay: 1,
|
|
1208
|
+
controls: 1,
|
|
1209
|
+
default: 1,
|
|
1210
|
+
defer: 1,
|
|
1211
|
+
disabled: 1,
|
|
1212
|
+
hidden: 1,
|
|
1213
|
+
inert: 1,
|
|
1214
|
+
loop: 1,
|
|
1215
|
+
open: 1,
|
|
1216
|
+
required: 1,
|
|
1217
|
+
reversed: 1,
|
|
1218
|
+
scoped: 1,
|
|
1219
|
+
seamless: 1,
|
|
1220
|
+
checked: 1,
|
|
1221
|
+
muted: 1,
|
|
1222
|
+
multiple: 1,
|
|
1223
|
+
selected: 1
|
|
1224
|
+
};
|
|
1225
|
+
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
1226
|
+
if (option) {
|
|
1227
|
+
option = unref(option);
|
|
1228
|
+
if (flags && flags.includes("camel")) option = camelize(option);
|
|
1229
|
+
patchAttr(
|
|
1230
|
+
el,
|
|
1231
|
+
option,
|
|
1232
|
+
unref(values[0]),
|
|
1233
|
+
unref(previousOption)
|
|
1234
|
+
);
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
const len = values.length;
|
|
1238
|
+
for (let i = 0; i < len; ++i) {
|
|
1239
|
+
const next = values[i];
|
|
1240
|
+
if (isArray(next)) {
|
|
1241
|
+
const previousKey = unref(previousValues?.[i]?.[0]);
|
|
1242
|
+
const key = unref(next[0]);
|
|
1243
|
+
const value = unref(next[1]);
|
|
1244
|
+
patchAttr(el, key, value, previousKey);
|
|
1245
|
+
} else if (isObject(next)) {
|
|
1246
|
+
for (const item of Object.entries(next)) {
|
|
1247
|
+
const key = item[0];
|
|
1248
|
+
const value = unref(item[1]);
|
|
1249
|
+
const p = unref(previousValues?.[i]);
|
|
1250
|
+
const previousKey = p && key in p ? key : void 0;
|
|
1251
|
+
patchAttr(el, key, value, previousKey);
|
|
1252
|
+
}
|
|
1253
|
+
} else {
|
|
1254
|
+
const previousKey = unref(previousValues?.[i]);
|
|
1255
|
+
const key = unref(values[i++]);
|
|
1256
|
+
const value = unref(values[i]);
|
|
1257
|
+
patchAttr(el, key, value, previousKey);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
var attrDirective = {
|
|
1262
|
+
mount: () => ({
|
|
1263
|
+
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
1264
|
+
updateAttr(
|
|
1265
|
+
el,
|
|
1266
|
+
values,
|
|
1267
|
+
previousValues,
|
|
1268
|
+
option,
|
|
1269
|
+
previousOption,
|
|
1270
|
+
flags
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
})
|
|
1274
|
+
};
|
|
1275
|
+
var patchAttr = (el, key, value, previousKey) => {
|
|
1276
|
+
if (previousKey && previousKey !== key) {
|
|
1277
|
+
el.removeAttribute(previousKey);
|
|
1278
|
+
}
|
|
1279
|
+
if (isNullOrUndefined(key)) {
|
|
1280
|
+
warning(3 /* KeyIsEmpty */, "r-bind", el);
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
if (!isString(key)) {
|
|
1284
|
+
warning(
|
|
1285
|
+
6 /* ErrorLog */,
|
|
1286
|
+
`Attribute key is not string at ${el.outerHTML}`,
|
|
1287
|
+
key
|
|
1288
|
+
);
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
if (key.startsWith("xlink:")) {
|
|
1292
|
+
if (isNullOrUndefined(value)) {
|
|
1293
|
+
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
1294
|
+
} else {
|
|
1295
|
+
el.setAttributeNS(xlinkNS, key, value);
|
|
1296
|
+
}
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
if (isNullOrUndefined(value)) {
|
|
1300
|
+
el.removeAttribute(key);
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
if (key in booleanAttributes) {
|
|
1304
|
+
if (toBoolean(value)) {
|
|
1305
|
+
el.setAttribute(key, "");
|
|
1306
|
+
} else {
|
|
1307
|
+
el.removeAttribute(key);
|
|
1308
|
+
}
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
el.setAttribute(key, value);
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1188
1314
|
// src/directives/context.ts
|
|
1189
1315
|
var contextDirective = {
|
|
1190
1316
|
collectRefObj: true,
|
|
@@ -1915,10 +2041,11 @@ var ComponentBinder = class {
|
|
|
1915
2041
|
} else if (attrName === ":style" || attrName === bindStyleName) {
|
|
1916
2042
|
mergeBinding(":style", bindStyleName, value);
|
|
1917
2043
|
} else {
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
2044
|
+
const normalizedName = normalizeAttributeName(
|
|
2045
|
+
attrName,
|
|
2046
|
+
binder.__config
|
|
1921
2047
|
);
|
|
2048
|
+
patchAttr(inheritor, normalizedName, value);
|
|
1922
2049
|
}
|
|
1923
2050
|
};
|
|
1924
2051
|
for (const { name, value } of inheritedPropAttrs) {
|
|
@@ -2254,12 +2381,6 @@ var DynamicBinder = class {
|
|
|
2254
2381
|
}
|
|
2255
2382
|
};
|
|
2256
2383
|
|
|
2257
|
-
// src/reactivity/unref.ts
|
|
2258
|
-
var unref = (value) => {
|
|
2259
|
-
const anyValue = value;
|
|
2260
|
-
return anyValue != null && anyValue[srefSymbol] > 0 ? anyValue() : anyValue;
|
|
2261
|
-
};
|
|
2262
|
-
|
|
2263
2384
|
// src/directives/html.ts
|
|
2264
2385
|
var updateHtml = (el, values) => {
|
|
2265
2386
|
const [value, replacer] = values;
|
|
@@ -3195,115 +3316,6 @@ var Binder = class {
|
|
|
3195
3316
|
}
|
|
3196
3317
|
};
|
|
3197
3318
|
|
|
3198
|
-
// src/directives/attr.ts
|
|
3199
|
-
var xlinkNS = "http://www.w3.org/1999/xlink";
|
|
3200
|
-
var booleanAttributes = {
|
|
3201
|
-
itemscope: 2,
|
|
3202
|
-
allowfullscreen: 2,
|
|
3203
|
-
formnovalidate: 2,
|
|
3204
|
-
ismap: 2,
|
|
3205
|
-
nomodule: 2,
|
|
3206
|
-
novalidate: 2,
|
|
3207
|
-
readonly: 2,
|
|
3208
|
-
async: 1,
|
|
3209
|
-
autofocus: 1,
|
|
3210
|
-
autoplay: 1,
|
|
3211
|
-
controls: 1,
|
|
3212
|
-
default: 1,
|
|
3213
|
-
defer: 1,
|
|
3214
|
-
disabled: 1,
|
|
3215
|
-
hidden: 1,
|
|
3216
|
-
inert: 1,
|
|
3217
|
-
loop: 1,
|
|
3218
|
-
open: 1,
|
|
3219
|
-
required: 1,
|
|
3220
|
-
reversed: 1,
|
|
3221
|
-
scoped: 1,
|
|
3222
|
-
seamless: 1,
|
|
3223
|
-
checked: 1,
|
|
3224
|
-
muted: 1,
|
|
3225
|
-
multiple: 1,
|
|
3226
|
-
selected: 1
|
|
3227
|
-
};
|
|
3228
|
-
function includeBooleanAttr(value) {
|
|
3229
|
-
return !!value || value === "";
|
|
3230
|
-
}
|
|
3231
|
-
var updateAttr = (el, values, previousValues, option, previousOption, flags) => {
|
|
3232
|
-
if (option) {
|
|
3233
|
-
if (flags && flags.includes("camel")) option = camelize(option);
|
|
3234
|
-
patchAttribute(el, option, values[0], previousOption);
|
|
3235
|
-
return;
|
|
3236
|
-
}
|
|
3237
|
-
const len = values.length;
|
|
3238
|
-
for (let i = 0; i < len; ++i) {
|
|
3239
|
-
const next = values[i];
|
|
3240
|
-
if (isArray(next)) {
|
|
3241
|
-
const previousKey = previousValues?.[i]?.[0];
|
|
3242
|
-
const key = next[0];
|
|
3243
|
-
const value = next[1];
|
|
3244
|
-
patchAttribute(el, key, value, previousKey);
|
|
3245
|
-
} else if (isObject(next)) {
|
|
3246
|
-
for (const item of Object.entries(next)) {
|
|
3247
|
-
const key = item[0];
|
|
3248
|
-
const value = item[1];
|
|
3249
|
-
const p = previousValues?.[i];
|
|
3250
|
-
const previousKey = p && key in p ? key : void 0;
|
|
3251
|
-
patchAttribute(el, key, value, previousKey);
|
|
3252
|
-
}
|
|
3253
|
-
} else {
|
|
3254
|
-
const previousKey = previousValues?.[i];
|
|
3255
|
-
const key = values[i++];
|
|
3256
|
-
const value = values[i];
|
|
3257
|
-
patchAttribute(el, key, value, previousKey);
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
};
|
|
3261
|
-
var attrDirective = {
|
|
3262
|
-
mount: () => ({
|
|
3263
|
-
update: ({ el, values, previousValues, option, previousOption, flags }) => {
|
|
3264
|
-
updateAttr(
|
|
3265
|
-
el,
|
|
3266
|
-
values,
|
|
3267
|
-
previousValues,
|
|
3268
|
-
option,
|
|
3269
|
-
previousOption,
|
|
3270
|
-
flags
|
|
3271
|
-
);
|
|
3272
|
-
}
|
|
3273
|
-
})
|
|
3274
|
-
};
|
|
3275
|
-
var patchAttribute = (el, key, value, previousKey) => {
|
|
3276
|
-
if (previousKey && previousKey !== key) {
|
|
3277
|
-
el.removeAttribute(previousKey);
|
|
3278
|
-
}
|
|
3279
|
-
if (isNullOrUndefined(key)) {
|
|
3280
|
-
warning(3 /* KeyIsEmpty */, "r-bind", el);
|
|
3281
|
-
return;
|
|
3282
|
-
}
|
|
3283
|
-
if (!isString(key)) {
|
|
3284
|
-
warning(
|
|
3285
|
-
6 /* ErrorLog */,
|
|
3286
|
-
`Attribute key is not string at ${el.outerHTML}`,
|
|
3287
|
-
key
|
|
3288
|
-
);
|
|
3289
|
-
return;
|
|
3290
|
-
}
|
|
3291
|
-
if (key.startsWith("xlink:")) {
|
|
3292
|
-
if (isNullOrUndefined(value)) {
|
|
3293
|
-
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
3294
|
-
} else {
|
|
3295
|
-
el.setAttributeNS(xlinkNS, key, value);
|
|
3296
|
-
}
|
|
3297
|
-
return;
|
|
3298
|
-
}
|
|
3299
|
-
const isBoolean2 = key in booleanAttributes;
|
|
3300
|
-
if (isNullOrUndefined(value) || isBoolean2 && !includeBooleanAttr(value)) {
|
|
3301
|
-
el.removeAttribute(key);
|
|
3302
|
-
} else {
|
|
3303
|
-
el.setAttribute(key, isBoolean2 ? "" : value);
|
|
3304
|
-
}
|
|
3305
|
-
};
|
|
3306
|
-
|
|
3307
3319
|
// src/directives/class.ts
|
|
3308
3320
|
var updateClass = (el, values, previousValues) => {
|
|
3309
3321
|
const len = values.length;
|
|
@@ -3948,7 +3960,7 @@ var propDirective = {
|
|
|
3948
3960
|
}
|
|
3949
3961
|
})
|
|
3950
3962
|
};
|
|
3951
|
-
function
|
|
3963
|
+
function includeBooleanAttr(value) {
|
|
3952
3964
|
return !!value || value === "";
|
|
3953
3965
|
}
|
|
3954
3966
|
var patchProp = (el, key, value) => {
|
|
@@ -3980,7 +3992,7 @@ var patchProp = (el, key, value) => {
|
|
|
3980
3992
|
if (value === "" || value == null) {
|
|
3981
3993
|
const type = typeof el[key];
|
|
3982
3994
|
if (type === "boolean") {
|
|
3983
|
-
value =
|
|
3995
|
+
value = includeBooleanAttr(value);
|
|
3984
3996
|
} else if (value == null && type === "string") {
|
|
3985
3997
|
value = "";
|
|
3986
3998
|
needRemove = true;
|
|
@@ -4146,6 +4158,8 @@ var flatten = (reference) => {
|
|
|
4146
4158
|
var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
|
|
4147
4159
|
if (!value) return value;
|
|
4148
4160
|
if (!isObject(value)) return value;
|
|
4161
|
+
if (value instanceof Node || value instanceof Date || value instanceof RegExp || value instanceof Promise || value instanceof Error)
|
|
4162
|
+
return value;
|
|
4149
4163
|
if (isArray(value)) {
|
|
4150
4164
|
return value.map(flatten);
|
|
4151
4165
|
}
|
|
@@ -4233,6 +4247,11 @@ function ref(value) {
|
|
|
4233
4247
|
return result;
|
|
4234
4248
|
}
|
|
4235
4249
|
|
|
4250
|
+
// src/reactivity/cref.ts
|
|
4251
|
+
function cref(value) {
|
|
4252
|
+
return ref(flatten(value));
|
|
4253
|
+
}
|
|
4254
|
+
|
|
4236
4255
|
// src/app/RegorConfig.ts
|
|
4237
4256
|
var RegorConfig = class _RegorConfig {
|
|
4238
4257
|
static getDefault() {
|
|
@@ -4300,6 +4319,7 @@ var RegorConfig = class _RegorConfig {
|
|
|
4300
4319
|
obj[key] = global[key];
|
|
4301
4320
|
}
|
|
4302
4321
|
obj.ref = ref;
|
|
4322
|
+
obj.cref = cref;
|
|
4303
4323
|
obj.sref = sref;
|
|
4304
4324
|
obj.flatten = flatten;
|
|
4305
4325
|
return obj;
|