* Perform selections on a subtree using the address "selector" methods. * * @param node - A FormKitNode | FormKitNode * @param selector - A `string | number` to find in the node * * @returns A FormKitNode | FormKitNode or `undefined` * * @internal
( node: FormKitNode, selector: string | number )
| 2846 | * @internal |
| 2847 | */ |
| 2848 | function select( |
| 2849 | node: FormKitNode, |
| 2850 | selector: string | number |
| 2851 | ): FormKitNode | undefined { |
| 2852 | const matches = String(selector).match(/^(find)\((.*)\)$/) |
| 2853 | if (matches) { |
| 2854 | const [, action, argStr] = matches |
| 2855 | const args = argStr.split(',').map((arg) => arg.trim()) |
| 2856 | switch (action) { |
| 2857 | case 'find': |
| 2858 | return node.find(args[0], args[1] as keyof FormKitNode) |
| 2859 | default: |
| 2860 | return undefined |
| 2861 | } |
| 2862 | } |
| 2863 | return undefined |
| 2864 | } |
| 2865 | |
| 2866 | /** |
| 2867 | * Perform a breadth first search and return the first instance of a node that |