@pageboard/html 0.15.1 → 0.15.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/elements/form.js +31 -68
- package/elements/image.js +8 -0
- package/lib/nouislider.js +64 -5
- package/package.json +2 -2
- package/ui/form.js +1 -1
- package/ui/image.js +5 -4
- package/ui/otp.js +1 -0
package/elements/form.js
CHANGED
|
@@ -72,6 +72,7 @@ exports.api_form = {
|
|
|
72
72
|
group: 'block form',
|
|
73
73
|
menu: "form",
|
|
74
74
|
required: ["action"],
|
|
75
|
+
unique: ["name"],
|
|
75
76
|
expressions: true,
|
|
76
77
|
$lock: {
|
|
77
78
|
'data.action.parameters': 'webmaster'
|
|
@@ -79,9 +80,9 @@ exports.api_form = {
|
|
|
79
80
|
properties: {
|
|
80
81
|
name: {
|
|
81
82
|
title: 'Name',
|
|
82
|
-
description: "
|
|
83
|
+
description: "Exposes /@api/$name\nUsed by query 'submit' or 'toggle'",
|
|
83
84
|
type: 'string',
|
|
84
|
-
format: '
|
|
85
|
+
format: 'name',
|
|
85
86
|
nullable: true
|
|
86
87
|
},
|
|
87
88
|
hidden: {
|
|
@@ -101,72 +102,16 @@ exports.api_form = {
|
|
|
101
102
|
description: 'Choose a service',
|
|
102
103
|
$ref: '/writes'
|
|
103
104
|
},
|
|
104
|
-
request: {
|
|
105
|
-
title: 'Map inputs',
|
|
106
|
-
description: `
|
|
107
|
-
expr is supposed to be used to merge stuff into html,
|
|
108
|
-
not really to merge stuff into methods parameters
|
|
109
|
-
Also expr has a bad design because
|
|
110
|
-
- it can be replaced by a binding element inside the block
|
|
111
|
-
- it forces the expression to be in a specific attribute,
|
|
112
|
-
and mostly when a block has no content (so a binding cannot be used)
|
|
113
|
-
- the editor is ugly and shows fields that might not even be merged into html
|
|
114
|
-
Use cases
|
|
115
|
-
- links in anchors, images
|
|
116
|
-
- input or buttons values, checked attributes
|
|
117
|
-
- hidden attributes
|
|
118
|
-
- show/hide blocks depending on response
|
|
119
|
-
The "expr" mecanism could instead be a list of expressions like
|
|
120
|
-
[url|as:url|assign:.query.reservation:$query.reservation]
|
|
121
|
-
[url][$query|pick:text:cover|as:query]
|
|
122
|
-
|
|
123
|
-
Things to solve:
|
|
124
|
-
- do we want expr to be able to do changes outside the DOM of the block itself ? (no, this should be done by a binding element)
|
|
125
|
-
- do we want expr to change only data before merge - outside of any dom context ? Possibly ! In which case the current system is not that bad,
|
|
126
|
-
but it should not use matchdom dom plugin at all
|
|
127
|
-
- how to deal with "template" expressions when one cannot insert a binding
|
|
128
|
-
element ? Is it really something that happens ?
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
`,
|
|
133
|
-
type: 'object',
|
|
134
|
-
nullable: true
|
|
135
|
-
},
|
|
136
|
-
response: {
|
|
137
|
-
title: 'Map outputs',
|
|
138
|
-
description: `
|
|
139
|
-
'item.id': '[item.data.id]'
|
|
140
|
-
'item.title': '[item.content.title]'
|
|
141
|
-
// etc...
|
|
142
|
-
`,
|
|
143
|
-
type: 'object',
|
|
144
|
-
nullable: true
|
|
145
|
-
},
|
|
146
105
|
redirection: {
|
|
147
106
|
title: 'Success',
|
|
148
|
-
description:
|
|
149
|
-
redirection can be used by client,
|
|
150
|
-
to change the page state. In which case the "url" is not an api url.
|
|
151
|
-
It can be used by the server, in which case the "url" is an api url.
|
|
152
|
-
The parameters for a page url make the query, and $query, $request, $response are available.
|
|
153
|
-
The parameters for a user api call are...?
|
|
154
|
-
The user api endpoint is a real url (/@api/xxx) that can expect
|
|
155
|
-
a body ($request) and a query ($query) too.
|
|
156
|
-
Currently client pages use a trick to redirect and submit: a specific parameter triggers a form submit on the redirected page. This makes sense in the context of page navigation - the body is filled by the form that is triggered by the parameters.
|
|
157
|
-
How can that be transposed for internal user api redirection ?
|
|
158
|
-
1. since it redirects, output mapping can be done to format the $response
|
|
159
|
-
2. in the next api call, parameters mean $query, $response becomes $request ?
|
|
160
|
-
3. this works if output can merge $query, $request as well
|
|
161
|
-
`,
|
|
107
|
+
description: 'Page state or action',
|
|
162
108
|
type: 'object',
|
|
163
109
|
properties: {
|
|
164
|
-
|
|
165
|
-
title: '
|
|
110
|
+
name: {
|
|
111
|
+
title: 'Form or Fetch Name',
|
|
166
112
|
nullable: true,
|
|
167
|
-
type:
|
|
168
|
-
format:
|
|
169
|
-
$helper: "page"
|
|
113
|
+
type: 'string',
|
|
114
|
+
format: 'name'
|
|
170
115
|
},
|
|
171
116
|
parameters: {
|
|
172
117
|
title: 'Parameters',
|
|
@@ -180,6 +125,12 @@ exports.api_form = {
|
|
|
180
125
|
title: 'Bad request',
|
|
181
126
|
type: 'object',
|
|
182
127
|
properties: {
|
|
128
|
+
name: {
|
|
129
|
+
title: 'Form or Fetch Name',
|
|
130
|
+
nullable: true,
|
|
131
|
+
type: 'string',
|
|
132
|
+
format: 'name'
|
|
133
|
+
},
|
|
183
134
|
parameters: {
|
|
184
135
|
title: 'Parameters',
|
|
185
136
|
type: "object",
|
|
@@ -192,6 +143,12 @@ exports.api_form = {
|
|
|
192
143
|
title: 'Unauthorized request',
|
|
193
144
|
type: 'object',
|
|
194
145
|
properties: {
|
|
146
|
+
name: {
|
|
147
|
+
title: 'Form or Fetch Name',
|
|
148
|
+
nullable: true,
|
|
149
|
+
type: 'string',
|
|
150
|
+
format: 'name'
|
|
151
|
+
},
|
|
195
152
|
parameters: {
|
|
196
153
|
title: 'Parameters',
|
|
197
154
|
type: "object",
|
|
@@ -204,6 +161,12 @@ exports.api_form = {
|
|
|
204
161
|
title: 'Request not found',
|
|
205
162
|
type: 'object',
|
|
206
163
|
properties: {
|
|
164
|
+
name: {
|
|
165
|
+
title: 'Form or Fetch Name',
|
|
166
|
+
nullable: true,
|
|
167
|
+
type: 'string',
|
|
168
|
+
format: 'name'
|
|
169
|
+
},
|
|
207
170
|
parameters: {
|
|
208
171
|
title: 'Parameters',
|
|
209
172
|
type: "object",
|
|
@@ -217,11 +180,11 @@ exports.api_form = {
|
|
|
217
180
|
tag: 'form[method="post"]',
|
|
218
181
|
html: `<form is="element-form" method="post" name="[name]" masked="[masked]"
|
|
219
182
|
action="/@api/form/[name|else:$id]"
|
|
220
|
-
parameters="[
|
|
221
|
-
success="[redirection.
|
|
222
|
-
badrequest="[badrequest.
|
|
223
|
-
unauthorized="[unauthorized.
|
|
224
|
-
notfound="[notfound.
|
|
183
|
+
parameters="[action?.request|as:expressions]"
|
|
184
|
+
success="[redirection.parameters|as:query]"
|
|
185
|
+
badrequest="[badrequest.parameters|as:query]"
|
|
186
|
+
unauthorized="[unauthorized.parameters|as:query]"
|
|
187
|
+
notfound="[notfound.parameters|as:query]"
|
|
225
188
|
class="ui form [hidden]"></form>`,
|
|
226
189
|
stylesheets: [
|
|
227
190
|
'../ui/components/form.css',
|
package/elements/image.js
CHANGED
|
@@ -25,6 +25,10 @@ exports.image = {
|
|
|
25
25
|
filter: {
|
|
26
26
|
type: ["image"]
|
|
27
27
|
}
|
|
28
|
+
},
|
|
29
|
+
$file: {
|
|
30
|
+
size: 50000000,
|
|
31
|
+
types: ["image/*"]
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
display: {
|
|
@@ -169,6 +173,10 @@ exports.inlineImage = {
|
|
|
169
173
|
maxWidth: 320,
|
|
170
174
|
maxHeight: 320
|
|
171
175
|
}
|
|
176
|
+
},
|
|
177
|
+
$file: {
|
|
178
|
+
size: 200000,
|
|
179
|
+
types: ["image/*"]
|
|
172
180
|
}
|
|
173
181
|
},
|
|
174
182
|
display: {
|
package/lib/nouislider.js
CHANGED
|
@@ -713,6 +713,7 @@
|
|
|
713
713
|
var snap = entry.indexOf("snap") >= 0;
|
|
714
714
|
var hover = entry.indexOf("hover") >= 0;
|
|
715
715
|
var unconstrained = entry.indexOf("unconstrained") >= 0;
|
|
716
|
+
var invertConnects = entry.indexOf("invert-connects") >= 0;
|
|
716
717
|
var dragAll = entry.indexOf("drag-all") >= 0;
|
|
717
718
|
var smoothSteps = entry.indexOf("smooth-steps") >= 0;
|
|
718
719
|
if (fixed) {
|
|
@@ -722,6 +723,9 @@
|
|
|
722
723
|
// Use margin to enforce fixed state
|
|
723
724
|
testMargin(parsed, parsed.start[1] - parsed.start[0]);
|
|
724
725
|
}
|
|
726
|
+
if (invertConnects && parsed.handles !== 2) {
|
|
727
|
+
throw new Error("noUiSlider: 'invert-connects' behaviour must be used with 2 handles");
|
|
728
|
+
}
|
|
725
729
|
if (unconstrained && (parsed.margin || parsed.limit)) {
|
|
726
730
|
throw new Error("noUiSlider: 'unconstrained' behaviour cannot be used with margin or limit");
|
|
727
731
|
}
|
|
@@ -734,6 +738,7 @@
|
|
|
734
738
|
snap: snap,
|
|
735
739
|
hover: hover,
|
|
736
740
|
unconstrained: unconstrained,
|
|
741
|
+
invertConnects: invertConnects,
|
|
737
742
|
};
|
|
738
743
|
}
|
|
739
744
|
function testTooltips(parsed, entry) {
|
|
@@ -904,6 +909,7 @@
|
|
|
904
909
|
// Slider DOM Nodes
|
|
905
910
|
var scope_Target = target;
|
|
906
911
|
var scope_Base;
|
|
912
|
+
var scope_ConnectBase;
|
|
907
913
|
var scope_Handles;
|
|
908
914
|
var scope_Connects;
|
|
909
915
|
var scope_Pips;
|
|
@@ -915,6 +921,7 @@
|
|
|
915
921
|
var scope_HandleNumbers = [];
|
|
916
922
|
var scope_ActiveHandlesCount = 0;
|
|
917
923
|
var scope_Events = {};
|
|
924
|
+
var scope_ConnectsInverted = false;
|
|
918
925
|
// Document Nodes
|
|
919
926
|
var scope_Document = target.ownerDocument;
|
|
920
927
|
var scope_DocumentElement = options.documentElement || scope_Document.documentElement;
|
|
@@ -971,17 +978,17 @@
|
|
|
971
978
|
}
|
|
972
979
|
// Add handles to the slider base.
|
|
973
980
|
function addElements(connectOptions, base) {
|
|
974
|
-
|
|
981
|
+
scope_ConnectBase = addNodeTo(base, options.cssClasses.connects);
|
|
975
982
|
scope_Handles = [];
|
|
976
983
|
scope_Connects = [];
|
|
977
|
-
scope_Connects.push(addConnect(
|
|
984
|
+
scope_Connects.push(addConnect(scope_ConnectBase, connectOptions[0]));
|
|
978
985
|
// [::::O====O====O====]
|
|
979
986
|
// connectOptions = [0, 1, 1, 1]
|
|
980
987
|
for (var i = 0; i < options.handles; i++) {
|
|
981
988
|
// Keep a list of all added handles.
|
|
982
989
|
scope_Handles.push(addOrigin(base, i));
|
|
983
990
|
scope_HandleNumbers[i] = i;
|
|
984
|
-
scope_Connects.push(addConnect(
|
|
991
|
+
scope_Connects.push(addConnect(scope_ConnectBase, connectOptions[i + 1]));
|
|
985
992
|
}
|
|
986
993
|
}
|
|
987
994
|
// Initialize a single slider.
|
|
@@ -1930,8 +1937,26 @@
|
|
|
1930
1937
|
var translation = transformDirection(to, 0) - scope_DirOffset;
|
|
1931
1938
|
var translateRule = "translate(" + inRuleOrder(translation + "%", "0") + ")";
|
|
1932
1939
|
scope_Handles[handleNumber].style[options.transformRule] = translateRule;
|
|
1940
|
+
// sanity check for at least 2 handles (e.g. during setup)
|
|
1941
|
+
if (options.events.invertConnects && scope_Locations.length > 1) {
|
|
1942
|
+
// check if handles passed each other, but don't match the ConnectsInverted state
|
|
1943
|
+
var handlesAreInOrder = scope_Locations.every(function (position, index, locations) {
|
|
1944
|
+
return index === 0 || position >= locations[index - 1];
|
|
1945
|
+
});
|
|
1946
|
+
if (scope_ConnectsInverted !== !handlesAreInOrder) {
|
|
1947
|
+
// invert connects when handles pass each other
|
|
1948
|
+
invertConnects();
|
|
1949
|
+
// invertConnects already updates all connect elements
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1933
1953
|
updateConnect(handleNumber);
|
|
1934
1954
|
updateConnect(handleNumber + 1);
|
|
1955
|
+
if (scope_ConnectsInverted) {
|
|
1956
|
+
// When connects are inverted, we also have to update adjacent connects
|
|
1957
|
+
updateConnect(handleNumber - 1);
|
|
1958
|
+
updateConnect(handleNumber + 2);
|
|
1959
|
+
}
|
|
1935
1960
|
}
|
|
1936
1961
|
// Handles before the slider middle are stacked later = higher,
|
|
1937
1962
|
// Handles after the middle later is lower
|
|
@@ -1961,13 +1986,20 @@
|
|
|
1961
1986
|
if (!scope_Connects[index]) {
|
|
1962
1987
|
return;
|
|
1963
1988
|
}
|
|
1989
|
+
// Create a copy of locations, so we can sort them for the local scope logic
|
|
1990
|
+
var locations = scope_Locations.slice();
|
|
1991
|
+
if (scope_ConnectsInverted) {
|
|
1992
|
+
locations.sort(function (a, b) {
|
|
1993
|
+
return a - b;
|
|
1994
|
+
});
|
|
1995
|
+
}
|
|
1964
1996
|
var l = 0;
|
|
1965
1997
|
var h = 100;
|
|
1966
1998
|
if (index !== 0) {
|
|
1967
|
-
l =
|
|
1999
|
+
l = locations[index - 1];
|
|
1968
2000
|
}
|
|
1969
2001
|
if (index !== scope_Connects.length - 1) {
|
|
1970
|
-
h =
|
|
2002
|
+
h = locations[index];
|
|
1971
2003
|
}
|
|
1972
2004
|
// We use two rules:
|
|
1973
2005
|
// 'translate' to change the left/top offset;
|
|
@@ -2159,6 +2191,7 @@
|
|
|
2159
2191
|
"format",
|
|
2160
2192
|
"pips",
|
|
2161
2193
|
"tooltips",
|
|
2194
|
+
"connect",
|
|
2162
2195
|
];
|
|
2163
2196
|
// Only change options that we're actually passed to update.
|
|
2164
2197
|
updateAble.forEach(function (name) {
|
|
@@ -2196,6 +2229,32 @@
|
|
|
2196
2229
|
// Invalidate the current positioning so valueSet forces an update.
|
|
2197
2230
|
scope_Locations = [];
|
|
2198
2231
|
valueSet(isSet(optionsToUpdate.start) ? optionsToUpdate.start : v, fireSetEvent);
|
|
2232
|
+
// Update connects only if it was set
|
|
2233
|
+
if (optionsToUpdate.connect) {
|
|
2234
|
+
updateConnectOption();
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
function updateConnectOption() {
|
|
2238
|
+
// IE supported way of removing children including event handlers
|
|
2239
|
+
while (scope_ConnectBase.firstChild) {
|
|
2240
|
+
scope_ConnectBase.removeChild(scope_ConnectBase.firstChild);
|
|
2241
|
+
}
|
|
2242
|
+
// Adding new connects according to the new connect options
|
|
2243
|
+
for (var i = 0; i <= options.handles; i++) {
|
|
2244
|
+
scope_Connects[i] = addConnect(scope_ConnectBase, options.connect[i]);
|
|
2245
|
+
updateConnect(i);
|
|
2246
|
+
}
|
|
2247
|
+
// re-adding drag events for the new connect elements
|
|
2248
|
+
// to ignore the other events we have to negate the 'if (!behaviour.fixed)' check
|
|
2249
|
+
bindSliderEvents({ drag: options.events.drag, fixed: true });
|
|
2250
|
+
}
|
|
2251
|
+
// Invert options for connect handles
|
|
2252
|
+
function invertConnects() {
|
|
2253
|
+
scope_ConnectsInverted = !scope_ConnectsInverted;
|
|
2254
|
+
testConnect(options,
|
|
2255
|
+
// inverse the connect boolean array
|
|
2256
|
+
options.connect.map(function (b) { return !b; }));
|
|
2257
|
+
updateConnectOption();
|
|
2199
2258
|
}
|
|
2200
2259
|
// Initialization steps
|
|
2201
2260
|
function setupSlider() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pageboard/html",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"homepage": "https://github.com/pageboard/client#readme",
|
|
16
16
|
"dependencies": {},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"nouislider": "^15.
|
|
18
|
+
"nouislider": "^15.8.1",
|
|
19
19
|
"postinstall": "^0.10.3"
|
|
20
20
|
},
|
|
21
21
|
"postinstall": {},
|
package/ui/form.js
CHANGED
|
@@ -212,7 +212,7 @@ class HTMLElementForm extends Page.create(HTMLFormElement) {
|
|
|
212
212
|
save() {
|
|
213
213
|
this.classList.remove('unsaved');
|
|
214
214
|
for (const node of this.querySelectorAll("element-fieldset-list")) {
|
|
215
|
-
node.save();
|
|
215
|
+
node.save?.();
|
|
216
216
|
}
|
|
217
217
|
for (const node of this.elements) {
|
|
218
218
|
node.save?.();
|
package/ui/image.js
CHANGED
|
@@ -81,15 +81,16 @@ const HTMLElementImageConstructor = Superclass => class extends Superclass {
|
|
|
81
81
|
const { w, h } = this.dimensions;
|
|
82
82
|
if (w) this.image.width = w || d.width;
|
|
83
83
|
if (h) this.image.height = h || d.height;
|
|
84
|
-
|
|
84
|
+
const cur = this.currentSrc;
|
|
85
|
+
if (!cur) {
|
|
85
86
|
this.placeholder();
|
|
87
|
+
} else if (cur.startsWith('data:')) {
|
|
88
|
+
this.image.setAttribute('src', cur);
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
get currentSrc() {
|
|
90
|
-
|
|
91
|
-
if (src?.startsWith('data:image/svg')) return null;
|
|
92
|
-
else return src;
|
|
93
|
+
return this.image?.currentSrc;
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
requestSrc(srcLoc) {
|