@etdt/etdt-e-comps 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +20 -2
- package/dist/PFooter.d.ts +15 -0
- package/dist/PFooter.d.ts.map +1 -0
- package/dist/PFooter.js +27 -0
- package/dist/PForm/PForm.d.ts +14 -0
- package/dist/PForm/PForm.d.ts.map +1 -0
- package/dist/PForm/PForm.js +47 -0
- package/dist/PForm/PForm.types.d.ts +34 -0
- package/dist/PForm/PForm.types.d.ts.map +1 -0
- package/dist/PForm/PForm.types.js +1 -0
- package/dist/PInput/PInput.d.ts +5 -0
- package/dist/PInput/PInput.d.ts.map +1 -0
- package/dist/PInput/PInput.js +50 -0
- package/dist/PInput/PInput.types.d.ts +24 -0
- package/dist/PInput/PInput.types.d.ts.map +1 -0
- package/dist/PInput/PInput.types.js +1 -0
- package/dist/PRecordList.d.ts +38 -0
- package/dist/PRecordList.d.ts.map +1 -0
- package/dist/PRecordList.js +12 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/package.json +58 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ETDT
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
-
#
|
|
1
|
+
# etdt-e-comps
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Componentes reutilizables para aplicaciones React con Ionic:
|
|
4
|
+
|
|
5
|
+
- `PForm`: formulario con campos Ionic y validación de `react-hook-form`.
|
|
6
|
+
- `PInput`: campo Ionic controlado por `react-hook-form`.
|
|
7
|
+
- `PFooter`: pie de página Ionic con texto opcional.
|
|
8
|
+
- `PRecordList`: lista de registros con acciones opcionales.
|
|
9
|
+
|
|
10
|
+
## Instalar y usar
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
npm install etdt-e-comps
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import { PFooter, PForm, PInput, PRecordList } from 'etdt-e-comps';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
> La aplicación que utilice estos componentes debe tener instaladas las dependencias
|
|
21
|
+
peer declaradas en `package.json`.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Usage:
|
|
3
|
+
|
|
4
|
+
import PFooter from '../e_comps/PFooter'
|
|
5
|
+
|
|
6
|
+
<PFooter comp_name="Footer" footer_text={footer_text} color={color}/>
|
|
7
|
+
|
|
8
|
+
*/
|
|
9
|
+
interface PFooterProps {
|
|
10
|
+
footer_text?: string;
|
|
11
|
+
color?: string;
|
|
12
|
+
}
|
|
13
|
+
declare const PFooter: React.FC<PFooterProps>;
|
|
14
|
+
export default PFooter;
|
|
15
|
+
//# sourceMappingURL=PFooter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PFooter.d.ts","sourceRoot":"","sources":["../src/PFooter.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,UAAU,YAAY;IAEpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAG,MAAM,CAAA;CAGhB;AAGD,QAAA,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAyBnC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/PFooter.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
Usage:
|
|
4
|
+
|
|
5
|
+
import PFooter from '../e_comps/PFooter'
|
|
6
|
+
|
|
7
|
+
<PFooter comp_name="Footer" footer_text={footer_text} color={color}/>
|
|
8
|
+
|
|
9
|
+
*/
|
|
10
|
+
// Ionic
|
|
11
|
+
import { IonFooter, IonToolbar } from '@ionic/react';
|
|
12
|
+
// Component
|
|
13
|
+
const PFooter = ({
|
|
14
|
+
// comp_name,
|
|
15
|
+
footer_text, color = "tertiary",
|
|
16
|
+
// test_h,
|
|
17
|
+
// test_click_h,
|
|
18
|
+
}) => {
|
|
19
|
+
// Could be undefined
|
|
20
|
+
// const on_click_h = test_h ? () => test_h ({comp_data:comp_name}) : undefined
|
|
21
|
+
// const on_test_click_h = test_click_h ? (e : React.MouseEvent<HTMLIonButtonElement, MouseEvent>) => test_click_h (e) : undefined
|
|
22
|
+
/** Part renders **/
|
|
23
|
+
// Small centered note
|
|
24
|
+
const opt_part = footer_text ? (_jsx("div", { className: "ion-padding ion-text-center", children: _jsx("small", { children: footer_text }) })) : null;
|
|
25
|
+
return (_jsx(IonFooter, { children: _jsx(IonToolbar, { color: color, children: opt_part }) }));
|
|
26
|
+
};
|
|
27
|
+
export default PFooter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
Custom validation fn
|
|
7
|
+
- returns true or false
|
|
8
|
+
|
|
9
|
+
*/
|
|
10
|
+
import type { FC } from "react";
|
|
11
|
+
import type { PFormProps } from './PForm.types.js';
|
|
12
|
+
declare const PForm: FC<PFormProps>;
|
|
13
|
+
export default PForm;
|
|
14
|
+
//# sourceMappingURL=PForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PForm.d.ts","sourceRoot":"","sources":["../../src/PForm/PForm.tsx"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAA;AA8B/B,OAAO,KAAK,EACV,UAAU,EACX,MAAM,kBAAkB,CAAC;AAG1B,QAAA,MAAM,KAAK,EAAE,EAAE,CAAC,UAAU,CAgIzB,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Hooks
|
|
3
|
+
import { useForm } from "react-hook-form";
|
|
4
|
+
// Ionic
|
|
5
|
+
import { IonContent, IonButton, IonTitle, IonItem, IonLabel, IonText, IonToolbar, IonButtons, IonIcon, } from '@ionic/react';
|
|
6
|
+
// Icons
|
|
7
|
+
import { chevronBackOutline } from 'ionicons/icons';
|
|
8
|
+
// Components
|
|
9
|
+
import PInput from '../PInput/PInput.js';
|
|
10
|
+
// Component
|
|
11
|
+
const PForm = ({ form_title, form_fields, fixed_fields, custom_validate_h, submit_handler, submit_btn_text = "Submit", submit_disabled, submit_btn_color = "secondary", on_back, pre_submit_btn, after_submit_content, debug = false }) => {
|
|
12
|
+
// react-hook-form
|
|
13
|
+
const { control, handleSubmit, getValues, formState: { errors, isValid }, } = useForm({
|
|
14
|
+
defaultValues: {}
|
|
15
|
+
});
|
|
16
|
+
// Customize onChange event - just log
|
|
17
|
+
const common_on_change = (e) => {
|
|
18
|
+
debug && console.debug(`common_on_change :: ${e.target.name} : ${e.target.value}`);
|
|
19
|
+
};
|
|
20
|
+
if (fixed_fields) {
|
|
21
|
+
debug && console.debug(`fixed_fields passed : `, fixed_fields);
|
|
22
|
+
}
|
|
23
|
+
// Could be more performant ?
|
|
24
|
+
const val_h = custom_validate_h && (() => {
|
|
25
|
+
if (custom_validate_h) {
|
|
26
|
+
const vals = getValues();
|
|
27
|
+
debug && console.debug("PForm : getValues: ", vals);
|
|
28
|
+
// Pass values down
|
|
29
|
+
return custom_validate_h(vals);
|
|
30
|
+
// Validate its actually a boolean ?
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
// console.og("Render : isValid :", isValid)
|
|
35
|
+
// debug bar
|
|
36
|
+
const debug_status = debug &&
|
|
37
|
+
_jsxs(IonText, { children: ["IsValid : ", `${isValid}`] });
|
|
38
|
+
const back_btn = on_back ? (_jsx(IonButtons, { slot: "start", children: _jsx(IonButton, { onClick: on_back, children: _jsx(IonIcon, { icon: chevronBackOutline }) }) })) : null;
|
|
39
|
+
return (_jsxs(IonContent, { children: [form_title &&
|
|
40
|
+
_jsxs(IonToolbar, { children: [back_btn, _jsx(IonTitle, { children: form_title })] }), _jsxs("form", { onSubmit: handleSubmit(submit_handler), style: { padding: "1em" }, children: [fixed_fields?.map((f, index) => {
|
|
41
|
+
debug && console.debug(`Fixed field`, f);
|
|
42
|
+
return (_jsxs(IonItem, { children: [_jsx(IonLabel, { position: "stacked", children: f.label }), _jsx(IonText, { className: "ion-padding-top ion-padding-bottom", children: f.fixed_value })] }, index));
|
|
43
|
+
}), form_fields.map((field, index) => {
|
|
44
|
+
return (_jsx(PInput, { input_name: field.name, ion_label: field.label, input_type: field.type, control: control, readonly: field.readonly ?? false, on_change_h: field.custom_on_change || common_on_change, init_value: field.init_value, validate_h: val_h, options: field.options, modal_title: field.modal_title, ion_input_props: field.ion_input_props }, index));
|
|
45
|
+
}), pre_submit_btn, _jsx(IonButton, { color: submit_btn_color, expand: "block", type: "submit", disabled: submit_disabled || !isValid, children: submit_btn_text }), after_submit_content, debug_status] })] }));
|
|
46
|
+
};
|
|
47
|
+
export default PForm;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { TextFieldTypes } from '@ionic/core';
|
|
3
|
+
import type { FieldValues, SubmitHandler } from 'react-hook-form';
|
|
4
|
+
import type { PInputOption } from '../PInput/PInput.types.js';
|
|
5
|
+
export interface PFormProps {
|
|
6
|
+
form_title?: string;
|
|
7
|
+
form_fields: PFormField[];
|
|
8
|
+
fixed_fields?: PFixedField[];
|
|
9
|
+
custom_validate_h?: (values: FieldValues) => boolean;
|
|
10
|
+
submit_handler: SubmitHandler<FieldValues>;
|
|
11
|
+
submit_btn_text?: string;
|
|
12
|
+
submit_disabled?: boolean;
|
|
13
|
+
submit_btn_color?: string;
|
|
14
|
+
on_back?: () => void;
|
|
15
|
+
pre_submit_btn?: ReactNode;
|
|
16
|
+
after_submit_content?: ReactNode;
|
|
17
|
+
debug?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface PFormField {
|
|
20
|
+
name: string;
|
|
21
|
+
type?: TextFieldTypes | 'select';
|
|
22
|
+
label: string;
|
|
23
|
+
init_value?: unknown;
|
|
24
|
+
readonly?: boolean;
|
|
25
|
+
options?: PInputOption[];
|
|
26
|
+
modal_title?: string;
|
|
27
|
+
custom_on_change?: (event: unknown) => void;
|
|
28
|
+
ion_input_props?: Object;
|
|
29
|
+
}
|
|
30
|
+
export interface PFixedField {
|
|
31
|
+
label: string;
|
|
32
|
+
fixed_value: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=PForm.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PForm.types.d.ts","sourceRoot":"","sources":["../../src/PForm/PForm.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EACV,WAAW,EACX,aAAa,EACd,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D,MAAM,WAAW,UAAU;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,YAAY,CAAC,EAAE,WAAW,EAAE,CAAA;IAC5B,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAA;IACpD,cAAc,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;IAC1C,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,CAAC,EAAG,MAAM,IAAI,CAAA;IACrB,cAAc,CAAC,EAAE,SAAS,CAAA;IAC1B,oBAAoB,CAAC,EAAE,SAAS,CAAA;IAChC,KAAK,CAAC,EAAG,OAAO,CAAA;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5C,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,SAAS,CAAC;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PInput.d.ts","sourceRoot":"","sources":["../../src/PInput/PInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAkBhC,OAAO,KAAK,EACV,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAG3B,QAAA,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CA0H3B,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import moment from 'moment';
|
|
3
|
+
// Hooks
|
|
4
|
+
import { Controller } from "react-hook-form";
|
|
5
|
+
// Ionic
|
|
6
|
+
import { IonItem, IonLabel, IonInput, IonSelect, IonIcon, IonBadge, IonSelectOption, } from '@ionic/react';
|
|
7
|
+
// Component
|
|
8
|
+
const PInput = ({ input_name, input_type, ion_label, init_value, readonly, options, control, on_change_h, validate_h, ion_input_props, modal_title, debug = false }) => {
|
|
9
|
+
debug && console.debug(`PInput - type : ${input_type}; label: ${ion_label};name : (${input_name}) : init: ${init_value}`);
|
|
10
|
+
// Example: Default date to today
|
|
11
|
+
let default_value;
|
|
12
|
+
if (input_type === 'date' && !init_value) {
|
|
13
|
+
default_value = moment().format('YYYY-MM-DD');
|
|
14
|
+
debug && console.debug(`Default date set : ${moment(default_value).format('YYYY-MM-DD')}`);
|
|
15
|
+
}
|
|
16
|
+
if (init_value) {
|
|
17
|
+
default_value = init_value;
|
|
18
|
+
debug && console.debug(`Init value present for ${input_name} :: ${init_value}`);
|
|
19
|
+
}
|
|
20
|
+
// Compare function for objects
|
|
21
|
+
const compareWith = (o1, o2) => {
|
|
22
|
+
return o1 && o2 ? o1.id === o2.id : o1 === o2;
|
|
23
|
+
};
|
|
24
|
+
return (_jsxs(IonItem, { children: [ion_label && (_jsx(IonLabel, { position: "stacked", children: ion_label })), _jsx(Controller, { name: input_name, control: control, defaultValue: default_value, rules: {
|
|
25
|
+
validate: validate_h
|
|
26
|
+
}, render: ({ field: { name, onChange, value } }) => {
|
|
27
|
+
// Render IonSelect...
|
|
28
|
+
if (input_type === 'select') {
|
|
29
|
+
// console.info ("Select options:", options)
|
|
30
|
+
// console.debug ("Value is here:", value) // Undefined
|
|
31
|
+
return (_jsx(IonSelect, { interface: "modal", name: name, placeholder: "Seleccionar", selectedText: value?.disp, interfaceOptions: { header: modal_title }, onIonChange: (e) => {
|
|
32
|
+
debug && console.debug("onIonChange select! ");
|
|
33
|
+
on_change_h(e);
|
|
34
|
+
onChange(e.detail.value); // h will return the event
|
|
35
|
+
}, compareWith: compareWith, value: value, children: options?.map((o, index) => (_jsxs(IonSelectOption, { value: o, children: [o.badge && _jsx(IonIcon, { color: "warning", icon: o.badge.icon, slot: "start" }), o.disp, o.badge && _jsx(IonBadge, { color: "warning", slot: "end", children: o.badge.title })] }, index))) }));
|
|
36
|
+
}
|
|
37
|
+
// Or render IonInput
|
|
38
|
+
else {
|
|
39
|
+
// console.log ("Rendering IonInput : ", input_type, name)
|
|
40
|
+
if (readonly) {
|
|
41
|
+
debug && console.debug("Got readonly!! ", readonly);
|
|
42
|
+
}
|
|
43
|
+
return (_jsx(IonInput, { ...ion_input_props, name: name, type: input_type, readonly: readonly, onIonInput: (e) => {
|
|
44
|
+
on_change_h?.(e);
|
|
45
|
+
onChange(e.detail.value);
|
|
46
|
+
}, value: value }));
|
|
47
|
+
}
|
|
48
|
+
} })] }));
|
|
49
|
+
};
|
|
50
|
+
export default PInput;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TextFieldTypes } from '@ionic/core';
|
|
2
|
+
import type { Control, FieldValues, Validate } from 'react-hook-form';
|
|
3
|
+
export interface PInputOption {
|
|
4
|
+
disp: string;
|
|
5
|
+
badge?: {
|
|
6
|
+
icon: string;
|
|
7
|
+
title: string;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface PInputProps {
|
|
11
|
+
input_name: string;
|
|
12
|
+
input_type?: TextFieldTypes | 'select';
|
|
13
|
+
ion_label?: string;
|
|
14
|
+
init_value?: unknown;
|
|
15
|
+
readonly?: boolean;
|
|
16
|
+
options?: PInputOption[];
|
|
17
|
+
control: Control<FieldValues>;
|
|
18
|
+
on_change_h: Function;
|
|
19
|
+
validate_h?: Validate<FieldValues, FieldValues>;
|
|
20
|
+
ion_input_props?: Object;
|
|
21
|
+
modal_title?: string;
|
|
22
|
+
debug?: boolean;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=PInput.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PInput.types.d.ts","sourceRoot":"","sources":["../../src/PInput/PInput.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACf,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAA;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;IACxB,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAC7B,WAAW,EAAE,QAAQ,CAAA;IACrB,UAAU,CAAC,EAAE,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;IAC/C,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
|
|
3
|
+
Basic "table"
|
|
4
|
+
|
|
5
|
+
IonList with Edit and Delete icons
|
|
6
|
+
|
|
7
|
+
Usage:
|
|
8
|
+
|
|
9
|
+
import PRecordList from '../e_comps/PRecordList'
|
|
10
|
+
|
|
11
|
+
// Render:
|
|
12
|
+
|
|
13
|
+
<PRecordList
|
|
14
|
+
rec_array={rec_array}
|
|
15
|
+
list_name="Footer"
|
|
16
|
+
opt_prop={footer_text}/>
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
import type { FC, MouseEventHandler } from 'react';
|
|
20
|
+
export interface PRecordAction {
|
|
21
|
+
icon?: string;
|
|
22
|
+
click_h?: MouseEventHandler<HTMLIonButtonElement>;
|
|
23
|
+
}
|
|
24
|
+
export interface PRecord {
|
|
25
|
+
id?: string | number;
|
|
26
|
+
name: string;
|
|
27
|
+
note?: string;
|
|
28
|
+
icon?: string;
|
|
29
|
+
edit_params?: PRecordAction;
|
|
30
|
+
delete_params?: PRecordAction;
|
|
31
|
+
}
|
|
32
|
+
export interface PRecordListProps {
|
|
33
|
+
rec_array: PRecord[];
|
|
34
|
+
list_name?: string;
|
|
35
|
+
}
|
|
36
|
+
declare const PRecordList: FC<PRecordListProps>;
|
|
37
|
+
export default PRecordList;
|
|
38
|
+
//# sourceMappingURL=PRecordList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PRecordList.d.ts","sourceRoot":"","sources":["../src/PRecordList.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAgBnD,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,OAAO,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CA0CrC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Ionic
|
|
3
|
+
import { IonList, IonListHeader, IonItem, IonLabel, IonIcon, IonButton, IonButtons, } from '@ionic/react';
|
|
4
|
+
// Icons
|
|
5
|
+
import { closeCircleOutline } from 'ionicons/icons';
|
|
6
|
+
const PRecordList = ({ rec_array, list_name }) => {
|
|
7
|
+
if (rec_array.length === 0) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return (_jsxs(IonList, { children: [_jsx(IonListHeader, { color: "tertiary", lines: "full", children: list_name }), /* Records */ rec_array.map((r, key) => (_jsxs(IonItem, { children: [r.note && _jsx(IonLabel, { children: r.note }), _jsx(IonLabel, { children: r.name }), _jsxs(IonButtons, { slot: "end", children: [r.icon && (_jsx(IonIcon, { color: "secondary", size: "large", icon: r.icon })), r.edit_params && (_jsx(IonButton, { onClick: r.edit_params.click_h, children: _jsx(IonIcon, { color: "success", size: "large", icon: r.edit_params.icon }) })), r.delete_params && (_jsx(IonButton, { onClick: r.delete_params.click_h, children: _jsx(IonIcon, { color: "danger", size: "large", icon: closeCircleOutline }) }))] })] }, key)))] }));
|
|
11
|
+
};
|
|
12
|
+
export default PRecordList;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as PForm } from './PForm/PForm.js';
|
|
2
|
+
export type { PFixedField, PFormField, PFormProps, } from './PForm/PForm.types.js';
|
|
3
|
+
export { default as PInput } from './PInput/PInput.js';
|
|
4
|
+
export type { PInputOption, PInputProps, } from './PInput/PInput.types.js';
|
|
5
|
+
export { default as PFooter } from './PFooter.js';
|
|
6
|
+
export { default as PRecordList } from './PRecordList.js';
|
|
7
|
+
export type { PRecord, PRecordAction, PRecordListProps, } from './PRecordList.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EACV,WAAW,EACX,UAAU,EACV,UAAU,GACX,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EACV,OAAO,EACP,aAAa,EACb,gBAAgB,GACjB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etdt/etdt-e-comps",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Reusable Ionic React form components",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"typescript"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://gitlab.com/etdt/etdt-e-comps#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://gitlab.com/etdt/etdt-e-comps/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+ssh://git@gitlab.com/etdt/etdt-e-comps.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "ETDT",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc --project tsconfig.json",
|
|
36
|
+
"prepack": "npm run build"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"moment": "^2.30.1",
|
|
40
|
+
"ionicons": "^7.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@capacitor/core": "^7.0.0",
|
|
44
|
+
"@ionic/react": "^9.0.0",
|
|
45
|
+
"@types/react": "^18.0.27",
|
|
46
|
+
"@types/react-dom": "^18.0.10",
|
|
47
|
+
"react": "^18.0.0",
|
|
48
|
+
"react-dom": "^18.0.0",
|
|
49
|
+
"react-hook-form": "^7.0.0",
|
|
50
|
+
"typescript": "^5.4.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@capacitor/core": "^7.0.0",
|
|
54
|
+
"@ionic/react": "^9.0.0",
|
|
55
|
+
"react": "^18.2.0",
|
|
56
|
+
"react-dom": "^18.2.0",
|
|
57
|
+
"react-hook-form": "^7.53.2"
|
|
58
|
+
},
|
|
59
|
+
"sideEffects": false
|
|
60
|
+
}
|