@flourish/ui-styles 6.0.2 → 7.0.1

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/ui-styles.js CHANGED
@@ -57,7 +57,7 @@
57
57
  return this.parent.select(this.selector + " " + selector);
58
58
  };
59
59
 
60
- var DEFAULTS$3 = Object.freeze({
60
+ var DEFAULTS$4 = Object.freeze({
61
61
  font_size: 1,
62
62
  font_weight: "bold",
63
63
  height: 2,
@@ -65,8 +65,8 @@
65
65
 
66
66
  function GeneralControlsStyle(state_, selector_, layout_) {
67
67
  this._state = state_;
68
- for (var key in DEFAULTS$3) {
69
- if (this._state[key] === undefined) this._state[key] = DEFAULTS$3[key];
68
+ for (var key in DEFAULTS$4) {
69
+ if (this._state[key] === undefined) this._state[key] = DEFAULTS$4[key];
70
70
  }
71
71
 
72
72
  this._layout = layout_ || {};
@@ -629,6 +629,9 @@
629
629
  each: proto.each
630
630
  };
631
631
 
632
+ const ascent_descent_canvas = document.createElement("canvas");
633
+ ascent_descent_canvas.getContext("2d");
634
+
632
635
  // This is an exception because mocha doesn't run in a browser context, so some
633
636
  // browser methods aren't available.
634
637
  const is_browser =
@@ -661,7 +664,7 @@
661
664
  return window.getComputedStyle(document.body).direction || "ltr";
662
665
  }
663
666
 
664
- function hexToColor(hex_string, opacity) {
667
+ function hexToColor$1(hex_string, opacity) {
665
668
  if (typeof hex_string != "string") return false;
666
669
  var c = color(hex_string);
667
670
  c.opacity = opacity !== undefined ? opacity : 1;
@@ -669,7 +672,7 @@
669
672
  }
670
673
 
671
674
  function hexToRgba(hex_string, opacity) {
672
- var c = hexToColor(hex_string, opacity);
675
+ var c = hexToColor$1(hex_string, opacity);
673
676
 
674
677
  return c ? c.toString() : false;
675
678
  }
@@ -739,7 +742,7 @@
739
742
  };
740
743
  };
741
744
 
742
- var DEFAULTS$2 = Object.freeze({
745
+ var DEFAULTS$3 = Object.freeze({
743
746
  background: null,
744
747
  font_color: null,
745
748
 
@@ -757,8 +760,8 @@
757
760
 
758
761
  function ButtonStyle(state_, selector_, layout_) {
759
762
  this._state = state_;
760
- for (var key in DEFAULTS$2) {
761
- if (this._state[key] === undefined) this._state[key] = DEFAULTS$2[key];
763
+ for (var key in DEFAULTS$3) {
764
+ if (this._state[key] === undefined) this._state[key] = DEFAULTS$3[key];
762
765
  }
763
766
 
764
767
  this._layout = layout_ || {};
@@ -863,7 +866,7 @@
863
866
  this._stylesheet.innerHTML = this._styles.print();
864
867
  };
865
868
 
866
- var DEFAULTS$1 = Object.freeze({
869
+ var DEFAULTS$2 = Object.freeze({
867
870
  background: null,
868
871
  font_color: null,
869
872
 
@@ -876,8 +879,8 @@
876
879
 
877
880
  function DropdownStyle(state_, selector_, layout_) {
878
881
  this._state = state_;
879
- for (var key in DEFAULTS$1) {
880
- if (this._state[key] === undefined) this._state[key] = DEFAULTS$1[key];
882
+ for (var key in DEFAULTS$2) {
883
+ if (this._state[key] === undefined) this._state[key] = DEFAULTS$2[key];
881
884
  }
882
885
 
883
886
  this._layout = layout_ || {};
@@ -1023,7 +1026,7 @@
1023
1026
  return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
1024
1027
  }
1025
1028
 
1026
- var DEFAULTS = Object.freeze({
1029
+ var DEFAULTS$1 = Object.freeze({
1027
1030
  play_color: null,
1028
1031
  handle_color: null,
1029
1032
  font_color: null,
@@ -1038,8 +1041,8 @@
1038
1041
 
1039
1042
  function SliderStyle(state_, selector_, layout_) {
1040
1043
  this._state = state_;
1041
- for (var key in DEFAULTS) {
1042
- if (this._state[key] === undefined) this._state[key] = DEFAULTS[key];
1044
+ for (var key in DEFAULTS$1) {
1045
+ if (this._state[key] === undefined) this._state[key] = DEFAULTS$1[key];
1043
1046
  }
1044
1047
 
1045
1048
  this._layout = layout_ || {};
@@ -1134,6 +1137,1340 @@
1134
1137
  this._stylesheet.innerHTML = this._styles.print();
1135
1138
  };
1136
1139
 
1140
+ var xhtml = "http://www.w3.org/1999/xhtml";
1141
+
1142
+ var namespaces = {
1143
+ svg: "http://www.w3.org/2000/svg",
1144
+ xhtml: xhtml,
1145
+ xlink: "http://www.w3.org/1999/xlink",
1146
+ xml: "http://www.w3.org/XML/1998/namespace",
1147
+ xmlns: "http://www.w3.org/2000/xmlns/"
1148
+ };
1149
+
1150
+ function namespace(name) {
1151
+ var prefix = name += "", i = prefix.indexOf(":");
1152
+ if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1);
1153
+ return namespaces.hasOwnProperty(prefix) ? {space: namespaces[prefix], local: name} : name;
1154
+ }
1155
+
1156
+ function creatorInherit(name) {
1157
+ return function() {
1158
+ var document = this.ownerDocument,
1159
+ uri = this.namespaceURI;
1160
+ return uri === xhtml && document.documentElement.namespaceURI === xhtml
1161
+ ? document.createElement(name)
1162
+ : document.createElementNS(uri, name);
1163
+ };
1164
+ }
1165
+
1166
+ function creatorFixed(fullname) {
1167
+ return function() {
1168
+ return this.ownerDocument.createElementNS(fullname.space, fullname.local);
1169
+ };
1170
+ }
1171
+
1172
+ function creator(name) {
1173
+ var fullname = namespace(name);
1174
+ return (fullname.local
1175
+ ? creatorFixed
1176
+ : creatorInherit)(fullname);
1177
+ }
1178
+
1179
+ function none() {}
1180
+
1181
+ function selector(selector) {
1182
+ return selector == null ? none : function() {
1183
+ return this.querySelector(selector);
1184
+ };
1185
+ }
1186
+
1187
+ function selection_select(select) {
1188
+ if (typeof select !== "function") select = selector(select);
1189
+
1190
+ for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
1191
+ for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
1192
+ if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) {
1193
+ if ("__data__" in node) subnode.__data__ = node.__data__;
1194
+ subgroup[i] = subnode;
1195
+ }
1196
+ }
1197
+ }
1198
+
1199
+ return new Selection(subgroups, this._parents);
1200
+ }
1201
+
1202
+ function empty() {
1203
+ return [];
1204
+ }
1205
+
1206
+ function selectorAll(selector) {
1207
+ return selector == null ? empty : function() {
1208
+ return this.querySelectorAll(selector);
1209
+ };
1210
+ }
1211
+
1212
+ function selection_selectAll(select) {
1213
+ if (typeof select !== "function") select = selectorAll(select);
1214
+
1215
+ for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) {
1216
+ for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
1217
+ if (node = group[i]) {
1218
+ subgroups.push(select.call(node, node.__data__, i, group));
1219
+ parents.push(node);
1220
+ }
1221
+ }
1222
+ }
1223
+
1224
+ return new Selection(subgroups, parents);
1225
+ }
1226
+
1227
+ function matcher(selector) {
1228
+ return function() {
1229
+ return this.matches(selector);
1230
+ };
1231
+ }
1232
+
1233
+ function selection_filter(match) {
1234
+ if (typeof match !== "function") match = matcher(match);
1235
+
1236
+ for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) {
1237
+ for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) {
1238
+ if ((node = group[i]) && match.call(node, node.__data__, i, group)) {
1239
+ subgroup.push(node);
1240
+ }
1241
+ }
1242
+ }
1243
+
1244
+ return new Selection(subgroups, this._parents);
1245
+ }
1246
+
1247
+ function sparse(update) {
1248
+ return new Array(update.length);
1249
+ }
1250
+
1251
+ function selection_enter() {
1252
+ return new Selection(this._enter || this._groups.map(sparse), this._parents);
1253
+ }
1254
+
1255
+ function EnterNode(parent, datum) {
1256
+ this.ownerDocument = parent.ownerDocument;
1257
+ this.namespaceURI = parent.namespaceURI;
1258
+ this._next = null;
1259
+ this._parent = parent;
1260
+ this.__data__ = datum;
1261
+ }
1262
+
1263
+ EnterNode.prototype = {
1264
+ constructor: EnterNode,
1265
+ appendChild: function(child) { return this._parent.insertBefore(child, this._next); },
1266
+ insertBefore: function(child, next) { return this._parent.insertBefore(child, next); },
1267
+ querySelector: function(selector) { return this._parent.querySelector(selector); },
1268
+ querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); }
1269
+ };
1270
+
1271
+ function constant(x) {
1272
+ return function() {
1273
+ return x;
1274
+ };
1275
+ }
1276
+
1277
+ var keyPrefix = "$"; // Protect against keys like “__proto__”.
1278
+
1279
+ function bindIndex(parent, group, enter, update, exit, data) {
1280
+ var i = 0,
1281
+ node,
1282
+ groupLength = group.length,
1283
+ dataLength = data.length;
1284
+
1285
+ // Put any non-null nodes that fit into update.
1286
+ // Put any null nodes into enter.
1287
+ // Put any remaining data into enter.
1288
+ for (; i < dataLength; ++i) {
1289
+ if (node = group[i]) {
1290
+ node.__data__ = data[i];
1291
+ update[i] = node;
1292
+ } else {
1293
+ enter[i] = new EnterNode(parent, data[i]);
1294
+ }
1295
+ }
1296
+
1297
+ // Put any non-null nodes that don’t fit into exit.
1298
+ for (; i < groupLength; ++i) {
1299
+ if (node = group[i]) {
1300
+ exit[i] = node;
1301
+ }
1302
+ }
1303
+ }
1304
+
1305
+ function bindKey(parent, group, enter, update, exit, data, key) {
1306
+ var i,
1307
+ node,
1308
+ nodeByKeyValue = {},
1309
+ groupLength = group.length,
1310
+ dataLength = data.length,
1311
+ keyValues = new Array(groupLength),
1312
+ keyValue;
1313
+
1314
+ // Compute the key for each node.
1315
+ // If multiple nodes have the same key, the duplicates are added to exit.
1316
+ for (i = 0; i < groupLength; ++i) {
1317
+ if (node = group[i]) {
1318
+ keyValues[i] = keyValue = keyPrefix + key.call(node, node.__data__, i, group);
1319
+ if (keyValue in nodeByKeyValue) {
1320
+ exit[i] = node;
1321
+ } else {
1322
+ nodeByKeyValue[keyValue] = node;
1323
+ }
1324
+ }
1325
+ }
1326
+
1327
+ // Compute the key for each datum.
1328
+ // If there a node associated with this key, join and add it to update.
1329
+ // If there is not (or the key is a duplicate), add it to enter.
1330
+ for (i = 0; i < dataLength; ++i) {
1331
+ keyValue = keyPrefix + key.call(parent, data[i], i, data);
1332
+ if (node = nodeByKeyValue[keyValue]) {
1333
+ update[i] = node;
1334
+ node.__data__ = data[i];
1335
+ nodeByKeyValue[keyValue] = null;
1336
+ } else {
1337
+ enter[i] = new EnterNode(parent, data[i]);
1338
+ }
1339
+ }
1340
+
1341
+ // Add any remaining nodes that were not bound to data to exit.
1342
+ for (i = 0; i < groupLength; ++i) {
1343
+ if ((node = group[i]) && (nodeByKeyValue[keyValues[i]] === node)) {
1344
+ exit[i] = node;
1345
+ }
1346
+ }
1347
+ }
1348
+
1349
+ function selection_data(value, key) {
1350
+ if (!value) {
1351
+ data = new Array(this.size()), j = -1;
1352
+ this.each(function(d) { data[++j] = d; });
1353
+ return data;
1354
+ }
1355
+
1356
+ var bind = key ? bindKey : bindIndex,
1357
+ parents = this._parents,
1358
+ groups = this._groups;
1359
+
1360
+ if (typeof value !== "function") value = constant(value);
1361
+
1362
+ for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) {
1363
+ var parent = parents[j],
1364
+ group = groups[j],
1365
+ groupLength = group.length,
1366
+ data = value.call(parent, parent && parent.__data__, j, parents),
1367
+ dataLength = data.length,
1368
+ enterGroup = enter[j] = new Array(dataLength),
1369
+ updateGroup = update[j] = new Array(dataLength),
1370
+ exitGroup = exit[j] = new Array(groupLength);
1371
+
1372
+ bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
1373
+
1374
+ // Now connect the enter nodes to their following update node, such that
1375
+ // appendChild can insert the materialized enter node before this node,
1376
+ // rather than at the end of the parent node.
1377
+ for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
1378
+ if (previous = enterGroup[i0]) {
1379
+ if (i0 >= i1) i1 = i0 + 1;
1380
+ while (!(next = updateGroup[i1]) && ++i1 < dataLength);
1381
+ previous._next = next || null;
1382
+ }
1383
+ }
1384
+ }
1385
+
1386
+ update = new Selection(update, parents);
1387
+ update._enter = enter;
1388
+ update._exit = exit;
1389
+ return update;
1390
+ }
1391
+
1392
+ function selection_exit() {
1393
+ return new Selection(this._exit || this._groups.map(sparse), this._parents);
1394
+ }
1395
+
1396
+ function selection_join(onenter, onupdate, onexit) {
1397
+ var enter = this.enter(), update = this, exit = this.exit();
1398
+ enter = typeof onenter === "function" ? onenter(enter) : enter.append(onenter + "");
1399
+ if (onupdate != null) update = onupdate(update);
1400
+ if (onexit == null) exit.remove(); else onexit(exit);
1401
+ return enter && update ? enter.merge(update).order() : update;
1402
+ }
1403
+
1404
+ function selection_merge(selection) {
1405
+
1406
+ for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) {
1407
+ for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) {
1408
+ if (node = group0[i] || group1[i]) {
1409
+ merge[i] = node;
1410
+ }
1411
+ }
1412
+ }
1413
+
1414
+ for (; j < m0; ++j) {
1415
+ merges[j] = groups0[j];
1416
+ }
1417
+
1418
+ return new Selection(merges, this._parents);
1419
+ }
1420
+
1421
+ function selection_order() {
1422
+
1423
+ for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) {
1424
+ for (var group = groups[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
1425
+ if (node = group[i]) {
1426
+ if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next);
1427
+ next = node;
1428
+ }
1429
+ }
1430
+ }
1431
+
1432
+ return this;
1433
+ }
1434
+
1435
+ function selection_sort(compare) {
1436
+ if (!compare) compare = ascending;
1437
+
1438
+ function compareNode(a, b) {
1439
+ return a && b ? compare(a.__data__, b.__data__) : !a - !b;
1440
+ }
1441
+
1442
+ for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) {
1443
+ for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) {
1444
+ if (node = group[i]) {
1445
+ sortgroup[i] = node;
1446
+ }
1447
+ }
1448
+ sortgroup.sort(compareNode);
1449
+ }
1450
+
1451
+ return new Selection(sortgroups, this._parents).order();
1452
+ }
1453
+
1454
+ function ascending(a, b) {
1455
+ return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
1456
+ }
1457
+
1458
+ function selection_call() {
1459
+ var callback = arguments[0];
1460
+ arguments[0] = this;
1461
+ callback.apply(null, arguments);
1462
+ return this;
1463
+ }
1464
+
1465
+ function selection_nodes() {
1466
+ var nodes = new Array(this.size()), i = -1;
1467
+ this.each(function() { nodes[++i] = this; });
1468
+ return nodes;
1469
+ }
1470
+
1471
+ function selection_node() {
1472
+
1473
+ for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
1474
+ for (var group = groups[j], i = 0, n = group.length; i < n; ++i) {
1475
+ var node = group[i];
1476
+ if (node) return node;
1477
+ }
1478
+ }
1479
+
1480
+ return null;
1481
+ }
1482
+
1483
+ function selection_size() {
1484
+ var size = 0;
1485
+ this.each(function() { ++size; });
1486
+ return size;
1487
+ }
1488
+
1489
+ function selection_empty() {
1490
+ return !this.node();
1491
+ }
1492
+
1493
+ function selection_each(callback) {
1494
+
1495
+ for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) {
1496
+ for (var group = groups[j], i = 0, n = group.length, node; i < n; ++i) {
1497
+ if (node = group[i]) callback.call(node, node.__data__, i, group);
1498
+ }
1499
+ }
1500
+
1501
+ return this;
1502
+ }
1503
+
1504
+ function attrRemove(name) {
1505
+ return function() {
1506
+ this.removeAttribute(name);
1507
+ };
1508
+ }
1509
+
1510
+ function attrRemoveNS(fullname) {
1511
+ return function() {
1512
+ this.removeAttributeNS(fullname.space, fullname.local);
1513
+ };
1514
+ }
1515
+
1516
+ function attrConstant(name, value) {
1517
+ return function() {
1518
+ this.setAttribute(name, value);
1519
+ };
1520
+ }
1521
+
1522
+ function attrConstantNS(fullname, value) {
1523
+ return function() {
1524
+ this.setAttributeNS(fullname.space, fullname.local, value);
1525
+ };
1526
+ }
1527
+
1528
+ function attrFunction(name, value) {
1529
+ return function() {
1530
+ var v = value.apply(this, arguments);
1531
+ if (v == null) this.removeAttribute(name);
1532
+ else this.setAttribute(name, v);
1533
+ };
1534
+ }
1535
+
1536
+ function attrFunctionNS(fullname, value) {
1537
+ return function() {
1538
+ var v = value.apply(this, arguments);
1539
+ if (v == null) this.removeAttributeNS(fullname.space, fullname.local);
1540
+ else this.setAttributeNS(fullname.space, fullname.local, v);
1541
+ };
1542
+ }
1543
+
1544
+ function selection_attr(name, value) {
1545
+ var fullname = namespace(name);
1546
+
1547
+ if (arguments.length < 2) {
1548
+ var node = this.node();
1549
+ return fullname.local
1550
+ ? node.getAttributeNS(fullname.space, fullname.local)
1551
+ : node.getAttribute(fullname);
1552
+ }
1553
+
1554
+ return this.each((value == null
1555
+ ? (fullname.local ? attrRemoveNS : attrRemove) : (typeof value === "function"
1556
+ ? (fullname.local ? attrFunctionNS : attrFunction)
1557
+ : (fullname.local ? attrConstantNS : attrConstant)))(fullname, value));
1558
+ }
1559
+
1560
+ function defaultView(node) {
1561
+ return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node
1562
+ || (node.document && node) // node is a Window
1563
+ || node.defaultView; // node is a Document
1564
+ }
1565
+
1566
+ function styleRemove(name) {
1567
+ return function() {
1568
+ this.style.removeProperty(name);
1569
+ };
1570
+ }
1571
+
1572
+ function styleConstant(name, value, priority) {
1573
+ return function() {
1574
+ this.style.setProperty(name, value, priority);
1575
+ };
1576
+ }
1577
+
1578
+ function styleFunction(name, value, priority) {
1579
+ return function() {
1580
+ var v = value.apply(this, arguments);
1581
+ if (v == null) this.style.removeProperty(name);
1582
+ else this.style.setProperty(name, v, priority);
1583
+ };
1584
+ }
1585
+
1586
+ function selection_style(name, value, priority) {
1587
+ return arguments.length > 1
1588
+ ? this.each((value == null
1589
+ ? styleRemove : typeof value === "function"
1590
+ ? styleFunction
1591
+ : styleConstant)(name, value, priority == null ? "" : priority))
1592
+ : styleValue(this.node(), name);
1593
+ }
1594
+
1595
+ function styleValue(node, name) {
1596
+ return node.style.getPropertyValue(name)
1597
+ || defaultView(node).getComputedStyle(node, null).getPropertyValue(name);
1598
+ }
1599
+
1600
+ function propertyRemove(name) {
1601
+ return function() {
1602
+ delete this[name];
1603
+ };
1604
+ }
1605
+
1606
+ function propertyConstant(name, value) {
1607
+ return function() {
1608
+ this[name] = value;
1609
+ };
1610
+ }
1611
+
1612
+ function propertyFunction(name, value) {
1613
+ return function() {
1614
+ var v = value.apply(this, arguments);
1615
+ if (v == null) delete this[name];
1616
+ else this[name] = v;
1617
+ };
1618
+ }
1619
+
1620
+ function selection_property(name, value) {
1621
+ return arguments.length > 1
1622
+ ? this.each((value == null
1623
+ ? propertyRemove : typeof value === "function"
1624
+ ? propertyFunction
1625
+ : propertyConstant)(name, value))
1626
+ : this.node()[name];
1627
+ }
1628
+
1629
+ function classArray(string) {
1630
+ return string.trim().split(/^|\s+/);
1631
+ }
1632
+
1633
+ function classList(node) {
1634
+ return node.classList || new ClassList(node);
1635
+ }
1636
+
1637
+ function ClassList(node) {
1638
+ this._node = node;
1639
+ this._names = classArray(node.getAttribute("class") || "");
1640
+ }
1641
+
1642
+ ClassList.prototype = {
1643
+ add: function(name) {
1644
+ var i = this._names.indexOf(name);
1645
+ if (i < 0) {
1646
+ this._names.push(name);
1647
+ this._node.setAttribute("class", this._names.join(" "));
1648
+ }
1649
+ },
1650
+ remove: function(name) {
1651
+ var i = this._names.indexOf(name);
1652
+ if (i >= 0) {
1653
+ this._names.splice(i, 1);
1654
+ this._node.setAttribute("class", this._names.join(" "));
1655
+ }
1656
+ },
1657
+ contains: function(name) {
1658
+ return this._names.indexOf(name) >= 0;
1659
+ }
1660
+ };
1661
+
1662
+ function classedAdd(node, names) {
1663
+ var list = classList(node), i = -1, n = names.length;
1664
+ while (++i < n) list.add(names[i]);
1665
+ }
1666
+
1667
+ function classedRemove(node, names) {
1668
+ var list = classList(node), i = -1, n = names.length;
1669
+ while (++i < n) list.remove(names[i]);
1670
+ }
1671
+
1672
+ function classedTrue(names) {
1673
+ return function() {
1674
+ classedAdd(this, names);
1675
+ };
1676
+ }
1677
+
1678
+ function classedFalse(names) {
1679
+ return function() {
1680
+ classedRemove(this, names);
1681
+ };
1682
+ }
1683
+
1684
+ function classedFunction(names, value) {
1685
+ return function() {
1686
+ (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
1687
+ };
1688
+ }
1689
+
1690
+ function selection_classed(name, value) {
1691
+ var names = classArray(name + "");
1692
+
1693
+ if (arguments.length < 2) {
1694
+ var list = classList(this.node()), i = -1, n = names.length;
1695
+ while (++i < n) if (!list.contains(names[i])) return false;
1696
+ return true;
1697
+ }
1698
+
1699
+ return this.each((typeof value === "function"
1700
+ ? classedFunction : value
1701
+ ? classedTrue
1702
+ : classedFalse)(names, value));
1703
+ }
1704
+
1705
+ function textRemove() {
1706
+ this.textContent = "";
1707
+ }
1708
+
1709
+ function textConstant(value) {
1710
+ return function() {
1711
+ this.textContent = value;
1712
+ };
1713
+ }
1714
+
1715
+ function textFunction(value) {
1716
+ return function() {
1717
+ var v = value.apply(this, arguments);
1718
+ this.textContent = v == null ? "" : v;
1719
+ };
1720
+ }
1721
+
1722
+ function selection_text(value) {
1723
+ return arguments.length
1724
+ ? this.each(value == null
1725
+ ? textRemove : (typeof value === "function"
1726
+ ? textFunction
1727
+ : textConstant)(value))
1728
+ : this.node().textContent;
1729
+ }
1730
+
1731
+ function htmlRemove() {
1732
+ this.innerHTML = "";
1733
+ }
1734
+
1735
+ function htmlConstant(value) {
1736
+ return function() {
1737
+ this.innerHTML = value;
1738
+ };
1739
+ }
1740
+
1741
+ function htmlFunction(value) {
1742
+ return function() {
1743
+ var v = value.apply(this, arguments);
1744
+ this.innerHTML = v == null ? "" : v;
1745
+ };
1746
+ }
1747
+
1748
+ function selection_html(value) {
1749
+ return arguments.length
1750
+ ? this.each(value == null
1751
+ ? htmlRemove : (typeof value === "function"
1752
+ ? htmlFunction
1753
+ : htmlConstant)(value))
1754
+ : this.node().innerHTML;
1755
+ }
1756
+
1757
+ function raise() {
1758
+ if (this.nextSibling) this.parentNode.appendChild(this);
1759
+ }
1760
+
1761
+ function selection_raise() {
1762
+ return this.each(raise);
1763
+ }
1764
+
1765
+ function lower() {
1766
+ if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild);
1767
+ }
1768
+
1769
+ function selection_lower() {
1770
+ return this.each(lower);
1771
+ }
1772
+
1773
+ function selection_append(name) {
1774
+ var create = typeof name === "function" ? name : creator(name);
1775
+ return this.select(function() {
1776
+ return this.appendChild(create.apply(this, arguments));
1777
+ });
1778
+ }
1779
+
1780
+ function constantNull() {
1781
+ return null;
1782
+ }
1783
+
1784
+ function selection_insert(name, before) {
1785
+ var create = typeof name === "function" ? name : creator(name),
1786
+ select = before == null ? constantNull : typeof before === "function" ? before : selector(before);
1787
+ return this.select(function() {
1788
+ return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null);
1789
+ });
1790
+ }
1791
+
1792
+ function remove() {
1793
+ var parent = this.parentNode;
1794
+ if (parent) parent.removeChild(this);
1795
+ }
1796
+
1797
+ function selection_remove() {
1798
+ return this.each(remove);
1799
+ }
1800
+
1801
+ function selection_cloneShallow() {
1802
+ var clone = this.cloneNode(false), parent = this.parentNode;
1803
+ return parent ? parent.insertBefore(clone, this.nextSibling) : clone;
1804
+ }
1805
+
1806
+ function selection_cloneDeep() {
1807
+ var clone = this.cloneNode(true), parent = this.parentNode;
1808
+ return parent ? parent.insertBefore(clone, this.nextSibling) : clone;
1809
+ }
1810
+
1811
+ function selection_clone(deep) {
1812
+ return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
1813
+ }
1814
+
1815
+ function selection_datum(value) {
1816
+ return arguments.length
1817
+ ? this.property("__data__", value)
1818
+ : this.node().__data__;
1819
+ }
1820
+
1821
+ var filterEvents = {};
1822
+
1823
+ if (typeof document !== "undefined") {
1824
+ var element = document.documentElement;
1825
+ if (!("onmouseenter" in element)) {
1826
+ filterEvents = {mouseenter: "mouseover", mouseleave: "mouseout"};
1827
+ }
1828
+ }
1829
+
1830
+ function filterContextListener(listener, index, group) {
1831
+ listener = contextListener(listener, index, group);
1832
+ return function(event) {
1833
+ var related = event.relatedTarget;
1834
+ if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) {
1835
+ listener.call(this, event);
1836
+ }
1837
+ };
1838
+ }
1839
+
1840
+ function contextListener(listener, index, group) {
1841
+ return function(event1) {
1842
+ try {
1843
+ listener.call(this, this.__data__, index, group);
1844
+ } finally {
1845
+ }
1846
+ };
1847
+ }
1848
+
1849
+ function parseTypenames(typenames) {
1850
+ return typenames.trim().split(/^|\s+/).map(function(t) {
1851
+ var name = "", i = t.indexOf(".");
1852
+ if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
1853
+ return {type: t, name: name};
1854
+ });
1855
+ }
1856
+
1857
+ function onRemove(typename) {
1858
+ return function() {
1859
+ var on = this.__on;
1860
+ if (!on) return;
1861
+ for (var j = 0, i = -1, m = on.length, o; j < m; ++j) {
1862
+ if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) {
1863
+ this.removeEventListener(o.type, o.listener, o.capture);
1864
+ } else {
1865
+ on[++i] = o;
1866
+ }
1867
+ }
1868
+ if (++i) on.length = i;
1869
+ else delete this.__on;
1870
+ };
1871
+ }
1872
+
1873
+ function onAdd(typename, value, capture) {
1874
+ var wrap = filterEvents.hasOwnProperty(typename.type) ? filterContextListener : contextListener;
1875
+ return function(d, i, group) {
1876
+ var on = this.__on, o, listener = wrap(value, i, group);
1877
+ if (on) for (var j = 0, m = on.length; j < m; ++j) {
1878
+ if ((o = on[j]).type === typename.type && o.name === typename.name) {
1879
+ this.removeEventListener(o.type, o.listener, o.capture);
1880
+ this.addEventListener(o.type, o.listener = listener, o.capture = capture);
1881
+ o.value = value;
1882
+ return;
1883
+ }
1884
+ }
1885
+ this.addEventListener(typename.type, listener, capture);
1886
+ o = {type: typename.type, name: typename.name, value: value, listener: listener, capture: capture};
1887
+ if (!on) this.__on = [o];
1888
+ else on.push(o);
1889
+ };
1890
+ }
1891
+
1892
+ function selection_on(typename, value, capture) {
1893
+ var typenames = parseTypenames(typename + ""), i, n = typenames.length, t;
1894
+
1895
+ if (arguments.length < 2) {
1896
+ var on = this.node().__on;
1897
+ if (on) for (var j = 0, m = on.length, o; j < m; ++j) {
1898
+ for (i = 0, o = on[j]; i < n; ++i) {
1899
+ if ((t = typenames[i]).type === o.type && t.name === o.name) {
1900
+ return o.value;
1901
+ }
1902
+ }
1903
+ }
1904
+ return;
1905
+ }
1906
+
1907
+ on = value ? onAdd : onRemove;
1908
+ if (capture == null) capture = false;
1909
+ for (i = 0; i < n; ++i) this.each(on(typenames[i], value, capture));
1910
+ return this;
1911
+ }
1912
+
1913
+ function dispatchEvent(node, type, params) {
1914
+ var window = defaultView(node),
1915
+ event = window.CustomEvent;
1916
+
1917
+ if (typeof event === "function") {
1918
+ event = new event(type, params);
1919
+ } else {
1920
+ event = window.document.createEvent("Event");
1921
+ if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail;
1922
+ else event.initEvent(type, false, false);
1923
+ }
1924
+
1925
+ node.dispatchEvent(event);
1926
+ }
1927
+
1928
+ function dispatchConstant(type, params) {
1929
+ return function() {
1930
+ return dispatchEvent(this, type, params);
1931
+ };
1932
+ }
1933
+
1934
+ function dispatchFunction(type, params) {
1935
+ return function() {
1936
+ return dispatchEvent(this, type, params.apply(this, arguments));
1937
+ };
1938
+ }
1939
+
1940
+ function selection_dispatch(type, params) {
1941
+ return this.each((typeof params === "function"
1942
+ ? dispatchFunction
1943
+ : dispatchConstant)(type, params));
1944
+ }
1945
+
1946
+ var root = [null];
1947
+
1948
+ function Selection(groups, parents) {
1949
+ this._groups = groups;
1950
+ this._parents = parents;
1951
+ }
1952
+
1953
+ Selection.prototype = {
1954
+ constructor: Selection,
1955
+ select: selection_select,
1956
+ selectAll: selection_selectAll,
1957
+ filter: selection_filter,
1958
+ data: selection_data,
1959
+ enter: selection_enter,
1960
+ exit: selection_exit,
1961
+ join: selection_join,
1962
+ merge: selection_merge,
1963
+ order: selection_order,
1964
+ sort: selection_sort,
1965
+ call: selection_call,
1966
+ nodes: selection_nodes,
1967
+ node: selection_node,
1968
+ size: selection_size,
1969
+ empty: selection_empty,
1970
+ each: selection_each,
1971
+ attr: selection_attr,
1972
+ style: selection_style,
1973
+ property: selection_property,
1974
+ classed: selection_classed,
1975
+ text: selection_text,
1976
+ html: selection_html,
1977
+ raise: selection_raise,
1978
+ lower: selection_lower,
1979
+ append: selection_append,
1980
+ insert: selection_insert,
1981
+ remove: selection_remove,
1982
+ clone: selection_clone,
1983
+ datum: selection_datum,
1984
+ on: selection_on,
1985
+ dispatch: selection_dispatch
1986
+ };
1987
+
1988
+ function select(selector) {
1989
+ return typeof selector === "string"
1990
+ ? new Selection([[document.querySelector(selector)]], [document.documentElement])
1991
+ : new Selection([[selector]], root);
1992
+ }
1993
+
1994
+ ///////////////////////////////////////////////////////////////////////////////
1995
+ /** @preserve
1996
+ ///// SAPC APCA - Advanced Perceptual Contrast Algorithm
1997
+ ///// Beta 0.1.9 W3 • contrast function only
1998
+ ///// DIST: W3 • Revision date: July 3, 2022
1999
+ ///// Function to parse color values and determine Lc contrast
2000
+ ///// Copyright © 2019-2022 by Andrew Somers. All Rights Reserved.
2001
+ ///// LICENSE: W3 LICENSE
2002
+ ///// CONTACT: Please use the ISSUES or DISCUSSIONS tab at:
2003
+ ///// https://github.com/Myndex/SAPC-APCA/
2004
+ /////
2005
+ ///////////////////////////////////////////////////////////////////////////////
2006
+ /////
2007
+ ///// MINIMAL IMPORTS:
2008
+ ///// import { APCAcontrast, sRGBtoY, displayP3toY,
2009
+ ///// calcAPCA, fontLookupAPCA } from 'apca-w3';
2010
+ ///// import { colorParsley } from 'colorparsley';
2011
+ /////
2012
+ ///// FORWARD CONTRAST USAGE:
2013
+ ///// Lc = APCAcontrast( sRGBtoY( TEXTcolor ) , sRGBtoY( BACKGNDcolor ) );
2014
+ ///// Where the colors are sent as an rgba array [255,255,255,1]
2015
+ /////
2016
+ ///// Retrieving an array of font sizes for the contrast:
2017
+ ///// fontArray = fontLookupAPCA(Lc);
2018
+ /////
2019
+ ///// Live Demonstrator at https://www.myndex.com/APCA/
2020
+ // */
2021
+ ///////////////////////////////////////////////////////////////////////////////
2022
+
2023
+ // */ //// END LOCAL TESTING SWITCH
2024
+
2025
+
2026
+ ///// Module Scope Object Containing Constants /////
2027
+ ///// APCA 0.0.98G - 4g - W3 Compatible Constants
2028
+
2029
+ ///// 𝒦 SA98G ///////////////////////////////////
2030
+ const SA98G = {
2031
+
2032
+ mainTRC: 2.4, // 2.4 exponent for emulating actual monitor perception
2033
+
2034
+ // sRGB coefficients
2035
+ sRco: 0.2126729,
2036
+ sGco: 0.7151522,
2037
+ sBco: 0.0721750,
2038
+
2039
+ // G-4g constants for use with 2.4 exponent
2040
+ normBG: 0.56,
2041
+ normTXT: 0.57,
2042
+ revTXT: 0.62,
2043
+ revBG: 0.65,
2044
+
2045
+ // G-4g Clamps and Scalers
2046
+ blkThrs: 0.022,
2047
+ blkClmp: 1.414,
2048
+ scaleBoW: 1.14,
2049
+ scaleWoB: 1.14,
2050
+ loBoWoffset: 0.027,
2051
+ loWoBoffset: 0.027,
2052
+ deltaYmin: 0.0005,
2053
+ loClip: 0.1};
2054
+
2055
+
2056
+
2057
+
2058
+ //////////////////////////////////////////////////////////////////////////////
2059
+ ////////// APCA CALCULATION FUNCTIONS \/////////////////////////////////////
2060
+
2061
+ ////////// ƒ APCAcontrast() ////////////////////////////////////////////
2062
+ function APCAcontrast (txtY,bgY,places = -1) {
2063
+ // send linear Y (luminance) for text and background.
2064
+ // txtY and bgY must be between 0.0-1.0
2065
+ // IMPORTANT: Do not swap, polarity is important.
2066
+
2067
+ const icp = [0.0,1.1]; // input range clamp / input error check
2068
+
2069
+ if(isNaN(txtY)||isNaN(bgY)||Math.min(txtY,bgY)<icp[0]||
2070
+ Math.max(txtY,bgY)>icp[1]){
2071
+ return 0.0; // return zero on error
2072
+ // return 'error'; // optional string return for error
2073
+ }
2074
+ ////////// SAPC LOCAL VARS /////////////////////////////////////////
2075
+
2076
+ let SAPC = 0.0; // For raw SAPC values
2077
+ let outputContrast = 0.0; // For weighted final values
2078
+ let polCat = 'BoW'; // Alternate Polarity Indicator. N normal R reverse
2079
+
2080
+ // TUTORIAL
2081
+
2082
+ // Use Y for text and BG, and soft clamp black,
2083
+ // return 0 for very close luminances, determine
2084
+ // polarity, and calculate SAPC raw contrast
2085
+ // Then scale for easy to remember levels.
2086
+
2087
+ // Note that reverse contrast (white text on black)
2088
+ // intentionally returns a negative number
2089
+ // Proper polarity is important!
2090
+
2091
+ ////////// BLACK SOFT CLAMP ////////////////////////////////////////
2092
+
2093
+ // Soft clamps Y for either color if it is near black.
2094
+ txtY = (txtY > SA98G.blkThrs) ? txtY :
2095
+ txtY + Math.pow(SA98G.blkThrs - txtY, SA98G.blkClmp);
2096
+ bgY = (bgY > SA98G.blkThrs) ? bgY :
2097
+ bgY + Math.pow(SA98G.blkThrs - bgY, SA98G.blkClmp);
2098
+
2099
+ ///// Return 0 Early for extremely low ∆Y
2100
+ if ( Math.abs(bgY - txtY) < SA98G.deltaYmin ) { return 0.0; }
2101
+
2102
+
2103
+ ////////// APCA/SAPC CONTRAST - LOW CLIP (W3 LICENSE) ///////////////
2104
+
2105
+ if ( bgY > txtY ) { // For normal polarity, black text on white (BoW)
2106
+
2107
+ // Calculate the SAPC contrast value and scale
2108
+ SAPC = ( Math.pow(bgY, SA98G.normBG) -
2109
+ Math.pow(txtY, SA98G.normTXT) ) * SA98G.scaleBoW;
2110
+
2111
+ // Low Contrast smooth rollout to prevent polarity reversal
2112
+ // and also a low-clip for very low contrasts
2113
+ outputContrast = (SAPC < SA98G.loClip) ? 0.0 : SAPC - SA98G.loBoWoffset;
2114
+
2115
+ } else { // For reverse polarity, light text on dark (WoB)
2116
+ // WoB should always return negative value.
2117
+ polCat = 'WoB';
2118
+
2119
+ SAPC = ( Math.pow(bgY, SA98G.revBG) -
2120
+ Math.pow(txtY, SA98G.revTXT) ) * SA98G.scaleWoB;
2121
+
2122
+ outputContrast = (SAPC > -0.1) ? 0.0 : SAPC + SA98G.loWoBoffset;
2123
+ }
2124
+
2125
+ // return Lc (lightness contrast) as a signed numeric value
2126
+ // Round to the nearest whole number as string is optional.
2127
+ // Rounded can be a signed INT as output will be within ± 127
2128
+ // places = -1 returns signed float, 1 or more set that many places
2129
+ // 0 returns rounded string, uses BoW or WoB instead of minus sign
2130
+
2131
+ if(places < 0 ){ // Default (-1) number out, all others are strings
2132
+ return outputContrast * 100.0;
2133
+ } else if(places == 0 ){
2134
+ return Math.round(Math.abs(outputContrast)*100.0)+'<sub>'+polCat+'</sub>';
2135
+ } else if(Number.isInteger(places)){
2136
+ return (outputContrast * 100.0).toFixed(places);
2137
+ } else { return 0.0 }
2138
+
2139
+ } // End APCAcontrast()
2140
+
2141
+ /////////\ ///////////////////////////\
2142
+ //////////\ END fontLookupAPCA() 0.1.7 (G) /////////////////////////////\
2143
+ /////////////////////////////////////////////////////////////////////////////\
2144
+
2145
+
2146
+
2147
+
2148
+ //////////////////////////////////////////////////////////////////////////////
2149
+ ////////// LUMINANCE CONVERTERS |//////////////////////////////////////////
2150
+
2151
+
2152
+ ////////// ƒ sRGBtoY() //////////////////////////////////////////////////
2153
+ function sRGBtoY (rgb = [0,0,0]) { // send sRGB 8bpc (0xFFFFFF) or string
2154
+
2155
+ // NOTE: Currently expects 0-255
2156
+
2157
+ ///// APCA 0.0.98G - 4g - W3 Compatible Constants ////////////////////
2158
+ /*
2159
+ const mainTRC = 2.4; // 2.4 exponent emulates actual monitor perception
2160
+
2161
+ const sRco = 0.2126729,
2162
+ sGco = 0.7151522,
2163
+ sBco = 0.0721750; // sRGB coefficients
2164
+ */
2165
+ // Future:
2166
+ // 0.2126478133913640 0.7151791475336150 0.0721730390750208
2167
+ // Derived from:
2168
+ // xW yW K xR yR xG yG xB yB
2169
+ // 0.312720 0.329030 6504 0.640 0.330 0.300 0.600 0.150 0.060
2170
+
2171
+ // linearize r, g, or b then apply coefficients
2172
+ // and sum then return the resulting luminance
2173
+
2174
+ function simpleExp (chan) { return Math.pow(chan/255.0, SA98G.mainTRC); }
2175
+ return SA98G.sRco * simpleExp(rgb[0]) +
2176
+ SA98G.sGco * simpleExp(rgb[1]) +
2177
+ SA98G.sBco * simpleExp(rgb[2]);
2178
+
2179
+ } // End sRGBtoY()
2180
+
2181
+
2182
+
2183
+
2184
+ //\ ////////////////////////////////////////
2185
+ ///\ ////////////////////////////////////////
2186
+ ////\ ////////////////////////////////////////
2187
+ /////\ END APCA 0.1.9 G-4g BLOCK ////////////////////////////////////////
2188
+ ////////////////////////////////////////////////////////////////////////////
2189
+ ///////////////////////////////////////////////////////////////////////////
2190
+
2191
+ function hexToColor(hex_string, opacity) {
2192
+ if (typeof hex_string != "string") return false;
2193
+ var c = color(hex_string);
2194
+ c.opacity = 1;
2195
+
2196
+ return c;
2197
+ }
2198
+
2199
+ function getAPCAContrast(text_hex, background_hex) {
2200
+ if (!text_hex || !background_hex) {
2201
+ console.warn("No valid color", text_hex, background_hex);
2202
+ return;
2203
+ }
2204
+ const text_y = sRGBtoY(Object.values(hexToColor(text_hex)));
2205
+ const background_y = sRGBtoY(Object.values(hexToColor(background_hex)));
2206
+ return Math.abs(APCAcontrast(text_y, background_y));
2207
+ }
2208
+
2209
+ function isPaleBackground(background_hex) {
2210
+ if (!background_hex) {
2211
+ console.warn("No valid color", background_hex);
2212
+ return;
2213
+ }
2214
+
2215
+ const black_contrast = getAPCAContrast("#000000", background_hex);
2216
+ const white_contrast = getAPCAContrast("#ffffff", background_hex);
2217
+ return white_contrast < black_contrast ? true : false;
2218
+ }
2219
+
2220
+ const DEFAULTS = Object.freeze({
2221
+ searchbox_input_expanded: false,
2222
+ searchbox_size: 2,
2223
+ searchbox_width: 12,
2224
+ search_bg_color: null,
2225
+ search_bg_opacity: 0.9,
2226
+ searchbox_stroke: 0.1,
2227
+ searchbox_color: null,
2228
+ searchbox_radius: 4,
2229
+ });
2230
+
2231
+ function SearchboxStyle(state_, selector_, layout_) {
2232
+ this._state = state_;
2233
+ for (const key in DEFAULTS) {
2234
+ if (this._state[key] === undefined) this._state[key] = DEFAULTS[key];
2235
+ }
2236
+
2237
+ this._layout = layout_ || {};
2238
+
2239
+ this._styles = new Stylesheet();
2240
+ this._selector = selector_;
2241
+ this._createStylesheet();
2242
+
2243
+ return this;
2244
+ }
2245
+
2246
+ SearchboxStyle.prototype._createStylesheet = function () {
2247
+ this._stylesheet = document.createElement("style");
2248
+ this._stylesheet.className = "fl-ui-styles-searchbox";
2249
+ document.head.appendChild(this._stylesheet);
2250
+ };
2251
+
2252
+ SearchboxStyle.prototype.update = function () {
2253
+ this._styles.clear();
2254
+ const prefers_reduced_motion =
2255
+ window.matchMedia &&
2256
+ window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2257
+
2258
+ const bg_color = this._state.search_bg_color || this._layout.background_color;
2259
+ const background_color = bg_color
2260
+ ? hexToRgba(bg_color, this._state.search_bg_opacity)
2261
+ : "transparent";
2262
+
2263
+ const user_defined_searchbox_color =
2264
+ this._state.searchbox_color || this._layout.font_color;
2265
+ const searchbox_color = user_defined_searchbox_color || "inherit";
2266
+ const searchbox_color_paler = user_defined_searchbox_color
2267
+ ? hexToRgba(
2268
+ user_defined_searchbox_color,
2269
+ (this._state.searchbox_stroke + 1) / 2,
2270
+ )
2271
+ : "currentColor";
2272
+ const searchbox_color_palest = user_defined_searchbox_color
2273
+ ? hexToRgba(user_defined_searchbox_color, this._state.searchbox_stroke)
2274
+ : "currentColor";
2275
+
2276
+ const TEXT_SIZE = 0.55; // Relative to the search box height
2277
+ const ICON_SIZE = 0.45; // Relative to the search box height
2278
+
2279
+ // Main container
2280
+ this._styles
2281
+ .select(this._selector)
2282
+ .style("display", "inline-block")
2283
+ .style(
2284
+ "width",
2285
+ this._state.searchbox_size + this._state.searchbox_width + "rem",
2286
+ )
2287
+ .style("max-width", "calc(100% - 2px)")
2288
+ .style("box-sizing", "border-box");
2289
+
2290
+ select(this._selector).attr(
2291
+ "data-pale-background",
2292
+ isPaleBackground(background_color),
2293
+ );
2294
+
2295
+ // Input field
2296
+ this._styles
2297
+ .select(this._selector + " input")
2298
+ .style("border", "2px solid " + searchbox_color_palest)
2299
+ .style("border-radius", this._state.searchbox_radius + "px")
2300
+ .style("background-color", background_color)
2301
+ .style("color", searchbox_color)
2302
+ .style("font-family", "inherit")
2303
+ .style("cursor", this._state.searchbox_input_expanded ? "text" : "pointer")
2304
+ .style("position", "relative")
2305
+ .style("opacity", this._state.search_bg_opacity)
2306
+ .style("transition", prefers_reduced_motion ? "none" : "200ms width")
2307
+ .style("display", "block")
2308
+ .style("box-sizing", "border-box")
2309
+ .style("padding", "0 0 0 calc(" + this._state.searchbox_size + "rem - 4px)")
2310
+ .style("font-size", this._state.searchbox_size * TEXT_SIZE + "rem");
2311
+
2312
+ this._styles
2313
+ .select(this._selector + ".expanded input")
2314
+ .style("cursor", "text");
2315
+
2316
+ if (this._state.searchbox_input_expanded) {
2317
+ this._styles
2318
+ .select(this._selector + " input")
2319
+ .style("width", "100%")
2320
+ .style("height", this._state.searchbox_size + "rem");
2321
+ } else {
2322
+ this._styles
2323
+ .select(this._selector + " input")
2324
+ .style("width", this._state.searchbox_size + "rem")
2325
+ .style("height", this._state.searchbox_size + "rem");
2326
+ }
2327
+
2328
+ // Search icon
2329
+ this._styles
2330
+ .select(this._selector + " .search-icon")
2331
+ .style("position", "absolute")
2332
+ .style("pointer-events", "none")
2333
+ .style("width", this._state.searchbox_size * ICON_SIZE + "rem")
2334
+ .style("height", this._state.searchbox_size * ICON_SIZE + "rem")
2335
+ .style(
2336
+ "left",
2337
+ this._state.searchbox_size * Math.pow(1 - ICON_SIZE, 2) + "rem",
2338
+ )
2339
+ .style(
2340
+ "top",
2341
+ this._state.searchbox_size * Math.pow(1 - ICON_SIZE, 2) + "rem",
2342
+ );
2343
+
2344
+ // Search icon SVG
2345
+ this._styles
2346
+ .select(this._selector + " .search-icon svg")
2347
+ .style("width", "100%")
2348
+ .style("height", "100%")
2349
+ .select("path")
2350
+ .style("fill", searchbox_color);
2351
+
2352
+ // Search list (dropdown)
2353
+ const list_bg_color =
2354
+ this._state.search_bg_color || this._layout.background_color;
2355
+ this._styles
2356
+ .select(this._selector + " .search-list")
2357
+ .style("display", "none")
2358
+ .style("opacity", "0")
2359
+ .style("margin-top", "1px")
2360
+ .style("min-width", "100%")
2361
+ .style("max-height", "50vh")
2362
+ .style("overflow", "auto")
2363
+ .style("position", "absolute")
2364
+ .style("box-shadow", "0 1px 3px rgba(0,0,0,0.2)")
2365
+ .style("color", searchbox_color)
2366
+ .style("border-radius", "3px")
2367
+ .style("font-size", this._state.searchbox_size * TEXT_SIZE + "rem")
2368
+ .style("z-index", "1000");
2369
+
2370
+ this._styles
2371
+ .select(this._selector + " .search-list.visible")
2372
+ .style("opacity", 1)
2373
+ .style("visibility", "visible")
2374
+ .style("pointer-events", "auto");
2375
+
2376
+ // Apply data-pale-background to the search-list for accessibility styles
2377
+ select(this._selector + " .search-list").attr(
2378
+ "data-pale-background",
2379
+ isPaleBackground(list_bg_color || background_color),
2380
+ );
2381
+
2382
+ // Search list items
2383
+ this._styles
2384
+ .select(this._selector + " .search-list .search-item")
2385
+ .style("height", this._state.searchbox_size * TEXT_SIZE + 1 + "rem")
2386
+ .style("background-color", list_bg_color || "transparent")
2387
+ .style("opacity", this._state.search_bg_opacity)
2388
+ .style("padding", "0.5rem")
2389
+ .style("cursor", "pointer")
2390
+ .style("position", "relative")
2391
+ .select("p")
2392
+ .style("margin", "0")
2393
+ .style("line-height", "1.2em")
2394
+ .style("display", "block")
2395
+ .style("white-space", "nowrap")
2396
+ .style("font-weight", "normal")
2397
+ .style("overflow", "hidden")
2398
+ .style("text-overflow", "ellipsis")
2399
+ .style("pointer-events", "none");
2400
+
2401
+ // Search list item hover and selected states for pale backgrounds
2402
+ this._styles
2403
+ .select(
2404
+ this._selector +
2405
+ " .search-list[data-pale-background='true'] .search-item:hover",
2406
+ )
2407
+ .style("outline", "2px solid black")
2408
+ .style("outline-offset", "-2px");
2409
+
2410
+ this._styles
2411
+ .select(
2412
+ this._selector +
2413
+ " .search-list[data-pale-background='true'] .search-item.selected",
2414
+ )
2415
+ .style("outline", "2px solid black")
2416
+ .style("outline-offset", "-2px")
2417
+ .style("cursor", "default");
2418
+
2419
+ this._styles
2420
+ .select(
2421
+ this._selector +
2422
+ " .search-list[data-pale-background='true'] .search-item:focus-visible",
2423
+ )
2424
+ .style("outline", "2px solid black")
2425
+ .style("outline-offset", "-2px");
2426
+
2427
+ // Search list item hover and selected states for dark backgrounds
2428
+ this._styles
2429
+ .select(
2430
+ this._selector +
2431
+ " .search-list[data-pale-background='false'] .search-item:hover",
2432
+ )
2433
+ .style("outline", "2px solid white")
2434
+ .style("outline-offset", "-2px");
2435
+
2436
+ this._styles
2437
+ .select(
2438
+ this._selector +
2439
+ " .search-list[data-pale-background='false'] .search-item.selected",
2440
+ )
2441
+ .style("outline", "2px solid white")
2442
+ .style("outline-offset", "-2px")
2443
+ .style("cursor", "default");
2444
+
2445
+ this._styles
2446
+ .select(
2447
+ this._selector +
2448
+ " .search-list[data-pale-background='false'] .search-item:focus-visible",
2449
+ )
2450
+ .style("outline", "2px solid white")
2451
+ .style("outline-offset", "-2px");
2452
+
2453
+ // Active state (when search is focused)
2454
+ this._styles
2455
+ .select(this._selector + ".active .search-list")
2456
+ .style("display", "block");
2457
+
2458
+ // Expanded state
2459
+ this._styles
2460
+ .select(this._selector + ".expanded input")
2461
+ .style("width", "100% !important");
2462
+
2463
+ this._styles
2464
+ .select(this._selector + " input::placeholder")
2465
+ .style("color", searchbox_color_paler);
2466
+
2467
+ this._stylesheet.innerHTML = this._styles.print();
2468
+ };
2469
+
2470
+ /**
2471
+ * @typedef {import('./searchbox-style/index.js').SearchboxStyleState} SearchboxStyleState
2472
+ */
2473
+
1137
2474
  function createGeneralControlsStyle(state, selector, layout) {
1138
2475
  return new GeneralControlsStyle(state, selector, layout);
1139
2476
  }
@@ -1150,9 +2487,14 @@
1150
2487
  return new SliderStyle(state, selector, layout);
1151
2488
  }
1152
2489
 
2490
+ function createSearchboxStyle(state, selector, layout) {
2491
+ return new SearchboxStyle(state, selector, layout);
2492
+ }
2493
+
1153
2494
  exports.createButtonStyle = createButtonStyle;
1154
2495
  exports.createDropdownStyle = createDropdownStyle;
1155
2496
  exports.createGeneralControlsStyle = createGeneralControlsStyle;
2497
+ exports.createSearchboxStyle = createSearchboxStyle;
1156
2498
  exports.createSliderStyle = createSliderStyle;
1157
2499
 
1158
2500
  }));