reke-ui 0.2.1 → 0.3.0
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/custom-elements.json +403 -0
- package/dist/components/reke-combobox/reke-combobox.d.ts +70 -0
- package/dist/components/reke-combobox/reke-combobox.d.ts.map +1 -0
- package/dist/components/reke-combobox/reke-combobox.js +146 -0
- package/dist/components/reke-combobox/reke-combobox.styles.d.ts +2 -0
- package/dist/components/reke-combobox/reke-combobox.styles.d.ts.map +1 -0
- package/dist/components/reke-combobox/reke-combobox.styles.js +162 -0
- package/dist/components/reke-table/reke-table.d.ts +11 -0
- package/dist/components/reke-table/reke-table.d.ts.map +1 -1
- package/dist/components/reke-table/reke-table.js +39 -7
- package/dist/components/reke-table/reke-table.styles.d.ts.map +1 -1
- package/dist/components/reke-table/reke-table.styles.js +28 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -11
- package/dist/react.d.ts +9 -0
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +61 -52
- package/dist/shared/tailwind.js +1 -1
- package/package.json +5 -1
package/custom-elements.json
CHANGED
|
@@ -1021,6 +1021,388 @@
|
|
|
1021
1021
|
}
|
|
1022
1022
|
]
|
|
1023
1023
|
},
|
|
1024
|
+
{
|
|
1025
|
+
"kind": "javascript-module",
|
|
1026
|
+
"path": "src/components/reke-combobox/reke-combobox.ts",
|
|
1027
|
+
"declarations": [
|
|
1028
|
+
{
|
|
1029
|
+
"kind": "class",
|
|
1030
|
+
"description": "",
|
|
1031
|
+
"name": "RekeCombobox",
|
|
1032
|
+
"cssProperties": [
|
|
1033
|
+
{
|
|
1034
|
+
"description": "Focus ring and active/selected option color.",
|
|
1035
|
+
"name": "--reke-color-primary",
|
|
1036
|
+
"default": "#22C55E"
|
|
1037
|
+
},
|
|
1038
|
+
{
|
|
1039
|
+
"description": "Input and dropdown background.",
|
|
1040
|
+
"name": "--reke-color-surface",
|
|
1041
|
+
"default": "#1A1A1A"
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
"description": "Option hover/active background.",
|
|
1045
|
+
"name": "--reke-color-surface-elevated",
|
|
1046
|
+
"default": "#151515"
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
"description": "Input and dropdown border.",
|
|
1050
|
+
"name": "--reke-color-border",
|
|
1051
|
+
"default": "#252525"
|
|
1052
|
+
},
|
|
1053
|
+
{
|
|
1054
|
+
"description": "Error state border.",
|
|
1055
|
+
"name": "--reke-color-danger",
|
|
1056
|
+
"default": "#EF4444"
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
"description": "Text color.",
|
|
1060
|
+
"name": "--reke-color-text",
|
|
1061
|
+
"default": "#E5E5E5"
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
"description": "Placeholder / empty color.",
|
|
1065
|
+
"name": "--reke-color-text-muted",
|
|
1066
|
+
"default": "#525252"
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
"description": "Label color.",
|
|
1070
|
+
"name": "--reke-color-text-label",
|
|
1071
|
+
"default": "#8A8A8A"
|
|
1072
|
+
}
|
|
1073
|
+
],
|
|
1074
|
+
"cssParts": [
|
|
1075
|
+
{
|
|
1076
|
+
"description": "The text input element.",
|
|
1077
|
+
"name": "input"
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
"description": "The dropdown list container.",
|
|
1081
|
+
"name": "dropdown"
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
"description": "Each option row.",
|
|
1085
|
+
"name": "option"
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
"description": "The \"no results\" row.",
|
|
1089
|
+
"name": "empty"
|
|
1090
|
+
}
|
|
1091
|
+
],
|
|
1092
|
+
"members": [
|
|
1093
|
+
{
|
|
1094
|
+
"kind": "field",
|
|
1095
|
+
"name": "value",
|
|
1096
|
+
"type": {
|
|
1097
|
+
"text": "string"
|
|
1098
|
+
},
|
|
1099
|
+
"default": "''",
|
|
1100
|
+
"attribute": "value"
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
"kind": "field",
|
|
1104
|
+
"name": "placeholder",
|
|
1105
|
+
"type": {
|
|
1106
|
+
"text": "string"
|
|
1107
|
+
},
|
|
1108
|
+
"default": "'Buscar...'",
|
|
1109
|
+
"attribute": "placeholder"
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
"kind": "field",
|
|
1113
|
+
"name": "options",
|
|
1114
|
+
"type": {
|
|
1115
|
+
"text": "ComboboxOption[]"
|
|
1116
|
+
},
|
|
1117
|
+
"default": "[]"
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
"kind": "field",
|
|
1121
|
+
"name": "disabled",
|
|
1122
|
+
"type": {
|
|
1123
|
+
"text": "boolean"
|
|
1124
|
+
},
|
|
1125
|
+
"default": "false",
|
|
1126
|
+
"attribute": "disabled",
|
|
1127
|
+
"reflects": true
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
"kind": "field",
|
|
1131
|
+
"name": "error",
|
|
1132
|
+
"type": {
|
|
1133
|
+
"text": "boolean"
|
|
1134
|
+
},
|
|
1135
|
+
"default": "false",
|
|
1136
|
+
"attribute": "error",
|
|
1137
|
+
"reflects": true
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
"kind": "field",
|
|
1141
|
+
"name": "label",
|
|
1142
|
+
"type": {
|
|
1143
|
+
"text": "string"
|
|
1144
|
+
},
|
|
1145
|
+
"default": "''",
|
|
1146
|
+
"attribute": "label"
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
"kind": "field",
|
|
1150
|
+
"name": "emptyText",
|
|
1151
|
+
"type": {
|
|
1152
|
+
"text": "string"
|
|
1153
|
+
},
|
|
1154
|
+
"default": "'Sin resultados'",
|
|
1155
|
+
"attribute": "emptyText"
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
"kind": "field",
|
|
1159
|
+
"name": "size",
|
|
1160
|
+
"type": {
|
|
1161
|
+
"text": "ComboboxSize"
|
|
1162
|
+
},
|
|
1163
|
+
"default": "'md'",
|
|
1164
|
+
"attribute": "size",
|
|
1165
|
+
"reflects": true
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
"kind": "field",
|
|
1169
|
+
"name": "_open",
|
|
1170
|
+
"type": {
|
|
1171
|
+
"text": "boolean"
|
|
1172
|
+
},
|
|
1173
|
+
"privacy": "private",
|
|
1174
|
+
"default": "false"
|
|
1175
|
+
},
|
|
1176
|
+
{
|
|
1177
|
+
"kind": "field",
|
|
1178
|
+
"name": "_query",
|
|
1179
|
+
"type": {
|
|
1180
|
+
"text": "string"
|
|
1181
|
+
},
|
|
1182
|
+
"privacy": "private",
|
|
1183
|
+
"default": "''"
|
|
1184
|
+
},
|
|
1185
|
+
{
|
|
1186
|
+
"kind": "field",
|
|
1187
|
+
"name": "_activeIndex",
|
|
1188
|
+
"type": {
|
|
1189
|
+
"text": "number"
|
|
1190
|
+
},
|
|
1191
|
+
"privacy": "private",
|
|
1192
|
+
"default": "0"
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
"kind": "field",
|
|
1196
|
+
"name": "_dropdownStyle",
|
|
1197
|
+
"type": {
|
|
1198
|
+
"text": "string"
|
|
1199
|
+
},
|
|
1200
|
+
"privacy": "private",
|
|
1201
|
+
"default": "''",
|
|
1202
|
+
"description": "Inline `position: fixed` coords so the dropdown escapes any ancestor\n`overflow: hidden` (cards, table cells, etc.)."
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
"kind": "field",
|
|
1206
|
+
"name": "_boundHandleOutsideClick",
|
|
1207
|
+
"privacy": "private"
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
"kind": "field",
|
|
1211
|
+
"name": "_boundReposition",
|
|
1212
|
+
"privacy": "private"
|
|
1213
|
+
},
|
|
1214
|
+
{
|
|
1215
|
+
"kind": "method",
|
|
1216
|
+
"name": "updatePosition",
|
|
1217
|
+
"privacy": "private"
|
|
1218
|
+
},
|
|
1219
|
+
{
|
|
1220
|
+
"kind": "method",
|
|
1221
|
+
"name": "addPositionListeners",
|
|
1222
|
+
"privacy": "private"
|
|
1223
|
+
},
|
|
1224
|
+
{
|
|
1225
|
+
"kind": "method",
|
|
1226
|
+
"name": "removePositionListeners",
|
|
1227
|
+
"privacy": "private"
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
"kind": "method",
|
|
1231
|
+
"name": "handleOutsideClick",
|
|
1232
|
+
"privacy": "private",
|
|
1233
|
+
"parameters": [
|
|
1234
|
+
{
|
|
1235
|
+
"name": "e",
|
|
1236
|
+
"type": {
|
|
1237
|
+
"text": "Event"
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
]
|
|
1241
|
+
},
|
|
1242
|
+
{
|
|
1243
|
+
"kind": "field",
|
|
1244
|
+
"name": "selectedLabel",
|
|
1245
|
+
"type": {
|
|
1246
|
+
"text": "string"
|
|
1247
|
+
},
|
|
1248
|
+
"privacy": "private",
|
|
1249
|
+
"readonly": true
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
"kind": "field",
|
|
1253
|
+
"name": "filteredOptions",
|
|
1254
|
+
"type": {
|
|
1255
|
+
"text": "ComboboxOption[]"
|
|
1256
|
+
},
|
|
1257
|
+
"privacy": "private",
|
|
1258
|
+
"readonly": true
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
"kind": "method",
|
|
1262
|
+
"name": "open",
|
|
1263
|
+
"privacy": "private"
|
|
1264
|
+
},
|
|
1265
|
+
{
|
|
1266
|
+
"kind": "method",
|
|
1267
|
+
"name": "close",
|
|
1268
|
+
"privacy": "private"
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
"kind": "method",
|
|
1272
|
+
"name": "selectOption",
|
|
1273
|
+
"privacy": "private",
|
|
1274
|
+
"parameters": [
|
|
1275
|
+
{
|
|
1276
|
+
"name": "option",
|
|
1277
|
+
"type": {
|
|
1278
|
+
"text": "ComboboxOption"
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
]
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
"kind": "method",
|
|
1285
|
+
"name": "handleInput",
|
|
1286
|
+
"privacy": "private",
|
|
1287
|
+
"parameters": [
|
|
1288
|
+
{
|
|
1289
|
+
"name": "e",
|
|
1290
|
+
"type": {
|
|
1291
|
+
"text": "Event"
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
]
|
|
1295
|
+
},
|
|
1296
|
+
{
|
|
1297
|
+
"kind": "method",
|
|
1298
|
+
"name": "handleKeyDown",
|
|
1299
|
+
"privacy": "private",
|
|
1300
|
+
"parameters": [
|
|
1301
|
+
{
|
|
1302
|
+
"name": "e",
|
|
1303
|
+
"type": {
|
|
1304
|
+
"text": "KeyboardEvent"
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
]
|
|
1308
|
+
}
|
|
1309
|
+
],
|
|
1310
|
+
"events": [
|
|
1311
|
+
{
|
|
1312
|
+
"description": "Fired when an option is selected. Detail: `{ value: string }`.",
|
|
1313
|
+
"name": "reke-change"
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
"description": "Fired when the query changes (for remote filtering). Detail: `{ query: string }`.",
|
|
1317
|
+
"name": "reke-search"
|
|
1318
|
+
}
|
|
1319
|
+
],
|
|
1320
|
+
"attributes": [
|
|
1321
|
+
{
|
|
1322
|
+
"name": "value",
|
|
1323
|
+
"type": {
|
|
1324
|
+
"text": "string"
|
|
1325
|
+
},
|
|
1326
|
+
"default": "''",
|
|
1327
|
+
"fieldName": "value"
|
|
1328
|
+
},
|
|
1329
|
+
{
|
|
1330
|
+
"name": "placeholder",
|
|
1331
|
+
"type": {
|
|
1332
|
+
"text": "string"
|
|
1333
|
+
},
|
|
1334
|
+
"default": "'Buscar...'",
|
|
1335
|
+
"fieldName": "placeholder"
|
|
1336
|
+
},
|
|
1337
|
+
{
|
|
1338
|
+
"name": "disabled",
|
|
1339
|
+
"type": {
|
|
1340
|
+
"text": "boolean"
|
|
1341
|
+
},
|
|
1342
|
+
"default": "false",
|
|
1343
|
+
"fieldName": "disabled"
|
|
1344
|
+
},
|
|
1345
|
+
{
|
|
1346
|
+
"name": "error",
|
|
1347
|
+
"type": {
|
|
1348
|
+
"text": "boolean"
|
|
1349
|
+
},
|
|
1350
|
+
"default": "false",
|
|
1351
|
+
"fieldName": "error"
|
|
1352
|
+
},
|
|
1353
|
+
{
|
|
1354
|
+
"name": "label",
|
|
1355
|
+
"type": {
|
|
1356
|
+
"text": "string"
|
|
1357
|
+
},
|
|
1358
|
+
"default": "''",
|
|
1359
|
+
"fieldName": "label"
|
|
1360
|
+
},
|
|
1361
|
+
{
|
|
1362
|
+
"name": "emptyText",
|
|
1363
|
+
"type": {
|
|
1364
|
+
"text": "string"
|
|
1365
|
+
},
|
|
1366
|
+
"default": "'Sin resultados'",
|
|
1367
|
+
"fieldName": "emptyText"
|
|
1368
|
+
},
|
|
1369
|
+
{
|
|
1370
|
+
"name": "size",
|
|
1371
|
+
"type": {
|
|
1372
|
+
"text": "ComboboxSize"
|
|
1373
|
+
},
|
|
1374
|
+
"default": "'md'",
|
|
1375
|
+
"fieldName": "size"
|
|
1376
|
+
}
|
|
1377
|
+
],
|
|
1378
|
+
"superclass": {
|
|
1379
|
+
"name": "RekeElement",
|
|
1380
|
+
"module": "/src/shared/base-element.js"
|
|
1381
|
+
},
|
|
1382
|
+
"tagName": "reke-combobox",
|
|
1383
|
+
"customElement": true,
|
|
1384
|
+
"summary": "A searchable select. Type to filter options, navigate with the\nkeyboard. Unlike `reke-select`, it exposes a text query and is meant for long\noption lists."
|
|
1385
|
+
}
|
|
1386
|
+
],
|
|
1387
|
+
"exports": [
|
|
1388
|
+
{
|
|
1389
|
+
"kind": "js",
|
|
1390
|
+
"name": "RekeCombobox",
|
|
1391
|
+
"declaration": {
|
|
1392
|
+
"name": "RekeCombobox",
|
|
1393
|
+
"module": "src/components/reke-combobox/reke-combobox.ts"
|
|
1394
|
+
}
|
|
1395
|
+
},
|
|
1396
|
+
{
|
|
1397
|
+
"kind": "custom-element-definition",
|
|
1398
|
+
"name": "reke-combobox",
|
|
1399
|
+
"declaration": {
|
|
1400
|
+
"name": "RekeCombobox",
|
|
1401
|
+
"module": "src/components/reke-combobox/reke-combobox.ts"
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
]
|
|
1405
|
+
},
|
|
1024
1406
|
{
|
|
1025
1407
|
"kind": "javascript-module",
|
|
1026
1408
|
"path": "src/components/reke-date-range/reke-date-range.ts",
|
|
@@ -2710,6 +3092,27 @@
|
|
|
2710
3092
|
"default": "new Set<RowKey>()",
|
|
2711
3093
|
"description": "Track which keys are currently mounted in the DOM, to honor the contract that mount happens after `updated()` reconciles."
|
|
2712
3094
|
},
|
|
3095
|
+
{
|
|
3096
|
+
"kind": "field",
|
|
3097
|
+
"name": "_collapsingKeys",
|
|
3098
|
+
"privacy": "private",
|
|
3099
|
+
"default": "new Set<RowKey>()",
|
|
3100
|
+
"description": "Keys currently animating their collapse. Cleanup is deferred until transitionend."
|
|
3101
|
+
},
|
|
3102
|
+
{
|
|
3103
|
+
"kind": "field",
|
|
3104
|
+
"name": "_enteringKeys",
|
|
3105
|
+
"privacy": "private",
|
|
3106
|
+
"default": "new Set<RowKey>()",
|
|
3107
|
+
"description": "Keys newly expanded this tick. They render collapsed (0fr) for the first\npaint, then `updated()` clears them on the next frame so the CSS grid\ntransition animates open (0fr → 1fr). Without this, a freshly-mounted\nexpand row starts at 1fr and pops open with no animation."
|
|
3108
|
+
},
|
|
3109
|
+
{
|
|
3110
|
+
"kind": "field",
|
|
3111
|
+
"name": "_collapseEndHandlers",
|
|
3112
|
+
"privacy": "private",
|
|
3113
|
+
"default": "new Map<RowKey, (e: TransitionEvent) => void>()",
|
|
3114
|
+
"description": "transitionend handlers keyed by row key, for cleanup on collapse animation end."
|
|
3115
|
+
},
|
|
2713
3116
|
{
|
|
2714
3117
|
"kind": "field",
|
|
2715
3118
|
"name": "_keyToRow",
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { RekeElement } from '../../shared/base-element.js';
|
|
2
|
+
export type ComboboxSize = 'sm' | 'md' | 'lg';
|
|
3
|
+
export interface ComboboxOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** Optional image (e.g. a token/coin logo) rendered before the label. */
|
|
7
|
+
image?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @tag reke-combobox
|
|
11
|
+
* @summary A searchable select. Type to filter options, navigate with the
|
|
12
|
+
* keyboard. Unlike `reke-select`, it exposes a text query and is meant for long
|
|
13
|
+
* option lists.
|
|
14
|
+
*
|
|
15
|
+
* @fires reke-change - Fired when an option is selected. Detail: `{ value: string }`.
|
|
16
|
+
* @fires reke-search - Fired when the query changes (for remote filtering). Detail: `{ query: string }`.
|
|
17
|
+
*
|
|
18
|
+
* @csspart input - The text input element.
|
|
19
|
+
* @csspart dropdown - The dropdown list container.
|
|
20
|
+
* @csspart option - Each option row.
|
|
21
|
+
* @csspart empty - The "no results" row.
|
|
22
|
+
*
|
|
23
|
+
* @cssprop [--reke-color-primary=#22C55E] - Focus ring and active/selected option color.
|
|
24
|
+
* @cssprop [--reke-color-surface=#1A1A1A] - Input and dropdown background.
|
|
25
|
+
* @cssprop [--reke-color-surface-elevated=#151515] - Option hover/active background.
|
|
26
|
+
* @cssprop [--reke-color-border=#252525] - Input and dropdown border.
|
|
27
|
+
* @cssprop [--reke-color-danger=#EF4444] - Error state border.
|
|
28
|
+
* @cssprop [--reke-color-text=#E5E5E5] - Text color.
|
|
29
|
+
* @cssprop [--reke-color-text-muted=#525252] - Placeholder / empty color.
|
|
30
|
+
* @cssprop [--reke-color-text-label=#8A8A8A] - Label color.
|
|
31
|
+
*/
|
|
32
|
+
export declare class RekeCombobox extends RekeElement {
|
|
33
|
+
static styles: import("lit").CSSResult[];
|
|
34
|
+
value: string;
|
|
35
|
+
placeholder: string;
|
|
36
|
+
options: ComboboxOption[];
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
error: boolean;
|
|
39
|
+
label: string;
|
|
40
|
+
emptyText: string;
|
|
41
|
+
size: ComboboxSize;
|
|
42
|
+
private _open;
|
|
43
|
+
private _query;
|
|
44
|
+
private _activeIndex;
|
|
45
|
+
/** Inline `position: fixed` coords so the dropdown escapes any ancestor
|
|
46
|
+
* `overflow: hidden` (cards, table cells, etc.). */
|
|
47
|
+
private _dropdownStyle;
|
|
48
|
+
private _boundHandleOutsideClick;
|
|
49
|
+
private _boundReposition;
|
|
50
|
+
connectedCallback(): void;
|
|
51
|
+
disconnectedCallback(): void;
|
|
52
|
+
private updatePosition;
|
|
53
|
+
private addPositionListeners;
|
|
54
|
+
private removePositionListeners;
|
|
55
|
+
private handleOutsideClick;
|
|
56
|
+
private get selectedLabel();
|
|
57
|
+
private get filteredOptions();
|
|
58
|
+
private open;
|
|
59
|
+
private close;
|
|
60
|
+
private selectOption;
|
|
61
|
+
private handleInput;
|
|
62
|
+
private handleKeyDown;
|
|
63
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
64
|
+
}
|
|
65
|
+
declare global {
|
|
66
|
+
interface HTMLElementTagNameMap {
|
|
67
|
+
'reke-combobox': RekeCombobox;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=reke-combobox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reke-combobox.d.ts","sourceRoot":"","sources":["../../../src/components/reke-combobox/reke-combobox.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBACa,YAAa,SAAQ,WAAW;IAC3C,OAAgB,MAAM,4BAAU;IAGhC,KAAK,SAAM;IAGX,WAAW,SAAe;IAG1B,OAAO,EAAE,cAAc,EAAE,CAAM;IAG/B,QAAQ,UAAS;IAGjB,KAAK,UAAS;IAGd,KAAK,SAAM;IAGX,SAAS,SAAoB;IAG7B,IAAI,EAAE,YAAY,CAAQ;IAG1B,OAAO,CAAC,KAAK,CAAS;IAGtB,OAAO,CAAC,MAAM,CAAM;IAGpB,OAAO,CAAC,YAAY,CAAK;IAEzB;wDACoD;IAEpD,OAAO,CAAC,cAAc,CAAM;IAE5B,OAAO,CAAC,wBAAwB,CAAsC;IACtE,OAAO,CAAC,gBAAgB,CAA+B;IAE9C,iBAAiB;IAKjB,oBAAoB;IAM7B,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,uBAAuB;IAK/B,OAAO,CAAC,kBAAkB;IAM1B,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,KAAK,eAAe,GAM1B;IAED,OAAO,CAAC,IAAI;IASZ,OAAO,CAAC,KAAK;IAMb,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,aAAa;IA4BZ,MAAM;CAmFhB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,YAAY,CAAC;KAC/B;CACF"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { RekeElement as e } from "../../shared/base-element.js";
|
|
2
|
+
import { __decorate as t } from "../../_virtual/_@oxc-project_runtime@0.137.0/helpers/esm/decorate.js";
|
|
3
|
+
import { styles as n } from "./reke-combobox.styles.js";
|
|
4
|
+
import { html as r, nothing as i } from "lit";
|
|
5
|
+
import { customElement as a, property as o, state as s } from "lit/decorators.js";
|
|
6
|
+
import { classMap as c } from "lit/directives/class-map.js";
|
|
7
|
+
//#region src/components/reke-combobox/reke-combobox.ts
|
|
8
|
+
var l = class extends e {
|
|
9
|
+
constructor(...e) {
|
|
10
|
+
super(...e), this.value = "", this.placeholder = "Buscar...", this.options = [], this.disabled = !1, this.error = !1, this.label = "", this.emptyText = "Sin resultados", this.size = "md", this._open = !1, this._query = "", this._activeIndex = 0, this._dropdownStyle = "", this._boundHandleOutsideClick = this.handleOutsideClick.bind(this), this._boundReposition = () => this.updatePosition();
|
|
11
|
+
}
|
|
12
|
+
static {
|
|
13
|
+
this.styles = n;
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback(), document.addEventListener("click", this._boundHandleOutsideClick);
|
|
17
|
+
}
|
|
18
|
+
disconnectedCallback() {
|
|
19
|
+
super.disconnectedCallback(), document.removeEventListener("click", this._boundHandleOutsideClick), this.removePositionListeners();
|
|
20
|
+
}
|
|
21
|
+
updatePosition() {
|
|
22
|
+
let e = this.shadowRoot?.querySelector(".control");
|
|
23
|
+
if (!e) return;
|
|
24
|
+
let t = e.getBoundingClientRect();
|
|
25
|
+
this._dropdownStyle = `position:fixed;top:${t.bottom + 4}px;left:${t.left}px;width:${t.width}px;right:auto;`;
|
|
26
|
+
}
|
|
27
|
+
addPositionListeners() {
|
|
28
|
+
window.addEventListener("scroll", this._boundReposition, !0), window.addEventListener("resize", this._boundReposition);
|
|
29
|
+
}
|
|
30
|
+
removePositionListeners() {
|
|
31
|
+
window.removeEventListener("scroll", this._boundReposition, !0), window.removeEventListener("resize", this._boundReposition);
|
|
32
|
+
}
|
|
33
|
+
handleOutsideClick(e) {
|
|
34
|
+
e.composedPath().includes(this) || this.close();
|
|
35
|
+
}
|
|
36
|
+
get selectedLabel() {
|
|
37
|
+
return this.options.find((e) => e.value === this.value)?.label ?? "";
|
|
38
|
+
}
|
|
39
|
+
get filteredOptions() {
|
|
40
|
+
let e = this._query.trim().toLowerCase();
|
|
41
|
+
return e === "" ? this.options : this.options.filter((t) => t.label.toLowerCase().includes(e) || t.value.toLowerCase().includes(e));
|
|
42
|
+
}
|
|
43
|
+
open() {
|
|
44
|
+
this.disabled || this._open || (this._open = !0, this._query = "", this._activeIndex = 0, this.addPositionListeners(), this.updateComplete.then(() => this.updatePosition()));
|
|
45
|
+
}
|
|
46
|
+
close() {
|
|
47
|
+
this._open = !1, this._query = "", this.removePositionListeners();
|
|
48
|
+
}
|
|
49
|
+
selectOption(e) {
|
|
50
|
+
this.value = e.value, this.close(), this.emit("reke-change", { value: this.value });
|
|
51
|
+
}
|
|
52
|
+
handleInput(e) {
|
|
53
|
+
this._query = e.target.value, this._open = !0, this._activeIndex = 0, this.emit("reke-search", { query: this._query });
|
|
54
|
+
}
|
|
55
|
+
handleKeyDown(e) {
|
|
56
|
+
let t = this.filteredOptions;
|
|
57
|
+
switch (e.key) {
|
|
58
|
+
case "ArrowDown":
|
|
59
|
+
e.preventDefault(), this._open ? this._activeIndex = Math.min(this._activeIndex + 1, t.length - 1) : this.open();
|
|
60
|
+
break;
|
|
61
|
+
case "ArrowUp":
|
|
62
|
+
e.preventDefault(), this._activeIndex = Math.max(this._activeIndex - 1, 0);
|
|
63
|
+
break;
|
|
64
|
+
case "Enter": {
|
|
65
|
+
if (!this._open) break;
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
let n = t[this._activeIndex];
|
|
68
|
+
n && this.selectOption(n);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case "Escape":
|
|
72
|
+
this._open && (e.preventDefault(), this.close());
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
render() {
|
|
77
|
+
let e = this.filteredOptions, t = this._open ? this._query : this.selectedLabel, n = {
|
|
78
|
+
input: !0,
|
|
79
|
+
[`input--${this.size}`]: !0,
|
|
80
|
+
"input--error": this.error
|
|
81
|
+
};
|
|
82
|
+
return r`
|
|
83
|
+
${this.label ? r`<label class="label">${this.label}</label>` : i}
|
|
84
|
+
<div class="control">
|
|
85
|
+
<input
|
|
86
|
+
part="input"
|
|
87
|
+
class=${c(n)}
|
|
88
|
+
type="text"
|
|
89
|
+
role="combobox"
|
|
90
|
+
.value=${t}
|
|
91
|
+
placeholder=${this.selectedLabel || this.placeholder}
|
|
92
|
+
?disabled=${this.disabled}
|
|
93
|
+
autocomplete="off"
|
|
94
|
+
aria-expanded=${this._open}
|
|
95
|
+
aria-controls="reke-combobox-list"
|
|
96
|
+
aria-autocomplete="list"
|
|
97
|
+
aria-invalid=${this.error}
|
|
98
|
+
aria-activedescendant=${this._open && e[this._activeIndex] ? `reke-combobox-opt-${this._activeIndex}` : i}
|
|
99
|
+
@focus=${this.open}
|
|
100
|
+
@click=${this.open}
|
|
101
|
+
@input=${this.handleInput}
|
|
102
|
+
@keydown=${this.handleKeyDown}
|
|
103
|
+
/>
|
|
104
|
+
<span class="chevron" aria-hidden="true">▼</span>
|
|
105
|
+
</div>
|
|
106
|
+
${this._open ? r`
|
|
107
|
+
<ul
|
|
108
|
+
part="dropdown"
|
|
109
|
+
id="reke-combobox-list"
|
|
110
|
+
class="dropdown"
|
|
111
|
+
role="listbox"
|
|
112
|
+
style=${this._dropdownStyle}
|
|
113
|
+
>
|
|
114
|
+
${e.length === 0 ? r`<li part="empty" class="empty">${this.emptyText}</li>` : e.map((e, t) => r`
|
|
115
|
+
<li
|
|
116
|
+
part="option"
|
|
117
|
+
id="reke-combobox-opt-${t}"
|
|
118
|
+
class=${c({
|
|
119
|
+
option: !0,
|
|
120
|
+
"option--selected": e.value === this.value,
|
|
121
|
+
"option--active": t === this._activeIndex
|
|
122
|
+
})}
|
|
123
|
+
role="option"
|
|
124
|
+
aria-selected=${e.value === this.value}
|
|
125
|
+
@click=${() => this.selectOption(e)}
|
|
126
|
+
@mousemove=${() => {
|
|
127
|
+
this._activeIndex = t;
|
|
128
|
+
}}
|
|
129
|
+
>
|
|
130
|
+
${e.image ? r`<img class="option-img" src=${e.image} alt="" loading="lazy" />` : i}${e.label}
|
|
131
|
+
</li>
|
|
132
|
+
`)}
|
|
133
|
+
</ul>
|
|
134
|
+
` : i}
|
|
135
|
+
`;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
t([o()], l.prototype, "value", void 0), t([o()], l.prototype, "placeholder", void 0), t([o({ attribute: !1 })], l.prototype, "options", void 0), t([o({
|
|
139
|
+
type: Boolean,
|
|
140
|
+
reflect: !0
|
|
141
|
+
})], l.prototype, "disabled", void 0), t([o({
|
|
142
|
+
type: Boolean,
|
|
143
|
+
reflect: !0
|
|
144
|
+
})], l.prototype, "error", void 0), t([o()], l.prototype, "label", void 0), t([o()], l.prototype, "emptyText", void 0), t([o({ reflect: !0 })], l.prototype, "size", void 0), t([s()], l.prototype, "_open", void 0), t([s()], l.prototype, "_query", void 0), t([s()], l.prototype, "_activeIndex", void 0), t([s()], l.prototype, "_dropdownStyle", void 0), l = t([a("reke-combobox")], l);
|
|
145
|
+
//#endregion
|
|
146
|
+
export { l as RekeCombobox };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reke-combobox.styles.d.ts","sourceRoot":"","sources":["../../../src/components/reke-combobox/reke-combobox.styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM,2BA+JlB,CAAC"}
|