@iwsio/react-blog-examples
Advanced tools
Comparing version 3.2.0 to 4.0.0
@@ -21,8 +21,8 @@ export declare const items: { | ||
label: string; | ||
transform: (v: any) => "downloaded" | "pending"; | ||
transform: (v: unknown) => "downloaded" | "pending"; | ||
} | { | ||
name: string; | ||
label: string; | ||
transform: (value: any) => "Test 1" | "Test 2" | "Unknown"; | ||
transform: (value: unknown) => "Test 1" | "Test 2" | "Unknown"; | ||
})[]; | ||
}; |
@@ -44,3 +44,3 @@ export const items = [ | ||
label: 'Downloaded', | ||
transform: v => v ? 'downloaded' : 'pending' | ||
transform: (v) => v ? 'downloaded' : 'pending' | ||
}, | ||
@@ -54,3 +54,3 @@ { | ||
label: 'Level', | ||
transform: function (value) { | ||
transform: (value) => { | ||
switch (value) { | ||
@@ -57,0 +57,0 @@ case 1: return 'Test 1'; |
import { ExportOptions } from '@iwsio/json-csv-core/types'; | ||
export type JsonCsvExampleProps = { | ||
export interface JsonCsvExampleProps { | ||
resultUpdated?: () => void; | ||
}; | ||
export type JsonValues = { | ||
} | ||
export interface JsonValues { | ||
items: Record<string, any>[]; | ||
options: Partial<ExportOptions>; | ||
}; | ||
} | ||
export declare const JsonCsvExample: import("react").ForwardRefExoticComponent<JsonCsvExampleProps & import("react").RefAttributes<HTMLFormElement>>; | ||
export default JsonCsvExample; |
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
import { FieldManager } from '@iwsio/forms/FieldManager'; | ||
import { useForwardRef } from '@iwsio/forms/useForwardRef'; | ||
import { toCsv } from '@iwsio/json-csv-core'; | ||
import { forwardRef, useEffect, useState } from 'react'; | ||
import { items as initialItems, options as initialOptions } from './data.js'; | ||
import { JsonField } from './JsonField.js'; | ||
import { ResetButton } from './ResetButton.js'; | ||
import { ResultView } from './ResultView.js'; | ||
import { items as initialItems, options as initialOptions } from './data.js'; | ||
import { simpleErrorMapping } from './simpleErrors.js'; | ||
import { useForwardRef } from '@iwsio/forms/useForwardRef'; | ||
import { FieldManager } from '@iwsio/forms/FieldManager'; | ||
const defaultValues = { items: JSON.stringify(initialItems, null, 2), options: JSON.stringify(initialOptions, null, 2) }; | ||
@@ -34,4 +34,4 @@ // forwarding ref here because I was tinkering with hljs and the example dom | ||
resultUpdated(); | ||
}, [result]); | ||
return (_jsxs(FieldManager, { fields: { ...defaultValues }, defaultValues: defaultValues, onValidSubmit: handleValidSubmit, errorMapping: simpleErrorMapping, ref: refDom, children: [_jsxs("div", { className: "flex flex-col sm:flex-row sm:gap-4", children: [_jsx(JsonField, { name: "items", label: "Items" }), _jsx(JsonField, { name: "options", label: "Options" })] }), _jsx("div", { className: "form-row my-3", children: _jsx("div", { className: "col", children: _jsxs("p", { className: "text-right gap-2", children: [_jsx(ResetButton, { onReset: () => setResult(_old => '') }), _jsx("button", { type: "submit", className: "btn", children: "Convert" })] }) }) }), _jsx(ResultView, { result: result })] })); | ||
}, [result, resultUpdated]); | ||
return (_jsxs(FieldManager, { fields: { ...defaultValues }, defaultValues: defaultValues, onValidSubmit: handleValidSubmit, errorMapping: simpleErrorMapping, ref: refDom, children: [_jsxs("div", { className: "flex flex-col sm:flex-row sm:gap-4", children: [_jsx(JsonField, { name: "items", label: "Items" }), _jsx(JsonField, { name: "options", label: "Options" })] }), _jsx("div", { className: "form-row my-3", children: _jsx("div", { className: "col", children: _jsxs("p", { className: "gap-2 text-right", children: [_jsx(ResetButton, { onReset: () => setResult(_old => '') }), _jsx("button", { type: "submit", className: "btn", children: "Convert" })] }) }) }), _jsx(ResultView, { result: result })] })); | ||
}); | ||
@@ -38,0 +38,0 @@ JsonCsvExample.displayName = 'JsonCsvExample'; |
@@ -19,3 +19,3 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; | ||
} | ||
}, [onChange, setFieldError]); | ||
}, [name, onChange, setFieldError]); | ||
useEffect(() => { | ||
@@ -30,5 +30,5 @@ if (fields[name] == null) | ||
}; | ||
}, [fields[name]]); | ||
return (_jsx("div", { className: "grow", children: _jsxs("label", { className: "label flex-col items-start prose", children: [_jsx("h3", { children: label }), _jsxs("div", { className: "w-full indicator", children: [_jsx(InvalidFeedbackForField, { name: name, className: "indicator-item badge badge-error" }), _jsx(TextAreaField, { name: name, className: `w-full font-mono textarea textarea-bordered ${fieldError ? 'textarea-error' : ''}`, rows: 25, required: true, ...props })] })] }) })); | ||
}, [checkValueAndTriggerChange, fields, name]); | ||
return (_jsx("div", { className: "grow", children: _jsxs("label", { className: "label prose flex-col items-start", children: [_jsx("h3", { children: label }), _jsxs("div", { className: "indicator w-full", children: [_jsx(InvalidFeedbackForField, { name: name, className: "indicator-item badge badge-error" }), _jsx(TextAreaField, { name: name, className: `textarea textarea-bordered w-full font-mono ${fieldError ? 'textarea-error' : ''}`, rows: 25, required: true, ...props })] })] }) })); | ||
}; | ||
//# sourceMappingURL=JsonField.js.map |
{ | ||
"name": "@iwsio/react-blog-examples", | ||
"version": "3.2.0", | ||
"version": "4.0.0", | ||
"description": "Example React components for blog posts.", | ||
@@ -37,19 +37,21 @@ "exports": { | ||
"devDependencies": { | ||
"@testing-library/jest-dom": "^6.4.6", | ||
"@testing-library/react": "^16.0.0", | ||
"@testing-library/user-event": "^14.5.2", | ||
"jsdom": "^24.1.0", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"rimraf": "^5.0.7", | ||
"vitest": "^1.6.0" | ||
"@iwsio/forms": "^5.0.2", | ||
"@iwsio/json-csv-core": "^1.2.0", | ||
"@testing-library/jest-dom": "^6.6.3", | ||
"@testing-library/react": "^16.2.0", | ||
"@testing-library/user-event": "^14.6.1", | ||
"@types/react": "^19.0.8", | ||
"@types/react-dom": "^19.0.3", | ||
"jsdom": "^26.0.0", | ||
"react": "^19.0.0", | ||
"react-dom": "^19.0.0", | ||
"rimraf": "^6.0.1", | ||
"vitest": "^3.0.5" | ||
}, | ||
"peerDependencies": { | ||
"react": "^18", | ||
"react-dom": "^18" | ||
}, | ||
"dependencies": { | ||
"@iwsio/forms": "^4.3.0", | ||
"@iwsio/json-csv-core": "^1.1.5" | ||
"react": ">= 18 < 20", | ||
"react-dom": ">= 18 < 20", | ||
"@iwsio/forms": ">= 5", | ||
"@iwsio/json-csv-core": ">= 1" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
23013
12
+ Added@iwsio/forms@5.0.3(transitive)
+ Addedclassnames@2.5.1(transitive)
+ Addedreact@19.0.0(transitive)
+ Addedreact-dom@19.0.0(transitive)
+ Addedscheduler@0.25.0(transitive)
- Removed@iwsio/forms@^4.3.0
- Removed@iwsio/json-csv-core@^1.1.5
- Removed@iwsio/forms@4.3.3(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedreact@18.3.1(transitive)
- Removedreact-dom@18.3.1(transitive)
- Removedscheduler@0.23.2(transitive)