@pageboard/html 0.15.2 → 0.15.4

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 CHANGED
@@ -80,9 +80,9 @@ exports.api_form = {
80
80
  properties: {
81
81
  name: {
82
82
  title: 'Name',
83
- description: "Used by query 'submit' or 'toggle'\nExposes /@api/form/$name",
83
+ description: "Exposes /@api/$name\nUsed by query 'submit' or 'toggle'",
84
84
  type: 'string',
85
- format: 'id',
85
+ format: 'name',
86
86
  nullable: true
87
87
  },
88
88
  hidden: {
@@ -107,12 +107,11 @@ exports.api_form = {
107
107
  description: 'Page state or action',
108
108
  type: 'object',
109
109
  properties: {
110
- url: {
111
- title: 'Page',
110
+ name: {
111
+ title: 'Form or Fetch Name',
112
112
  nullable: true,
113
- type: "string",
114
- format: "page",
115
- $helper: "page"
113
+ type: 'string',
114
+ format: 'singleline'
116
115
  },
117
116
  parameters: {
118
117
  title: 'Parameters',
@@ -126,6 +125,12 @@ exports.api_form = {
126
125
  title: 'Bad request',
127
126
  type: 'object',
128
127
  properties: {
128
+ name: {
129
+ title: 'Form or Fetch Name',
130
+ nullable: true,
131
+ type: 'string',
132
+ format: 'singleline'
133
+ },
129
134
  parameters: {
130
135
  title: 'Parameters',
131
136
  type: "object",
@@ -138,6 +143,12 @@ exports.api_form = {
138
143
  title: 'Unauthorized request',
139
144
  type: 'object',
140
145
  properties: {
146
+ name: {
147
+ title: 'Form or Fetch Name',
148
+ nullable: true,
149
+ type: 'string',
150
+ format: 'singleline'
151
+ },
141
152
  parameters: {
142
153
  title: 'Parameters',
143
154
  type: "object",
@@ -150,6 +161,12 @@ exports.api_form = {
150
161
  title: 'Request not found',
151
162
  type: 'object',
152
163
  properties: {
164
+ name: {
165
+ title: 'Form or Fetch Name',
166
+ nullable: true,
167
+ type: 'string',
168
+ format: 'singleline'
169
+ },
153
170
  parameters: {
154
171
  title: 'Parameters',
155
172
  type: "object",
@@ -164,10 +181,10 @@ exports.api_form = {
164
181
  html: `<form is="element-form" method="post" name="[name]" masked="[masked]"
165
182
  action="/@api/form/[name|else:$id]"
166
183
  parameters="[action?.request|as:expressions]"
167
- success="[redirection.url][redirection.parameters|as:query]"
168
- badrequest="[badrequest.url][badrequest.parameters|as:query]"
169
- unauthorized="[unauthorized.url][unauthorized.parameters|as:query]"
170
- notfound="[notfound.url][notfound.parameters|as:query]"
184
+ success="[redirection.parameters|as:query]"
185
+ badrequest="[badrequest.parameters|as:query]"
186
+ unauthorized="[unauthorized.parameters|as:query]"
187
+ notfound="[notfound.parameters|as:query]"
171
188
  class="ui form [hidden]"></form>`,
172
189
  stylesheets: [
173
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
- var connectBase = addNodeTo(base, options.cssClasses.connects);
981
+ scope_ConnectBase = addNodeTo(base, options.cssClasses.connects);
975
982
  scope_Handles = [];
976
983
  scope_Connects = [];
977
- scope_Connects.push(addConnect(connectBase, connectOptions[0]));
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(connectBase, connectOptions[i + 1]));
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 = scope_Locations[index - 1];
1999
+ l = locations[index - 1];
1968
2000
  }
1969
2001
  if (index !== scope_Connects.length - 1) {
1970
- h = scope_Locations[index];
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.2",
3
+ "version": "0.15.4",
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.7.1",
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
- if (!this.currentSrc) {
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
- const src = this.image?.currentSrc;
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) {