@adcops/autocore-react 3.0.28 → 3.0.29

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.
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  type FileSelectProps = {
3
3
  domain?: string;
4
4
  subdir?: string;
5
+ /** Filter results using unix-style patterns. */
6
+ filter?: string | null;
5
7
  onFileSelected?: (fileName: string) => void;
6
8
  onAccept?: (fileName: string) => void;
7
9
  onCancel?: () => void;
@@ -1 +1 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useState,useContext,useEffect}from"react";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{Button}from"primereact/button";import{EventEmitterContext}from"../core/EventEmitterContext";export const FileSelect=({domain:e="DATASTORE",subdir:t,onFileSelected:n,onAccept:a,onCancel:l})=>{const{invoke:i}=useContext(EventEmitterContext),[o,s]=useState([]),[c,m]=useState(null),r=e=>{m(e),n&&n(e.name)};return useEffect((()=>{(async()=>{try{const n=t?{subdir:t}:{},a=(await i(e,"list_files",n)).data.map(((e,t)=>({id:t+1,name:e})));s(a)}catch(e){}})()}),[e,t]),_jsxs("div",{children:[_jsxs(DataTable,{value:o,selectionMode:"single",selection:c,onSelectionChange:e=>r(e.value),children:[_jsx(Column,{field:"name",header:"File Name"}),_jsx(Column,{body:e=>_jsx(Button,{label:c?.name===e.name?"Selected":"Select",icon:c?.name===e.name?"pi pi-check-circle":"pi pi-circle-off",onClick:()=>r(e),className:"p-button-rounded "+(c?.name===e.name?"p-button-success":"p-button-outlined"),"aria-label":"Select",size:"small"}),header:"Select"})]}),_jsxs("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"10px"},children:[_jsx(Button,{label:"Cancel",icon:"pi pi-times",className:"p-button-text",onClick:l}),_jsx(Button,{label:"Accept",icon:"pi pi-check",className:"p-button",onClick:()=>{void 0!==a&&null!==c&&a(null!==c?void 0!==t?`${t}/${c.name}`:c.name:"")},disabled:!c})]})]})};export default FileSelect;
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useState,useContext,useEffect}from"react";import{DataTable}from"primereact/datatable";import{Column}from"primereact/column";import{Button}from"primereact/button";import{EventEmitterContext}from"../core/EventEmitterContext";export const FileSelect=({domain:e="DATASTORE",subdir:t,filter:n,onFileSelected:l,onAccept:i,onCancel:o})=>{const{invoke:a}=useContext(EventEmitterContext),[s,c]=useState([]),[r,m]=useState(null),u=e=>{m(e),l&&l(e.name)};return useEffect((()=>{(async()=>{try{let l;l=null!=n?t?{subdir:t,options:{filter:n}}:{options:{filter:n}}:t?{subdir:t}:{};const i=(await a(e,"list_files",l)).data.map(((e,t)=>({id:t+1,name:e})));c(i)}catch(e){}})()}),[e,t]),_jsxs("div",{children:[_jsxs(DataTable,{value:s,selectionMode:"single",selection:r,onSelectionChange:e=>u(e.value),children:[_jsx(Column,{field:"name",header:"File Name"}),_jsx(Column,{body:e=>_jsx(Button,{label:r?.name===e.name?"Selected":"Select",icon:r?.name===e.name?"pi pi-check-circle":"pi pi-circle-off",onClick:()=>u(e),className:"p-button-rounded "+(r?.name===e.name?"p-button-success":"p-button-outlined"),"aria-label":"Select",size:"small"}),header:"Select"})]}),_jsxs("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"10px"},children:[_jsx(Button,{label:"Cancel",icon:"pi pi-times",className:"p-button-text",onClick:o}),_jsx(Button,{label:"Accept",icon:"pi pi-check",className:"p-button",onClick:()=>{void 0!==i&&null!==r&&i(null!==r?void 0!==t?`${t}/${r.name}`:r.name:"")},disabled:!r})]})]})};export default FileSelect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adcops/autocore-react",
3
- "version": "3.0.28",
3
+ "version": "3.0.29",
4
4
  "description": "A React component library for industrial user interfaces.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
3
  * Created Date: 2024-04-28 16:06:59
4
4
  * -----
5
- * Last Modified: 2024-05-01 07:30:49
5
+ * Last Modified: 2024-06-12 14:40:20
6
6
  * -----
7
7
  *
8
8
  */
@@ -18,6 +18,8 @@ import { EventEmitterContext } from "../core/EventEmitterContext";
18
18
  type FileSelectProps = {
19
19
  domain?: string,
20
20
  subdir?: string,
21
+ /** Filter results using unix-style patterns. */
22
+ filter?: string | null,
21
23
  onFileSelected?: (fileName: string) => void,
22
24
  onAccept?: (fileName: string) => void,
23
25
  onCancel?: () => void
@@ -31,6 +33,7 @@ type FileItem = {
31
33
  export const FileSelect: React.FC<FileSelectProps> = ({
32
34
  domain = "DATASTORE",
33
35
  subdir,
36
+ filter,
34
37
  onFileSelected,
35
38
  onAccept,
36
39
  onCancel
@@ -41,7 +44,16 @@ export const FileSelect: React.FC<FileSelectProps> = ({
41
44
 
42
45
  const listFiles = async () => {
43
46
  try {
44
- const args = subdir ? { "subdir": subdir } : {};
47
+
48
+ let args;
49
+
50
+ if (filter !== undefined && filter !== null) {
51
+ args = subdir ? { "subdir": subdir, options : {"filter" : filter }} : {options : {"filter" : filter }};
52
+ }
53
+ else {
54
+ args = subdir ? { "subdir": subdir } : {};
55
+ }
56
+
45
57
  const res = await invoke(domain, "list_files", args);
46
58
  const items = res.data.map((item: string, index: number) => ({
47
59
  id: index + 1,