@yuneta/gobj-ui 7.23.60 → 7.23.63

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.
@@ -6035,6 +6035,7 @@ function yui_file_control(gobj, { name, value, readonly, accept, on_pick }) {
6035
6035
  accept: accept || YUI_FILE_ACCEPT,
6036
6036
  hidden: ""
6037
6037
  }]);
6038
+ if (readonly) $input.disabled = true;
6038
6039
  const $pick = (0, _yuneta_gobj_js.createElement2)([
6039
6040
  "button",
6040
6041
  {
@@ -6083,6 +6084,7 @@ function yui_file_control(gobj, { name, value, readonly, accept, on_pick }) {
6083
6084
  const picked = $control.yui_file;
6084
6085
  const kept = $control.yui_file_value;
6085
6086
  $name.textContent = picked ? picked.name || "" : yui_file_id_label(kept);
6087
+ $name.title = picked ? picked.name || "" : kept || "";
6086
6088
  $size.textContent = picked ? yui_file_size_label(picked.size) : "";
6087
6089
  $state.className = "FILE_STATE";
6088
6090
  $state.removeAttribute("data-i18n");
@@ -7999,6 +8001,12 @@ function apply_readonly_to_control(readonly, tag, inputType, $extend) {
7999
8001
  case "jsoneditor":
8000
8002
  $extend.classList.add("yui-jse-readonly");
8001
8003
  break;
8004
+ case "file":
8005
+ {
8006
+ const $picker = $extend.querySelector(".FILE_INPUT");
8007
+ if ($picker) $picker.disabled = true;
8008
+ }
8009
+ break;
8002
8010
  case "input": if (inputType === "color") $extend.setAttribute("disabled", "disabled");
8003
8011
  }
8004
8012
  }
@@ -8641,6 +8649,7 @@ function treedb_value_2_form_value(gobj, field_desc, value) {
8641
8649
  return { json: (0, _yuneta_gobj_js.is_object)(value) || (0, _yuneta_gobj_js.is_array)(value) ? value : {} };
8642
8650
  }
8643
8651
  switch (type) {
8652
+ case "file": return value;
8644
8653
  case "fkey": {
8645
8654
  let new_value = [];
8646
8655
  if ((0, _yuneta_gobj_js.is_string)(value) && !(0, _yuneta_gobj_js.empty_string)(value)) {
@@ -8737,6 +8746,7 @@ function form_value_2_treedb_value(gobj, field_desc, value) {
8737
8746
  return value;
8738
8747
  }
8739
8748
  switch (type) {
8749
+ case "file": break;
8740
8750
  case "fkey":
8741
8751
  value = build_fkey_ref$1(gobj, field_desc, value);
8742
8752
  break;
@@ -25338,7 +25348,7 @@ function transform__form_record_2_treedb_record(gobj, kw, operation) {
25338
25348
  let col = get_schema_col(gobj, field_name);
25339
25349
  if (!col) continue;
25340
25350
  const field_desc = (0, _yuneta_gobj_js.treedb_get_field_desc)(col);
25341
- if (!field_desc.is_writable && field_desc.type !== "fkey" && col.id !== pkey) continue;
25351
+ if (!field_desc.is_writable && field_desc.type !== "fkey" && !field_desc.is_file && col.id !== pkey) continue;
25342
25352
  let value = kw[field_name];
25343
25353
  row[field_name] = transform__form_value_2_treedb_value(gobj, col, value, operation);
25344
25354
  }
@@ -6030,6 +6030,7 @@ function yui_file_control(gobj, { name, value, readonly, accept, on_pick }) {
6030
6030
  accept: accept || YUI_FILE_ACCEPT,
6031
6031
  hidden: ""
6032
6032
  }]);
6033
+ if (readonly) $input.disabled = true;
6033
6034
  const $pick = createElement2([
6034
6035
  "button",
6035
6036
  {
@@ -6078,6 +6079,7 @@ function yui_file_control(gobj, { name, value, readonly, accept, on_pick }) {
6078
6079
  const picked = $control.yui_file;
6079
6080
  const kept = $control.yui_file_value;
6080
6081
  $name.textContent = picked ? picked.name || "" : yui_file_id_label(kept);
6082
+ $name.title = picked ? picked.name || "" : kept || "";
6081
6083
  $size.textContent = picked ? yui_file_size_label(picked.size) : "";
6082
6084
  $state.className = "FILE_STATE";
6083
6085
  $state.removeAttribute("data-i18n");
@@ -7994,6 +7996,12 @@ function apply_readonly_to_control(readonly, tag, inputType, $extend) {
7994
7996
  case "jsoneditor":
7995
7997
  $extend.classList.add("yui-jse-readonly");
7996
7998
  break;
7999
+ case "file":
8000
+ {
8001
+ const $picker = $extend.querySelector(".FILE_INPUT");
8002
+ if ($picker) $picker.disabled = true;
8003
+ }
8004
+ break;
7997
8005
  case "input": if (inputType === "color") $extend.setAttribute("disabled", "disabled");
7998
8006
  }
7999
8007
  }
@@ -8636,6 +8644,7 @@ function treedb_value_2_form_value(gobj, field_desc, value) {
8636
8644
  return { json: is_object(value) || is_array(value) ? value : {} };
8637
8645
  }
8638
8646
  switch (type) {
8647
+ case "file": return value;
8639
8648
  case "fkey": {
8640
8649
  let new_value = [];
8641
8650
  if (is_string(value) && !empty_string(value)) {
@@ -8732,6 +8741,7 @@ function form_value_2_treedb_value(gobj, field_desc, value) {
8732
8741
  return value;
8733
8742
  }
8734
8743
  switch (type) {
8744
+ case "file": break;
8735
8745
  case "fkey":
8736
8746
  value = build_fkey_ref$1(gobj, field_desc, value);
8737
8747
  break;
@@ -25333,7 +25343,7 @@ function transform__form_record_2_treedb_record(gobj, kw, operation) {
25333
25343
  let col = get_schema_col(gobj, field_name);
25334
25344
  if (!col) continue;
25335
25345
  const field_desc = treedb_get_field_desc(col);
25336
- if (!field_desc.is_writable && field_desc.type !== "fkey" && col.id !== pkey) continue;
25346
+ if (!field_desc.is_writable && field_desc.type !== "fkey" && !field_desc.is_file && col.id !== pkey) continue;
25337
25347
  let value = kw[field_name];
25338
25348
  row[field_name] = transform__form_value_2_treedb_value(gobj, col, value, operation);
25339
25349
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.60",
3
+ "version": "7.23.63",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
package/src/c_yui_form.js CHANGED
@@ -1578,6 +1578,17 @@ function apply_readonly_to_control(readonly, tag, inputType, $extend)
1578
1578
  * `input` has done since it existed. */
1579
1579
  $extend.classList.add('yui-jse-readonly');
1580
1580
  break;
1581
+ case 'file':
1582
+ /* The button is hidden by the control itself; this is the
1583
+ * INPUT, which stays in the DOM and would otherwise report a
1584
+ * read-only form as writable. */
1585
+ {
1586
+ const $picker = $extend.querySelector('.FILE_INPUT');
1587
+ if($picker) {
1588
+ $picker.disabled = true;
1589
+ }
1590
+ }
1591
+ break;
1581
1592
  case 'input':
1582
1593
  /* `readonly` does not apply to a colour input -- the spec lists
1583
1594
  * the types it applies to and colour is not one of them -- so
@@ -2654,6 +2665,14 @@ function treedb_value_2_form_value(gobj, field_desc, value)
2654
2665
  }
2655
2666
 
2656
2667
  switch(type) {
2668
+ /* A `file` column is handed to the control AS IT COMES: the
2669
+ * control reads the fkey itself (yui_asset_id knows the three
2670
+ * shapes a link comes back in), and converting it here would be
2671
+ * reading it twice, in two places, with two ideas of what a link
2672
+ * looks like. */
2673
+ case "file":
2674
+ return value;
2675
+
2657
2676
  case "fkey": {
2658
2677
  /* Decode ref(s) ("topic^id^hook", bare "$id", dict keys or
2659
2678
  * {topic_name,id,hook_name}) into a plain array of ids for
@@ -2804,6 +2823,13 @@ function form_value_2_treedb_value(gobj, field_desc, value)
2804
2823
  }
2805
2824
 
2806
2825
  switch(type) {
2826
+ /* The BARE id, and treedb expands it into the full reference
2827
+ * (`__assets__^<sha>^as_<T>_<C>`). That is the whole point of the
2828
+ * host declaring nothing but the column: the client never has to
2829
+ * learn the name of a hook that is DERIVED. */
2830
+ case "file":
2831
+ break;
2832
+
2807
2833
  case "fkey":
2808
2834
  value = build_fkey_ref(gobj, field_desc, value);
2809
2835
  break;
@@ -2620,7 +2620,14 @@ function transform__form_record_2_treedb_record(gobj, kw, operation)
2620
2620
  */
2621
2621
  const field_desc = treedb_get_field_desc(col);
2622
2622
  if(!field_desc.is_writable &&
2623
- field_desc.type !== "fkey" && col.id !== pkey) {
2623
+ field_desc.type !== "fkey" && !field_desc.is_file &&
2624
+ col.id !== pkey) {
2625
+ /* `is_file` and not the type: a `file` column IS an fkey (it
2626
+ * is flagged ['fkey','file']) but answers `type: "file"`, and
2627
+ * the write goes out with `autolink`, which rebuilds the links
2628
+ * from what the record carries. Dropped here, a read-only
2629
+ * `file` column -- the one only a load fills -- was UNLINKED
2630
+ * by every save of any other field of its record. */
2624
2631
  continue;
2625
2632
  }
2626
2633
 
@@ -245,6 +245,17 @@ function yui_file_control(gobj, {name, value, readonly, accept, on_pick})
245
245
  accept: accept || YUI_FILE_ACCEPT,
246
246
  hidden: ""
247
247
  }]);
248
+ /*
249
+ * A read-only form must not merely LOOK read-only. Hiding the button
250
+ * hides the way in for a person and leaves the input enabled, so the
251
+ * DOM still says the field is writable -- which is what anything
252
+ * reading the form programmatically believes, and what a form opened
253
+ * by a click to READ must not say. `disabled` and not `readonly`: the
254
+ * spec does not list `file` among the types `readonly` applies to.
255
+ */
256
+ if(readonly) {
257
+ $input.disabled = true;
258
+ }
248
259
 
249
260
  const $pick = createElement2(["button", {
250
261
  type: "button",
@@ -289,6 +300,10 @@ function yui_file_control(gobj, {name, value, readonly, accept, on_pick})
289
300
  const kept = $control.yui_file_value;
290
301
 
291
302
  $name.textContent = picked? (picked.name || ""): yui_file_id_label(kept);
303
+ /* The shortened id is unusable on its own -- it cannot be looked
304
+ * up, pasted or compared. The whole of it belongs in the tooltip,
305
+ * which is also where the full NAME of a long picked file goes. */
306
+ $name.title = picked? (picked.name || ""): (kept || "");
292
307
  $size.textContent = picked? yui_file_size_label(picked.size): "";
293
308
 
294
309
  $state.className = "FILE_STATE";